Commit be2ec4aa7f4ac5e76c1233492ad5ea2b3fb170c5

Authored by xp.Huang
2 parents 3df76cd1 c909411a

Merge branch 'dev-fix-ww' into 'main_dev'

fix(dynamic request): 修复动态表单设备选择器拥有别名时显示别名

See merge request yunteng/thingskit-view!49
... ... @@ -107,7 +107,9 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => {
107 107
108 108 const getDeviceOption = async () => {
109 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 115 const getDeviceAttrOption = async () => {
... ... @@ -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 179 const getSelectDevice = computed<SelectProps>(() => {
178 180 return {
179 181 ...basicPreset('name'),
180 182 value: params[BuiltInVariable.ENTITY_ID],
181 183 options: unref(optionsSet[BuiltInVariable.ENTITY_ID]),
182   - labelField: 'alias' || 'name',
  184 + labelField: 'alias',
183 185 valueField: 'tbDeviceId',
184 186 onUpdateValue(value) {
185 187 params[BuiltInVariable.ENTITY_ID] = value
... ... @@ -331,7 +333,7 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => {
331 333 getDeviceOption()
332 334 }
333 335
334   - const setParams = (Params: Recordable = {}) => {
  336 + const setParams = (Params: Recordable = {}) => {
335 337 for (const { key, value } of unref(getParams)) {
336 338 const splitKeys = value ? value.split(GROUP_SEPARATOR) : key.split(GROUP_SEPARATOR)
337 339 if (isDateComponent(key as BuiltInVariable)) {
... ... @@ -356,7 +358,7 @@ export const useDynamicPublicForm = (paramsItemList: Ref<ParamsItemType[]>) => {
356 358 }
357 359
358 360 const setDynamicFormValue = (params: Recordable) => {
359   - setParams(params)
  361 + setParams(params)
360 362 getOrgOption()
361 363 getDeviceProfileOption()
362 364 getDeviceOption()
... ...
1 1 <template>
2 2 <section>
3 3 <preview v-if="!allowLoadPreviewPage" :key="key"></preview>
  4 + <NEmpty v-if="isEmpty" style="position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);" />
4 5 <NModal :show="showModal" :maskClosable="false" :closable="false" style="width: 300px;">
5 6 <NCard>
6 7 <NForm @keyup.enter="handleSubmit">
... ... @@ -9,8 +10,8 @@
9 10 <NInput v-model:value="accessCredentials" show-password-on="mousedown" type="password"
10 11 style="width: 70%;" />
11 12 <NButton :loading="loading" type="primary" style="width: 30%;" @click="handleSubmit">
12   - <svg t="1682068997810" class="icon" viewBox="0 0 1024 1024" version="1.1"
13   - xmlns="http://www.w3.org/2000/svg" p-id="79416" width="24" height="24">
  13 + <svg style="transform: rotate(180deg);" t="1682068997810" class="icon" viewBox="0 0 1024 1024"
  14 + version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="79416" width="24" height="24">
14 15 <path
15 16 d="M512 928H128c-19.2 0-32-12.8-32-32V128c0-19.2 12.8-32 32-32h384c19.2 0 32 12.8 32 32s-12.8 32-32 32H160v704h352c19.2 0 32 12.8 32 32s-12.8 32-32 32z"
16 17 fill="#fff" p-id="79417" />
... ... @@ -30,7 +31,7 @@
30 31 </template>
31 32
32 33 <script setup lang="ts">
33   -import { NModal, NCard, NForm, NFormItem, NInput, NButton, NInputGroup } from 'naive-ui'
  34 +import { NEmpty, NCard, NForm, NFormItem, NInput, NButton, NInputGroup } from 'naive-ui'
34 35 import { getSessionStorageInfo } from '../preview/utils'
35 36 import type { ChartEditStorageType } from '../preview/index.d'
36 37 import { SavePageEnum } from '@/enums/editPageEnum'
... ... @@ -76,6 +77,7 @@ const sharePageHandlerProcess = async () => {
76 77 }
77 78 }
78 79
  80 +const isEmpty = ref(false)
79 81 const getSharePageContentData = async () => {
80 82 try {
81 83 const { params } = ROUTE
... ... @@ -83,7 +85,8 @@ const getSharePageContentData = async () => {
83 85 loading.value = true
84 86 const res = await getShareContentData({ id, accessCredentials: unref(accessCredentials) })
85 87 const { dataViewContent, dataViewName, dataViewId } = res.data
86   - const content = JSONParse(dataViewContent.content) as ChartEditStorageType
  88 + if (!dataViewContent.content) isEmpty.value = true
  89 + const content = JSONParse(dataViewContent.content || '{}') as ChartEditStorageType
87 90 if (content) {
88 91 const { editCanvasConfig, requestGlobalConfig, componentList } = content
89 92 chartEditStore.editCanvasConfig = editCanvasConfig
... ...