几个插件入表功能字段修改
This commit is contained in:
@@ -386,15 +386,13 @@ const findRowWithParents = (rowIndex: number = -1) => {
|
||||
if(row){
|
||||
return {
|
||||
...row,
|
||||
scene: `${row.cause?row.cause+';':''}${currentDev.value?.deviation+';'}${row.consequence?'可能导致:'+row.consequence:''}`,
|
||||
source: 'HAZOP',
|
||||
scene: `${row.cause?row.cause+';':''}${row.effect?'可能导致:'+row.effect:''}`,
|
||||
source: 'FMEA',
|
||||
item: `${currentDev.value?.deviation}${currentNode.value?.node_name?`(${currentNode.value?.node_name})`:''}`,
|
||||
safeguards: row?.safeguards?.map((item:any) => item.name).join(';') || '',
|
||||
suggestions: row?.suggestions?.map((item:any) => item.name).join(';') || '',
|
||||
safeguards: row?.safeguards || '',
|
||||
suggestions: row?.suggestions || '',
|
||||
residual_level: row?.residual_level || '',
|
||||
to_pssr: 0,
|
||||
safes: row?.safeguards || [],
|
||||
sugs: row?.suggestions || [],
|
||||
};
|
||||
}
|
||||
return null;
|
||||
@@ -409,28 +407,23 @@ const enterToTable = (type: string, rowIndex: number = -1) => {
|
||||
const enrichedRows:any[] = [];
|
||||
nodes.value.forEach((node:any) => {
|
||||
const node_ame = node.node_name;
|
||||
node.objects.forEach((obj:any) => {
|
||||
const obj_ame = obj.obj_name;
|
||||
obj.deviations.forEach((dev:any) => {
|
||||
const deviation = dev.deviation;
|
||||
if (dev.rows && dev.rows.length > 0) {
|
||||
dev.rows.forEach((row:any) => {
|
||||
// 创建新对象,保留原 row 全部属性,并添加父级信息
|
||||
enrichedRows.push({
|
||||
...row,
|
||||
scene: `${row.cause?row.cause+';':''}${deviation?deviation+';':''}${row.consequence?'可能导致:'+row.consequence:''}`,
|
||||
source: 'HAZOP',
|
||||
item: `${deviation}${node_ame?`(${node_ame}${obj_ame?`-${obj_ame}`:''})`:''}`,
|
||||
safeguards: row?.safeguards?.map((item:any) => item.name).join(';') || '',
|
||||
suggestions: row?.suggestions?.map((item:any) => item.name).join(';') || '',
|
||||
residual_level: row?.residual_level || '',
|
||||
to_pssr: 0,
|
||||
safes: row?.safeguards || [],
|
||||
sugs: row?.suggestions || [],
|
||||
});
|
||||
node.deviations.forEach((dev:any) => {
|
||||
const deviation = dev.deviation;
|
||||
if (dev.rows && dev.rows.length > 0) {
|
||||
dev.rows.forEach((row:any) => {
|
||||
// 创建新对象,保留原 row 全部属性,并添加父级信息
|
||||
enrichedRows.push({
|
||||
...row,
|
||||
scene: `${row.cause?row.cause+';':''}${row.effect?'可能导致:'+row.effect:''}`,
|
||||
source: 'FMEA',
|
||||
item: `${deviation}${node_ame?`(${node_ame})`:''}`,
|
||||
safeguards: row?.safeguards || '',
|
||||
suggestions: row?.suggestions || '',
|
||||
residual_level: row?.residual_level || '',
|
||||
to_pssr: 0,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
emit('toTable',type,enrichedRows);
|
||||
|
||||
@@ -414,6 +414,16 @@ const save = async (isClick: boolean = false) => {
|
||||
const { org_name, ...rest } = item;
|
||||
return rest;
|
||||
});
|
||||
// 修改risk_value值
|
||||
nodes.value?.forEach((node:any) =>
|
||||
node.objects?.forEach((obj:any) =>{
|
||||
obj?.deviations?.forEach((dev:any) =>
|
||||
dev?.rows?.forEach((row:any) => {
|
||||
row.risk_value = riskLevel(row?.l_value,row?.s_value)?.name || '';
|
||||
})
|
||||
)
|
||||
})
|
||||
);
|
||||
const {error} = await hazopSaveApi(props.currentId, {
|
||||
nodes: nodes.value,
|
||||
users: workers,
|
||||
@@ -437,7 +447,7 @@ const findRowWithParents = (rowIndex: number = -1) => {
|
||||
scene: `${row.cause?row.cause+';':''}${currentDev.value?.deviation+';'}${row.consequence?'可能导致:'+row.consequence:''}`,
|
||||
source: 'HAZOP',
|
||||
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 || '',
|
||||
inherent_level: riskLevel(row?.l_value,row?.s_value)?.name || '',
|
||||
safeguards: row?.safeguards?.map((item:any) => item.name).join(';') || '',
|
||||
suggestions: row?.suggestions?.map((item:any) => item.name).join(';') || '',
|
||||
residual_level: countRiskLevel(row)?.name || '',
|
||||
@@ -470,7 +480,7 @@ const enterToTable = (type: string, rowIndex: number = -1) => {
|
||||
scene: `${row.cause?row.cause+';':''}${deviation?deviation+';':''}${row.consequence?'可能导致:'+row.consequence:''}`,
|
||||
source: 'HAZOP',
|
||||
item: `${deviation}${node_ame?`(${node_ame}${obj_ame?`-${obj_ame}`:''})`:''}`,
|
||||
inherent_level: row?.risk_value || '',
|
||||
inherent_level: riskLevel(row?.l_value,row?.s_value)?.name || '',
|
||||
safeguards: row?.safeguards?.map((item:any) => item.name).join(';') || '',
|
||||
suggestions: row?.suggestions?.map((item:any) => item.name).join(';') || '',
|
||||
residual_level: countRiskLevel(row)?.name || '',
|
||||
@@ -590,7 +600,7 @@ const addRow = async () => {
|
||||
consequence: "",
|
||||
l_value: l_options.value[0]?.key || 1,
|
||||
s_value: s_options.value[0]?.key || 1,
|
||||
risk_value: riskLevel(l_options.value[0]?.key || 1, s_options.value[0]?.key || 1)?.name || '',
|
||||
risk_value: '',
|
||||
safeguards: [],
|
||||
suggestions: [],
|
||||
});
|
||||
|
||||
@@ -48,68 +48,33 @@ const TOOL_CARDS = [
|
||||
];
|
||||
|
||||
// 根据l和s获取风险等级
|
||||
const hazopRiskLevel = (l: number, s: number) => {
|
||||
const num = l * s;
|
||||
const hazopRiskLevel = (level: string) => {
|
||||
for (let i = 0; i < hazopRiskMatrixConfig.value?.risk_grades.length; i++) {
|
||||
const item = hazopRiskMatrixConfig.value?.risk_grades[i];
|
||||
if (num >= item.min && num <= item.max) {
|
||||
if (level === item.name) {
|
||||
return item; // 返回整条数据
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const jsaRiskLevel = (l: number, s: number) => {
|
||||
const num = l * s;
|
||||
const jsaRiskLevel = (level: string) => {
|
||||
for (let i = 0; i < jsaRiskMatrixConfig.value?.risk_grades.length; i++) {
|
||||
const item = jsaRiskMatrixConfig.value?.risk_grades[i];
|
||||
if (num >= item.min && num <= item.max) {
|
||||
if (level === item.name) {
|
||||
return item; // 返回整条数据
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// 计算RR1风险等级
|
||||
const countHazopRiskLevel = (row: any) => {
|
||||
const l = row.l_value;
|
||||
const s = row.s_value;
|
||||
const newArr = [...row?.safes || [],...row?.sugs || []];
|
||||
const result:any = { L: 0, S: 0 };
|
||||
newArr.forEach(item => {
|
||||
if (!item.value) return; // 跳过空值
|
||||
const parts = item.value.split('_');
|
||||
if (parts.length === 2) {
|
||||
const type = parts[0].toUpperCase(); // 统一大写
|
||||
const num = parseInt(parts[1], 10);
|
||||
if (!isNaN(num) && (type === 'L' || type === 'S')) {
|
||||
result[type] += num;
|
||||
}
|
||||
const fmeaRiskLevel = (level: string) => {
|
||||
for (let i = 0; i < fmeaRiskMatrixConfig.value?.risk_grades.length; i++) {
|
||||
const item = fmeaRiskMatrixConfig.value?.risk_grades[i];
|
||||
if (level === item.name) {
|
||||
return item; // 返回整条数据
|
||||
}
|
||||
});
|
||||
const newL = (l - result.L) > 0 ? l - result.L : 1;
|
||||
const newS = (s - result.S) > 0 ? s - result.S : 1;
|
||||
return hazopRiskLevel(newL, newS);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const countJsaRiskLevel = (row: any) => {
|
||||
const l = row.l_value;
|
||||
const s = row.s_value;
|
||||
const newArr = [...row?.safes || [],...row?.sugs || []];
|
||||
const result:any = { L: 0, S: 0 };
|
||||
newArr.forEach(item => {
|
||||
if (!item.value) return; // 跳过空值
|
||||
const parts = item.value.split('_');
|
||||
if (parts.length === 2) {
|
||||
const type = parts[0].toUpperCase(); // 统一大写
|
||||
const num = parseInt(parts[1], 10);
|
||||
if (!isNaN(num) && (type === 'L' || type === 'S')) {
|
||||
result[type] += num;
|
||||
}
|
||||
}
|
||||
});
|
||||
const newL = (l - result.L) > 0 ? l - result.L : 1;
|
||||
const newS = (s - result.S) > 0 ? s - result.S : 1;
|
||||
return jsaRiskLevel(newL, newS);
|
||||
}
|
||||
|
||||
|
||||
// 删除记录
|
||||
const delRec = (i: number) => {
|
||||
@@ -325,41 +290,51 @@ onMounted(() => {
|
||||
</div>
|
||||
<div v-if="rec.source==='HAZOP'">
|
||||
<NTag
|
||||
v-if="rec.l_value>0 && rec.s_value>0"
|
||||
v-if="rec.inherent_level"
|
||||
class="text-[11px]"
|
||||
size="small"
|
||||
:color="{
|
||||
color: hazopRiskLevel(rec.l_value, rec.s_value)?.bg_color,
|
||||
textColor: hazopRiskLevel(rec.l_value, rec.s_value)?.font_color,
|
||||
borderColor: hazopRiskLevel(rec.l_value, rec.s_value)?.bg_color,
|
||||
color: hazopRiskLevel(rec.inherent_level)?.bg_color,
|
||||
textColor: hazopRiskLevel(rec.inherent_level)?.font_color,
|
||||
borderColor: hazopRiskLevel(rec.inherent_level)?.bg_color,
|
||||
}"
|
||||
>
|
||||
{{hazopRiskLevel(rec.l_value, rec.s_value)?.name}}
|
||||
{{rec.inherent_level}}
|
||||
</NTag>
|
||||
</div>
|
||||
<div v-if="rec.source==='FMEA'">
|
||||
<NTag
|
||||
v-if="rec.inherent_level"
|
||||
class="text-[11px]"
|
||||
size="small"
|
||||
:color="{
|
||||
color: fmeaRiskLevel(rec.inherent_level)?.bg_color,
|
||||
textColor: fmeaRiskLevel(rec.inherent_level)?.font_color,
|
||||
borderColor: fmeaRiskLevel(rec.inherent_level)?.bg_color,
|
||||
}"
|
||||
>
|
||||
{{rec.inherent_level}}
|
||||
</NTag>
|
||||
<span v-else>-</span>
|
||||
</div>
|
||||
<div v-if="rec.source==='JSA'">
|
||||
<NTag
|
||||
v-if="rec.l_value>0 && rec.s_value>0"
|
||||
v-if="rec.inherent_level"
|
||||
class="text-[11px]"
|
||||
size="small"
|
||||
:color="{
|
||||
color: jsaRiskLevel(rec.l_value, rec.s_value)?.bg_color,
|
||||
textColor: jsaRiskLevel(rec.l_value, rec.s_value)?.font_color,
|
||||
borderColor: jsaRiskLevel(rec.l_value, rec.s_value)?.bg_color,
|
||||
color: jsaRiskLevel(rec.inherent_level)?.bg_color,
|
||||
textColor: jsaRiskLevel(rec.inherent_level)?.font_color,
|
||||
borderColor: jsaRiskLevel(rec.inherent_level)?.bg_color,
|
||||
}"
|
||||
>
|
||||
{{jsaRiskLevel(rec.l_value, rec.s_value)?.name}}
|
||||
{{rec.inherent_level}}
|
||||
</NTag>
|
||||
</div>
|
||||
<div v-if="rec.source==='RISK_CHECK'">
|
||||
<NTag
|
||||
class="text-[11px]"
|
||||
size="small"
|
||||
>
|
||||
<span>
|
||||
{{rec.inherent_level?rec.inherent_level:'-'}}
|
||||
</span>
|
||||
</NTag>
|
||||
<span>
|
||||
{{rec.inherent_level?rec.inherent_level:'-'}}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="border px-1.5 py-1">
|
||||
@@ -397,45 +372,55 @@ onMounted(() => {
|
||||
</div>
|
||||
<div v-if="rec.source==='HAZOP'">
|
||||
<NTag
|
||||
v-if="rec.l_value>0 && rec.s_value>0"
|
||||
v-if="rec.residual_level"
|
||||
class="text-[11px]"
|
||||
size="small"
|
||||
:color="{
|
||||
color: countHazopRiskLevel(rec)?.bg_color,
|
||||
textColor: countHazopRiskLevel(rec)?.font_color,
|
||||
borderColor: countHazopRiskLevel(rec)?.bg_color,
|
||||
color: hazopRiskLevel(rec.residual_level)?.bg_color,
|
||||
textColor: hazopRiskLevel(rec.residual_level)?.font_color,
|
||||
borderColor: hazopRiskLevel(rec.residual_level)?.bg_color,
|
||||
}"
|
||||
>
|
||||
<span>
|
||||
{{countHazopRiskLevel(rec)?.name}}
|
||||
{{rec.residual_level}}
|
||||
</span>
|
||||
</NTag>
|
||||
</div>
|
||||
<div v-if="rec.source==='JSA'">
|
||||
<div v-if="rec.source==='FMEA'">
|
||||
<NTag
|
||||
v-if="rec.l_value>0 && rec.s_value>0"
|
||||
v-if="rec.residual_level"
|
||||
class="text-[11px]"
|
||||
size="small"
|
||||
:color="{
|
||||
color: countJsaRiskLevel(rec)?.bg_color,
|
||||
textColor: countJsaRiskLevel(rec)?.font_color,
|
||||
borderColor: countJsaRiskLevel(rec)?.bg_color,
|
||||
color: fmeaRiskLevel(rec.residual_level)?.bg_color,
|
||||
textColor: fmeaRiskLevel(rec.residual_level)?.font_color,
|
||||
borderColor: fmeaRiskLevel(rec.residual_level)?.bg_color,
|
||||
}"
|
||||
>
|
||||
{{rec.residual_level}}
|
||||
</NTag>
|
||||
<span v-else>-</span>
|
||||
</div>
|
||||
<div v-if="rec.source==='JSA'">
|
||||
<NTag
|
||||
v-if="rec.residual_level"
|
||||
class="text-[11px]"
|
||||
size="small"
|
||||
:color="{
|
||||
color: jsaRiskLevel(rec.residual_level)?.bg_color,
|
||||
textColor: jsaRiskLevel(rec.residual_level)?.font_color,
|
||||
borderColor: jsaRiskLevel(rec.residual_level)?.bg_color,
|
||||
}"
|
||||
>
|
||||
<span>
|
||||
{{countJsaRiskLevel(rec)?.name}}
|
||||
{{rec.residual_level}}
|
||||
</span>
|
||||
</NTag>
|
||||
</div>
|
||||
<div v-if="rec.source==='RISK_CHECK'">
|
||||
<NTag
|
||||
class="text-[11px]"
|
||||
size="small"
|
||||
>
|
||||
<span>
|
||||
{{rec.residual_level?rec.residual_level:'-'}}
|
||||
</span>
|
||||
</NTag>
|
||||
<span>
|
||||
{{rec.residual_level?rec.residual_level:'-'}}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="border px-1.5 py-1 text-center align-top">
|
||||
|
||||
Reference in New Issue
Block a user