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/applyReview/components/reportDialog.vue |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 104 insertions(+), 9 deletions(-)

diff --git a/src/views/analyse/applyReview/components/reportDialog.vue b/src/views/analyse/applyReview/components/reportDialog.vue
index 38ed33b..4837c74 100644
--- a/src/views/analyse/applyReview/components/reportDialog.vue
+++ b/src/views/analyse/applyReview/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.experimentType)?.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>
@@ -208,6 +210,7 @@
               <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,10 +225,11 @@
 import {userApi} from "/@/api/systemManage/user";
 import {roomApi} from "/@/api/basic/room";
 import {assessApplyApi} from "/@/api/analyse/assessApply";
-
+import {generateWordDocument} from "/@/views/experiment/developing/components/exportWord.js";
 const SelectDanger = defineAsyncComponent(() => import('./selectDanger.vue'))
 const selectDangerRef = ref()
 const reportFormRef = ref()
+const typeValue = ref([])
 const reportDialogState = reactive<ReportDialogType>({
     title: '',
     disabled: false,
@@ -250,7 +254,10 @@
         riskSource: [],
         riskSourceType: [],
         description: '',
-        person: []
+        person: [],
+        process:'',
+      experimentAndType: [],
+      oldRiskAssess: []
     },
     reportFormRules: {
       assessPerson: [{ required: true, message: '请填写评估人员', trigger: 'blur' }],
@@ -268,7 +275,23 @@
       {id: 4, name: '机电类'},
       {id: 5, name: '特种设备类'},
       {id: 6, 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 []) => {
@@ -317,6 +340,8 @@
         reportDialogState.reportForm[i] = res.data.data[0][i];
       }
     }
+    const arr = reportDialogState.reportForm.experimentAndType.map(item => item.type.experimentType)
+    typeValue.value = arr.join(',')
     console.log(reportDialogState.reportForm,'reportDialogState.reportForm')
   }else{
     ElMessage({
@@ -424,6 +449,76 @@
 defineExpose({
     showReportDialog,
 });
+const templatePath = '/static/exampleScience.docx'
+const startGeneration = async () => {
+  const 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.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: '失败'
+    });
+  }
+};
 
 onMounted(() => {
     getAllPersonList();
@@ -605,16 +700,16 @@
     margin-left: 20px;
 }
 .tag-bg1 {
-    background: rgba(255,0,0,0.5);
+    background: rgba(255,0,0,0.65);
 }
 .tag-bg2 {
-    background: rgba(248,82,8,0.5);
+    background: rgba(248,82,8,0.65);
 }
 .tag-bg3 {
-    background: rgba(247,255,0,0.5);
+    background: rgba(247,255,0,0.65);
 }
 .tag-bg4 {
-    background: rgba(0,112,192,0.5);
+    background: rgba(0,112,192,0.65);
 }
 
 

--
Gitblit v1.9.2