| | |
| | | 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{ |
| | |
| | | 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 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 // 用于生成表头 |
| | | }; |
| | | } |
| | | |