fmea插件保存完成
This commit is contained in:
@@ -240,28 +240,38 @@ const setSave = async () => {
|
|||||||
const handleSelect = (key: string) => {
|
const handleSelect = (key: string) => {
|
||||||
runAi(key);
|
runAi(key);
|
||||||
}
|
}
|
||||||
console.log(props.fmeaRiskMatrixConfig)
|
|
||||||
const s_options = computed(() => {
|
const s_options = computed(() => {
|
||||||
const newArr = props.fmeaRiskMatrixConfig?.s_grades?.map((item:any) => ({
|
const newArr = props.fmeaRiskMatrixConfig?.s_grades?.map((item:any) => ({
|
||||||
label: item.label+'('+item.score+')',
|
label: item.label+'('+item.score+')',
|
||||||
value: item.score
|
text: item.label,
|
||||||
|
value: item.score,
|
||||||
|
key: item.score
|
||||||
}));
|
}));
|
||||||
return newArr;
|
return newArr;
|
||||||
});
|
});
|
||||||
const p_options = computed(() => {
|
const p_options = computed(() => {
|
||||||
const newArr = props.fmeaRiskMatrixConfig?.p_grades?.map((item:any) => ({
|
const newArr = props.fmeaRiskMatrixConfig?.p_grades?.map((item:any) => ({
|
||||||
label: item.label+'('+item.score+')',
|
label: item.label+'('+item.score+')',
|
||||||
value: item.score
|
text: item.label,
|
||||||
|
value: item.score,
|
||||||
|
key: item.score
|
||||||
}));
|
}));
|
||||||
return newArr;
|
return newArr;
|
||||||
});
|
});
|
||||||
const d_options = computed(() => {
|
const d_options = computed(() => {
|
||||||
const newArr = props.fmeaRiskMatrixConfig?.d_grades?.map((item:any) => ({
|
const newArr = props.fmeaRiskMatrixConfig?.d_grades?.map((item:any) => ({
|
||||||
label: item.label+'('+item.score+')',
|
label: item.label+'('+item.score+')',
|
||||||
value: item.score
|
text: item.label,
|
||||||
|
value: item.score,
|
||||||
|
key: item.score
|
||||||
}));
|
}));
|
||||||
return newArr;
|
return newArr;
|
||||||
});
|
});
|
||||||
|
// 用value找到text
|
||||||
|
const getText = (value:number, options:any[]) => {
|
||||||
|
const item = options.find((item:any) => item.value === value);
|
||||||
|
return item?.text || '';
|
||||||
|
}
|
||||||
|
|
||||||
// 右键菜单状态
|
// 右键菜单状态
|
||||||
const contextMenuShow = ref<boolean>(false)
|
const contextMenuShow = ref<boolean>(false)
|
||||||
@@ -348,6 +358,14 @@ const save = async (isClick: boolean = false) => {
|
|||||||
const { org_name, ...rest } = item;
|
const { org_name, ...rest } = item;
|
||||||
return rest;
|
return rest;
|
||||||
});
|
});
|
||||||
|
// 修改residual_level值
|
||||||
|
nodes.value?.forEach((node:any) =>
|
||||||
|
node?.deviations?.forEach((dev:any) =>
|
||||||
|
dev?.rows?.forEach((row:any) => {
|
||||||
|
row.residual_level = calculateRiskGrade(row.s_value, row.p_value, row.d_value)?.name || '';
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
const {error} = await fmeaSaveApi(props.currentId, {
|
const {error} = await fmeaSaveApi(props.currentId, {
|
||||||
nodes: nodes.value,
|
nodes: nodes.value,
|
||||||
users: workers,
|
users: workers,
|
||||||
@@ -450,6 +468,16 @@ const runInference = async () => {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算风险等级
|
||||||
|
const calculateRiskGrade = (s: number,p: number,d: number) => {
|
||||||
|
const rpn = s * p * d;
|
||||||
|
const levels = props.fmeaRiskMatrixConfig?.risk_grades || [];
|
||||||
|
if (!Number.isFinite(rpn)) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return levels.find((item:any) => rpn >= item.min_rpn && rpn <= item.max_rpn) || null;
|
||||||
|
}
|
||||||
|
|
||||||
// 新增行
|
// 新增行
|
||||||
const addRow = async () => {
|
const addRow = async () => {
|
||||||
if(!currentDev.value){
|
if(!currentDev.value){
|
||||||
@@ -517,7 +545,6 @@ const modalSave = async () => {
|
|||||||
deviation: name.value,
|
deviation: name.value,
|
||||||
rows: []
|
rows: []
|
||||||
}
|
}
|
||||||
console.log(contextTarget.value?.nodeIndex)
|
|
||||||
if(nodes.value[contextTarget.value?.nodeIndex].deviations){
|
if(nodes.value[contextTarget.value?.nodeIndex].deviations){
|
||||||
nodes.value[contextTarget.value?.nodeIndex].deviations.push(dev);
|
nodes.value[contextTarget.value?.nodeIndex].deviations.push(dev);
|
||||||
}else {
|
}else {
|
||||||
@@ -658,7 +685,6 @@ const getFmeaNodes = async () => {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
const {data,error} = await fmeaNodesApi(props.currentId);
|
const {data,error} = await fmeaNodesApi(props.currentId);
|
||||||
if(!error){
|
if(!error){
|
||||||
console.log(data)
|
|
||||||
nodes.value = data.nodes;
|
nodes.value = data.nodes;
|
||||||
selectedWorkers.value = data.users;
|
selectedWorkers.value = data.users;
|
||||||
clickDev(nodes.value[0]?.deviations[0] || null,0)
|
clickDev(nodes.value[0]?.deviations[0] || null,0)
|
||||||
@@ -909,47 +935,64 @@ onBeforeUnmount(() => {
|
|||||||
<NInput type="textarea" size="small" v-model:value="row.effect" :autosize="{minRows:1}" class="text-xs" />
|
<NInput type="textarea" size="small" v-model:value="row.effect" :autosize="{minRows:1}" class="text-xs" />
|
||||||
</td>
|
</td>
|
||||||
<td :class="TD" class="text-center">
|
<td :class="TD" class="text-center">
|
||||||
<NSelect v-model:value="row.s_value" size="tiny" :options="s_options" placeholder="请选择" class="text-center w-full mt-2px" />
|
<NDropdown trigger="click" :options="s_options" @select="(key) => row.s_value = key">
|
||||||
|
<div class="cursor-pointer" title="点击选择">
|
||||||
|
<p>{{row.s_value || '-'}}</p>
|
||||||
|
<p class="text-slate-400">{{getText(row.s_value, s_options) || '点击选择'}}</p>
|
||||||
|
</div>
|
||||||
|
</NDropdown>
|
||||||
</td>
|
</td>
|
||||||
<td :class="TD">
|
<td :class="TD">
|
||||||
<NInput type="textarea" size="small" v-model:value="row.cause" :autosize="{minRows:1}" class="text-xs" />
|
<NInput type="textarea" size="small" v-model:value="row.cause" :autosize="{minRows:1}" class="text-xs" />
|
||||||
</td>
|
</td>
|
||||||
<td :class="TD" class="text-center">
|
<td :class="TD" class="text-center">
|
||||||
<NSelect v-model:value="row.p_value" size="tiny" :options="p_options" placeholder="请选择" class="text-center w-full mt-2px" />
|
<NDropdown trigger="click" :options="p_options" @select="(key) => row.p_value = key">
|
||||||
|
<div class="cursor-pointer" title="点击选择">
|
||||||
|
<p>{{row.p_value || '-'}}</p>
|
||||||
|
<p class="text-slate-400">{{getText(row.p_value, p_options) || '点击选择'}}</p>
|
||||||
|
</div>
|
||||||
|
</NDropdown>
|
||||||
</td>
|
</td>
|
||||||
<td :class="TD">
|
<td :class="TD">
|
||||||
<NInput type="textarea" size="small" v-model:value="row.safeguards" :autosize="{minRows:1}" class="text-xs" />
|
<NInput type="textarea" size="small" v-model:value="row.safeguards" :autosize="{minRows:1}" class="text-xs" />
|
||||||
</td>
|
</td>
|
||||||
<td :class="TD" class="text-center">
|
<td :class="TD" class="text-center">
|
||||||
<NSelect v-model:value="row.d_value" size="tiny" :options="d_options" placeholder="请选择" class="text-center w-full mt-2px" />
|
<NDropdown trigger="click" :options="d_options" @select="(key) => row.d_value = key">
|
||||||
|
<div class="cursor-pointer" title="点击选择">
|
||||||
|
<p>{{row.d_value || '-'}}</p>
|
||||||
|
<p class="text-slate-400">{{getText(row.d_value, d_options) || '点击选择'}}</p>
|
||||||
|
</div>
|
||||||
|
</NDropdown>
|
||||||
</td>
|
</td>
|
||||||
<td :class="TD" class="text-center">
|
<td :class="TD" class="text-center">
|
||||||
<!-- <NTag
|
<NTag
|
||||||
v-if="row.l_value>0 && row.s_value>0"
|
v-if="calculateRiskGrade(row.s_value, row.p_value, row.d_value)"
|
||||||
class="text-[11px]"
|
class="text-[11px]"
|
||||||
size="small"
|
size="small"
|
||||||
:color="{
|
:color="{
|
||||||
color: riskLevel(row.l_value, row.s_value)?.bg_color,
|
color: calculateRiskGrade(row.s_value, row.p_value, row.d_value)?.bg_color,
|
||||||
textColor: riskLevel(row.l_value, row.s_value)?.font_color,
|
textColor: calculateRiskGrade(row.s_value, row.p_value, row.d_value)?.font_color,
|
||||||
borderColor: riskLevel(row.l_value, row.s_value)?.bg_color,
|
borderColor: calculateRiskGrade(row.s_value, row.p_value, row.d_value)?.bg_color,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
{{row.l_value * row.s_value}}
|
{{row.s_value * row.p_value * row.d_value}}
|
||||||
</NTag> -->
|
</NTag>
|
||||||
|
<span v-else>-</span>
|
||||||
</td>
|
</td>
|
||||||
<td :class="TD" class="text-center">
|
<td :class="TD" class="text-center">
|
||||||
<!-- <NTag
|
<NTag
|
||||||
v-if="row.l_value>0 && row.s_value>0"
|
v-if="calculateRiskGrade(row.s_value, row.p_value, row.d_value)"
|
||||||
class="text-[11px]"
|
class="text-[11px]"
|
||||||
size="small"
|
size="small"
|
||||||
:color="{
|
:color="{
|
||||||
color: countRiskLevel(row)?.bg_color,
|
color: calculateRiskGrade(row.s_value, row.p_value, row.d_value)?.bg_color,
|
||||||
textColor: countRiskLevel(row)?.font_color,
|
textColor: calculateRiskGrade(row.s_value, row.p_value, row.d_value)?.font_color,
|
||||||
borderColor: countRiskLevel(row)?.bg_color,
|
borderColor: calculateRiskGrade(row.s_value, row.p_value, row.d_value)?.bg_color,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
{{countRiskLevel(row)?.name}}
|
{{calculateRiskGrade(row.s_value, row.p_value, row.d_value)?.name}}
|
||||||
</NTag> -->
|
</NTag>
|
||||||
|
<span v-else>-</span>
|
||||||
</td>
|
</td>
|
||||||
<td :class="TD">
|
<td :class="TD">
|
||||||
<NInput type="textarea" size="small" v-model:value="row.suggestions" :autosize="{minRows:1}" class="text-xs" @blur="save()" />
|
<NInput type="textarea" size="small" v-model:value="row.suggestions" :autosize="{minRows:1}" class="text-xs" @blur="save()" />
|
||||||
|
|||||||
Reference in New Issue
Block a user