hazop插件添加

This commit is contained in:
2026-08-26 14:51:53 +08:00
parent 26f33d8219
commit 80cc999687
4 changed files with 327 additions and 25 deletions
+43 -24
View File
@@ -3,12 +3,12 @@ import { computed, ref } from 'vue';
import { Icon } from '@iconify/vue'
import { useThemeStore } from '@/store/modules/theme';
import {
CHANGES, DOC_TODO, LEVEL_COLOR, STATUS_COLOR, TEMP_WATCH, URGE_RECORDS,
countOpenStatus, type ChangeLevel, type ChangeOrder, type ChangeStatus, type ChangeType,
CHANGES, type ChangeLevel, type ChangeOrder, type ChangeStatus, type ChangeType,
} from "@/typings/model";
import { getColorWithOpacity } from "@/utils/common";
import HighlightText from "@/views/my/modules/HighlightText.vue";
import Ed from "@/views/my/modules/Ed.vue";
import HighlightText from "./modules/HighlightText.vue";
import Ed from "./modules/Ed.vue";
import Hazop from "./modules/hazop.vue";
const themeStore = useThemeStore();
@@ -108,8 +108,7 @@ const formGen = ref<string>("idle");
const materialsText = ref("");
const updateDocs = ref<string[]>([]);
const disciplines = ref<string[]>([]);
const tools = ref<string[]>(["JSA", "检查表法", "通用检查表"]);
const plugin = ref<"HAZOP" | "JSA" | "检查表法" | "通用检查表" | null>(null);
const tools = ref<string[]>(["HAZOP","JSA", "SCL", "通用检查表"]);
const genForm = () => {
if (formGen.value === "generating") return;
formGen.value = "generating";
@@ -136,8 +135,8 @@ const genForm = () => {
updateDocs.value = ["PID图纸", "操作规程", "总图", "设备台账"];
disciplines.value = ["技术", "仪表"];
signers.value = { 技术: "王仪表(技术部)", 仪表: "王仪表(技术部 · 仪表)" };
tools.value = ["JSA", "检查表法", "通用检查表"];
plugin.value = null;
tools.value = ["HAZOP","JSA", "SCL", "通用检查表"];
currentPlugin.value = "";
formGen.value = "done";
tab.value = "form";
window.$message?.success("变更申请单已生成:AI 自动总结名称、预填内容,均可手动修改");
@@ -293,7 +292,7 @@ const levelResult = computed(() => (totalScore.value >= 20 ? "重要变更" : "
const RISK_TOOLS_FORM = [
{ key: "HAZOP", label: "HAZOP" },
{ key: "JSA", label: "JSA" },
{ key: "检查表法", label: "设备SCL" },
{ key: "SCL", label: "设备SCL" },
{ key: "通用检查表", label: "风险检查表" },
];
const recommendTools = () => {
@@ -301,9 +300,6 @@ const recommendTools = () => {
tools.value = lv === "重要" ? ["HAZOP", "JSA", "检查表法", "通用检查表"] : ["JSA", "检查表法", "通用检查表"];
window.$message?.success(`已按「${lv}变更」规则匹配风险分析工具,可继续手动重选`);
};
const toggleTool = (t: string) => {
tools.value = tools.value.includes(t) ? tools.value.filter((x) => x !== t) : [...tools.value, t];
};
const files = ref<string[]>(["小试实验报告.pdf", "杂质初步分析.docx"]);
const previewFile = ref<string | null>(null);
@@ -396,7 +392,7 @@ const finishApprover = () => {
const TOOL_CARDS = [
{ key: "HAZOP" as const, name: "HAZOP 分析", desc: "节点-偏离结构化分析:原因 / 后果 / LS 风险矩阵 / 安全措施" },
{ key: "JSA" as const, name: "JSA 分析", desc: "作业步骤分解:危害因素识别与 LS 风险分级管控" },
{ key: "检查表法" as const, name: "设备 SCL", desc: "设备 / 管理检查项目对照标准逐项核查" },
{ key: "SCL" as const, name: "设备 SCL", desc: "设备 / 管理检查项目对照标准逐项核查" },
{ key: "通用检查表" as const, name: "风险检查表", desc: "变更通用检查项:是 / 否 / 不涉及逐项判定,输出风险描述与管控措施" },
];
const pluginDone = ref<Record<string, number>>({});
@@ -404,15 +400,6 @@ const riskRecords = ref<any>([]);
const updRec = (i: number, patch: Partial<any>) => {
riskRecords.value = riskRecords.value.map((x, j) => (j === i ? { ...x, ...patch } : x));
};
const addRiskRecords = (items: any[], mode: "manual" | "ai") => {
riskRecords.value = [...riskRecords.value, ...items];
if (mode === "ai") {
plugin.value = null;
window.$message?.success(`AI 已自动整理形成风险分析记录表(新增 ${items.length} 项),支持手动修改`);
} else {
window.$message?.success(`已选入 ${items.length} 条风险记录,可继续挑选或返回查看记录表`);
}
};
const lvlNext = (v: string) => (v === "高" ? "中" : v === "中" ? "低" : "高");
const pssrGroups = ref<{ g: string; items: any[] }[]>([
{ g: "一、风险分析行动项落实", items: [
@@ -561,6 +548,30 @@ const uploadConfirm = () => {
uploadDoc.value = null;
}
const pluginDrawer = ref<boolean>(false);
const currentPlugin = ref<string>("");
// 插件选择
const toggleTool = (t: any) => {
if (!tools.value.includes(t.key))
tools.value = tools.value.includes(t.key) ? tools.value.filter((x) => x !== t.key) : [...tools.value, t.key];
currentPlugin.value = t.key;
pluginDrawer.value = true;
};
const exportAll = (items: any[], mode: "manual" | "ai") => {
riskRecords.value = [...riskRecords.value, ...items];
if (mode === "ai") {
pluginDrawer.value = false;
currentPlugin.value = '';
window.$message?.success(`AI 已自动整理形成风险分析记录表(新增 ${items.length} 项),支持手动修改`);
} else {
window.$message?.success(`已选入 ${items.length} 条风险记录,可继续挑选或返回查看记录表`);
}
}
const onBack = () => {
pluginDrawer.value = false;
}
</script>
@@ -927,7 +938,7 @@ const uploadConfirm = () => {
</div>
</template>
<!-- ===== 风险记录表 ===== -->
<!-- ===== 风险分析记录表 ===== -->
<template v-if="tab === 'risk'">
<div class="border p-3" :style="{ borderRadius: themeStore.themeRadius + 'px' }">
<div class="flex flex-wrap items-center gap-2">
@@ -962,7 +973,7 @@ const uploadConfirm = () => {
</div>
</div>
<NButton size="small" class="text-xs" :type="pluginDone[t.key] !== undefined ? 'default' : tools.includes(t.key) ? 'primary' : 'default'"
@click="if (!tools.includes(t.key)) toggleTool(t.key); plugin = t.key;">
@click="toggleTool(t)">
使用
</NButton>
</div>
@@ -1632,6 +1643,14 @@ const uploadConfirm = () => {
</div>
</template>
</NModal>
<!-- 插件抽屉 -->
<NDrawer v-model:show="pluginDrawer" :width="1200" placement="right">
<NDrawerContent>
<template v-if="currentPlugin === 'HAZOP'">
<Hazop @back="onBack" @export="exportAll" />
</template>
</NDrawerContent>
</NDrawer>
</NCard>
</NSpace>
</template>