Commit cc7a319b13d8763c9ea25c92d7d3035cb366bc8b
1 parent
3df76cd1
fix(dynamic request): 修复动态表单设备选择器拥有别名时显示别名
Showing
1 changed file
with
12 additions
and
10 deletions
@@ -107,7 +107,9 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => { | @@ -107,7 +107,9 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => { | ||
107 | 107 | ||
108 | const getDeviceOption = async () => { | 108 | const getDeviceOption = async () => { |
109 | if (!validIsExist(BuiltInVariable.DEVICE_PROFILE_ID) || !validIsExist(BuiltInVariable.ORGANIZATION_ID) || !params[BuiltInVariable.ORGANIZATION_ID]) return | 109 | if (!validIsExist(BuiltInVariable.DEVICE_PROFILE_ID) || !validIsExist(BuiltInVariable.ORGANIZATION_ID) || !params[BuiltInVariable.ORGANIZATION_ID]) return |
110 | - optionsSet[BuiltInVariable.ENTITY_ID] = await getDeviceList({ [BuiltInVariable.ORGANIZATION_ID]: params[BuiltInVariable.ORGANIZATION_ID], [BuiltInVariable.DEVICE_PROFILE_ID]: params[BuiltInVariable.DEVICE_PROFILE_ID] }) | 110 | + const result: Recordable[] = await getDeviceList({ [BuiltInVariable.ORGANIZATION_ID]: params[BuiltInVariable.ORGANIZATION_ID], [BuiltInVariable.DEVICE_PROFILE_ID]: params[BuiltInVariable.DEVICE_PROFILE_ID] }) |
111 | + optionsSet[BuiltInVariable.ENTITY_ID] = result.map(item => ({ ...item, alias: item.alias || item.name })) | ||
112 | + console.log(optionsSet[BuiltInVariable.ENTITY_ID]) | ||
111 | } | 113 | } |
112 | 114 | ||
113 | const getDeviceAttrOption = async () => { | 115 | const getDeviceAttrOption = async () => { |
@@ -168,18 +170,18 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => { | @@ -168,18 +170,18 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => { | ||
168 | } | 170 | } |
169 | }) | 171 | }) |
170 | 172 | ||
171 | - /** | ||
172 | - * ft 更改设备别名 | ||
173 | - * 修改后的代码在注释之间,并标注好源代码和修改后代码,方便回溯 | ||
174 | - * 源代码 labelField: 'name' | ||
175 | - * 修改后代码 labelField: 'alias' || 'name' | ||
176 | - */ | 173 | + /** |
174 | + * ft 更改设备别名 | ||
175 | + * 修改后的代码在注释之间,并标注好源代码和修改后代码,方便回溯 | ||
176 | + * 源代码 labelField: 'name' | ||
177 | + * 修改后代码 labelField: 'alias' || 'name' | ||
178 | + */ | ||
177 | const getSelectDevice = computed<SelectProps>(() => { | 179 | const getSelectDevice = computed<SelectProps>(() => { |
178 | return { | 180 | return { |
179 | ...basicPreset('name'), | 181 | ...basicPreset('name'), |
180 | value: params[BuiltInVariable.ENTITY_ID], | 182 | value: params[BuiltInVariable.ENTITY_ID], |
181 | options: unref(optionsSet[BuiltInVariable.ENTITY_ID]), | 183 | options: unref(optionsSet[BuiltInVariable.ENTITY_ID]), |
182 | - labelField: 'alias' || 'name', | 184 | + labelField: 'alias', |
183 | valueField: 'tbDeviceId', | 185 | valueField: 'tbDeviceId', |
184 | onUpdateValue(value) { | 186 | onUpdateValue(value) { |
185 | params[BuiltInVariable.ENTITY_ID] = value | 187 | params[BuiltInVariable.ENTITY_ID] = value |
@@ -331,7 +333,7 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => { | @@ -331,7 +333,7 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => { | ||
331 | getDeviceOption() | 333 | getDeviceOption() |
332 | } | 334 | } |
333 | 335 | ||
334 | - const setParams = (Params: Recordable = {}) => { | 336 | + const setParams = (Params: Recordable = {}) => { |
335 | for (const { key, value } of unref(getParams)) { | 337 | for (const { key, value } of unref(getParams)) { |
336 | const splitKeys = value ? value.split(GROUP_SEPARATOR) : key.split(GROUP_SEPARATOR) | 338 | const splitKeys = value ? value.split(GROUP_SEPARATOR) : key.split(GROUP_SEPARATOR) |
337 | if (isDateComponent(key as BuiltInVariable)) { | 339 | if (isDateComponent(key as BuiltInVariable)) { |
@@ -356,7 +358,7 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => { | @@ -356,7 +358,7 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => { | ||
356 | } | 358 | } |
357 | 359 | ||
358 | const setDynamicFormValue = (params: Recordable) => { | 360 | const setDynamicFormValue = (params: Recordable) => { |
359 | - setParams(params) | 361 | + setParams(params) |
360 | getOrgOption() | 362 | getOrgOption() |
361 | getDeviceProfileOption() | 363 | getDeviceProfileOption() |
362 | getDeviceOption() | 364 | getDeviceOption() |