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,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()
1 <template> 1 <template>
2 <section> 2 <section>
3 <preview v-if="!allowLoadPreviewPage" :key="key"></preview> 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 <NModal :show="showModal" :maskClosable="false" :closable="false" style="width: 300px;"> 5 <NModal :show="showModal" :maskClosable="false" :closable="false" style="width: 300px;">
5 <NCard> 6 <NCard>
6 <NForm @keyup.enter="handleSubmit"> 7 <NForm @keyup.enter="handleSubmit">
@@ -9,8 +10,8 @@ @@ -9,8 +10,8 @@
9 <NInput v-model:value="accessCredentials" show-password-on="mousedown" type="password" 10 <NInput v-model:value="accessCredentials" show-password-on="mousedown" type="password"
10 style="width: 70%;" /> 11 style="width: 70%;" />
11 <NButton :loading="loading" type="primary" style="width: 30%;" @click="handleSubmit"> 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 <path 15 <path
15 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 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 fill="#fff" p-id="79417" /> 17 fill="#fff" p-id="79417" />
@@ -30,7 +31,7 @@ @@ -30,7 +31,7 @@
30 </template> 31 </template>
31 32
32 <script setup lang="ts"> 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 import { getSessionStorageInfo } from '../preview/utils' 35 import { getSessionStorageInfo } from '../preview/utils'
35 import type { ChartEditStorageType } from '../preview/index.d' 36 import type { ChartEditStorageType } from '../preview/index.d'
36 import { SavePageEnum } from '@/enums/editPageEnum' 37 import { SavePageEnum } from '@/enums/editPageEnum'
@@ -76,6 +77,7 @@ const sharePageHandlerProcess = async () => { @@ -76,6 +77,7 @@ const sharePageHandlerProcess = async () => {
76 } 77 }
77 } 78 }
78 79
  80 +const isEmpty = ref(false)
79 const getSharePageContentData = async () => { 81 const getSharePageContentData = async () => {
80 try { 82 try {
81 const { params } = ROUTE 83 const { params } = ROUTE
@@ -83,7 +85,8 @@ const getSharePageContentData = async () => { @@ -83,7 +85,8 @@ const getSharePageContentData = async () => {
83 loading.value = true 85 loading.value = true
84 const res = await getShareContentData({ id, accessCredentials: unref(accessCredentials) }) 86 const res = await getShareContentData({ id, accessCredentials: unref(accessCredentials) })
85 const { dataViewContent, dataViewName, dataViewId } = res.data 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 if (content) { 90 if (content) {
88 const { editCanvasConfig, requestGlobalConfig, componentList } = content 91 const { editCanvasConfig, requestGlobalConfig, componentList } = content
89 chartEditStore.editCanvasConfig = editCanvasConfig 92 chartEditStore.editCanvasConfig = editCanvasConfig