发起变更几个插件字段添加
This commit is contained in:
@@ -373,19 +373,21 @@ const save = async (isClick: boolean = false) => {
|
||||
if(!error){
|
||||
if(isClick){
|
||||
window.$message?.success("保存成功");
|
||||
getFmeaNodes();
|
||||
}
|
||||
}
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据行下标 查找并返回带有父级名称的行对象
|
||||
*/
|
||||
const findRowWithParents = (rowIndex: number = -1) => {
|
||||
const row = currentDev.value.rows[rowIndex];
|
||||
if(row){
|
||||
return {
|
||||
...row,
|
||||
// AI整理如表、入表
|
||||
const enterToTable = (type: string, rowIndex: number = -1) => {
|
||||
if(type==='single'){
|
||||
const row = currentDev.value.rows[rowIndex];
|
||||
if(!row?.id){
|
||||
return window.$message?.warning("请先保存再入表");
|
||||
}
|
||||
const enrichedRow = {
|
||||
id: row?.id || 0,
|
||||
scene: `${row.cause?row.cause+';':''}${row.effect?'可能导致:'+row.effect:''}`,
|
||||
source: 'FMEA',
|
||||
item: `${currentDev.value?.deviation}${currentNode.value?.node_name?`(${currentNode.value?.node_name})`:''}`,
|
||||
@@ -393,17 +395,25 @@ const findRowWithParents = (rowIndex: number = -1) => {
|
||||
suggestions: row?.suggestions || '',
|
||||
residual_level: row?.residual_level || '',
|
||||
to_pssr: 0,
|
||||
source_row_id: row?.id || 0,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// AI整理如表、入表
|
||||
const enterToTable = (type: string, rowIndex: number = -1) => {
|
||||
if(type==='single'){
|
||||
const enrichedRow = findRowWithParents(rowIndex);
|
||||
emit('toTable',type,enrichedRow?[enrichedRow]:[]);
|
||||
}
|
||||
if(type==='all'){
|
||||
const invalidRows = nodes.value.flatMap((root:any) =>
|
||||
(root.deviations || []).flatMap((dev:any) =>
|
||||
(dev.rows || [])
|
||||
.map((row:any, index:number) => ({
|
||||
deviation_id: dev.id,
|
||||
rowIndex: index,
|
||||
row
|
||||
}))
|
||||
.filter(({ row }:any) => !row.id)
|
||||
)
|
||||
);
|
||||
if(invalidRows.length){
|
||||
return window.$message?.warning("请先保存再入表");
|
||||
}
|
||||
const enrichedRows:any[] = [];
|
||||
nodes.value.forEach((node:any) => {
|
||||
const node_ame = node.node_name;
|
||||
@@ -413,7 +423,7 @@ const enterToTable = (type: string, rowIndex: number = -1) => {
|
||||
dev.rows.forEach((row:any) => {
|
||||
// 创建新对象,保留原 row 全部属性,并添加父级信息
|
||||
enrichedRows.push({
|
||||
...row,
|
||||
id: row?.id || 0,
|
||||
scene: `${row.cause?row.cause+';':''}${row.effect?'可能导致:'+row.effect:''}`,
|
||||
source: 'FMEA',
|
||||
item: `${deviation}${node_ame?`(${node_ame})`:''}`,
|
||||
@@ -421,6 +431,7 @@ const enterToTable = (type: string, rowIndex: number = -1) => {
|
||||
suggestions: row?.suggestions || '',
|
||||
residual_level: row?.residual_level || '',
|
||||
to_pssr: 0,
|
||||
source_row_id: row.id || 0,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -673,6 +684,18 @@ if (typeof window !== 'undefined') {
|
||||
})
|
||||
}
|
||||
|
||||
function findRowsById(data:any, targetId: number) {
|
||||
for (const node of data) {
|
||||
if (!node?.deviations) continue;
|
||||
for (const dev of node.deviations) {
|
||||
if (dev.id === targetId) {
|
||||
return dev.rows ?? [];
|
||||
}
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取FMEA列表
|
||||
const getFmeaNodes = async () => {
|
||||
loading.value = true;
|
||||
@@ -680,7 +703,12 @@ const getFmeaNodes = async () => {
|
||||
if(!error){
|
||||
nodes.value = data.nodes;
|
||||
selectedWorkers.value = data.users;
|
||||
clickDev(nodes.value[0]?.deviations[0] || null,0)
|
||||
if(!currentDev.value){
|
||||
clickDev(nodes.value[0]?.deviations[0] || null,0)
|
||||
}else{
|
||||
const rows = findRowsById(nodes.value,currentDev.value?.id);
|
||||
currentDev.value.rows = rows;
|
||||
}
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user