fix: 缓存网元类型获取级联数据判断

This commit is contained in:
TsMask
2023-12-08 18:20:21 +08:00
parent fafe604323
commit e6a4591fb6
11 changed files with 144 additions and 108 deletions

View File

@@ -10,7 +10,7 @@ type NeInfo = {
/**网元列表 */ /**网元列表 */
neList: Record<string, any>[]; neList: Record<string, any>[];
/**级联options树结构 */ /**级联options树结构 */
neCascaderOtions: Record<string, any>[]; neCascaderOptions: Record<string, any>[];
/**选择器单级父类型 */ /**选择器单级父类型 */
neSelectOtions: Record<string, any>[]; neSelectOtions: Record<string, any>[];
/**跟踪接口列表 */ /**跟踪接口列表 */
@@ -22,7 +22,7 @@ type NeInfo = {
const useNeInfoStore = defineStore('neinfo', { const useNeInfoStore = defineStore('neinfo', {
state: (): NeInfo => ({ state: (): NeInfo => ({
neList: [], neList: [],
neCascaderOtions: [], neCascaderOptions: [],
neSelectOtions: [], neSelectOtions: [],
traceInterfaceList: [], traceInterfaceList: [],
perMeasurementList: [], perMeasurementList: [],
@@ -33,8 +33,8 @@ const useNeInfoStore = defineStore('neinfo', {
* @param state 内部属性不用传入 * @param state 内部属性不用传入
* @returns 级联options * @returns 级联options
*/ */
getNeCascaderOtions(state) { getNeCascaderOptions(state) {
return state.neCascaderOtions; return state.neCascaderOptions;
}, },
/** /**
* 选择器单级父类型 * 选择器单级父类型
@@ -70,7 +70,7 @@ const useNeInfoStore = defineStore('neinfo', {
'neName', 'neName',
'neId' 'neId'
); );
this.neCascaderOtions = options; this.neCascaderOptions = options;
// 转选择器单级父类型 // 转选择器单级父类型
this.neSelectOtions = options.map(item => item); this.neSelectOtions = options.map(item => item);

View File

@@ -20,7 +20,7 @@ import { regExpIPv4, regExpIPv6 } from '@/utils/regular-utils';
const { t } = useI18n(); const { t } = useI18n();
/**网元参数 */ /**网元参数 */
let neCascaderOtions = ref<Record<string, any>[]>([]); let neCascaderOptions = ref<Record<string, any>[]>([]);
/**网元类型选择 type,id */ /**网元类型选择 type,id */
let neTypeSelect = ref<string[]>(['', '']); let neTypeSelect = ref<string[]>(['', '']);
@@ -1068,18 +1068,25 @@ onMounted(() => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
if (res.data.length > 0) { if (res.data.length > 0) {
// 过滤不可用的网元 // 过滤不可用的网元
neCascaderOtions.value = useNeInfoStore().getNeCascaderOtions.filter( neCascaderOptions.value = useNeInfoStore().getNeCascaderOptions.filter(
(item: any) => { (item: any) => {
return !['OMC'].includes(item.value); return !['OMC'].includes(item.value);
} }
); );
if (neCascaderOptions.value.length === 0) {
message.warning({
content: t('common.noData'),
duration: 2,
});
return;
}
// 默认选择AMF // 默认选择AMF
const item = neCascaderOtions.value.find(s => s.value === 'AMF'); const item = neCascaderOptions.value.find(s => s.value === 'AMF');
if (item && item.children) { if (item && item.children) {
const info = item.children[0]; const info = item.children[0];
neTypeSelect.value = [info.neType, info.neId]; neTypeSelect.value = [info.neType, info.neId];
} else { } else {
const info = neCascaderOtions.value[0].children[0]; const info = neCascaderOptions.value[0]?.children[0];
neTypeSelect.value = [info.neType, info.neId]; neTypeSelect.value = [info.neType, info.neId];
} }
fnGetParamConfigTopTab(); fnGetParamConfigTopTab();
@@ -1110,7 +1117,7 @@ onMounted(() => {
> >
<a-cascader <a-cascader
v-model:value="neTypeSelect" v-model:value="neTypeSelect"
:options="neCascaderOtions" :options="neCascaderOptions"
:allow-clear="false" :allow-clear="false"
@change="fnGetParamConfigTopTab" @change="fnGetParamConfigTopTab"
/> />

View File

@@ -989,7 +989,7 @@ onMounted(() => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
if (res.data.length > 0) { if (res.data.length > 0) {
// 过滤不可用的网元 // 过滤不可用的网元
neCascaderOtions.value = useNeInfoStore().getNeCascaderOtions.filter( neCascaderOtions.value = useNeInfoStore().getNeCascaderOptions.filter(
(item: any) => { (item: any) => {
return !['OMC'].includes(item.value); return !['OMC'].includes(item.value);
} }

View File

@@ -16,10 +16,11 @@ import { toRaw } from 'vue';
import { regExpIPv4, regExpIPv6 } from '@/utils/regular-utils'; import { regExpIPv4, regExpIPv6 } from '@/utils/regular-utils';
import { SizeType } from 'ant-design-vue/lib/config-provider'; import { SizeType } from 'ant-design-vue/lib/config-provider';
import { DataNode } from 'ant-design-vue/lib/tree'; import { DataNode } from 'ant-design-vue/lib/tree';
const neInfoStore = useNeInfoStore();
const { t } = useI18n(); const { t } = useI18n();
/**网元参数 */ /**网元参数 */
let neCascaderOtions = ref<Record<string, any>[]>([]); let neCascaderOptions = ref<Record<string, any>[]>([]);
/**网元类型选择 type,id */ /**网元类型选择 type,id */
let neTypeSelect = ref<string[]>(['', '']); let neTypeSelect = ref<string[]>(['', '']);
@@ -1011,24 +1012,29 @@ function fnModalCancel() {
onMounted(() => { onMounted(() => {
// 获取网元网元列表 // 获取网元网元列表
useNeInfoStore() neInfoStore.fnNelist().then(res => {
.fnNelist()
.then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
if (res.data.length > 0) { if (res.data.length > 0) {
// 过滤不可用的网元 // 过滤不可用的网元
neCascaderOtions.value = useNeInfoStore().getNeCascaderOtions.filter( neCascaderOptions.value = neInfoStore.getNeCascaderOptions.filter(
(item: any) => { (item: any) => {
return !['OMC'].includes(item.value); return !['OMC'].includes(item.value);
} }
); );
if (neCascaderOptions.value.length === 0) {
message.warning({
content: t('common.noData'),
duration: 2,
});
return;
}
// 默认选择AMF // 默认选择AMF
const item = neCascaderOtions.value.find(s => s.value === 'AMF'); const item = neCascaderOptions.value.find(s => s.value === 'AMF');
if (item && item.children) { if (item && item.children) {
const info = item.children[0]; const info = item.children[0];
neTypeSelect.value = [info.neType, info.neId]; neTypeSelect.value = [info.neType, info.neId];
} else { } else {
const info = neCascaderOtions.value[0].children[0]; const info = neCascaderOptions.value[0].children[0];
neTypeSelect.value = [info.neType, info.neId]; neTypeSelect.value = [info.neType, info.neId];
} }
fnGetParamConfigTopTab(); fnGetParamConfigTopTab();
@@ -1058,7 +1064,7 @@ onMounted(() => {
<a-form-item name="neId "> <a-form-item name="neId ">
<a-cascader <a-cascader
v-model:value="neTypeSelect" v-model:value="neTypeSelect"
:options="neCascaderOtions" :options="neCascaderOptions"
:allow-clear="false" :allow-clear="false"
@change="fnGetParamConfigTopTab" @change="fnGetParamConfigTopTab"
/> />

View File

@@ -16,10 +16,11 @@ import useNeInfoStore from '@/store/modules/neinfo';
import { regExpIPv4, regExpIPv6 } from '@/utils/regular-utils'; import { regExpIPv4, regExpIPv6 } from '@/utils/regular-utils';
import { SizeType } from 'ant-design-vue/lib/config-provider'; import { SizeType } from 'ant-design-vue/lib/config-provider';
import { DataNode } from 'ant-design-vue/lib/tree'; import { DataNode } from 'ant-design-vue/lib/tree';
const neInfoStore = useNeInfoStore();
const { t } = useI18n(); const { t } = useI18n();
/**网元参数 */ /**网元参数 */
let neCascaderOtions = ref<Record<string, any>[]>([]); let neCascaderOptions = ref<Record<string, any>[]>([]);
/**网元类型选择 type,id */ /**网元类型选择 type,id */
let neTypeSelect = ref<string[]>(['', '']); let neTypeSelect = ref<string[]>(['', '']);
@@ -1052,24 +1053,31 @@ function fnModalCancel() {
onMounted(() => { onMounted(() => {
// 获取网元网元列表 // 获取网元网元列表
useNeInfoStore() neInfoStore
.fnNelist() .fnNelist()
.then(res => { .then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
if (res.data.length > 0) { if (res.data.length > 0) {
// 过滤不可用的网元 // 过滤不可用的网元
neCascaderOtions.value = useNeInfoStore().getNeCascaderOtions.filter( neCascaderOptions.value = neInfoStore.getNeCascaderOptions.filter(
(item: any) => { (item: any) => {
return !['OMC'].includes(item.value); return !['OMC'].includes(item.value);
} }
); );
if (neCascaderOptions.value.length === 0) {
message.warning({
content: t('common.noData'),
duration: 2,
});
return;
}
// 默认选择AMF // 默认选择AMF
const item = neCascaderOtions.value.find(s => s.value === 'UPF'); const item = neCascaderOptions.value.find(s => s.value === 'UPF');
if (item && item.children) { if (item && item.children) {
const info = item.children[0]; const info = item.children[0];
neTypeSelect.value = [info.neType, info.neId]; neTypeSelect.value = [info.neType, info.neId];
} else { } else {
const info = neCascaderOtions.value[0].children[0]; const info = neCascaderOptions.value[0].children[0];
neTypeSelect.value = [info.neType, info.neId]; neTypeSelect.value = [info.neType, info.neId];
} }
fnGetParamConfigTopTab(); fnGetParamConfigTopTab();
@@ -1099,7 +1107,7 @@ onMounted(() => {
<a-form-item name="neId "> <a-form-item name="neId ">
<a-cascader <a-cascader
v-model:value="neTypeSelect" v-model:value="neTypeSelect"
:options="neCascaderOtions" :options="neCascaderOptions"
:allow-clear="false" :allow-clear="false"
@change="fnGetParamConfigTopTab" @change="fnGetParamConfigTopTab"
/> />

View File

@@ -11,6 +11,7 @@ import useI18n from '@/hooks/useI18n';
import useNeInfoStore from '@/store/modules/neinfo'; import useNeInfoStore from '@/store/modules/neinfo';
import { FileType } from 'ant-design-vue/lib/upload/interface'; import { FileType } from 'ant-design-vue/lib/upload/interface';
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface'; import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
const neInfoStore = useNeInfoStore();
const { t } = useI18n(); const { t } = useI18n();
/**查询参数 */ /**查询参数 */
@@ -267,7 +268,10 @@ function fnBeforeUploadFile(file: FileType) {
const fileName = file.name; const fileName = file.name;
const suff = fileName.substring(fileName.lastIndexOf('.')); const suff = fileName.substring(fileName.lastIndexOf('.'));
if (!['.ini'].includes(suff)) { if (!['.ini'].includes(suff)) {
message.error(t('views.configManage.softwareManage.onlyAble',{fileText:'(.ini)'}), 3); message.error(
t('views.configManage.softwareManage.onlyAble', { fileText: '(.ini)' }),
3
);
return false; return false;
} }
@@ -287,9 +291,7 @@ function fnUploadFile(up: UploadRequestOption) {
onMounted(() => { onMounted(() => {
// 获取网元网元列表 // 获取网元网元列表
useNeInfoStore() neInfoStore.fnNelist().then(res => {
.fnNelist()
.then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
// 获取列表数据 // 获取列表数据
fnGetList(); fnGetList();
@@ -320,7 +322,7 @@ onMounted(() => {
> >
<a-auto-complete <a-auto-complete
v-model:value="queryParams.neType" v-model:value="queryParams.neType"
:options="useNeInfoStore().getNeSelectOtions" :options="neInfoStore.getNeSelectOtions"
allow-clear allow-clear
:placeholder="t('views.configManage.license.neTypePlease')" :placeholder="t('views.configManage.license.neTypePlease')"
/> />
@@ -425,10 +427,7 @@ onMounted(() => {
@ok="fnModalOk" @ok="fnModalOk"
@cancel="fnModalCancel" @cancel="fnModalCancel"
> >
<a-form <a-form name="modalStateFrom" layout="horizontal">
name="modalStateFrom"
layout="horizontal"
>
<a-form-item <a-form-item
:label="t('views.configManage.license.neType')" :label="t('views.configManage.license.neType')"
name="neType" name="neType"
@@ -436,7 +435,7 @@ onMounted(() => {
> >
<a-cascader <a-cascader
v-model:value="modalState.from.neType" v-model:value="modalState.from.neType"
:options="useNeInfoStore().getNeCascaderOtions" :options="useNeInfoStore().getNeCascaderOptions"
:allow-clear="false" :allow-clear="false"
:placeholder="t('views.configManage.license.neTypePlease')" :placeholder="t('views.configManage.license.neTypePlease')"
/> />

View File

@@ -10,6 +10,7 @@ import useI18n from '@/hooks/useI18n';
import { getMMLByNE, sendMMlByNE } from '@/api/mmlManage/neOperate'; import { getMMLByNE, sendMMlByNE } from '@/api/mmlManage/neOperate';
import { uploadFileToNE } from '@/api/tool/file'; import { uploadFileToNE } from '@/api/tool/file';
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface'; import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
const neInfoStore = useNeInfoStore();
const { t } = useI18n(); const { t } = useI18n();
/**网元参数 */ /**网元参数 */
@@ -455,17 +456,22 @@ function fnAutoCompleteChange(value: any, _: any) {
onMounted(() => { onMounted(() => {
// 获取网元网元列表 // 获取网元网元列表
useNeInfoStore() neInfoStore.fnNelist().then(res => {
.fnNelist()
.then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
if (res.data.length > 0) { if (res.data.length > 0) {
// 过滤不可用的网元 // 过滤不可用的网元
neCascaderOptions.value = useNeInfoStore().getNeCascaderOtions.filter( neCascaderOptions.value = neInfoStore.getNeCascaderOptions.filter(
(item: any) => { (item: any) => {
return !['OMC'].includes(item.value); return !['OMC'].includes(item.value);
} }
); );
if (neCascaderOptions.value.length === 0) {
message.warning({
content: t('common.noData'),
duration: 2,
});
return;
}
// 默认选择AMF // 默认选择AMF
const item = neCascaderOptions.value.find(s => s.value === 'AMF'); const item = neCascaderOptions.value.find(s => s.value === 'AMF');
if (item && item.children) { if (item && item.children) {

View File

@@ -12,7 +12,7 @@ import useNeInfoStore from '@/store/modules/neinfo';
import useI18n from '@/hooks/useI18n'; import useI18n from '@/hooks/useI18n';
import { getGoldTitleByNE, goldData } from '@/api/perfManage/goldTarget'; import { getGoldTitleByNE, goldData } from '@/api/perfManage/goldTarget';
import { parseDateToStr } from '@/utils/date-utils'; import { parseDateToStr } from '@/utils/date-utils';
const neInfoStore = useNeInfoStore();
const { t, currentLocale } = useI18n(); const { t, currentLocale } = useI18n();
/**网元参数 */ /**网元参数 */
@@ -284,17 +284,24 @@ function fnDesign() {
onMounted(() => { onMounted(() => {
// 获取网元网元列表 // 获取网元网元列表
useNeInfoStore() neInfoStore
.fnNelist() .fnNelist()
.then(res => { .then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
if (res.data.length > 0) { if (res.data.length > 0) {
// 过滤不可用的网元 // 过滤不可用的网元
neCascaderOptions.value = useNeInfoStore().getNeCascaderOtions.filter( neCascaderOptions.value = neInfoStore.getNeCascaderOptions.filter(
(item: any) => { (item: any) => {
return !['OMC'].includes(item.value); return !['OMC'].includes(item.value);
} }
); );
if (neCascaderOptions.value.length === 0) {
message.warning({
content: t('common.noData'),
duration: 2,
});
return;
}
// 默认选择AMF // 默认选择AMF
const item = neCascaderOptions.value.find(s => s.value === 'UPF'); const item = neCascaderOptions.value.find(s => s.value === 'UPF');
if (item && item.children) { if (item && item.children) {

View File

@@ -19,6 +19,7 @@ import {
taskStop, taskStop,
taskRun, taskRun,
} from '@/api/perfManage/taskManage'; } from '@/api/perfManage/taskManage';
const neInfoStore = useNeInfoStore();
const { t, currentLocale } = useI18n(); const { t, currentLocale } = useI18n();
const generateOptions = (start: any, end: any) => { const generateOptions = (start: any, end: any) => {
@@ -378,7 +379,7 @@ function fnSelectPer(s: any, option: any) {
/**性能测量数据集选择初始 */ /**性能测量数据集选择初始 */
function fnSelectPerformanceInit(neType: string) { function fnSelectPerformanceInit(neType: string) {
//console.logg(currentLocale.value); //当前语言 //console.logg(currentLocale.value); //当前语言
const performance = useNeInfoStore().perMeasurementList.filter( const performance = neInfoStore.perMeasurementList.filter(
i => i.neType === neType i => i.neType === neType
); );
//进行分组选择 //进行分组选择
@@ -692,9 +693,9 @@ onMounted(() => {
Promise.allSettled([ Promise.allSettled([
// 获取网元网元列表 // 获取网元网元列表
useNeInfoStore().fnNelist(), neInfoStore.fnNelist(),
// 获取性能测量集列表 // 获取性能测量集列表
useNeInfoStore().fnNeTaskPerformance(), neInfoStore.fnNeTaskPerformance(),
]).finally(() => { ]).finally(() => {
// 获取列表数据 // 获取列表数据
fnGetList(); fnGetList();
@@ -719,7 +720,7 @@ onMounted(() => {
> >
<a-auto-complete <a-auto-complete
v-model:value="queryParams.neType" v-model:value="queryParams.neType"
:options="useNeInfoStore().getNeSelectOtions" :options="neInfoStore.getNeSelectOtions"
allow-clear allow-clear
:placeholder="t('views.traceManage.task.neTypePlease')" :placeholder="t('views.traceManage.task.neTypePlease')"
/> />
@@ -887,7 +888,7 @@ onMounted(() => {
> >
<a-cascader <a-cascader
:value="modalState.neType" :value="modalState.neType"
:options="useNeInfoStore().getNeCascaderOtions" :options="neInfoStore.getNeCascaderOptions"
disabled disabled
/> />
</a-form-item> </a-form-item>
@@ -1002,7 +1003,7 @@ onMounted(() => {
> >
<a-cascader <a-cascader
v-model:value="modalState.neType" v-model:value="modalState.neType"
:options="useNeInfoStore().getNeCascaderOtions" :options="neInfoStore.getNeCascaderOptions"
@change="fnNeChange" @change="fnNeChange"
:allow-clear="false" :allow-clear="false"
:placeholder="t('views.traceManage.task.neTypePlease')" :placeholder="t('views.traceManage.task.neTypePlease')"

View File

@@ -15,6 +15,7 @@ import {
tcpdumpPcapDownload, tcpdumpPcapDownload,
} from '@/api/traceManage/pcap'; } from '@/api/traceManage/pcap';
import { ref } from 'vue'; import { ref } from 'vue';
const neInfoStore = useNeInfoStore();
const { t } = useI18n(); const { t } = useI18n();
/**对话框对象信息状态类型 */ /**对话框对象信息状态类型 */
@@ -338,7 +339,7 @@ onUnmounted(() => {
> >
<a-cascader <a-cascader
v-model:value="modalState.neType" v-model:value="modalState.neType"
:options="useNeInfoStore().getNeCascaderOtions" :options="neInfoStore.getNeCascaderOptions"
@change="fnNeChange" @change="fnNeChange"
:allow-clear="false" :allow-clear="false"
:placeholder="t('views.traceManage.pcap.neTypePlease')" :placeholder="t('views.traceManage.pcap.neTypePlease')"

View File

@@ -19,6 +19,7 @@ import {
} from '@/api/traceManage/task'; } from '@/api/traceManage/task';
import useDictStore from '@/store/modules/dict'; import useDictStore from '@/store/modules/dict';
import { regExpIPv4, regExpPort } from '@/utils/regular-utils'; import { regExpIPv4, regExpPort } from '@/utils/regular-utils';
const neInfoStore = useNeInfoStore();
const { getDict } = useDictStore(); const { getDict } = useDictStore();
const { t } = useI18n(); const { t } = useI18n();
@@ -382,7 +383,7 @@ function fnSelectInterface(s: any, _: any) {
/**信令接口选择初始 */ /**信令接口选择初始 */
function fnSelectInterfaceInit(neType: string) { function fnSelectInterfaceInit(neType: string) {
const interfaces = useNeInfoStore().traceInterfaceList; const interfaces = neInfoStore.traceInterfaceList;
modalState.neTypeInterface = interfaces modalState.neTypeInterface = interfaces
.filter(i => i.neType === neType) .filter(i => i.neType === neType)
.map(i => { .map(i => {
@@ -535,9 +536,9 @@ onMounted(() => {
}); });
Promise.allSettled([ Promise.allSettled([
// 获取网元网元列表 // 获取网元网元列表
useNeInfoStore().fnNelist(), neInfoStore.fnNelist(),
// 获取跟踪接口列表 // 获取跟踪接口列表
useNeInfoStore().fnNeTraceInterface(), neInfoStore.fnNeTraceInterface(),
]).finally(() => { ]).finally(() => {
// 获取列表数据 // 获取列表数据
fnGetList(); fnGetList();
@@ -562,7 +563,7 @@ onMounted(() => {
> >
<a-auto-complete <a-auto-complete
v-model:value="queryParams.neType" v-model:value="queryParams.neType"
:options="useNeInfoStore().getNeSelectOtions" :options="neInfoStore.getNeSelectOtions"
allow-clear allow-clear
:placeholder="t('views.traceManage.task.neTypePlease')" :placeholder="t('views.traceManage.task.neTypePlease')"
/> />
@@ -748,7 +749,7 @@ onMounted(() => {
> >
<a-cascader <a-cascader
:value="modalState.neType" :value="modalState.neType"
:options="useNeInfoStore().getNeCascaderOtions" :options="neInfoStore.getNeCascaderOptions"
disabled disabled
/> />
</a-form-item> </a-form-item>
@@ -866,7 +867,7 @@ onMounted(() => {
> >
<a-cascader <a-cascader
v-model:value="modalState.neType" v-model:value="modalState.neType"
:options="useNeInfoStore().getNeCascaderOtions" :options="neInfoStore.getNeCascaderOptions"
@change="fnNeChange" @change="fnNeChange"
:allow-clear="false" :allow-clear="false"
:placeholder="t('views.traceManage.task.neTypePlease')" :placeholder="t('views.traceManage.task.neTypePlease')"