几个插件入表功能字段修改
This commit is contained in:
@@ -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