diff --git a/src/service/api/system.ts b/src/service/api/system.ts index ccad3c1..0c61c9a 100644 --- a/src/service/api/system.ts +++ b/src/service/api/system.ts @@ -84,5 +84,13 @@ export function matrixConfigApi(bizType:string) { method: 'get', }); } +// 保存风险矩阵配置 +export function saveMatrixConfigApi(bizType:string,data:any) { + return request({ + url: `/api/risk-matrix/${bizType}`, + method: 'put', + data, + }); +} diff --git a/src/views/my/initiateChange/index.vue b/src/views/my/initiateChange/index.vue index 73406c6..0d12ba9 100644 --- a/src/views/my/initiateChange/index.vue +++ b/src/views/my/initiateChange/index.vue @@ -43,7 +43,7 @@ const form = ref({ name: "", dept: "", mainChanges: [""], related: "", purposes: [], effect: "", type: "", level: "", duration: "", urgent: false, date: null, restoreDate: null, }); -const tab = ref("risk"); +const tab = ref("pre"); const TABS = [ { id: "pre", name: "变更预识别", icon: 'lucide:sparkles' }, { id: "form", name: "变更申请表", icon: 'akar-icons:file' }, diff --git a/src/views/systemManage/setting/index.vue b/src/views/systemManage/setting/index.vue index 4c80419..e26d749 100644 --- a/src/views/systemManage/setting/index.vue +++ b/src/views/systemManage/setting/index.vue @@ -10,7 +10,8 @@ import { editSystemConfigApi, deleteSystemConfigApi, updateConfigApi, - matrixConfigApi + matrixConfigApi, + saveMatrixConfigApi } from '@/service/api/system'; const appStore = useAppStore(); @@ -273,6 +274,13 @@ const ruleOptions = ref<{label:string, value:string}[]>([ {label:'按年度重置',value:'YEARLY'}, {label:'连续不重置',value:'CONTINUE'}, ]) +const levelOptions = ref<{label:string, value:string | null}[]>([ + {label:'低',value:'低'}, + {label:'一般',value:'一般'}, + {label:'较高',value:'较高'}, + {label:'高',value:'高'}, + {label:'很高',value:'很高'}, +]) // 保存编号规则 const saveRule = async () => { @@ -292,82 +300,102 @@ const saveRule = async () => { // *************** 风险矩阵设置(按分析方法) ***************// +const matrixLoading = ref(false); const dimensionModal = ref(false); -const dimensionLoading = ref(false); -const dimForm = ref<{s:string[], l:string[]}>({ s: [], l: [] }); -// 默认风险矩阵维度分级定义 -const matrices = ref([ - { - tool: "HAZOP", - sLabels: ["轻微", "一般", "较重", "严重", "灾难"], - lLabels: ["极少发生", "较少发生", "偶尔发生", "可能发生", "频繁发生"], - levels: [ - { name: "低", min: 1, max: 4, bgColor:'#d1fae5', color:'#047857' }, - { name: "一般", min: 5, max: 9, bgColor:'#fef9c3', color:'#c27707' }, - { name: "较大", min: 10, max: 16, bgColor:'#fee2e2', color:'#c2410c' }, - { name: "重大", min: 17, max: 25, bgColor:'#fff3cd', color:'#b91c1c' }, - ], - }, - { - tool: "JSA", - sLabels: ["轻微伤害", "轻伤", "重伤", "单人死亡", "多人死亡"], - lLabels: ["极不可能", "不太可能", "有可能", "较可能", "很可能"], - levels: [ - { name: "低", min: 1, max: 6, bgColor:'#d1fae5', color:'#047857' }, - { name: "一般", min: 7, max: 12, bgColor:'#fef9c3', color:'#c27707' }, - { name: "较大", min: 13, max: 19, bgColor:'#fee2e2', color:'#c2410c' }, - { name: "重大", min: 20, max: 25, bgColor:'#fff3cd', color:'#b91c1c' }, - ], - }, - { - tool: "SCL", - sLabels: ["轻微影响", "一般影响", "较大影响", "严重影响", "灾难性影响"], - lLabels: ["极少", "较少", "偶尔", "可能", "经常"], - levels: [ - { name: "低", min: 1, max: 2, bgColor:'#d1fae5', color:'#047857' }, - { name: "一般", min: 3, max: 6, bgColor:'#fef9c3', color:'#c27707' }, - { name: "较大", min: 7, max: 12, bgColor:'#fee2e2', color:'#c2410c' }, - { name: "重大", min: 13, max: 25, bgColor:'#fff3cd', color:'#b91c1c' }, - ], - }, -]); +const dimForm = ref<{s:{key:string, label:string}[], l:{key:string, label:string}[]}>({ s: [], l: [] }); // 当前选中的风险矩阵索引 -const activeMatrix = ref(0); +const activeMatrix = ref('HAZOP'); // 当前选中的风险矩阵 const curMatrix = ref(null); -const cellScore = (s:number, l:number) => (s + 1) * (l + 1); +// 查找匹配的等级配置 +function findMatchingConfig(num:number) { + for (let i = 0; i < curMatrix.value?.risk_grades.length; i++) { + const item = curMatrix.value?.risk_grades[i]; + if (num >= item.min && num <= item.max) { + return item; // 返回整条数据 + } + } + return null; +} +// 计算单元格等级 +const cellScore = (s:number, l:number) => { + return s*l; +} const cellLevel = (s:number, l:number) => { - const sc = cellScore(s, l); - return curMatrix.value?.levels.find((lv:{min:number,max:number}) => sc >= lv.min && sc <= lv.max); + const info = findMatchingConfig(s*l); + return info? info:null; } // 风险矩阵tabs切换 -const handleTabChange = (v: number) => { +const handleTabChange = (v: string) => { activeMatrix.value = v; - curMatrix.value = matrices.value[v]; + matrixConfig(); } // 打开风险矩阵编辑弹窗 const openDimEdit = () => { - dimForm.value = { s: [...curMatrix.value?.sLabels], l: [...curMatrix.value?.lLabels] }; + dimForm.value = { s: [...curMatrix.value?.consequence], l: [...curMatrix.value?.probability] }; dimensionModal.value = true; } // 添加后果严重性 S const addS = () => { - dimForm.value.s.push(""); + dimForm.value.s.push({key:'S'+(dimForm.value.s.length+1), label:''}); } // 添加发生可能性 L const addL = () => { - dimForm.value.l.push(""); + dimForm.value.l.push({key:'L'+(dimForm.value.l.length+1), label:''}); +} +// 删除后果严重性 S +const deleteS = (i:number) => { + dimForm.value.s.splice(i, 1); +} +// 删除发生可能性 L +const deleteL = (i:number) => { + dimForm.value.l.splice(i, 1); +} +// 添加等级配置 +const addLevelConfig = () => { + curMatrix.value?.risk_grades.push({name:null,bg_color:'#333333',font_color:'#ffffff', min:null, max:null}); +} +// 删除等级配置 +const delLevelConfig = (index:number) => { + curMatrix.value?.risk_grades.splice(index, 1); } // 矩阵维度分级定义保存 const dimensionSave = () => { - dimensionLoading.value = true; - setTimeout(() => { - window.$message?.success("操作成功"); - dimensionLoading.value = false; - dimensionModal.value = false; - }, 1000); + const hasEmptyLabel = dimForm.value.s.some((item:any) => item.label === ''); + if(hasEmptyLabel){ + return window.$message?.warning("请完善后果严重性S信息"); + } + const hasEmptyLabelL = dimForm.value.l.some((item:any) => item.label === ''); + if(hasEmptyLabelL){ + return window.$message?.warning("请完善发生可能性L信息"); + } + curMatrix.value.consequence = [...dimForm.value.s]; + curMatrix.value.probability = [...dimForm.value.l]; + dimensionModal.value = false; +} +// 保存风险矩阵 +const saveMatrix = async () => { + if(curMatrix.value.risk_grades.length === 0){ + return window.$message?.warning("请添加按分值区间定级信息"); + } + const hasNull = curMatrix.value.risk_grades.some((item:any) => + item.name === null || item.min === null || item.max === null + ); + if(hasNull){ + return window.$message?.warning("请完善按分值区间定级信息"); + } + matrixLoading.value = true; + const {error} = await saveMatrixConfigApi(activeMatrix.value,{ + consequence:curMatrix.value.consequence, + probability:curMatrix.value.probability, + risk_grades:curMatrix.value.risk_grades, + }); + if(!error){ + window.$message?.success("保存成功"); + } + matrixLoading.value = false; } // 获取配置 @@ -407,15 +435,13 @@ const getConfig = async () => { // 获取风险矩阵配置 const matrixConfig = async () => { - const {data,error} = await matrixConfigApi(curMatrix.value?.tool); + const {data,error} = await matrixConfigApi(activeMatrix.value); if(!error){ - // curMatrix.value = data; - console.log(data); + curMatrix.value = data; } } onMounted(() => { - curMatrix.value = matrices.value[activeMatrix.value]; matrixConfig(); getConfig(); }) @@ -714,39 +740,42 @@ onMounted(() => { 维度分级定义 - + 保存矩阵
- +
- - - - - + + + +
- L{{ Number(li) + 1 }}
{{ lb }} +
+ {{ lb.key }}
{{ lb.label }}
S{{ 6 - row }} {{ curMatrix?.sLabels[5 - row] }} -
- {{ cellScore(5 - row, col - 1) }} -
-
+ {{ curMatrix?.consequence[curMatrix?.consequence.length - (Number(rowIndex)+1)]?.key }} + {{ curMatrix?.consequence[curMatrix?.consequence.length - (Number(rowIndex)+1)]?.label }} + +
+ {{ cellScore(curMatrix?.consequence.length - Number(rowIndex), (Number(colIndex)+1)) }} +
+
@@ -758,15 +787,15 @@ onMounted(() => {
- + 新增 风险值 = 严重性 S × 可能性 L,按分值区间定级:
-
+
背景 - + 字体 - + - + 分值 - + - + {{ lv.name }}风险 - + + + 确定删除吗? + +
+
+

+ 各分析方法独立维护矩阵与维度分级;风险分析记录表按所选工具对应的矩阵自动定级。分值区间不得重叠、须落在 1–25 内;在途分析记录按原矩阵保留定级快照。 +

+
+
+ + +
+
+ + + + + + + + + + + + + +
+ {{ lb.key }}
{{ lb.label }} +
+ {{ curMatrix?.consequence[curMatrix?.consequence.length - (Number(rowIndex)+1)]?.key }} + {{ curMatrix?.consequence[curMatrix?.consequence.length - (Number(rowIndex)+1)]?.label }} + +
+ {{ cellScore(curMatrix?.consequence.length - Number(rowIndex), (Number(colIndex)+1)) }} +
+
+
+ 纵轴:后果严重性 S + 横轴:发生可能性 L +
+
+ + +
+
+ + 新增 + + 风险值 = 严重性 S × 可能性 L,按分值区间定级: +
+
+
+ 背景 + + + + 字体 + + + + + 分值 + + + + + {{ lv.name }}风险 + +
@@ -816,104 +956,6 @@ onMounted(() => {
- -
-
- - - - - - - - - - - - - -
- L{{ li + 1 }}
{{ lb }} -
S{{ 6 - row }} {{ curMatrix?.sLabels[5 - row] }} -
- {{ cellScore(5 - row, col - 1) }} -
-
-
- 纵轴:后果严重性 S - 横轴:发生可能性 L -
-
- - -
-
风险值 = 严重性 S × 可能性 L(5×5),按分值区间定级:
-
-
- - - 分值 - - - - {{ lv.name }}风险 -
-
-

- 各分析方法独立维护矩阵与维度分级;风险分析记录表按所选工具对应的矩阵自动定级。分值区间不得重叠、须落在 1–25 内;在途分析记录按原矩阵保留定级快照。 -

-
-
-
- -
-
- - - - - - - - - - - - - -
- L{{ li + 1 }}
{{ lb }} -
S{{ 6 - row }} {{ curMatrix?.sLabels[5 - row] }} -
- {{ cellScore(5 - row, col - 1) }} -
-
-
- 纵轴:后果严重性 S - 横轴:发生可能性 L -
-
- - -
-
风险值 = 严重性 S × 可能性 L(5×5),按分值区间定级:
-
-
- - - 分值 - - - - {{ lv.name }}风险 -
-
-

- 各分析方法独立维护矩阵与维度分级;风险分析记录表按所选工具对应的矩阵自动定级。分值区间不得重叠、须落在 1–25 内;在途分析记录按原矩阵保留定级快照。 -

-
-
-
@@ -1092,39 +1134,50 @@ onMounted(() => {
- 后果严重性 S(S1 → S5 递增) + 后果严重性 S({{dimForm.s[0].key}} → {{dimForm.s[dimForm.s.length-1].key}} 递增) 新增
-
- 发生可能性 L(L1 → L5 递增) + 发生可能性 L({{dimForm.l[0].key}} → {{dimForm.l[dimForm.l.length-1].key}} 递增) 新增
-
@@ -1132,7 +1185,7 @@ onMounted(() => {