fix 网元输入框自动完成下拉选择

This commit is contained in:
TsMask
2023-09-18 21:06:13 +08:00
parent 429f30c322
commit 307ab8bcf6
3 changed files with 28 additions and 10 deletions

View File

@@ -8,13 +8,16 @@ type NeInfo = {
/**网元列表 */
nelist: Record<string, any>[];
/**级联options树结构 */
neOtions: Record<string, any>[];
neCascaderOtions: Record<string, any>[];
/**选择器单级父类型 */
neSelectOtions: Record<string, any>[];
};
const useNeInfoStore = defineStore('neinfo', {
state: (): NeInfo => ({
nelist: [],
neOtions: [],
neCascaderOtions: [],
neSelectOtions: [],
}),
getters: {
/**
@@ -22,8 +25,16 @@ const useNeInfoStore = defineStore('neinfo', {
* @param state 内部属性不用传入
* @returns 级联options
*/
getNeOtions(state) {
return state.neOtions;
getNeCascaderOtions(state) {
return state.neCascaderOtions;
},
/**
* 选择器单级父类型
* @param state 内部属性不用传入
* @returns 级联options
*/
getNeSelectOtions(state) {
return state.neSelectOtions;
},
},
actions: {
@@ -41,6 +52,9 @@ const useNeInfoStore = defineStore('neinfo', {
}
const res = await getNelistAll();
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
// 原始列表
this.nelist = res.data;
// 转级联数据
const options = parseDataToOptions(
res.data,
@@ -48,8 +62,10 @@ const useNeInfoStore = defineStore('neinfo', {
'neName',
'neId'
);
this.neCascaderOtions = options;
this.neOtions = options;
// 转选择器单级父类型
this.neSelectOtions = options.map(item => item);
}
return res;
},