hazop插件和jsa插件修改完成

This commit is contained in:
2026-09-09 17:10:16 +08:00
parent d7b1f4b2ef
commit 000178f04d
6 changed files with 834 additions and 660 deletions
@@ -1,6 +1,6 @@
<!-- 风险分析记录表 -->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { computed, onMounted, ref } from 'vue';
import { Icon } from '@iconify/vue'
import { useThemeStore } from '@/store/modules/theme';
import Hazop from "./hazop.vue";
@@ -15,12 +15,15 @@ const themeStore = useThemeStore();
const props = defineProps(['type','isAiOpen','title','currentId','formInfo'])
const emit = defineEmits(['save','submit','confirmTab']);
const form = ref<{ content: string }>({
content: ''
});
const hazopRiskMatrixConfig = ref<any>(null);
const jsaRiskMatrixConfig = ref<any>(null);
const pluginDone = ref<Record<string, number>>({});
const pluginDone = computed(() =>
riskRecords.value.reduce((acc:any, item:any) => {
const s = item.source;
if (s) acc[s] = (acc[s] || 0) + 1;
return acc;
}, {} as Record<string, number>)
);
const tools = ref<string[]>(["HAZOP","JSA", "SCL", "RISK_CHECK"]);
const riskRecords = ref<any>([]);
const pluginDrawer = ref<boolean>(false);
@@ -157,6 +160,7 @@ const exportAll = (type: string, items: any[]) => {
// 使用插件弹框
const usePlugin = (key: string) => {
console.log(riskRecords.value)
currentPlugin.value = key;
pluginDrawer.value = true;
}
@@ -193,7 +197,7 @@ const getJsaRiskMatrixConfig = async () => {
}
}
defineExpose({form})
defineExpose({riskRecords})
onMounted(() => {
getHazopRiskMatrixConfig();
@@ -232,11 +236,11 @@ onMounted(() => {
<Icon icon="fluent:wand-24-regular" class="size-16px" />
{{ t.name }}
</div>
<div class="mt-0.5 text-[10px]" :class="pluginDone[t.key] !== undefined ? 'text-white/75' : 'text-slate-400'">
<div class="mt-0.5 text-[10px]" :class="pluginDone[t.key] !== undefined ? 'text-white' : 'text-slate-400'">
{{ pluginDone[t.key] !== undefined ? `已使用并分析了 ${pluginDone[t.key]} 条内容` : '未使用此工具分析' }}
</div>
</div>
<NButton size="small" class="text-xs" type="primary" @click="usePlugin(t.key)">
<NButton size="small" class="text-xs !text-white" :tertiary="pluginDone[t.key] !== undefined" type="primary" @click="usePlugin(t.key)">
使用
</NButton>
</div>
@@ -388,7 +392,7 @@ onMounted(() => {
:currentId="props.currentId"
:title="props.title"
:isAiOpen="props.isAiOpen"
:currentForm="form"
:currentForm="formInfo"
@save="saveDraft"
@submit="submitConfirm"
@confirmTab="confirmTab"
@@ -400,7 +404,7 @@ onMounted(() => {
<Hazop :isAiOpen="props.isAiOpen" :currentId="props.currentId" :hazopRiskMatrixConfig="hazopRiskMatrixConfig" @close="closePlugin" @toTable="exportAll" />
</template>
<template v-else-if="currentPlugin === 'JSA'">
<Jsa @close="closePlugin" @toTable="exportAll" />
<Jsa :isAiOpen="props.isAiOpen" :currentId="props.currentId" :jsaRiskMatrixConfig="jsaRiskMatrixConfig" @close="closePlugin" @toTable="exportAll" />
</template>
<template v-else-if="currentPlugin === 'SCL'">
<Scl @close="closePlugin" @toTable="exportAll" />