diff --git a/src/views/my/initiateChange/index.vue b/src/views/my/initiateChange/index.vue index 33e485f..3e40e95 100644 --- a/src/views/my/initiateChange/index.vue +++ b/src/views/my/initiateChange/index.vue @@ -5,6 +5,8 @@ import { useThemeStore } from '@/store/modules/theme'; import { useRoute } from 'vue-router'; import { getColorWithOpacity } from "@/utils/common"; import { localStg } from '@/utils/storage'; +import { storeToRefs } from 'pinia'; +import { useChangeStore } from '@/store/modules/change'; import { queryUnsavedApi, saveChangeApi, submitChangeApi, getChangeDetailApi } from '@/service/api/change'; import { systemConfigApi, templateListApi, } from '@/service/api/system'; import { orgListApi } from '@/service/api/user'; @@ -16,6 +18,8 @@ import Pssr from "./modules/pssr.vue"; import Evaluation from "./modules/evaluation.vue"; import CloseConfirm from "./modules/closeConfirm.vue"; +const changeStore = useChangeStore(); +const { getFlowInfo } = storeToRefs(changeStore); const themeStore = useThemeStore(); const route = useRoute(); @@ -130,20 +134,32 @@ const confirmTab = (tab: string, val: boolean) => { const getAllFormData = () => { let changePreForm = changePreRef.value?.form; let changeApplyForm = changeApplyRef.value?.form; + let questions = changeApplyRef.value?.questions; + let newQuestions = questions.map(({ question_id, score }:any) => ({ question_id, score })); let changeRiskForm = riskAnalysisRef.value?.riskRecords; let changeTrainingForm = changeTrainingRef.value?.form; let pssrForm = pssrRef.value?.list; + let allItems = pssrForm.flatMap((group:any) => group.items ?? []); let evaluationForm = evaluationRef.value?.list; + let flowList = getFlowInfo.value.map((item:any) => ({ + members: item.selectedMember.map((m:any) => ({ + user_id: m.user_id, + org_id: m.org_id, + org_name: m.org_name, + specialty: m.specialty === '' ? null : (m.specialty ?? null), + is_sign: m.is_sign + })) + })); // let closeConfirmForm = closeConfirmRef.value?.form; return { title: title.value, precheck:{...changePreForm}, - apply_form:{...changeApplyForm}, - approval_flow: {}, + apply_form:{...changeApplyForm,level_score:newQuestions}, + approval_flow: {steps:flowList}, risk_records:changeRiskForm, train:{...changeTrainingForm}, - pssr:{items:pssrForm}, - accept_form:{...evaluationForm}, + pssr:{items:allItems}, + accept_form:{items:evaluationForm,purposes:changeApplyForm?.purposes,effect:changeApplyForm?.effect}, }; } diff --git a/src/views/my/initiateChange/modules/changeApply.vue b/src/views/my/initiateChange/modules/changeApply.vue index a59eb3e..b1d2018 100644 --- a/src/views/my/initiateChange/modules/changeApply.vue +++ b/src/views/my/initiateChange/modules/changeApply.vue @@ -56,7 +56,6 @@ const form = ref<{ materials: string, update_docs: string[], disciplines: string[], - manage_dept: string, plan_use_date: number | null, risk_tools: string[], }>({ @@ -73,7 +72,6 @@ const form = ref<{ materials: '', update_docs: [], disciplines: [], - manage_dept: '', plan_use_date: null, risk_tools: [], }); @@ -92,9 +90,11 @@ const RISK_TOOLS_FORM = [ { key: "SCL", label: "设备SCL" }, { key: "RISK_CHECK", label: "风险检查表" }, ]; -const LEVEL_DIMS = ref([ +const questions = ref([ { - name: "1. 设备影响", note: "不合适的材质将会导致", + question_id: 1, + name: "1. 设备影响", + note: "不合适的材质将会导致", score: 0, options: [ { label: "对设备带来一定的损害及腐蚀", score: 1 }, @@ -104,7 +104,9 @@ const LEVEL_DIMS = ref([ ], }, { - name: "2. 财务影响", note: "工艺设计错误将会导致", + question_id: 2, + name: "2. 财务影响", + note: "工艺设计错误将会导致", score: 0, options: [ { label: "一定损失,a<1万人民币", score: 1 }, @@ -114,7 +116,9 @@ const LEVEL_DIMS = ref([ ], }, { - name: "3. 质量影响", note: "", + question_id: 3, + name: "3. 质量影响", + note: "", score: 0, options: [ { label: "对质量带来一定的风险(非关键工席、非关键设备设施的变更)", score: 1 }, @@ -124,7 +128,9 @@ const LEVEL_DIMS = ref([ ], }, { - name: "4. 设计的复杂程度", note: "工艺设计包含了", + question_id: 4, + name: "4. 设计的复杂程度", + note: "工艺设计包含了", score: 0, options: [ { label: "少量的简单系统(单个设备或单个部件)", score: 1 }, @@ -134,7 +140,9 @@ const LEVEL_DIMS = ref([ ], }, { - name: "5. 工艺设计的成熟度", note: "", + question_id: 5, + name: "5. 工艺设计的成熟度", + note: "", score: 0, options: [ { label: "被频繁使用,且被证明为专利方设计", score: 1 }, @@ -144,7 +152,9 @@ const LEVEL_DIMS = ref([ ], }, { - name: "6. 工艺危害", note: "物料性质和工艺条件", + question_id: 6, + name: "6. 工艺危害", + note: "物料性质和工艺条件", score: 0, options: [ { label: "无危害(常压、-10℃≤温度<40℃、无毒、无腐蚀不燃)", score: 1 }, @@ -250,14 +260,14 @@ const useAiLevel = async () => { if (levelAiLoading.value) return; levelAiLoading.value = true; try { - const dims = LEVEL_DIMS.value.map((d:any, i:any) => ({ dim: `DIM_${i + 1}`, name: d.name, max: Math.max(...d.options.map((o:any) => o.score)) })); + const dims = questions.value.map((d:any, i:any) => ({ dim: `DIM_${i + 1}`, name: d.name, max: Math.max(...d.options.map((o:any) => o.score)) })); const res = await aiLevelScore(form.description, (form.compare_rows ?? []).map((x: any) => ({ item: x.item, before_text: x.before_text, after_text: x.after_text })), dims); // 重新评分前清零,避免多次点击分数累加 totalScore.value = 0; levelAiBasis.value = []; res?.dims?.forEach((d, i) => { totalScore.value += d.score ?? 0; - LEVEL_DIMS.value[i].score = d.score ?? 0; + questions.value[i].score = d.score ?? 0; levelAiBasis.value[i] = d.basis ?? ""; }); levelAiText.value = res?.analysis_text ?? ""; @@ -316,9 +326,9 @@ const onRegenerate = async () => { } // 处理等级判定表评分变化 const handleScoreChange = (val:number,index:number) => { - LEVEL_DIMS.value[index].score = val; + questions.value[index].score = val; let score = 0; - LEVEL_DIMS.value.forEach((d:any) => { + questions.value.forEach((d:any) => { score += d.score; }); totalScore.value = score; @@ -398,7 +408,7 @@ const confirmTab = (tab:string, val:boolean) => { emit('confirmTab', tab, val); } -defineExpose({form, applyAiResult, generateLevel: useAiLevel}) +defineExpose({form, questions, applyAiResult, generateLevel: useAiLevel}) @@ -727,16 +737,16 @@ defineExpose({form, applyAiResult, generateLevel: useAiLevel})
-
+
{{ dim.name }} ({{ dim.note }}) - 得分 {{ LEVEL_DIMS[di].score }} + 得分 {{ questions[di].score }}
- +

{{ op.label }}({{ op.score }}分)

@@ -756,7 +766,7 @@ defineExpose({form, applyAiResult, generateLevel: useAiLevel})

{{ levelAiText }}

-

+

(各维度得分均可人工改判,修改留痕;改判后等级自动回填至申请表)

diff --git a/src/views/my/initiateChange/modules/hazop.vue b/src/views/my/initiateChange/modules/hazop.vue index 18304c7..192958e 100644 --- a/src/views/my/initiateChange/modules/hazop.vue +++ b/src/views/my/initiateChange/modules/hazop.vue @@ -174,10 +174,14 @@ const findRowWithParents = (rowIndex: number = -1) => { ...row, scene: `${row.cause?row.cause+';':''}${currentDev.value?.deviation+';'}${row.consequence?'可能导致:'+row.consequence:''}`, source: 'HAZOP', - risk_item: `${currentDev.value?.deviation}${currentNode.value?.node_name?`(${currentNode.value?.node_name}${currentObj.value?.obj_name?`-${currentObj.value?.obj_name}`:''})`:''}`, - safe: row?.safeguards?.map((item:any) => item.name).join(';') || '', - suggestion: row?.suggestions?.map((item:any) => item.name).join(';') || '', - to_pssr: 0 + item: `${currentDev.value?.deviation}${currentNode.value?.node_name?`(${currentNode.value?.node_name}${currentObj.value?.obj_name?`-${currentObj.value?.obj_name}`:''})`:''}`, + inherent_level: row?.risk_value || '', + safeguards: row?.safeguards?.map((item:any) => item.name).join(';') || '', + suggestions: row?.suggestions?.map((item:any) => item.name).join(';') || '', + residual_level: countRiskLevel(row)?.name || '', + to_pssr: 0, + safes: row?.safeguards || [], + sugs: row?.suggestions || [], }; } return null; @@ -203,10 +207,14 @@ const enterToTable = (type: string, rowIndex: number = -1) => { ...row, scene: `${row.cause?row.cause+';':''}${deviation?deviation+';':''}${row.consequence?'可能导致:'+row.consequence:''}`, source: 'HAZOP', - risk_item: `${deviation}${node_ame?`(${node_ame}${obj_ame?`-${obj_ame}`:''})`:''}`, - safe: row?.safeguards?.map((item:any) => item.name).join(';') || '', - suggestion: row?.suggestions?.map((item:any) => item.name).join(';') || '', - to_pssr: 0 + item: `${deviation}${node_ame?`(${node_ame}${obj_ame?`-${obj_ame}`:''})`:''}`, + inherent_level: row?.risk_value || '', + safeguards: row?.safeguards?.map((item:any) => item.name).join(';') || '', + suggestions: row?.suggestions?.map((item:any) => item.name).join(';') || '', + residual_level: countRiskLevel(row)?.name || '', + to_pssr: 0, + safes: row?.safeguards || [], + sugs: row?.suggestions || [], }); }); } diff --git a/src/views/my/initiateChange/modules/jsa.vue b/src/views/my/initiateChange/modules/jsa.vue index cef046a..b675bcb 100644 --- a/src/views/my/initiateChange/modules/jsa.vue +++ b/src/views/my/initiateChange/modules/jsa.vue @@ -131,25 +131,33 @@ const enterToTable = (type: string, row: any, stepIdx: number) => { ...row, scene: `${row.cause?row.cause+';':''}${row.consequence?'可能导致:'+row.consequence:''}`, source: 'JSA', - risk_item: `${step.step_name?step.step_name:''}`, - safe: row?.safeguards?.map((item:any) => item.name).join(';') || '', - suggestion: row?.suggestions?.map((item:any) => item.name).join(';') || '', - to_pssr: 0 + item: `${step.step_name?step.step_name:''}`, + inherent_level: row?.risk_value || '', + safeguards: row?.safeguards?.map((item:any) => item.name).join(';') || '', + suggestions: row?.suggestions?.map((item:any) => item.name).join(';') || '', + residual_level: countRiskLevel(row)?.name || '', + to_pssr: 0, + safes: row?.safeguards || [], + sugs: row?.suggestions || [], }); emit('toTable',type,enrichedRow); } if(type==='all'){ const enrichedRows:any[] = []; steps.value.forEach((step:any) => { - step?.risks?.forEach((risk:any) => { + step?.risks?.forEach((row:any) => { enrichedRows.push({ - ...risk, - scene: `${risk.cause?risk.cause+';':''}${risk.consequence?'可能导致:'+risk.consequence:''}`, + ...row, + scene: `${row.cause?row.cause+';':''}${row.consequence?'可能导致:'+row.consequence:''}`, source: 'JSA', - risk_item: `${step.step_name}`, - safe: risk?.safeguards?.map((item:any) => item.name).join(';') || '', - suggestion: risk?.suggestions?.map((item:any) => item.name).join(';') || '', - to_pssr: 0 + item: `${step.step_name}`, + inherent_level: row?.risk_value || '', + safeguards: row?.safeguards?.map((item:any) => item.name).join(';') || '', + suggestions: row?.suggestions?.map((item:any) => item.name).join(';') || '', + residual_level: countRiskLevel(row)?.name || '', + to_pssr: 0, + safes: row?.safeguards || [], + sugs: row?.suggestions || [], }); }) }) diff --git a/src/views/my/initiateChange/modules/riskAnalysis.vue b/src/views/my/initiateChange/modules/riskAnalysis.vue index f6ef21a..4d5314a 100644 --- a/src/views/my/initiateChange/modules/riskAnalysis.vue +++ b/src/views/my/initiateChange/modules/riskAnalysis.vue @@ -63,7 +63,7 @@ const jsaRiskLevel = (l: number, s: number) => { const countHazopRiskLevel = (row: any) => { const l = row.l_value; const s = row.s_value; - const newArr = [...row?.safeguards || [],...row?.suggestions || []]; + const newArr = [...row?.safes || [],...row?.sugs || []]; const result:any = { L: 0, S: 0 }; newArr.forEach(item => { if (!item.value) return; // 跳过空值 @@ -83,7 +83,7 @@ const countHazopRiskLevel = (row: any) => { const countJsaRiskLevel = (row: any) => { const l = row.l_value; const s = row.s_value; - const newArr = [...row?.safeguards || [],...row?.suggestions || []]; + const newArr = [...row?.safes || [],...row?.sugs || []]; const result:any = { L: 0, S: 0 }; newArr.forEach(item => { if (!item.value) return; // 跳过空值 @@ -287,7 +287,7 @@ onMounted(() => { - + @@ -295,28 +295,28 @@ onMounted(() => {
- {{rec.risk_value}} + {{rec.inherent_level}} - {{rec.risk_value}} + {{rec.inherent_level}} - {{rec.risk_value}} + {{rec.inherent_level}}
@@ -349,36 +349,36 @@ onMounted(() => {
- + - +
- {{rec.residual_risk_value}} + {{rec.residual_level}} - {{rec.residual_risk_value}} + {{rec.residual_level}} - {{rec.residual_risk_value}} + {{rec.residual_level}}
@@ -456,7 +456,7 @@ onMounted(() => {