From 5ecd8ac95cb30a851cb38119f9fc0d5559d77c30 Mon Sep 17 00:00:00 2001 From: bestlee Date: Mon, 31 Aug 2026 10:05:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BA=BF=E4=B8=8A=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global-header/components/user-avatar.vue | 3 +- src/service/api/system.ts | 9 + src/store/modules/route/index.ts | 2 +- src/utils/service.ts | 5 +- src/views/systemManage/setting/index.vue | 1010 +++++++++-------- 5 files changed, 565 insertions(+), 464 deletions(-) diff --git a/src/layouts/modules/global-header/components/user-avatar.vue b/src/layouts/modules/global-header/components/user-avatar.vue index 1f0796c..470e95f 100644 --- a/src/layouts/modules/global-header/components/user-avatar.vue +++ b/src/layouts/modules/global-header/components/user-avatar.vue @@ -4,6 +4,7 @@ import type { VNode } from 'vue'; import { useAuthStore } from '@/store/modules/auth'; import { useRouterPush } from '@/hooks/common/router'; import { useSvgIcon } from '@/hooks/common/icon'; +import { localStg } from '@/utils/storage'; defineOptions({ name: 'UserAvatar' @@ -80,7 +81,7 @@ function handleDropdown(key: DropdownKey) {
- {{ authStore.userInfo.username }} + {{ localStg.get('userInfo')?.username }}
diff --git a/src/service/api/system.ts b/src/service/api/system.ts index 2c454e7..ccad3c1 100644 --- a/src/service/api/system.ts +++ b/src/service/api/system.ts @@ -77,3 +77,12 @@ export function deleteTemplateApi(id:number) { }); } +// 获取风险矩阵配置 +export function matrixConfigApi(bizType:string) { + return request({ + url: `/api/risk-matrix/${bizType}`, + method: 'get', + }); +} + + diff --git a/src/store/modules/route/index.ts b/src/store/modules/route/index.ts index 415a4d6..3f221d8 100644 --- a/src/store/modules/route/index.ts +++ b/src/store/modules/route/index.ts @@ -198,7 +198,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => { * @param {string} parentPath - 父级路径(用于拼接相对路径,本例中所有路径都是绝对路径,可忽略) * @returns {Array} 过滤后的路由数组 */ - function filterRoutesByPaths(routes: ElegantConstRoute[], allowedPaths: string[], parentPath = '') { + function filterRoutesByPaths(routes: ElegantConstRoute[], allowedPaths: string[], parentPath = ''):any { const result = []; const pathSet = new Set(allowedPaths); diff --git a/src/utils/service.ts b/src/utils/service.ts index 58652bd..55a60a9 100644 --- a/src/utils/service.ts +++ b/src/utils/service.ts @@ -5,7 +5,7 @@ import json5 from 'json5'; * * @param env The current env */ -let url = 'http://192.168.0.230:8086'; +let url = ''; export function createServiceConfig(env: Env.ImportMeta) { const { VITE_SERVICE_BASE_URL, VITE_OTHER_SERVICE_BASE_URL } = env; @@ -19,7 +19,8 @@ export function createServiceConfig(env: Env.ImportMeta) { if(env.DEV){ url = 'http://192.168.0.230:8086'; }else{ - url = window.location.origin; + // url = window.location.origin; + url = 'http://192.168.0.230:8086'; } const httpConfig: App.Service.SimpleServiceConfig = { baseURL: url, diff --git a/src/views/systemManage/setting/index.vue b/src/views/systemManage/setting/index.vue index dff2005..f26513c 100644 --- a/src/views/systemManage/setting/index.vue +++ b/src/views/systemManage/setting/index.vue @@ -4,7 +4,14 @@ import { useAppStore } from '@/store/modules/app'; import { Icon } from '@iconify/vue' import { useThemeStore } from '@/store/modules/theme'; import { getColorWithOpacity, tagTextColor, tagBgColor, tagBorderColor } from '@/utils/common'; -import { systemConfigApi, addSystemConfigApi, editSystemConfigApi, deleteSystemConfigApi, updateConfigApi } from '@/service/api/system'; +import { + systemConfigApi, + addSystemConfigApi, + editSystemConfigApi, + deleteSystemConfigApi, + updateConfigApi, + matrixConfigApi +} from '@/service/api/system'; const appStore = useAppStore(); const themeStore = useThemeStore(); @@ -287,23 +294,18 @@ const saveRule = async () => { const dimensionModal = ref(false); const dimensionLoading = ref(false); -const dimForm = ref({ s: [], l: [] }); -const LV_CLS = [ - "border-emerald-300 bg-emerald-100 text-emerald-700", - "border-yellow-300 bg-yellow-100 text-yellow-700", - "border-orange-300 bg-orange-100 text-orange-700", - "border-red-300 bg-red-100 text-red-700", -]; +const dimForm = ref<{s:string[], l:string[]}>({ s: [], l: [] }); +// 默认风险矩阵维度分级定义 const matrices = ref([ { tool: "HAZOP", sLabels: ["轻微", "一般", "较重", "严重", "灾难"], lLabels: ["极少发生", "较少发生", "偶尔发生", "可能发生", "频繁发生"], levels: [ - { name: "低", min: 1, max: 4, cls: LV_CLS[0] }, - { name: "一般", min: 5, max: 9, cls: LV_CLS[1] }, - { name: "较大", min: 10, max: 16, cls: LV_CLS[2] }, - { name: "重大", min: 17, max: 25, cls: LV_CLS[3] }, + { name: "低", min: 1, max: 4, bgColor:'#d1fae5', color:'#047857' }, + { name: "一般", min: 5, max: 9, bgColor:'#fef9c3', color:'#c27707' }, + { name: "较大", min: 10, max: 16, bgColor:'#fee2e2', color:'#c2410c' }, + { name: "重大", min: 17, max: 25, bgColor:'#fff3cd', color:'#b91c1c' }, ], }, { @@ -311,10 +313,10 @@ const matrices = ref([ sLabels: ["轻微伤害", "轻伤", "重伤", "单人死亡", "多人死亡"], lLabels: ["极不可能", "不太可能", "有可能", "较可能", "很可能"], levels: [ - { name: "低", min: 1, max: 6, cls: LV_CLS[0] }, - { name: "一般", min: 7, max: 12, cls: LV_CLS[1] }, - { name: "较大", min: 13, max: 19, cls: LV_CLS[2] }, - { name: "重大", min: 20, max: 25, cls: LV_CLS[3] }, + { name: "低", min: 1, max: 6, bgColor:'#d1fae5', color:'#047857' }, + { name: "一般", min: 7, max: 12, bgColor:'#fef9c3', color:'#c27707' }, + { name: "较大", min: 13, max: 19, bgColor:'#fee2e2', color:'#c2410c' }, + { name: "重大", min: 20, max: 25, bgColor:'#fff3cd', color:'#b91c1c' }, ], }, { @@ -322,20 +324,43 @@ const matrices = ref([ sLabels: ["轻微影响", "一般影响", "较大影响", "严重影响", "灾难性影响"], lLabels: ["极少", "较少", "偶尔", "可能", "经常"], levels: [ - { name: "低", min: 1, max: 2, cls: LV_CLS[0] }, - { name: "一般", min: 3, max: 6, cls: LV_CLS[1] }, - { name: "较大", min: 7, max: 12, cls: LV_CLS[2] }, - { name: "重大", min: 13, max: 25, cls: LV_CLS[3] }, + { name: "低", min: 1, max: 2, bgColor:'#d1fae5', color:'#047857' }, + { name: "一般", min: 3, max: 6, bgColor:'#fef9c3', color:'#c27707' }, + { name: "较大", min: 7, max: 12, bgColor:'#fee2e2', color:'#c2410c' }, + { name: "重大", min: 13, max: 25, bgColor:'#fff3cd', color:'#b91c1c' }, ], }, ]); +// 当前选中的风险矩阵索引 const activeMatrix = ref(0); -const curMatrix = computed(() => matrices.value[activeMatrix.value]); +// 当前选中的风险矩阵 +const curMatrix = ref(null); const cellScore = (s:number, l:number) => (s + 1) * (l + 1); const cellLevel = (s:number, l:number) => { const sc = cellScore(s, l); - return curMatrix.value.levels.find((lv:{min:number,max:number}) => sc >= lv.min && sc <= lv.max); + return curMatrix.value?.levels.find((lv:{min:number,max:number}) => sc >= lv.min && sc <= lv.max); } + +// 风险矩阵tabs切换 +const handleTabChange = (v: number) => { + activeMatrix.value = v; + curMatrix.value = matrices.value[v]; +} + +// 打开风险矩阵编辑弹窗 +const openDimEdit = () => { + dimForm.value = { s: [...curMatrix.value?.sLabels], l: [...curMatrix.value?.lLabels] }; + dimensionModal.value = true; +} +// 添加后果严重性 S +const addS = () => { + dimForm.value.s.push(""); +} +// 添加发生可能性 L +const addL = () => { + dimForm.value.l.push(""); +} +// 矩阵维度分级定义保存 const dimensionSave = () => { dimensionLoading.value = true; setTimeout(() => { @@ -344,15 +369,6 @@ const dimensionSave = () => { dimensionModal.value = false; }, 1000); } -const openDimEdit = () => { - dimForm.value = { s: [...curMatrix.value.sLabels], l: [...curMatrix.value.lLabels] }; - dimensionModal.value = true; -} - -// tabs 切换 -const handleTabChange = (v: number) => { - activeMatrix.value = v; -} // 获取配置 const getConfig = async () => { @@ -389,461 +405,516 @@ const getConfig = async () => { } } +// 获取风险矩阵配置 +const matrixConfig = async () => { + const {data,error} = await matrixConfigApi(curMatrix.value?.tool); + if(!error){ + console.log(data); + } +} + onMounted(() => { - getConfig(); + curMatrix.value = matrices.value[activeMatrix.value]; + matrixConfig(); + getConfig(); })