style: 网元接口/补充注释
This commit is contained in:
@@ -2,22 +2,26 @@ import { defineStore } from 'pinia';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { getNelistAll } from '@/api/configManage/neManage';
|
||||
import { parseDataToOptions } from '@/utils/parse-tree-utils';
|
||||
import { getNeTraceInterfaceAll } from '@/api/trace/task';
|
||||
|
||||
/**网元信息类型 */
|
||||
type NeInfo = {
|
||||
/**网元列表 */
|
||||
nelist: Record<string, any>[];
|
||||
neList: Record<string, any>[];
|
||||
/**级联options树结构 */
|
||||
neCascaderOtions: Record<string, any>[];
|
||||
/**选择器单级父类型 */
|
||||
neSelectOtions: Record<string, any>[];
|
||||
/**跟踪接口列表 */
|
||||
traceInterfaceList: Record<string, any>[];
|
||||
};
|
||||
|
||||
const useNeInfoStore = defineStore('neinfo', {
|
||||
state: (): NeInfo => ({
|
||||
nelist: [],
|
||||
neList: [],
|
||||
neCascaderOtions: [],
|
||||
neSelectOtions: [],
|
||||
traceInterfaceList: [],
|
||||
}),
|
||||
getters: {
|
||||
/**
|
||||
@@ -40,20 +44,20 @@ const useNeInfoStore = defineStore('neinfo', {
|
||||
actions: {
|
||||
// 刷新网元列表
|
||||
async fnRefreshNelist() {
|
||||
this.nelist = [];
|
||||
this.neList = [];
|
||||
const res = await this.fnNelist();
|
||||
return res;
|
||||
},
|
||||
// 获取网元列表
|
||||
async fnNelist() {
|
||||
// 有数据不请求
|
||||
if (this.nelist.length > 0) {
|
||||
return { code: 1, data: this.nelist, msg: 'success' };
|
||||
if (this.neList.length > 0) {
|
||||
return { code: 1, data: this.neList, msg: 'success' };
|
||||
}
|
||||
const res = await getNelistAll();
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||
// 原始列表
|
||||
this.nelist = res.data;
|
||||
this.neList = res.data;
|
||||
|
||||
// 转级联数据
|
||||
const options = parseDataToOptions(
|
||||
@@ -69,6 +73,24 @@ const useNeInfoStore = defineStore('neinfo', {
|
||||
}
|
||||
return res;
|
||||
},
|
||||
// 刷新跟踪接口列表
|
||||
async fnRefreshNeTraceInterface() {
|
||||
this.traceInterfaceList = [];
|
||||
const res = await this.fnNeTraceInterface();
|
||||
return res;
|
||||
},
|
||||
// 获取跟踪接口列表
|
||||
async fnNeTraceInterface() {
|
||||
// 有数据不请求
|
||||
if (this.traceInterfaceList.length > 0) {
|
||||
return { code: 1, data: this.traceInterfaceList, msg: 'success' };
|
||||
}
|
||||
const res = await getNeTraceInterfaceAll();
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||
this.traceInterfaceList = res.data;
|
||||
}
|
||||
return res;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user