修改线上接口地址

This commit is contained in:
2026-08-31 10:05:51 +08:00
parent 76fe37d378
commit 5ecd8ac95c
5 changed files with 565 additions and 464 deletions
@@ -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) {
<div>
<ButtonIcon>
<SvgIcon icon="ph:user-circle" class="text-icon-large" />
<span class="text-16px font-medium">{{ authStore.userInfo.username }}</span>
<span class="text-16px font-medium">{{ localStg.get('userInfo')?.username }}</span>
</ButtonIcon>
</div>
</NDropdown>
+9
View File
@@ -77,3 +77,12 @@ export function deleteTemplateApi(id:number) {
});
}
// 获取风险矩阵配置
export function matrixConfigApi(bizType:string) {
return request({
url: `/api/risk-matrix/${bizType}`,
method: 'get',
});
}
+1 -1
View File
@@ -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);
+3 -2
View File
@@ -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,
+144 -54
View File
@@ -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<boolean>(false);
const dimensionLoading = ref<boolean>(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<any>(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,13 +405,24 @@ const getConfig = async () => {
}
}
// 获取风险矩阵配置
const matrixConfig = async () => {
const {data,error} = await matrixConfigApi(curMatrix.value?.tool);
if(!error){
console.log(data);
}
}
onMounted(() => {
curMatrix.value = matrices.value[activeMatrix.value];
matrixConfig();
getConfig();
})
</script>
<template>
<div>
<NSpace vertical :size="16">
<NGrid :x-gap="gap" :y-gap="16" responsive="screen" item-responsive>
<!-- AI 辅助功能 -->
@@ -695,20 +722,27 @@ onMounted(() => {
<NTabPane :name="0" tab="HAZOP分析矩阵">
<div class="flex flex-wrap items-start gap-6">
<div class="shrink-0">
<p class="mb-1.5 text-xs text-[var(--theme-color)] text-center">点击方框可切换等级</p>
<table class="border-collapse text-center text-[11px]">
<thead>
<tr>
<th class="px-1"></th>
<th v-for="(lb, li) in curMatrix.lLabels" :key="li" class="px-0.5 pb-1 font-normal leading-tight text-slate-500">
L{{ li + 1 }}<br />{{ lb }}
<th v-for="(lb, li) in curMatrix?.lLabels" :key="li" class="px-0.5 pb-1 font-normal leading-tight text-slate-500">
L{{ Number(li) + 1 }}<br />{{ lb }}
</th>
</tr>
</thead>
<tbody>
<tr v-for="row in 5" :key="row">
<td class="whitespace-nowrap pr-1.5 text-right leading-tight text-slate-500">S{{ 6 - row }} {{ curMatrix.sLabels[5 - row] }}</td>
<td class="whitespace-nowrap pr-1.5 text-right leading-tight text-slate-500">S{{ 6 - row }} {{ curMatrix?.sLabels[5 - row] }}</td>
<td v-for="col in 5" :key="col" class="p-0.5">
<div class="flex h-9 w-12 items-center justify-center rounded border font-semibold" :class="cellLevel(5 - row, col - 1)?.cls">
<div
class="flex h-9 w-12 items-center justify-center rounded font-semibold cursor-pointer select-none"
:style="{
backgroundColor:cellLevel(5 - row, col - 1)?.bgColor,
color:cellLevel(5 - row, col - 1)?.color,
}"
>
{{ cellScore(5 - row, col - 1) }}
</div>
</td>
@@ -725,14 +759,50 @@ onMounted(() => {
<div class="min-w-72 flex-1">
<div class="mb-2 text-xs text-slate-500">风险值 = 严重性 S × 可能性 L5×5按分值区间定级</div>
<div class="space-y-2">
<div v-for="lv in curMatrix.levels" :key="lv.name" class="flex items-center gap-2 rounded-lg border px-2.5 py-2">
<span class="h-3 w-3 shrink-0 rounded-sm border" :class="lv.cls"></span>
<div v-for="lv in curMatrix?.levels" :key="lv.name" class="flex items-center gap-2 rounded-lg border px-2.5 py-2">
<span class="text-xs">背景</span>
<NColorPicker v-model:value="lv.bgColor">
<template #trigger="{ value, onClick, ref: triggerRef }">
<div
:ref="triggerRef"
class="h-4 w-4 rounded-sm border cursor-pointer"
:style="{
backgroundColor: value || '#000',
cursor: 'pointer',
}"
@click="onClick"
></div>
</template>
</NColorPicker>
<span class="text-xs">字体</span>
<NColorPicker v-model:value="lv.color">
<template #trigger="{ value, onClick, ref: triggerRef }">
<div
:ref="triggerRef"
class="h-4 w-4 rounded-sm border cursor-pointer"
:style="{
backgroundColor: value || '#000',
cursor: 'pointer',
}"
@click="onClick"
></div>
</template>
</NColorPicker>
<NInput v-model:value="lv.name" size="small" class="!w-16 text-xs" />
<span class="shrink-0 text-xs text-slate-400">分值</span>
<NInputNumber v-model:value="lv.min" :min="1" :max="25" size="small" :show-button="false" class="!w-14 text-center text-xs" />
<span class="text-slate-400"></span>
<NInputNumber v-model:value="lv.max" :min="1" :max="25" size="small" :show-button="false" class="!w-14 text-center text-xs" />
<NTag size="small" :class="lv.cls" class="ml-auto">{{ lv.name }}风险</NTag>
<NTag
size="small"
:color="{color: lv.bgColor, textColor: lv.color, borderColor: lv.bgColor}"
class="ml-auto"
>
{{ lv.name }}风险
</NTag>
<NButton text type="error">
<Icon icon="akar-icons:circle-minus" class="size-16px" />
</NButton>
</div>
</div>
<p class="mt-2.5 text-[11px] text-slate-400">
@@ -748,14 +818,14 @@ onMounted(() => {
<thead>
<tr>
<th class="px-1"></th>
<th v-for="(lb, li) in curMatrix.lLabels" :key="li" class="px-0.5 pb-1 font-normal leading-tight text-slate-500">
<th v-for="(lb, li) in curMatrix?.lLabels" :key="li" class="px-0.5 pb-1 font-normal leading-tight text-slate-500">
L{{ li + 1 }}<br />{{ lb }}
</th>
</tr>
</thead>
<tbody>
<tr v-for="row in 5" :key="row">
<td class="whitespace-nowrap pr-1.5 text-right leading-tight text-slate-500">S{{ 6 - row }} {{ curMatrix.sLabels[5 - row] }}</td>
<td class="whitespace-nowrap pr-1.5 text-right leading-tight text-slate-500">S{{ 6 - row }} {{ curMatrix?.sLabels[5 - row] }}</td>
<td v-for="col in 5" :key="col" class="p-0.5">
<div class="flex h-9 w-12 items-center justify-center rounded border font-semibold" :class="cellLevel(5 - row, col - 1)?.cls">
{{ cellScore(5 - row, col - 1) }}
@@ -774,7 +844,7 @@ onMounted(() => {
<div class="min-w-72 flex-1">
<div class="mb-2 text-xs text-slate-500">风险值 = 严重性 S × 可能性 L5×5按分值区间定级</div>
<div class="space-y-2">
<div v-for="lv in curMatrix.levels" :key="lv.name" class="flex items-center gap-2 rounded-lg border px-2.5 py-2">
<div v-for="lv in curMatrix?.levels" :key="lv.name" class="flex items-center gap-2 rounded-lg border px-2.5 py-2">
<span class="h-3 w-3 shrink-0 rounded-sm border" :class="lv.cls"></span>
<NInput v-model:value="lv.name" size="small" class="!w-16 text-xs" />
<span class="shrink-0 text-xs text-slate-400">分值</span>
@@ -797,14 +867,14 @@ onMounted(() => {
<thead>
<tr>
<th class="px-1"></th>
<th v-for="(lb, li) in curMatrix.lLabels" :key="li" class="px-0.5 pb-1 font-normal leading-tight text-slate-500">
<th v-for="(lb, li) in curMatrix?.lLabels" :key="li" class="px-0.5 pb-1 font-normal leading-tight text-slate-500">
L{{ li + 1 }}<br />{{ lb }}
</th>
</tr>
</thead>
<tbody>
<tr v-for="row in 5" :key="row">
<td class="whitespace-nowrap pr-1.5 text-right leading-tight text-slate-500">S{{ 6 - row }} {{ curMatrix.sLabels[5 - row] }}</td>
<td class="whitespace-nowrap pr-1.5 text-right leading-tight text-slate-500">S{{ 6 - row }} {{ curMatrix?.sLabels[5 - row] }}</td>
<td v-for="col in 5" :key="col" class="p-0.5">
<div class="flex h-9 w-12 items-center justify-center rounded border font-semibold" :class="cellLevel(5 - row, col - 1)?.cls">
{{ cellScore(5 - row, col - 1) }}
@@ -823,7 +893,7 @@ onMounted(() => {
<div class="min-w-72 flex-1">
<div class="mb-2 text-xs text-slate-500">风险值 = 严重性 S × 可能性 L5×5按分值区间定级</div>
<div class="space-y-2">
<div v-for="lv in curMatrix.levels" :key="lv.name" class="flex items-center gap-2 rounded-lg border px-2.5 py-2">
<div v-for="lv in curMatrix?.levels" :key="lv.name" class="flex items-center gap-2 rounded-lg border px-2.5 py-2">
<span class="h-3 w-3 shrink-0 rounded-sm border" :class="lv.cls"></span>
<NInput v-model:value="lv.name" size="small" class="!w-16 text-xs" />
<span class="shrink-0 text-xs text-slate-400">分值</span>
@@ -844,6 +914,7 @@ onMounted(() => {
</NCard>
</NGi>
</NGrid>
</NSpace>
<!-- AI调用记录查询 -->
<NDrawer v-model:show="showLog" :width="700" placement="right">
@@ -1008,26 +1079,46 @@ onMounted(() => {
<NModal
v-model:show="dimensionModal"
preset="card"
:title="curMatrix.tool+'矩阵维度分级定义'"
:title="curMatrix?.tool+'矩阵维度分级定义'"
:auto-focus="false"
:style="{ width: '500px', height: 'auto' }"
:segmented="{ content: true, footer: true }"
>
<div class="space-y-4">
<div class="space-y-6">
<div>
<div class="mb-1.5 text-xs font-semibold text-slate-600">后果严重性 SS1 S5 递增</div>
<div class="grid grid-cols-5 gap-1.5">
<label v-for="(_, i) in dimForm.s" :key="'s' + i" class="text-center text-[10px] text-slate-400">
<div class="mb-1.5 text-xs font-semibold text-slate-600 flex items-center">
后果严重性 SS1 S5 递增
<NButton size="tiny" ghost type="primary" @click="addS">
<Icon icon="ic:round-plus" class="size-14px" />新增
</NButton>
</div>
<div class="grid grid-cols-5 gap-1.5 mt-3">
<label v-for="(_, i) in dimForm.s" :key="'s' + i" class="text-center text-xs text-slate-400">
<div class="flex items-center justify-center gap-2 mb-1">
S{{ i + 1 }}
<NButton text type="error">
<Icon icon="akar-icons:circle-minus" class="size-16px" />
</NButton>
</div>
<NInput v-model:value="dimForm.s[i]" size="small" class="mt-0.5 text-center text-xs" />
</label>
</div>
</div>
<div>
<div class="mb-1.5 text-xs font-semibold text-slate-600">发生可能性 LL1 L5 递增</div>
<div class="grid grid-cols-5 gap-1.5">
<label v-for="(_, i) in dimForm.l" :key="'l' + i" class="text-center text-[10px] text-slate-400">
<div class="mb-1.5 text-xs font-semibold text-slate-600 flex items-center">
发生可能性 LL1 L5 递增
<NButton size="tiny" ghost type="primary" @click="addL">
<Icon icon="ic:round-plus" class="size-14px" />新增
</NButton>
</div>
<div class="grid grid-cols-5 gap-1.5 mt-3">
<label v-for="(_, i) in dimForm.l" :key="'l' + i" class="text-center text-xs text-slate-400">
<div class="flex items-center justify-center gap-2 mb-1">
L{{ i + 1 }}
<NButton text type="error">
<Icon icon="akar-icons:circle-minus" class="size-16px" />
</NButton>
</div>
<NInput v-model:value="dimForm.l[i]" size="small" class="mt-0.5 text-center text-xs" />
</label>
</div>
@@ -1040,8 +1131,7 @@ onMounted(() => {
</div>
</template>
</NModal>
</NSpace>
</div>
</template>
<style scoped></style>