发起变更几个插件字段添加
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;
|
||||
}
|
||||
|
||||
@@ -431,19 +431,21 @@ const save = async (isClick: boolean = false) => {
|
||||
if(!error){
|
||||
if(isClick){
|
||||
window.$message?.success("保存成功");
|
||||
getHazopNodes();
|
||||
}
|
||||
}
|
||||
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+';':''}${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}`:''})`:''}`,
|
||||
@@ -453,18 +455,30 @@ const findRowWithParents = (rowIndex: number = -1) => {
|
||||
residual_level: countRiskLevel(row)?.name || '',
|
||||
to_pssr: 0,
|
||||
safes: row?.safeguards || [],
|
||||
sugs: row?.suggestions || [],
|
||||
sugs: row?.suggestions || [],
|
||||
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.objects || []).flatMap((obj:any) =>
|
||||
(obj.deviations || []).flatMap((dev:any) =>
|
||||
(dev.rows || [])
|
||||
.map((row:any, index:number) => ({
|
||||
node_id: root.id,
|
||||
object_id: obj.id,
|
||||
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;
|
||||
@@ -476,7 +490,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+';':''}${deviation?deviation+';':''}${row.consequence?'可能导致:'+row.consequence:''}`,
|
||||
source: 'HAZOP',
|
||||
item: `${deviation}${node_ame?`(${node_ame}${obj_ame?`-${obj_ame}`:''})`:''}`,
|
||||
@@ -486,7 +500,8 @@ const enterToTable = (type: string, rowIndex: number = -1) => {
|
||||
residual_level: countRiskLevel(row)?.name || '',
|
||||
to_pssr: 0,
|
||||
safes: row?.safeguards || [],
|
||||
sugs: row?.suggestions || [],
|
||||
sugs: row?.suggestions || [],
|
||||
source_row_id: row.id || 0,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -840,6 +855,20 @@ if (typeof window !== 'undefined') {
|
||||
})
|
||||
}
|
||||
|
||||
function findRowsById(data:any, targetId: number) {
|
||||
for (const node of data) {
|
||||
if (!node?.objects) continue;
|
||||
for (const obj of node.objects) {
|
||||
if (!obj?.deviations) continue;
|
||||
for (const dev of obj.deviations) {
|
||||
if (dev.id === targetId) {
|
||||
return dev.rows ?? [];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
// 获取HAZOP节点列表
|
||||
const getHazopNodes = async () => {
|
||||
loading.value = true;
|
||||
@@ -847,7 +876,12 @@ const getHazopNodes = async () => {
|
||||
if(!error){
|
||||
nodes.value = data.nodes;
|
||||
selectedWorkers.value = data.users;
|
||||
clickDev(nodes.value[0]?.objects[0]?.deviations[0] || null,0)
|
||||
if(!currentDev.value){
|
||||
clickDev(nodes.value[0]?.objects[0]?.deviations[0] || null,0)
|
||||
}else{
|
||||
const rows = findRowsById(nodes.value,currentDev.value?.id);
|
||||
currentDev.value.rows = rows;
|
||||
}
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -112,18 +112,19 @@ const aiOrganize = async () => {
|
||||
function uniqueById(arr: any[]) {
|
||||
const seen = new Set();
|
||||
const result = [];
|
||||
for (let i = arr.length - 1; i >= 0; i--) {
|
||||
const item = arr[i];
|
||||
if (!seen.has(item.id)) {
|
||||
seen.add(item.id);
|
||||
result.unshift(item); // 插入到头部,保持原顺序
|
||||
for (const item of arr) {
|
||||
const key = `${item.id}_${item.source}`;
|
||||
if (!seen.has(key)) {
|
||||
seen.add(key);
|
||||
result.push(item);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
// 整理入表
|
||||
const exportAll = (type: string, items: any[]) => {
|
||||
riskRecords.value = [...riskRecords.value, ...items];
|
||||
console.log(items)
|
||||
riskRecords.value = uniqueById([...riskRecords.value, ...items]);
|
||||
if (type === "all") {
|
||||
pluginDrawer.value = false;
|
||||
currentPlugin.value = '';
|
||||
|
||||
@@ -8,7 +8,7 @@ const emit = defineEmits(['close','toTable']);
|
||||
|
||||
// answer 1 是
|
||||
// answer 0 否
|
||||
// answer 2 未回答
|
||||
// answer 2 NA
|
||||
|
||||
const RISK_CHECKS_INIT = [
|
||||
{
|
||||
@@ -16,35 +16,35 @@ const RISK_CHECKS_INIT = [
|
||||
group_label: "安全健康",
|
||||
items: [
|
||||
{
|
||||
question_id: 'RISK_CHECK'+1,
|
||||
question_id: 1,
|
||||
answer: null,
|
||||
question: "是否存在任何可能导致安全问题的化学反应?检查化学反应禁忌表。",
|
||||
risk_desc: "",
|
||||
control_measure: "",
|
||||
},
|
||||
{
|
||||
question_id: 'RISK_CHECK'+2,
|
||||
question_id: 2,
|
||||
answer: null,
|
||||
question: "是否存在任何易燃易爆化学物质或粉尘?",
|
||||
risk_desc: "",
|
||||
control_measure: "",
|
||||
},
|
||||
{
|
||||
question_id: 'RISK_CHECK'+3,
|
||||
question_id: 3,
|
||||
answer: null,
|
||||
question: "是否存在任何有危险的原材料流速、成分或温度条件变更?",
|
||||
risk_desc: "",
|
||||
control_measure: "",
|
||||
},
|
||||
{
|
||||
question_id: 'RISK_CHECK'+4,
|
||||
question_id: 4,
|
||||
answer: null,
|
||||
question: "是否会因加热、冷却或精确的温度控制失控而导致安全问题?",
|
||||
risk_desc: "",
|
||||
control_measure: "",
|
||||
},
|
||||
{
|
||||
question_id: 'RISK_CHECK'+5,
|
||||
question_id: 5,
|
||||
answer: null,
|
||||
question: "是否具有为安全操作所必需的仪表、控制、紧急制动、开关或报警?",
|
||||
risk_desc: "",
|
||||
@@ -57,14 +57,14 @@ const RISK_CHECKS_INIT = [
|
||||
group_label: "工艺与操作",
|
||||
items: [
|
||||
{
|
||||
question_id: 'RISK_CHECK'+6,
|
||||
question_id: 6,
|
||||
answer: null,
|
||||
question: "变更后是否需要对操作人员进行专门培训?",
|
||||
risk_desc: "",
|
||||
control_measure: "",
|
||||
},
|
||||
{
|
||||
question_id: 'RISK_CHECK'+7,
|
||||
question_id: 7,
|
||||
answer: null,
|
||||
question: "是否涉及应急预案或消防设施的调整?",
|
||||
risk_desc: "",
|
||||
@@ -99,6 +99,7 @@ const save = async () => {
|
||||
});
|
||||
if(!error){
|
||||
window.$message?.success("保存成功");
|
||||
getRiskCheckDetail();
|
||||
}
|
||||
loading.value = false;
|
||||
};
|
||||
@@ -107,7 +108,11 @@ const save = async () => {
|
||||
const enterToTable = (type: string, groupIndex: number = -1, questionIndex: number = -1) => {
|
||||
if(type==='single'){
|
||||
const row = riskGroups.value[groupIndex]?.items[questionIndex];
|
||||
if(!row?.id){
|
||||
return window.$message?.warning("请先保存再入表");
|
||||
}
|
||||
const newRow = {
|
||||
id: row.id || 0,
|
||||
scene: row.risk_desc || '',
|
||||
source: 'RISK_CHECK',
|
||||
item: row.question || '',
|
||||
@@ -116,14 +121,22 @@ const enterToTable = (type: string, groupIndex: number = -1, questionIndex: numb
|
||||
suggestions: '',
|
||||
residual_level: '',
|
||||
to_pssr: 0,
|
||||
source_row_id: row.id || 0,
|
||||
}
|
||||
emit('toTable',type,newRow?[newRow]:[]);
|
||||
}
|
||||
if(type==='all'){
|
||||
const result = riskGroups.value.flatMap((group:any) =>
|
||||
group.items.map((item:any, index:number) => ({ group_id: group.group_id, group_label: group.group_label, index, item })).filter(({ item }:any) => !item.id)
|
||||
);
|
||||
if(result.length){
|
||||
return window.$message?.warning("请先保存再入表");
|
||||
}
|
||||
const enrichedRows:any[] = [];
|
||||
riskGroups.value.forEach((group:any) => {
|
||||
group.items.forEach((row:any) => {
|
||||
enrichedRows.push({
|
||||
id: row.id || 0,
|
||||
scene: row.risk_desc || '',
|
||||
source: 'RISK_CHECK',
|
||||
item: row.question || '',
|
||||
@@ -132,6 +145,7 @@ const enterToTable = (type: string, groupIndex: number = -1, questionIndex: numb
|
||||
suggestions: '',
|
||||
residual_level: '',
|
||||
to_pssr: 0,
|
||||
source_row_id: row.id || 0,
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
@@ -65,6 +65,7 @@ const save = async () => {
|
||||
});
|
||||
if(!error){
|
||||
window.$message?.success("保存成功");
|
||||
getDetail();
|
||||
}
|
||||
loading.value = false;
|
||||
};
|
||||
@@ -72,9 +73,12 @@ const save = async () => {
|
||||
// AI整理如表、入表
|
||||
const enterToTable = (type: string, row: any) => {
|
||||
if(type==='single'){
|
||||
if(!row?.id){
|
||||
return window.$message?.warning("请先保存再入表");
|
||||
}
|
||||
const enrichedRow:any[] = [];
|
||||
enrichedRow.push({
|
||||
...row,
|
||||
id: row?.id || 0,
|
||||
scene: row?.scene_desc || '',
|
||||
source: 'RISK',
|
||||
item: row?.risk_item || '',
|
||||
@@ -82,15 +86,20 @@ const enterToTable = (type: string, row: any) => {
|
||||
safeguards: row?.safeguards || '',
|
||||
suggestions: row?.suggestions || '',
|
||||
residual_level: row?.residual_risk_value || '',
|
||||
to_pssr: 0
|
||||
to_pssr: 0,
|
||||
source_row_id: row?.id || 0,
|
||||
});
|
||||
emit('toTable',type,enrichedRow);
|
||||
}
|
||||
if(type==='all'){
|
||||
const result = riskRecords.value.filter((item:any) => !item.id);
|
||||
if(result.length){
|
||||
return window.$message?.warning("请先保存再入表");
|
||||
}
|
||||
const enrichedRows:any[] = [];
|
||||
riskRecords.value.forEach((row:any) => {
|
||||
enrichedRows.push({
|
||||
...row,
|
||||
id: row?.id || 0,
|
||||
scene: row?.scene_desc || '',
|
||||
source: 'RISK',
|
||||
item: row?.risk_item || '',
|
||||
@@ -98,7 +107,8 @@ const enterToTable = (type: string, row: any) => {
|
||||
safeguards: row?.safeguards || '',
|
||||
suggestions: row?.suggestions || '',
|
||||
residual_level: row?.residual_risk_value || '',
|
||||
to_pssr: 0
|
||||
to_pssr: 0,
|
||||
source_row_id: row?.id || 0,
|
||||
});
|
||||
})
|
||||
emit('toTable',type,enrichedRows);
|
||||
@@ -135,8 +145,8 @@ const getWorkers = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取JSA详情
|
||||
const getJsaDetail = async () => {
|
||||
// 获取详情
|
||||
const getDetail = async () => {
|
||||
loading.value = true;
|
||||
const {data,error} = await riskPreDetailApi(props.currentId);
|
||||
if(!error){
|
||||
@@ -148,7 +158,7 @@ const getJsaDetail = async () => {
|
||||
|
||||
onMounted(() => {
|
||||
getWorkers();
|
||||
getJsaDetail();
|
||||
getDetail();
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user