| | |
| | | getStandardDetail, |
| | | getStandardQuality |
| | | } from "@/api/standardSys/standardSys"; |
| | | import {getDepart, getDistribution, getSysClause} from "@/api/orgStructure/depart"; |
| | | import {getDepart, getDistribution, getFunctionalRemarkList, getSysClause} from "@/api/orgStructure/depart"; |
| | | |
| | | const userStore = useUserStore() |
| | | const { proxy } = getCurrentInstance(); |
| | |
| | | const getDeptList = async (val) => { |
| | | const res = await getDepart({responsType: 1, companyId: val.companyId}) |
| | | if(res.code == 200){ |
| | | data.originDeptList = res.data |
| | | data.originDeptList = JSON.parse(JSON.stringify(res.data)) |
| | | data.deptList.deptName = val.companyName |
| | | data.deptList.children = proxy.handleTree(res.data, "deptId") |
| | | }else{ |
| | |
| | | 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)){ |
| | | return Promise.reject(new Error('该企业暂无质量数据')); |
| | | loading.value = false |
| | | return Promise.reject(new Error('该企业暂无质量数据')) |
| | | } |
| | | data.companyInfo.summaries = res.data.companySummaries ? res.data.companySummaries[0]?.companySummary : [] |
| | | data.companyInfo.policies = res.data.companyQualityPolicies ? res.data.companyQualityPolicies[0]?.policy : [] |
| | | const duties = transToTableData(res.data.sysFunctionalDistributions,data.originDeptList) |
| | | data.companyInfo.allDeptNames = duties.allDeptNames |
| | | data.companyInfo.allDepts = duties.allDepts |
| | | console.log(data.companyInfo.allDepts,'all') |
| | | data.companyInfo.clauses = duties.clauses |
| | | data.companyInfo.temps = res.data.companyIndustryTemplates?.map((item,index)=>{ |
| | | return { |
| | |
| | | } |
| | | } |
| | | |
| | | 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 = deptList ? deptList.map(item => item.deptName) : [...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) |
| | |
| | | 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, |
| | |
| | | // 最终数据结构 |
| | | return { |
| | | clauses: processedClauses, |
| | | allDeptNames // 用于生成表头 |
| | | allDepts // 用于生成表头 |
| | | }; |
| | | } |
| | | |
| | |
| | | try { |
| | | await getDeptList(val) |
| | | await getInfo(val) |
| | | await getRemarksList(val.companyId) |
| | | // 2. 等待DOM更新完成 |
| | | await nextTick(); |
| | | |