From d0d78b9fbe144326f136ee048bb59d314413032e Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期二, 27 五月 2025 08:45:29 +0800
Subject: [PATCH] 修改导出

---
 src/views/analyse/assessApply/components/reportDialog.vue |  234 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 223 insertions(+), 11 deletions(-)

diff --git a/src/views/analyse/assessApply/components/reportDialog.vue b/src/views/analyse/assessApply/components/reportDialog.vue
index d58e482..66a32f6 100644
--- a/src/views/analyse/assessApply/components/reportDialog.vue
+++ b/src/views/analyse/assessApply/components/reportDialog.vue
@@ -24,7 +24,8 @@
 <!--                                <el-radio :label="5">特种设备类</el-radio>-->
 <!--                                <el-radio :label="6">其他类</el-radio>-->
 <!--                            </el-radio-group>-->
-                            {{reportDialogState.experimentTypeList.find(i=>i.id === reportDialogState.reportForm.experimentType)?.name}}
+<!--                            {{reportDialogState.experimentTypeList.find(i=>i.id === reportDialogState.reportForm.experimentAndType)?.name}}-->
+                          {{typeValue}}
                         </td>
                     </tr>
                     <tr>
@@ -110,7 +111,8 @@
 
                     <tr class="m-color b-font" style="text-align: center">实验概况</tr>
                     <tr>
-                        <el-input type="textarea" :autosize="{ minRows: 3}" disabled v-model="reportDialogState.reportForm.experimentDesc" placeholder="(简要描述实验原理、实验步骤、所用试剂或材料设备等)" />
+<!--                        <el-input type="textarea" :autosize="{ minRows: 3}" disabled v-model="reportDialogState.reportForm.experimentDesc" placeholder="(简要描述实验原理、实验步骤、所用试剂或材料设备等)" />-->
+                      <el-input type="textarea" :autosize="{ minRows: 3}" disabled v-model="reportDialogState.reportForm.process" placeholder="(简要描述实验原理、实验步骤、所用试剂或材料设备等)" />
                     </tr>
                     <tr class="m-color b-font" style="text-align: center">实验涉及的危险源</tr>
                     <tr>
@@ -126,7 +128,7 @@
 <!--                          <el-radio :label="7">激光安全</el-radio>-->
 <!--                          <el-radio :label="8">其他安全</el-radio>-->
 <!--                        </el-radio-group>-->
-                        <el-checkbox-group disabled>
+                        <el-checkbox-group disabled class="checkTip">
                           <el-checkbox v-for="item in reportDialogState.reportForm.riskSourceType" :label="item.riskSourceType" :checked="item.status==1?true:false"/>
                         </el-checkbox-group>
                       </td>
@@ -150,7 +152,7 @@
                     <tr class="m-color b-font required" style="text-align: center">实验和实验项目综合风险等级评定</tr>
                     <tr>
                       <td class="m-color" style="width: 100%;height: 65px">
-                        <el-radio-group :disabled="reportDialogState.disabled"  v-model="reportDialogState.reportForm.assessLevel">
+                        <el-radio-group :disabled="reportDialogState.disabled"  v-model="reportDialogState.reportForm.assessLevel" class="checkTip">
                             <div style="display: flex;justify-content: center">
                                 <div style="display: flex;flex-direction: column">
                                     <el-radio :label="1">重大风险(一级)</el-radio>
@@ -194,7 +196,8 @@
                       <!--                      </td>-->
                     </tr>
                     <tr v-if="reportDialogState.reportForm.person?.length>0" class="m-color b-font" style="text-align: center">审批内容</tr>
-                    <template v-if="reportDialogState.reportForm.person?.length>0" v-for="item in reportDialogState.reportForm.person">
+                  <template v-if="reportDialogState.reportForm.person?.length > 0">
+                    <template v-for="item in reportDialogState.reportForm.person">
                       <tr>
                         <td class="w-25 m-color">{{item.approveStage}}</td>
                         <td class="w-25">{{item.approvePerson}}</td>
@@ -208,12 +211,14 @@
                         </td>
                       </tr>
                     </template>
+                  </template>
                 </table>
             </el-form>
             <template #footer>
               <span class="dialog-footer" style="padding-top:10px;text-align: center !important;">
                 <el-button @click="reportDialogState.reportDialogVisible = !reportDialogState.reportDialogVisible" size="default">取 消</el-button>
                 <el-button type="primary" v-if="!reportDialogState.disabled" @click="onSubmitProject()" size="default">提交审批</el-button>
+                <el-button type="primary" v-if="reportDialogState.disabled" @click="startGeneration()" size="default">导出评估报告</el-button>
               </span>
             </template>
         </el-dialog>
@@ -222,13 +227,14 @@
 
 <script setup lang="ts">
 import {defineAsyncComponent, nextTick, onMounted, reactive, ref} from "vue";
+import {generateWordDocument} from "/@/views/experiment/developing/components/exportWord.js";
 import {ElMessage} from "element-plus";
 import {projectApi} from "/@/api/experiment/project";
 import {personApi} from "/@/api/basic/person";
 import {userApi} from "/@/api/systemManage/user";
 import {roomApi} from "/@/api/basic/room";
 import {assessApplyApi} from "/@/api/analyse/assessApply";
-
+const typeValue = ref([])
 const SelectDanger = defineAsyncComponent(() => import('./selectDanger.vue'))
 const selectDangerRef = ref()
 const reportFormRef = ref()
@@ -256,7 +262,10 @@
         riskSource: [],
         riskSourceType: [],
         description: '',
-        person:[]
+        person:[],
+        process: '',
+      experimentAndType: [],
+      oldRiskAssess: []
     },
     reportFormRules: {
       assessPerson: [{ required: true, message: '请填写评估人员', trigger: 'blur' }],
@@ -266,6 +275,8 @@
     },
     allPersonList: [],
     allRoomList: [],
+    phaList: [],
+    details: {},
     systemPersonList: [],
     experimentTypeList: [
       {id: 1, name: '化学类'},
@@ -274,11 +285,58 @@
       {id: 4, name: '机电类'},
       {id: 5, name: '特种设备类'},
       {id: 6, name: '其它类'}
-    ]
+    ],
+  stuffTypeList: [
+    {id: 1, name: '化学试剂'},
+    {id:2, name: '基础材料'}
+  ],
+  stuffStorageList: [
+    {id:1, name: '智能试剂柜'},
+    {id:2, name: '普通储存柜'},
+  ],
+  stuffUnitList: [
+    {id:1, name: 'g'},
+    {id:2, name: 'kg'},
+    {id:3, name: 'ml'},
+    {id:4, name: 'l'},
+  ],
+  classifyList:[
+    {id:1, name: '有机'},
+    {id:2, name: '酸'},
+    {id:3, name: '碱性'},
+    {id:4, name: '固体废弃物'},
+    {id:5, name: '医疗废弃物'},
+    {id:6, name: '过期化学品'},
+    {id:7, name: '其他'}
+  ],
+  wasteStorageList: [
+    {id:1, name: '吨袋'},
+    {id:2, name: '吨桶'},
+    {id:3, name: '小桶'},
+    {id:4, name: '托盘'},
+    {id:5, name: '其他'},
+  ],
+  riskSourceTypeList: [
+    {id: 1, name: '化学安全'},
+    {id: 2, name: '辐射安全'},
+    {id: 3, name: '生物安全'},
+    {id: 4, name: '机电安全'},
+    {id: 5, name: '电气安全'},
+    {id: 6, name: '激光安全'},
+    {id: 7, name: '特种设备安全'},
+    {id: 8, name: '其他安全'},
+  ],
+  riskLevelList: [
+    {id: 1, name: '重大风险(一级)'},
+    {id: 2, name: '较大风险(二级)'},
+    {id: 3, name: '一般风险(三级)'},
+    {id: 4, name: '低风险(四级)'},
+  ],
 })
 
 const showReportDialog = (title: string, value: ProjectType, allRoomList: RoomType []) => {
     getReportData(value.id)
+    reportDialogState.details = value
     reportDialogState.reportDialogVisible = true;
     reportDialogState.allRoomList = allRoomList
     setTimeout(() => {
@@ -308,7 +366,6 @@
         //     }
         // }
     }
-    console.log(reportDialogState.reportForm,'form')
 };
 
 const isValidKey = (key: string | number | symbol, object:object): key is keyof typeof object =>{
@@ -320,7 +377,8 @@
     experimentId: id,
     pageIndex: 1,
     pageSize: 10,
-    tag: 3
+    tag: 3,
+    exportTag:true
   });
   if(res.data.code === 100){
     reportDialogState.reportForm = {
@@ -343,7 +401,10 @@
       riskSource: [],
       riskSourceType: [],
       description: '',
-      person:[]
+      person:[],
+      process: '',
+      experimentAndType: [],
+      oldRiskAssess: []
     }
     if(res.data.data&&res.data.data.length==0){
       ElMessage({
@@ -356,6 +417,9 @@
           reportDialogState.reportForm[i] = res.data.data[0][i];
         }
       }
+      reportDialogState.phaList = res.data.data[0].riskPlanMethodBO ?res.data.data[0].riskPlanMethodBO: []
+      const arr = reportDialogState.reportForm.experimentAndType.map(item => item.type.experimentType)
+      typeValue.value = arr.join(',')
     }
   }else{
     ElMessage({
@@ -461,6 +525,122 @@
             message: res.data.msg
         })
     }
+};
+
+const templatePath = '/static/exampleScience.docx'
+
+const startGeneration = async () => {
+  let data = JSON.parse(JSON.stringify(reportDialogState.reportForm))
+  const experimentTypeNameList = data.experimentAndType.map(item => {
+    return {
+      id: item.type.id,
+      experimentType: item.type.experimentType
+    }
+  })
+
+  const experimentTypeListExample =  JSON.parse(JSON.stringify(reportDialogState.experimentTypeList))
+  experimentTypeListExample.forEach(item => {
+    if(experimentTypeNameList.some(i => i.experimentType == item.name)){
+      item.label = item.name
+      item.checked = false
+    }else {
+      item.label = item.name
+      item.checked = true
+    }
+  })
+  data.typeList = experimentTypeListExample
+  data.depNameList = data.dep
+  const siteTest = data.experimentSite.map(item => item.siteName)
+  data.siteList = siteTest.join(',')
+
+  const riskType = data.riskSourceType.filter(item => item.status == 1)
+  const riskListExample = reportDialogState.riskSourceTypeList
+  riskListExample.forEach(item => {
+    if(riskType.some(i => i.riskSourceType === item.name)){
+      item.label = item.name
+      item.checked = false
+    }else {
+      item.label = item.name
+      item.checked = true
+    }
+  })
+  data.riskList = riskListExample
+
+  const level = data.assessLevel.toString().split(',')
+  const levelExample =  JSON.parse(JSON.stringify(reportDialogState.riskLevelList))
+  levelExample.forEach(item => {
+    if(level.some(i => i == item.id)){
+      item.label = item.name
+      item.checked = false
+    }else {
+      item.label = item.name
+      item.checked = true
+    }
+  })
+  data.riskLevel = levelExample
+  data.tableData = data.oldRiskAssess ?data.oldRiskAssess: []
+  data.phaData = reportDialogState.phaList?reportDialogState.phaList.map(item=>{
+    return {
+      ...item,
+      riskLevelName: item.riskLevel == 1?'低风险':item.riskLevel == 2?'一般风险':item.riskLevel == 3?'较大风险':item.riskLevel == 4?'重大风险':'--'
+    }
+  }):[]
+  data.siteData = data.experimentSite?data.experimentSite.map(item=>{
+    return {
+      ...item,
+      hasFireFacilities: item.fireFacilities== 1 ? '有' : item.fireFacilities== 2 ? '无' : '',
+      hasPartitionStatus: item.partitionStatus == 1 ? '有' : item.partitionStatus == 2 ? '无' : ''
+    }
+  }):[]
+  data.materialData = reportDialogState.details.stuffList?reportDialogState.details.stuffList.map(item=>{
+    return {
+      ...item,
+      typeName: reportDialogState.stuffTypeList.find(i=>i.id == item.stuffType)?.name,
+      storageName: reportDialogState.stuffStorageList.find(i=>i.id == item.stuffStorage)?.name,
+      unitName: reportDialogState.stuffUnitList.find(i=>i.id == item.stuffUnit)?.name
+    }
+  }):[]
+  data.equipData = reportDialogState.details.deviceList?reportDialogState.details.deviceList.map(item=>{
+    return {
+      ...item,
+      isSpecial: item.specialDevice == 1 ? '是' : item.specialDevice == 2 ? '否' : ''
+    }
+  }):[]
+  data.dangerData = reportDialogState.details.hazardousWasteList?reportDialogState.details.hazardousWasteList.map((item,index)=>{
+    return {
+      ...item,
+      sort: index + 1,
+      classifyName: reportDialogState.classifyList.find(i=>i.id == item.classify)?.name,
+      wasteStorageName: reportDialogState.wasteStorageList.find(i=>i.id == item.wasteStorage)?.name
+    }
+  }):[]
+  data.peopleData = reportDialogState.details.persons?reportDialogState.details.persons.map((item,index)=>{
+    return {
+      ...item,
+      sex: item.personGender == 1 ? '男' : item.personGender == 2 ? '女' : ''
+    }
+  }):[]
+  data.emergyData = reportDialogState.details.emergencyList?reportDialogState.details.emergencyList:[]
+  const {experimentStep,experimentMethod,process,keyProcess,measure,timeout,timeoutManager,closed,unclosedManager,explosionProof,fireProof,poisonProof} = reportDialogState.details
+  data = {...data,experimentStep,experimentMethod,process,keyProcess,measure,timeout:timeout == 1?'存在':timeout == 2?'不存在':'',timeoutManager,closed:closed == 1?'存在':closed == 2?'不存在':'',unclosedManager,explosionProof,fireProof,poisonProof}
+
+  data.riskSource = data.riskSource ? data.riskSource.map(item => {
+    return {
+      ...item,
+      description: item.description ? item.description: ''
+    }
+  }) :  []
+
+  data.safeRiskAnalysis = data.safeRiskAnalysis ?data.safeRiskAnalysis : ''
+
+  try {
+    generateWordDocument(templatePath, data, `材料科学姑苏实验室安全风险评估表---${data.experimentName}.docx`);
+  } catch (error){
+    ElMessage({
+      type: 'warning',
+      message: '失败'
+    });
+  }
 };
 
 const emit = defineEmits(['refresh']);
@@ -656,3 +836,35 @@
 
 
 </style>
+<style>
+.checkTip{
+  .is-disabled{
+    .el-checkbox__label{
+      color: #606266 !important
+    }
+    .el-radio__label{
+      color: #606266 !important
+    }
+    &.is-checked{
+      .el-checkbox__label{
+        color: #409eff !important
+      }
+      .el-radio__label{
+        color: #409eff !important
+      }
+      .el-checkbox__inner{
+        background-color: #409eff;
+        &::after{
+          border-color: #fff !important
+        }
+      }
+      .el-radio__inner{
+        background-color: #409eff !important;
+        &::after{
+          background-color: #fff !important
+        }
+      }
+    }
+  }
+}
+</style>
\ No newline at end of file

--
Gitblit v1.9.2