From 1b7d920815f9dd79338996c4c9df0cdc2e797bc1 Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: 星期二, 09 十二月 2025 16:58:19 +0800
Subject: [PATCH] 修改新增

---
 src/views/build/conpanyFunctionConsult/digitalFileDep/manageType/qualityManual/index.vue |  605 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 399 insertions(+), 206 deletions(-)

diff --git a/src/views/build/conpanyFunctionConsult/digitalFileDep/manageType/qualityManual/index.vue b/src/views/build/conpanyFunctionConsult/digitalFileDep/manageType/qualityManual/index.vue
index c2b1e27..7075911 100644
--- a/src/views/build/conpanyFunctionConsult/digitalFileDep/manageType/qualityManual/index.vue
+++ b/src/views/build/conpanyFunctionConsult/digitalFileDep/manageType/qualityManual/index.vue
@@ -1,16 +1,16 @@
 <template>
   <div class="app-container">
     <div style="display: flex;justify-content: space-between">
-      <el-form :inline="true" style="display: flex;align-items: center;flex-wrap: wrap;" >
-<!--        <el-form-item>-->
-<!--          <el-button-->
-<!--              type="primary"-->
-<!--              plain-->
-<!--              icon="Plus"-->
-<!--              @click="openDialog('add',{})"-->
-<!--          >新增</el-button>-->
-<!--        </el-form-item>-->
-        <el-form-item v-if="isAdmin" label="企业:" >
+      <el-form :inline="true" style="display: flex;align-items: center;flex-wrap: wrap;">
+        <!--        <el-form-item>-->
+        <!--          <el-button-->
+        <!--              type="primary"-->
+        <!--              plain-->
+        <!--              icon="Plus"-->
+        <!--              @click="openDialog('add',{})"-->
+        <!--          >新增</el-button>-->
+        <!--        </el-form-item>-->
+        <el-form-item v-if="isAdmin" label="单位:">
           <el-select v-model="data.queryParams.companyId" placeholder="请选择" clearable>
             <el-option
                 v-for="item in companyList"
@@ -20,10 +20,10 @@
             </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item >
+        <el-form-item>
           <el-button v-if="isAdmin" type="primary" @click="getList">查询</el-button>
           <el-button v-if="isAdmin" type="primary" plain @click="reset">重置</el-button>
-          <el-button type="primary" @click="addFile">生成质量手册</el-button>
+          <el-button type="primary" @click="addFile" v-hasPermi="['qualityManage2:list:add']">生成质量手册</el-button>
         </el-form-item>
       </el-form>
     </div>
@@ -32,20 +32,27 @@
       <el-table-column label="序号" type="index" align="center" width="80"/>
       <el-table-column label="质量手册" prop="fileName" align="center">
         <template #default="scope">
-          <el-button link type="primary" @click="initFile(scope.row)">{{scope.row.companyName + scope.row.qualityName + '.docx'}}</el-button>
+          <el-button link type="primary" @click="initFile(scope.row)">
+            {{ scope.row.companyName + scope.row.qualityName + '.docx' }}
+          </el-button>
         </template>
       </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template #default="scope">
-<!--          <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button>-->
-          <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>
+          <el-button link type="primary" @click="initFile(scope.row)" v-hasPermi="['qualityManage2:list:edit']">下载
+          </el-button>
+          <el-button link type="primary" @click="openDialog('add',scope.row)" v-hasPermi="['qualityManage2:list:add']">
+            上传
+          </el-button>
+          <el-button link type="danger" @click="handleDelete(scope.row)" v-hasPermi="['qualityManage2:list:del']">删除
+          </el-button>
         </template>
       </el-table-column>
     </el-table>
 
     <div class="orgTreeBox" id="org-tree-container">
       <vue3-tree-org
-          :data="deptList"
+          :data="deptTree"
           :horizontal="false"
           :props="treeProps"
           :toolBar="tools"
@@ -60,6 +67,81 @@
         v-model:limit="queryParams.pageSize"
         @pagination="getList"
     />
+    <edit-dialog ref="dialogRef" @getList=getList></edit-dialog>
+    <el-dialog
+        v-model="dialogVisible"
+        width="750px"
+        :before-close="handleClose"
+        :close-on-press-escape="false"
+        :close-on-click-modal="false"
+    >
+      <el-form :model="dialogForm" size="default" ref="formRef" :rules="formRules" label-width="150px">
+        <el-form-item label="编号:" prop="number">
+          <el-input v-model.trim="dialogForm.number" placeholder="手册编号"></el-input>
+        </el-form-item>
+        <el-form-item label="版本号:" prop="versionNum">
+          <el-input v-model.trim="dialogForm.versionNum" placeholder="版本号"></el-input>
+        </el-form-item>
+        <el-form-item label="文件状态:" prop="fileStatus">
+          <el-input v-model.trim="dialogForm.fileStatus" placeholder="文件状态"></el-input>
+        </el-form-item>
+        <el-form-item label="发放号:" prop="grantNum">
+          <el-input v-model.trim="dialogForm.grantNum" placeholder="发放号"></el-input>
+        </el-form-item>
+        <el-form-item label="编制:" prop="fictionName">
+          <el-select clearable v-model="dialogForm.fictionName" filterable placeholder="编制" style="width: 100%">
+            <el-option
+                v-for="item in userList"
+                :key="item.name"
+                :label="item.name"
+                :value="item.name"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="审核:" prop="checkName">
+          <el-select clearable v-model="dialogForm.checkName" filterable placeholder="审核" style="width: 100%">
+            <el-option
+                v-for="item in userList"
+                :key="item.name"
+                :label="item.name"
+                :value="item.name"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="批准:" prop="ratifyName">
+          <el-select clearable v-model="dialogForm.ratifyName" filterable placeholder="批准" style="width: 100%">
+            <el-option
+                v-for="item in userList"
+                :key="item.name"
+                :label="item.name"
+                :value="item.name"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="发布日期:" prop="releaseDate">
+          <el-date-picker
+              v-model="dialogForm.releaseDate"
+              type="date"
+              placeholder="请选择日期"
+              value-format="YYYY-MM-DD"
+          />
+        </el-form-item>
+        <el-form-item label="实施日期:" prop="executionDate">
+          <el-date-picker
+              v-model="dialogForm.executionDate"
+              type="date"
+              placeholder="请选择日期"
+              value-format="YYYY-MM-DD"
+          />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="handleClose" size="default">取 消</el-button>
+          <el-button type="primary" @click="onSubmitAdd" size="default" v-preReClick>确认</el-button>
+      </div>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -68,9 +150,9 @@
 import {ElMessage, ElMessageBox} from "element-plus";
 import {delCompany, getCompany} from "@/api/onlineEducation/company";
 import {generateWordDocument} from './components/exportDoc.js'
-// import OrgTree from 'vue-org-tree'
+import editDialog from './components/editDialog.vue'
 import html2canvas from 'html2canvas'
-import { saveAs } from 'file-saver'
+import {saveAs} from 'file-saver'
 import useUserStore from "@/store/modules/user";
 import {
   addStandardQuality,
@@ -78,10 +160,11 @@
   getStandardDetail,
   getStandardQuality
 } from "@/api/standardSys/standardSys";
-import {getDepart, getDistribution} from "@/api/orgStructure/depart";
+import {getDepart, getDistribution, getFunctionalRemarkList, getSysClause} from "@/api/orgStructure/depart";
+import {getEmployeeRecords} from "@/api/onlineEducation/user";
 
 const userStore = useUserStore()
-const { proxy } = getCurrentInstance();
+const {proxy} = getCurrentInstance();
 const loading = ref(false);
 const dialogRef = ref();
 const data = reactive({
@@ -94,17 +177,11 @@
   dataList: [],
   deptList: {
     id: 0,
-    deptName: "总经理",
-    children:[
-      {
-        id: '0-1',
-        deptName: "管理者代表",
-        children: []
-      }
-    ]
+    deptName: "",
+    children: []
   },
   treeProps: {
-    label: 'deptName'
+    label: 'label'
   },
   tools: {
     scale: false, restore: false, expand: false, zoom: false, fullscreen: false
@@ -115,170 +192,192 @@
   },
   companyList: [],
   isAdmin: false,
-  companyInfo: {
-    summaries: '',
-    policies: '',
-    deptList: [],
-    duties: [],
-    temps: []
+  companyInfo: {},
+  caluseList: [],
+  originDeptList: [],
+  dialogVisible: false,
+  dialogForm: {
+    qualityName: '质量手册',
+    companyId: null,
+    number: '',
+    versionNum: '',
+    fileStatus: '',
+    grantNum: '',
+    fictionName: '',
+    checkName: '',
+    ratifyName: '',
+    releaseDate: '',
+    executionDate: ''
   },
-  caluseList: [
-    {clauseNum: '4', content: '组织环境'},
-    {clauseNum: '4.1', content: '理解组织及其环境',manage: true,represent: false},
-    {clauseNum: '4.2', content: '理解相关方的需求和期望',manage: true,represent: false},
-    {clauseNum: '4.3', content: '确定质量管理体系的范围',manage: false,represent: true},
-    {clauseNum: '4.4', content: '质量管理体系及其过程',manage: false,represent: true},
-    {clauseNum: '5', content: '领导作用'},
-    {clauseNum: '5.1', content: '领导作用和承诺',manage: true,represent: false},
-    {clauseNum: '5.2', content: '质量方针',manage: true,represent: false},
-    {clauseNum: '5.3', content: '组织的岗位、职责和权限',manage: true,represent: false},
-    {clauseNum: '6', content: ''},
-    {clauseNum: '6.1', content: '应对风险和机遇的措施',manage: true,represent: false},
-    {clauseNum: '6.2', content: '质量目标及其实现的策划',manage: false,represent: true},
-    {clauseNum: '6.3', content: '变更的策划',manage: false,represent: true},
-    {clauseNum: '7', content: '支持'},
-    {clauseNum: '7.1', content: '资源',manage: true,represent: false},
-    {clauseNum: '7.1.1', content: '总则',manage: true,represent: false},
-    {clauseNum: '7.1.2', content: '人员',manage: true,represent: false},
-    {clauseNum: '7.1.3', content: '基础设施',manage: false,represent: true},
-    {clauseNum: '7.1.4', content: '过程运行环境',manage: false,represent: true},
-    {clauseNum: '7.1.5', content: '监视和测量资源',manage: false,represent: true},
-    {clauseNum: '7.1.6', content: '组织的知识',manage: false,represent: true},
-    {clauseNum: '7.2', content: '能力'},
-    {clauseNum: '7.3', content: '意识'},
-    {clauseNum: '7.4', content: '沟通'},
-    {clauseNum: '7.5', content: '成文信息'},
-    {clauseNum: '7.6', content: '质量信息'},
-    {clauseNum: '8', content: '运行'},
-    {clauseNum: '8.1', content: '运行策划和控制'},
-    {clauseNum: '8.2', content: '产品和服务的要求'},
-    {clauseNum: '8.2.1', content: '顾客沟通'},
-    {clauseNum: '8.2.2', content: '与产品和服务有关的要求的确定'},
-    {clauseNum: '8.2.3', content: '与产品和服务有关的要求的评审'},
-    {clauseNum: '8.2.4', content: '产品和服务要求的更改'},
-    {clauseNum: '8.3', content: '产品和服务的设计和开发'},
-    {clauseNum: '8.3.1', content: '总则'},
-    {clauseNum: '8.3.2', content: '设计和开发策划'},
-    {clauseNum: '8.3.3', content: '设计和开发输入'},
-    {clauseNum: '8.3.4', content: '设计和开发控制'},
-    {clauseNum: '8.3.5', content: '设计和开发输出'},
-    {clauseNum: '8.3.6', content: '设计和开发更改'},
-    {clauseNum: '8.3.7', content: '新产品试制'},
-    {clauseNum: '8.3.8', content: '设计和开发的试验控制'},
-    {clauseNum: '8.4', content: '外部提供过程、产品和服务的控制'},
-    {clauseNum: '8.4.1', content: '总则'},
-    {clauseNum: '8.4.2', content: '控制类型和程度'},
-    {clauseNum: '8.4.3', content: '提供给外部供方的信息'},
-    {clauseNum: '8.5', content: '生产和服务提供'},
-    {clauseNum: '8.5.1', content: '生产和服务提供的控制'},
-    {clauseNum: '8.5.2', content: '标识和可追溯性'},
-    {clauseNum: '8.5.3', content: '顾客或外部供方的财产'},
-    {clauseNum: '8.5.4', content: '防护'},
-    {clauseNum: '8.5.5', content: '交付后的活动'},
-    {clauseNum: '8.5.6', content: '更改控制'},
-    {clauseNum: '8.5.7', content: '关键过程'},
-    {clauseNum: '8.6', content: '产品和服务的放行'},
-    {clauseNum: '8.7', content: '不合格输出的控制'},
-    {clauseNum: '9', content: '绩效评价'},
-    {clauseNum: '9.1', content: '监视、测量、分析和评价'},
-    {clauseNum: '9.1.1', content: '总则'},
-    {clauseNum: '9.1.2', content: '顾客满意'},
-    {clauseNum: '9.1.3', content: '分析和评价'},
-    {clauseNum: '9.2', content: '内部审核'},
-    {clauseNum: '9.3', content: '管理评审'},
-    {clauseNum: '10', content: '持续改进'},
-    {clauseNum: '10.1', content: '总则'},
-    {clauseNum: '10.2', content: '不合格和纠正措施'},
-    {clauseNum: '10.3', content: '持续改进'}
-  ]
+  formRules: {},
+  userList: [],
+  deptTree: {
+    id: 0,
+    label: "",
+    children: []
+  }
 });
 
-const { queryParams, total, dataList,deptList,treeProps,tools,labelStyle,companyList, isAdmin, companyInfo, caluseList } = toRefs(data);
+const {
+  queryParams,
+  total,
+  dataList,
+  deptList,
+  treeProps,
+  tools,
+  labelStyle,
+  companyList,
+  isAdmin,
+  companyInfo,
+  caluseList,
+  dialogVisible,
+  dialogForm,
+  formRules,
+  userList,
+  deptTree
+} = toRefs(data);
 const userInfo = ref()
-onMounted(async ()=>{
-  if(userStore.roles.includes('admin')){
+const formRef = ref()
+onMounted(async () => {
+  await getSysClauseList()
+  if (userStore.roles.includes('admin')) {
     data.isAdmin = true
     await getCompanyList()
-  }else{
+  } else {
     data.isAdmin = false
     data.queryParams.companyId = userStore.companyId
   }
   await getList()
 })
 
-onUnmounted(()=>{
+onUnmounted(() => {
 
 })
+const handleClose = () => {
+  data.dialogForm = {
+    qualityName: '质量手册',
+    companyId: null,
+    number: '',
+    versionNum: '',
+    fileStatus: '',
+    grantNum: '',
+    fictionName: '',
+    checkName: '',
+    ratifyName: '',
+    releaseDate: '',
+    executionDate: ''
+  }
+  data.dialogVisible = false
+}
 
+const onSubmitAdd = async () => {
+  const valid = await formRef.value.validate()
+  if (valid) {
+    const res = await addStandardQuality(data.dialogForm)
+    if (res.code == 200) {
+      ElMessage.success(res.message)
+      await handleClose()
+      await reset()
+    } else {
+      ElMessage.warning(res.message)
+    }
+  }
+}
 
+const getSysClauseList = async () => {
+  const res = await getSysClause()
+  if (res.code == 200) {
+    data.caluseList = res.data.map(i => {
+      return {
+        clauseNum: i.clauseNum,
+        content: i.name
+      }
+    })
+  } else {
+    ElMessage.warning(res.message)
+  }
+}
+const getUserList = async (companyId)=> {
+  const res = await getEmployeeRecords({companyId: companyId})
+  if(res.code == 200){
+    data.userList = res.data ? res.data :[]
+  }else{
+    ElMessage.warning(res.message)
+  }
+}
 const getList = async () => {
   loading.value = true
   const res = await getStandardQuality(data.queryParams)
-  if(res.code == 200){
+  if (res.code == 200) {
     data.dataList = res.data.data || []
     data.total = res.data.total
-  }else{
+  } else {
     ElMessage.warning(res.message)
   }
   loading.value = false
 }
 
 const getDeptData = async (val) => {
-  await getDeptList(val.companyId)
+  await getDeptList(val)
   const res = await getDistribution({companyId: val.companyId})
-  if(res.code == 200){
-    for(let item of data.caluseList){
-      const sameNum = data.companyInfo.duties.filter(i=>i.clauseNum == item.clauseNum).map(j=> {
+  if (res.code == 200) {
+    for (let item of data.caluseList) {
+      const sameNum = data.companyInfo.duties.filter(i => i.clauseNum == item.clauseNum).map(j => {
             return {
               deptId: j.deptId,
               chooseLab: j.chooseLab
             }
           }
       )
-      for(let i of sameNum){
-        item[i.deptId] = i.chooseLab? (i.chooseLab==1?'●':'○'):'○'
+      for (let i of sameNum) {
+        item[i.deptId] = i.chooseLab ? (i.chooseLab == 1 ? '●' : '○') : '○'
       }
     }
-  }else{
+  } else {
     ElMessage.warning(res.message)
   }
 }
-const getDeptList = async (id) => {
-  const res = await getDepart({pageNum: 1, pageSize: 999, companyId: id})
-  if(res.code == 200){
-    data.deptList.children[0].children = res.data
-  }else{
+const getDeptList = async (val) => {
+  const res = await getDepart({responsType: 1, companyId: val.companyId})
+  if (res.code == 200) {
+    data.originDeptList = JSON.parse(JSON.stringify(res.data))
+    data.deptList.deptName = val.companyName
+    data.deptTree.label = val.companyName
+    data.deptList.children = proxy.handleTree(res.data, "deptId")
+  } else {
     ElMessage.warning(res.message)
   }
 }
-const addFile = async ()=>{
-  let params={}
-  if(data.queryParams.companyId){
-    params = {
-      qualityName: '质量手册',
-      companyId: data.queryParams.companyId
+const addFile = async () => {
+  if (data.queryParams.companyId) {
+    data.dialogForm.companyId = data.queryParams.companyId
+    const res = await getStandardQuality(data.queryParams)
+    if (res.code == 200) {
+      const val = res.data.data[0]
+      Object.keys(data.dialogForm).forEach(key => {
+        if (key in val) {
+          data.dialogForm[key] = val[key]
+        }
+      })
+    } else {
+      ElMessage.warning(res.message)
     }
-  }else{
+    await getUserList(data.queryParams.companyId)
+    data.dialogVisible = true
+  } else {
     ElMessage.warning('请先选择对应的企业')
     return
   }
-  const res = await addStandardQuality(params)
-  if(res.code == 200){
-    ElMessage.success(res.message)
-    await getList()
-  }else{
-    ElMessage.warning(res.message)
-  }
 }
 
-const getCompanyList = async ()=>{
+const getCompanyList = async () => {
   const queryParams = {
     pageNum: 1,
     pageSize: 999
   }
   const res = await getCompany(queryParams)
   if (res.code == 200) {
-    data.companyList = res.data.list?res.data.list:[]
+    data.companyList = res.data.list ? res.data.list : []
     // data.queryParams.companyId = data.companyList[0].id
   } else {
     ElMessage.warning(res.message)
@@ -286,95 +385,189 @@
 }
 
 const getInfo = async (val) => {
-  loading.value = true;
   const res = await getStandardDetail({companyId: val.companyId});
-  if(res.code === 200){
-    if(!res.data || (res.data.companyIndustryTemplates.length == 0 && res.data.companyQualityPolicies.length == 0 && res.data.companySummaries.length == 0 && res.data.sysFunctionalDistributions
-        .length == 0 && res.data.treeSelects.length == 0)){
-      loading.value = false;
-      return Promise.reject(new Error('该企业暂无质量数据'));
+  if (res.code === 200) {
+
+    // 调试 proclaim 数据
+    if (!res.data || (res.data.companyIndustryTemplates.length == 0 && res.data.companyQualityPolicies.length == 0 && res.data.companySummaries.length == 0 && res.data.sysFunctionalDistributions
+        .length == 0 && res.data.treeSelects.length == 0)) {
+      loading.value = false
+      return Promise.reject(new Error('该企业暂无质量数据'))
     }
+    data.deptTree.children = res.data.treeSelects || []
     data.companyInfo.summaries = res.data.companySummaries ? res.data.companySummaries[0]?.companySummary : []
     data.companyInfo.policies = res.data.companyQualityPolicies ? res.data.companyQualityPolicies[0]?.policy : []
-    data.companyInfo.deptList = res.data.treeSelects ? res.data.treeSelects : []
-    // data.companyInfo.clauses = data.caluseList
-    // data.companyInfo.duties = res.data.sysFunctionalDistributions
-
-    const duties = transToTableData(res.data.sysFunctionalDistributions)
-    data.companyInfo.allDeptNames = duties.allDeptNames
+    const duties = transToTableData(res.data.sysFunctionalDistributions, data.originDeptList)
+    data.companyInfo.allDepts = duties.allDepts
     data.companyInfo.clauses = duties.clauses
-    data.companyInfo.temps = res.data.companyIndustryTemplates?.map((item,index)=>{
+    data.companyInfo.temps = res.data.companyIndustryTemplates?.map((item, index) => {
       return {
         index: index + 1,
         templateName: item.templateName
       }
     }) || []
-    // const imageBase64 = await exportTableToImage()
-    // data.companyInfo.tableImage = {
-    //   data: imageBase64.split(",")[1], // 去掉 data:image/png;base64, 前缀
-    //   type: "png",
-    // }
-  }else{
+    data.companyInfo.productServiceImages = res.data.productServiceDatas ? await processImagesToBase64(res.data.productServiceDatas) : []
+    data.companyInfo.proclaim1 = res.data.proclaim.find(i=>i.type == 1)?.content || ''
+    data.companyInfo.sign1 = await urlToBase64(res.data.proclaim.find(i=>i.type == 1)?.sign) || ''
+    data.companyInfo.updateTime1 = res.data.proclaim.find(i=>i.type == 1 && i.status == 1)?.updateTime?.substring(0,10) || ''
+    data.companyInfo.proclaim2 = res.data.proclaim.find(i=>i.type == 2)?.content || ''
+    data.companyInfo.sign2 = await urlToBase64(res.data.proclaim.find(i=>i.type == 2)?.sign) || ''
+    data.companyInfo.updateTime2 = res.data.proclaim.find(i=>i.type == 2 && i.status == 1)?.updateTime?.substring(0,10) || ''
+    data.companyInfo.proclaim3 = res.data.proclaim.find(i=>i.type == 3)?.content || ''
+    data.companyInfo.sign3 = await urlToBase64(res.data.proclaim.find(i=>i.type == 3)?.sign) || ''
+    data.companyInfo.updateTime3 = res.data.proclaim.find(i=>i.type == 3 && i.status == 1)?.updateTime?.substring(0,10) || ''
+    data.companyInfo.proclaim4 = res.data.proclaim.find(i=>i.type == 4)?.content || ''
+    data.companyInfo.sign4 = await urlToBase64(res.data.proclaim.find(i=>i.type == 4)?.sign) || ''
+    data.companyInfo.updateTime4 = res.data.proclaim.find(i=>i.type == 4 && i.status == 1)?.updateTime?.substring(0,10) || ''
+  } else {
     ElMessage.warning(res.message)
   }
-  loading.value = false;
 }
 
-const transToTableData=(duties)=>{
+const getRemarksList = async (companyId) => {
+  const res = await getFunctionalRemarkList({companyId: companyId})
+  if (res.code == 200) {
+    const originRemark = res.data
+    for (let item of originRemark) {
+      const foundObj = data.caluseList.find(i => i.clauseNum == item.clauseNum)
+      if (foundObj) {
+        foundObj.remark = item.remark
+      }
+    }
+    data.companyInfo.remarks = originRemark.map(i => {
+      return `${i.clauseNum}:${i.remark}`
+    }).join(';')
+  } else {
+    ElMessage.warning(res.message)
+  }
+}
+
+const transToTableData = (duties, deptList) => {
   // 步骤1:获取所有唯一的部门和条款编号
-  const allDeptNames = [...new Set(duties.map(item => item.deptName))];
+  // const allDeptNames = [...new Set(duties.map(item => item.deptName))];
+  const allDepts = deptList
   const allClauseNums = [...new Set([
     ...data.caluseList.map(c => c.clauseNum),
     ...duties.map(d => d.clauseNum)
   ])];
 
 // 步骤2:为每个条款生成完整的部门数据(缺失数据默认 chooseLab: 0)
+  const mergeValues = ['7.1', '8.2', '8.3', '8.4', '8.5', '9.1']
   const processedClauses = allClauseNums.map(clauseNum => {
     const clauseContent = data.caluseList.find(c => c.clauseNum === clauseNum)?.content || "";
-
     // 为当前条款生成所有部门的数据(确保每个部门都有值)
-    const deptValues = allDeptNames.map(deptName => {
+    const deptValues = allDepts.map(dept => {
       const matchedDept = duties.find(
-          item => item.clauseNum === clauseNum && item.deptName === deptName
-      );
-      return matchedDept ? (matchedDept.chooseLab==1?'●':'○' ): '○';
-
+          item => item.clauseNum === clauseNum && item.deptId === dept.deptId
+      )
+      if (dept.deptType == '0') {
+        return matchedDept ? (matchedDept.chooseLab == 1 ? '●' : '○') : '○'
+      } else {
+        return matchedDept ? (matchedDept.chooseLab == 1 ? '▲' : '○') : '○'
+      }
     });
-
     return {
       clauseNum,
       content: clauseContent,
-      deptValues // 数组形式,例如 [0, 1, 0, 0]
-    };
-  });
-
+      deptValues: !mergeValues.includes(clauseNum) ? deptValues : deptValues.map(i => '')
+    }
+  })
 // 最终数据结构
   return {
     clauses: processedClauses,
-    allDeptNames // 用于生成表头
+    allDepts // 用于生成表头
   };
 }
 
-const initFile = async (val) => {
-  try {
-    await getInfo(val)
-    await getDeptData(val)
-    // 2. 等待DOM更新完成
-    await nextTick();
+// 新增:将图片URL转换为Base64
+async function urlToBase64(imageUrl) {
+  if (!imageUrl || imageUrl.trim() === '') {
+    console.log('urlToBase64: 接收到空URL');
+    return '';
+  }
+  return new Promise((resolve, reject) => {
+    // 如果是相对路径,添加基础URL
+    let fullUrl = imageUrl;
+    if (!imageUrl.startsWith('http')) {
+      fullUrl = import.meta.env.VITE_APP_BASE_API + '/' + imageUrl;
+    }
+    const xhr = new XMLHttpRequest();
+    xhr.open('GET', fullUrl, true);
+    xhr.responseType = 'blob';
 
-    // 3. 捕获组织结构图图片
-    const orgChartImage = await captureElementToImage('org-tree-container');
-    data.companyInfo.orgChart = orgChartImage
-    const templatePath = '/qualityFile.docx'
-    await generateWordDocument(
-        templatePath,
-        data.companyInfo,
-        val.companyName+'质量手册.docx'
-    );
-    ElMessage.success('手册导出成功!')
-  } catch (error) {
-    console.error('操作失败:', error);
-    ElMessage.warning(error.message || '操作失败');
+    xhr.onload = function () {
+      if (this.status === 200) {
+        const blob = this.response;
+        const reader = new FileReader();
+        reader.onloadend = function () {
+          resolve(reader.result); // 返回base64字符串
+        };
+        reader.onerror = reject;
+        reader.readAsDataURL(blob);
+      } else {
+        reject(new Error(`图片加载失败: ${this.status}`));
+      }
+    };
+    xhr.onerror = reject;
+    xhr.send();
+  });
+}
+
+// 新增:处理图片数组
+async function processImagesToBase64(imagePaths) {
+  if (!imagePaths || imagePaths.length === 0) return [];
+
+  const processed = [];
+  for (const path of imagePaths) {
+    try {
+      // 如果是网络路径,先下载
+      const base64 = await urlToBase64(path);
+      processed.push(base64);
+    } catch (error) {
+      console.error('处理图片失败:', path, error);
+      processed.push(''); // 或保持原始路径
+    }
+  }
+  return processed;
+}
+
+const initFile = async (val) => {
+  data.companyInfo = {}
+  loading.value = true
+  if (val.filePath !== '') {
+    window.open(import.meta.env.VITE_APP_BASE_API + '/' + val.filePath)
+  } else {
+    try {
+      await getDeptList(val)
+      await getInfo(val)
+      await getRemarksList(val.companyId)
+      // 2. 等待DOM更新完成
+      await nextTick();
+
+      // 3. 捕获组织结构图图片
+      const orgChartImage = await captureElementToImage('org-tree-container');
+      data.companyInfo.orgChart = orgChartImage
+      data.companyInfo.companyName = val.companyName
+      data.companyInfo.number = val.number
+      data.companyInfo.versionNum = val.versionNum
+      data.companyInfo.fileStatus = val.fileStatus
+      data.companyInfo.grantNum = val.grantNum
+      data.companyInfo.fictionName = val.fictionName
+      data.companyInfo.checkName = val.checkName
+      data.companyInfo.ratifyName = val.ratifyName
+      data.companyInfo.releaseDate = val.releaseDate?.substring(0,10)
+      data.companyInfo.executionDate = val.executionDate?.substring(0,10)
+      const templatePath = '/qualityFile1.docx'
+      await generateWordDocument(
+          templatePath,
+          data.companyInfo,
+          val.companyName + '质量手册.docx'
+      );
+      loading.value = false
+    } catch (error) {
+      console.error('操作失败:', error);
+      ElMessage.warning(error.message || '操作失败');
+    }
   }
 }
 
@@ -392,11 +585,11 @@
 }
 
 const openDialog = (type, value) => {
-  dialogRef.value.openDialog(type, value, data.queryParams.companyId, data.isAdmin, data.companyList);
+  dialogRef.value.openDialog(type, value);
 }
 
 /** 重置新增的表单以及其他数据  */
-const reset= async()=> {
+const reset = async () => {
   data.queryParams = {
     pageNum: 1,
     pageSize: 10,
@@ -414,12 +607,12 @@
         cancelButtonText: '取消',
         type: 'warning',
       })
-      .then( async() => {
+      .then(async () => {
         const res = await delStandardQuality({standardizedQualityId: val.id})
-        if(res.code == 200){
+        if (res.code == 200) {
           ElMessage.success('数据删除成功')
           await getList()
-        }else{
+        } else {
           ElMessage.warning(res.message)
         }
       })
@@ -427,12 +620,12 @@
 
 </script>
 <style lang="scss">
-  .orgTreeBox{
-    width: 700px;
-    height: 700px;
-    position: absolute;  /* 或 fixed */
-    left: -9999px;      /* 移出可视区域 */
-    pointer-events: none; /* 禁止交互 */
-    z-index: -1;
-  }
-</style>
\ No newline at end of file
+.orgTreeBox {
+  width: 1200px;
+  height: 1200px;
+  position: absolute; /* 或 fixed */
+  left: -9999px; /* 移出可视区域 */
+  pointer-events: none; /* 禁止交互 */
+  z-index: -1;
+}
+</style>

--
Gitblit v1.9.2