fix: 修改jetlinks-store
This commit is contained in:
parent
e3ef99cbe1
commit
b03dd8846e
|
@ -0,0 +1,17 @@
|
||||||
|
import { defineStore } from "pinia";
|
||||||
|
|
||||||
|
export const useTypeStore = defineStore({
|
||||||
|
id: 'type',
|
||||||
|
state: () => ({
|
||||||
|
configRef: [] as any,
|
||||||
|
resourcesClusters: {} as any,
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
setConfigRef(current: any[]) {
|
||||||
|
this.configRef = current
|
||||||
|
},
|
||||||
|
setResourcesClusters(current: any) {
|
||||||
|
this.resourcesClusters = current
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
|
@ -156,13 +156,10 @@
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { save, update } from '@/api/data-collect/collector';
|
import { save, update } from '@/api/data-collect/collector';
|
||||||
import { Store } from 'jetlinks-store';
|
|
||||||
import { LeftTreeRules } from '../../data';
|
import { LeftTreeRules } from '../../data';
|
||||||
import type { FormInstance } from 'ant-design-vue';
|
import type { FormInstance } from 'ant-design-vue';
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const channelListAll = ref();
|
|
||||||
const channelList = ref();
|
|
||||||
const visibleEndian = ref(false);
|
const visibleEndian = ref(false);
|
||||||
const visibleUnitId = ref(false);
|
const visibleUnitId = ref(false);
|
||||||
|
|
||||||
|
@ -171,6 +168,10 @@ const props = defineProps({
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
|
channelListAll: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['change']);
|
const emit = defineEmits(['change']);
|
||||||
|
@ -178,6 +179,16 @@ const emit = defineEmits(['change']);
|
||||||
const id = props.data.id;
|
const id = props.data.id;
|
||||||
const formRef = ref<FormInstance>();
|
const formRef = ref<FormInstance>();
|
||||||
|
|
||||||
|
const _channelListAll = computed(() => {
|
||||||
|
return props.channelListAll || [];
|
||||||
|
})
|
||||||
|
const channelList = computed(() => {
|
||||||
|
return _channelListAll.value.map((item: any) => ({
|
||||||
|
value: item.id,
|
||||||
|
label: item.name,
|
||||||
|
}));
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
const endianData = computed(() => {
|
const endianData = computed(() => {
|
||||||
const { endian, endianIn } = formData.value.configuration;
|
const { endian, endianIn } = formData.value.configuration;
|
||||||
|
@ -213,7 +224,7 @@ const formData = ref({
|
||||||
const handleOk = async () => {
|
const handleOk = async () => {
|
||||||
const data = await formRef.value?.validate();
|
const data = await formRef.value?.validate();
|
||||||
|
|
||||||
const { provider, name } = channelListAll.value.find(
|
const { provider, name } = _channelListAll.value.find(
|
||||||
(item: any) => item.id === formData.value.channelId,
|
(item: any) => item.id === formData.value.channelId,
|
||||||
);
|
);
|
||||||
const params = {
|
const params = {
|
||||||
|
@ -252,14 +263,6 @@ const changeCardSelectEndian = (value: Array<string>) => {
|
||||||
const changeCardSelectEndianIn = (value: Array<string>) => {
|
const changeCardSelectEndianIn = (value: Array<string>) => {
|
||||||
formData.value.configuration.endianIn = value[0];
|
formData.value.configuration.endianIn = value[0];
|
||||||
};
|
};
|
||||||
const getChannelNoPaging = async () => {
|
|
||||||
channelListAll.value = Store.get('channelListAll');
|
|
||||||
channelList.value = channelListAll.value.map((item) => ({
|
|
||||||
value: item.id,
|
|
||||||
label: item.name,
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
getChannelNoPaging();
|
|
||||||
|
|
||||||
const filterOption = (input: string, option: any) => {
|
const filterOption = (input: string, option: any) => {
|
||||||
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
||||||
|
@ -268,7 +271,7 @@ const filterOption = (input: string, option: any) => {
|
||||||
watch(
|
watch(
|
||||||
() => formData.value.channelId,
|
() => formData.value.channelId,
|
||||||
(value) => {
|
(value) => {
|
||||||
const dt = channelListAll.value.find((item) => item.id === value);
|
const dt = _channelListAll.value.find((item) => item.id === value);
|
||||||
visibleUnitId.value = visibleEndian.value =
|
visibleUnitId.value = visibleEndian.value =
|
||||||
dt?.provider && dt?.provider === 'MODBUS_TCP';
|
dt?.provider && dt?.provider === 'MODBUS_TCP';
|
||||||
},
|
},
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
</j-tree>
|
</j-tree>
|
||||||
<j-empty v-else description="暂无数据" />
|
<j-empty v-else description="暂无数据" />
|
||||||
</j-spin>
|
</j-spin>
|
||||||
<Save v-if="visible" :data="current" @change="saveChange" />
|
<Save :channelListAll="channelListAll" v-if="visible" :data="current" @change="saveChange" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -124,7 +124,6 @@ import {
|
||||||
} from '@/api/data-collect/collector';
|
} from '@/api/data-collect/collector';
|
||||||
import Save from './Save/index.vue';
|
import Save from './Save/index.vue';
|
||||||
import { onlyMessage } from '@/utils/comm';
|
import { onlyMessage } from '@/utils/comm';
|
||||||
import { Store } from 'jetlinks-store';
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { colorMap } from '../data.ts';
|
import { colorMap } from '../data.ts';
|
||||||
|
|
||||||
|
@ -144,6 +143,7 @@ const searchValue = ref();
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const current = ref({});
|
const current = ref({});
|
||||||
const collectorAll = ref();
|
const collectorAll = ref();
|
||||||
|
const channelListAll = ref<any[]>([])
|
||||||
|
|
||||||
const root = [
|
const root = [
|
||||||
{
|
{
|
||||||
|
@ -274,8 +274,8 @@ const handleSearch = async (value: any) => {
|
||||||
};
|
};
|
||||||
const getChannelNoPaging = async () => {
|
const getChannelNoPaging = async () => {
|
||||||
|
|
||||||
const res = await queryChannelNoPaging();
|
const res: any = await queryChannelNoPaging();
|
||||||
Store.set('channelListAll', res.result);
|
channelListAll.value = res.result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const treeSelect = (keys: string, e: any) => {
|
const treeSelect = (keys: string, e: any) => {
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
:bodyStyle="{ padding: 0 }"
|
:bodyStyle="{ padding: 0 }"
|
||||||
:defaultParams="defaultParams"
|
:defaultParams="defaultParams"
|
||||||
>
|
>
|
||||||
<template #rightExtraRender>
|
<!-- <template #rightExtraRender>
|
||||||
<j-popconfirm title="确认全部已读?" @confirm="onAllRead">
|
<j-popconfirm title="确认全部已读?" @confirm="onAllRead">
|
||||||
<j-button type="primary">全部已读</j-button>
|
<j-button type="primary">全部已读</j-button>
|
||||||
</j-popconfirm>
|
</j-popconfirm>
|
||||||
</template>
|
</template> -->
|
||||||
<template #topicProvider="slotProps">
|
<template #topicProvider="slotProps">
|
||||||
{{ slotProps.topicName }}
|
{{ slotProps.topicName }}
|
||||||
</template>
|
</template>
|
||||||
|
@ -240,14 +240,14 @@ watchEffect(() => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const onAllRead = async () => {
|
// const onAllRead = async () => {
|
||||||
const resp = await changeAllStatus('_read', getType.value);
|
// const resp = await changeAllStatus('_read', getType.value);
|
||||||
if (resp.status === 200) {
|
// if (resp.status === 200) {
|
||||||
onlyMessage('操作成功!');
|
// onlyMessage('操作成功!');
|
||||||
refresh();
|
// refresh();
|
||||||
user.updateAlarm();
|
// user.updateAlarm();
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (routerParams.params?.value.row) {
|
if (routerParams.params?.value.row) {
|
||||||
|
|
|
@ -59,7 +59,6 @@ import { DataTypeList, FileTypeList } from '@/views/device/data';
|
||||||
import { DefaultOptionType, SelectValue } from 'ant-design-vue/es/select';
|
import { DefaultOptionType, SelectValue } from 'ant-design-vue/es/select';
|
||||||
import { PropType } from 'vue'
|
import { PropType } from 'vue'
|
||||||
import { getUnit } from '@/api/device/instance';
|
import { getUnit } from '@/api/device/instance';
|
||||||
import { Store } from 'jetlinks-store';
|
|
||||||
import InputSelect from '@/components/InputSelect/index.vue';
|
import InputSelect from '@/components/InputSelect/index.vue';
|
||||||
import BooleanParam from '@/components/Metadata/BooleanParam/index.vue'
|
import BooleanParam from '@/components/Metadata/BooleanParam/index.vue'
|
||||||
import EnumParam from '@/components/Metadata/EnumParam/index.vue'
|
import EnumParam from '@/components/Metadata/EnumParam/index.vue'
|
||||||
|
@ -140,7 +139,6 @@ const unit = reactive({
|
||||||
value: item.id,
|
value: item.id,
|
||||||
}));
|
}));
|
||||||
// 缓存单位数据
|
// 缓存单位数据
|
||||||
Store.set('units', _data);
|
|
||||||
unit.unitOptions = _data;
|
unit.unitOptions = _data;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,8 +12,13 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Store } from "jetlinks-store"
|
|
||||||
import { resourceClustersById } from "@/api/link/type"
|
import { resourceClustersById } from "@/api/link/type"
|
||||||
|
import { useTypeStore } from "@/store/type"
|
||||||
|
import { cloneDeep } from "lodash-es"
|
||||||
|
import { storeToRefs } from "pinia"
|
||||||
|
|
||||||
|
const _typeStore = useTypeStore()
|
||||||
|
const { resourcesClusters } = storeToRefs(_typeStore)
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: {
|
value: {
|
||||||
|
@ -36,7 +41,7 @@ const host = ref<string>()
|
||||||
const options = ref<any[]>([])
|
const options = ref<any[]>([])
|
||||||
|
|
||||||
const getResourcesClustersById = async (id: string) => {
|
const getResourcesClustersById = async (id: string) => {
|
||||||
const _value = Store.get('resourcesClusters')?.[id]
|
const _value = resourcesClusters.value?.[id]
|
||||||
if(!_value){
|
if(!_value){
|
||||||
const resp = await resourceClustersById(id)
|
const resp = await resourceClustersById(id)
|
||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
|
@ -44,15 +49,15 @@ const getResourcesClustersById = async (id: string) => {
|
||||||
const checkedHost = [{ value: checked?.host, label: checked?.host }];
|
const checkedHost = [{ value: checked?.host, label: checked?.host }];
|
||||||
options.value = checked ? checkedHost : []
|
options.value = checked ? checkedHost : []
|
||||||
|
|
||||||
const resourcesClusters = Store.get('resourcesClusters') || {}
|
const _resourcesClusters = cloneDeep(resourcesClusters.value)
|
||||||
resourcesClusters[id] = resp.result
|
_resourcesClusters[id] = resp.result
|
||||||
Store.set('resourcesClusters', resourcesClusters)
|
_typeStore.setResourcesClusters(_resourcesClusters)
|
||||||
emit('valueChange', props.value)
|
emit('valueChange', props.value)
|
||||||
} else {
|
} else {
|
||||||
options.value = []
|
options.value = []
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const checked = Store.get('resourcesClusters')?.[id]?.[0]
|
const checked = resourcesClusters.value?.[id]?.[0]
|
||||||
const checkedHost = [{ value: checked?.host, label: checked?.host }];
|
const checkedHost = [{ value: checked?.host, label: checked?.host }];
|
||||||
options.value = checked ? checkedHost : []
|
options.value = checked ? checkedHost : []
|
||||||
}
|
}
|
||||||
|
|
|
@ -1143,9 +1143,10 @@ import {
|
||||||
} from '../data';
|
} from '../data';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
import type { FormData2Type, FormDataType } from '../type';
|
import type { FormData2Type, FormDataType } from '../type';
|
||||||
import { Store } from 'jetlinks-store';
|
|
||||||
import LocalAddressSelect from './LocalAddressSelect.vue';
|
import LocalAddressSelect from './LocalAddressSelect.vue';
|
||||||
import { isNoCommunity } from '@/utils/utils';
|
import { isNoCommunity } from '@/utils/utils';
|
||||||
|
import { useTypeStore } from '@/store/type';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const NetworkType = route.query.type as string;
|
const NetworkType = route.query.type as string;
|
||||||
|
@ -1157,6 +1158,9 @@ const formRef1 = ref<FormInstance>();
|
||||||
const formRef2 = ref<FormInstance>();
|
const formRef2 = ref<FormInstance>();
|
||||||
const shareCluster = ref(true);
|
const shareCluster = ref(true);
|
||||||
|
|
||||||
|
const _typeStore = useTypeStore()
|
||||||
|
const { configRef, resourcesClusters } = storeToRefs(_typeStore)
|
||||||
|
|
||||||
const formData = ref<FormDataType>({
|
const formData = ref<FormDataType>({
|
||||||
...FormStates,
|
...FormStates,
|
||||||
});
|
});
|
||||||
|
@ -1198,7 +1202,7 @@ const filterPortOption = (input: string, option: any) => {
|
||||||
|
|
||||||
const getPortList = (list: any[], id: string) => {
|
const getPortList = (list: any[], id: string) => {
|
||||||
const keys = dynamicValidateForm?.cluster?.map?.(item => item.configuration?.port) || []
|
const keys = dynamicValidateForm?.cluster?.map?.(item => item.configuration?.port) || []
|
||||||
console.log(dynamicValidateForm?.cluster, id, keys)
|
// console.log(dynamicValidateForm?.cluster, id, keys)
|
||||||
return (list || []).filter(item => item.value === id || !keys.includes(item.value) )
|
return (list || []).filter(item => item.value === id || !keys.includes(item.value) )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1251,7 +1255,7 @@ const changeType = (value: string) => {
|
||||||
const updateClustersListIndex = () => {
|
const updateClustersListIndex = () => {
|
||||||
const { cluster } = dynamicValidateForm;
|
const { cluster } = dynamicValidateForm;
|
||||||
const filters = cluster?.map((item) => item.serverId);
|
const filters = cluster?.map((item) => item.serverId);
|
||||||
const newConfigRef = shareCluster.value ? Store.get('configRef')?.filter(
|
const newConfigRef = shareCluster.value ? (configRef.value || [])?.filter(
|
||||||
(item: any) => !filters.includes(item.clusterNodeId),
|
(item: any) => !filters.includes(item.clusterNodeId),
|
||||||
) : configClustersList.value?.filter(
|
) : configClustersList.value?.filter(
|
||||||
(item: any) => !filters.includes(item.id),
|
(item: any) => !filters.includes(item.id),
|
||||||
|
@ -1299,7 +1303,7 @@ const changeHost = (
|
||||||
if(!flag){
|
if(!flag){
|
||||||
configuration.port = undefined;
|
configuration.port = undefined;
|
||||||
}
|
}
|
||||||
const checked = Store.get('resourcesClusters')?.[serverId || '']
|
const checked = resourcesClusters.value?.[serverId || '']
|
||||||
if(checked){
|
if(checked){
|
||||||
getPortOptions(checked, index)
|
getPortOptions(checked, index)
|
||||||
}
|
}
|
||||||
|
@ -1387,14 +1391,15 @@ const getCertificates = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getResourcesCurrent = () => {
|
const getResourcesCurrent = () => {
|
||||||
resourcesCurrent().then((resp) => {
|
resourcesCurrent().then((resp: any) => {
|
||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
|
_typeStore.setConfigRef(resp.result || [])
|
||||||
|
|
||||||
const clusterNodeId = resp.result?.[0]?.clusterNodeId
|
const clusterNodeId = resp.result?.[0]?.clusterNodeId
|
||||||
const resourcesClusters = Store.get('resourcesClusters') || {}
|
const _resourcesClusters = cloneDeep(resourcesClusters.value || {})
|
||||||
resourcesClusters[clusterNodeId] = resp.result
|
_resourcesClusters[clusterNodeId] = resp.result
|
||||||
Store.set('resourcesClusters', resourcesClusters)
|
_typeStore.setResourcesClusters(_resourcesClusters)
|
||||||
Store.set('configRef', resp.result);
|
getPortOptions(resp.result);
|
||||||
getPortOptions(Store.get('resourcesClusters')?.[clusterNodeId]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1422,11 +1427,6 @@ const getDetail = () => {
|
||||||
...cloneDeep(Configuration), //防止编辑时,表单字段不完善,导致输入/选择框新出现时找不到
|
...cloneDeep(Configuration), //防止编辑时,表单字段不完善,导致输入/选择框新出现时找不到
|
||||||
...configuration,
|
...configuration,
|
||||||
};
|
};
|
||||||
|
|
||||||
// const configRef = Store.get('configRef').filter(
|
|
||||||
// (item: any) => item.host === '0.0.0.0',
|
|
||||||
// );
|
|
||||||
// getPortOptions(configRef); //更新端口
|
|
||||||
} else {
|
} else {
|
||||||
dynamicValidateForm.cluster = cluster;
|
dynamicValidateForm.cluster = cluster;
|
||||||
// const arr = cluster.map((item: any) => item.configuration.serverId)
|
// const arr = cluster.map((item: any) => item.configuration.serverId)
|
||||||
|
@ -1479,7 +1479,7 @@ watch(
|
||||||
(value) => {
|
(value) => {
|
||||||
formData.value.shareCluster = value;
|
formData.value.shareCluster = value;
|
||||||
value
|
value
|
||||||
? getPortOptions(Store.get('configRef'))
|
? getPortOptions(configRef.value)
|
||||||
: (portOptionsIndex.value[0] = []);
|
: (portOptionsIndex.value[0] = []);
|
||||||
updateClustersListIndex();
|
updateClustersListIndex();
|
||||||
},
|
},
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
告警级别
|
告警级别
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{ (Store.get('default-level') || []).find((item: any) => item?.level === slotProps.level)?.title ||
|
{{ (defaultLevel || []).find((item: any) => item?.level === slotProps.level)?.title ||
|
||||||
slotProps.level }}
|
slotProps.level }}
|
||||||
</div>
|
</div>
|
||||||
</j-col>
|
</j-col>
|
||||||
|
@ -124,11 +124,11 @@
|
||||||
<template #level="slotProps">
|
<template #level="slotProps">
|
||||||
<j-tooltip
|
<j-tooltip
|
||||||
placement="topLeft"
|
placement="topLeft"
|
||||||
:title="(Store.get('default-level') || []).find((item) => item?.level === slotProps.level)?.title ||
|
:title="(defaultLevel || []).find((item) => item?.level === slotProps.level)?.title ||
|
||||||
slotProps.level"
|
slotProps.level"
|
||||||
>
|
>
|
||||||
<div class="ellipsis">
|
<div class="ellipsis">
|
||||||
{{ (Store.get('default-level') || []).find((item) => item?.level === slotProps.level)?.title ||
|
{{ (defaultLevel || []).find((item) => item?.level === slotProps.level)?.title ||
|
||||||
slotProps.level }}
|
slotProps.level }}
|
||||||
</div>
|
</div>
|
||||||
</j-tooltip>
|
</j-tooltip>
|
||||||
|
@ -196,7 +196,6 @@ import {
|
||||||
getScene,
|
getScene,
|
||||||
} from '@/api/rule-engine/configuration';
|
} from '@/api/rule-engine/configuration';
|
||||||
import { queryLevel } from '@/api/rule-engine/config';
|
import { queryLevel } from '@/api/rule-engine/config';
|
||||||
import { Store } from 'jetlinks-store';
|
|
||||||
import type { ActionsType } from '@/components/Table/index.vue';
|
import type { ActionsType } from '@/components/Table/index.vue';
|
||||||
import { getImage, onlyMessage } from '@/utils/comm';
|
import { getImage, onlyMessage } from '@/utils/comm';
|
||||||
import { useMenuStore } from '@/store/menu';
|
import { useMenuStore } from '@/store/menu';
|
||||||
|
@ -352,6 +351,8 @@ const columns = [
|
||||||
const visible = ref<boolean>(false);
|
const visible = ref<boolean>(false);
|
||||||
const current = ref<any>({});
|
const current = ref<any>({});
|
||||||
|
|
||||||
|
const defaultLevel = ref<any[]>([]);
|
||||||
|
|
||||||
const map = {
|
const map = {
|
||||||
product: '产品',
|
product: '产品',
|
||||||
device: '设备',
|
device: '设备',
|
||||||
|
@ -380,7 +381,7 @@ const handleSearch = (e: any) => {
|
||||||
const queryDefaultLevel = () => {
|
const queryDefaultLevel = () => {
|
||||||
queryLevel().then((res) => {
|
queryLevel().then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
Store.set('default-level', res.result?.levels || []);
|
defaultLevel.value = res.result?.levels || [];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,13 +30,11 @@
|
||||||
<j-descriptions-item label="告警级别" :span="1">
|
<j-descriptions-item label="告警级别" :span="1">
|
||||||
<j-tooltip
|
<j-tooltip
|
||||||
placement="topLeft"
|
placement="topLeft"
|
||||||
:title="(Store.get('default-level') || []).find((item: any) => item?.level === data?.level)
|
:title="_level"
|
||||||
?.title || props.data?.level"
|
|
||||||
>
|
>
|
||||||
<Ellipsis>
|
<Ellipsis>
|
||||||
<span>
|
<span>
|
||||||
{{(Store.get('default-level') || []).find((item: any) => item?.level === data?.level)
|
{{_level}}
|
||||||
?.title || props.data?.level}}
|
|
||||||
</span>
|
</span>
|
||||||
</Ellipsis>
|
</Ellipsis>
|
||||||
</j-tooltip>
|
</j-tooltip>
|
||||||
|
@ -60,8 +58,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { queryLevel } from '@/api/rule-engine/config';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { Store } from 'jetlinks-store';
|
|
||||||
import JsonViewer from 'vue-json-viewer';
|
import JsonViewer from 'vue-json-viewer';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: Object,
|
data: Object,
|
||||||
|
@ -70,11 +68,24 @@ const props = defineProps({
|
||||||
const data = computed(()=>{
|
const data = computed(()=>{
|
||||||
return JSON.parse(props.data?.alarmInfo);
|
return JSON.parse(props.data?.alarmInfo);
|
||||||
})
|
})
|
||||||
|
const defaultLevel = ref<any[]>([])
|
||||||
|
|
||||||
const emit = defineEmits(['close']);
|
const emit = defineEmits(['close']);
|
||||||
const closeModal = () => {
|
const closeModal = () => {
|
||||||
emit('close');
|
emit('close');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const _level = computed(() => {
|
||||||
|
return (defaultLevel.value || []).find((item: any) => item?.level === props.data?.level)?.title || props.data?.level
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
queryLevel().then((res)=>{
|
||||||
|
if(res.status === 200 ){
|
||||||
|
defaultLevel.value = res.result?.levels || [];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
</style>
|
</style>
|
|
@ -138,7 +138,6 @@ import { queryLevel } from '@/api/rule-engine/config';
|
||||||
import Search from '@/components/Search';
|
import Search from '@/components/Search';
|
||||||
import { useAlarmStore } from '@/store/alarm';
|
import { useAlarmStore } from '@/store/alarm';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { Store } from 'jetlinks-store';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import type { ActionsType } from '@/components/Table';
|
import type { ActionsType } from '@/components/Table';
|
||||||
import SolveComponent from '../SolveComponent/index.vue';
|
import SolveComponent from '../SolveComponent/index.vue';
|
||||||
|
@ -149,10 +148,10 @@ const menuStory = useMenuStore();
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const alarmStore = useAlarmStore();
|
const alarmStore = useAlarmStore();
|
||||||
const { data } = storeToRefs(alarmStore);
|
const { data } = storeToRefs(alarmStore);
|
||||||
|
|
||||||
const getDefaulitLevel = () => {
|
const getDefaulitLevel = () => {
|
||||||
queryLevel().then((res) => {
|
queryLevel().then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
Store.set('default-level', res.result?.levels || []);
|
|
||||||
data.value.defaultLevel = res.result?.levels || [];
|
data.value.defaultLevel = res.result?.levels || [];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,7 +9,6 @@ import { isNoCommunity } from '@/utils/utils';
|
||||||
import { useAlarmStore } from '@/store/alarm';
|
import { useAlarmStore } from '@/store/alarm';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { queryLevel } from '@/api/rule-engine/config';
|
import { queryLevel } from '@/api/rule-engine/config';
|
||||||
import { Store } from 'jetlinks-store';
|
|
||||||
import TableComponents from './TabComponent/index.vue';
|
import TableComponents from './TabComponent/index.vue';
|
||||||
const list = [
|
const list = [
|
||||||
{
|
{
|
||||||
|
@ -56,7 +55,6 @@ const { data } = storeToRefs(alarmStore);
|
||||||
const getDefaulitLevel = () => {
|
const getDefaulitLevel = () => {
|
||||||
queryLevel().then((res)=>{
|
queryLevel().then((res)=>{
|
||||||
if(res.status === 200 ){
|
if(res.status === 200 ){
|
||||||
Store.set('default-level', res.result?.levels || []);
|
|
||||||
data.value.defaultLevel = res.result?.levels || [];
|
data.value.defaultLevel = res.result?.levels || [];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue