Commit 7c9f4ba0bdaecedf4dbc1e191e2ffb20da16568e
1 parent
b950966b
fix: exclude id in functionJSON on model of matter page
Showing
5 changed files
with
50 additions
and
21 deletions
| 1 | +import { cloneDeep } from 'lodash-es'; | |
| 1 | 2 | import { DateTypeEnum } from './config'; |
| 2 | 3 | import { StructFormValue } from './type'; |
| 3 | 4 | import { DataType, ModelOfMatterParams, StructJSON } from '/@/api/device/model/modelOfMatterModel'; |
| 5 | +import { isArray } from '/@/utils/is'; | |
| 4 | 6 | |
| 5 | 7 | export function transfromToStructJSON(value: StructFormValue): StructJSON { |
| 6 | 8 | const { |
| ... | ... | @@ -16,9 +18,9 @@ export function transfromToStructJSON(value: StructFormValue): StructJSON { |
| 16 | 18 | identifier, |
| 17 | 19 | remark, |
| 18 | 20 | specs, |
| 19 | - assessMode, | |
| 21 | + accessMode, | |
| 20 | 22 | } = value; |
| 21 | - const basic = { functionName, identifier, remark, assessMode }; | |
| 23 | + const basic = { functionName, identifier, remark, accessMode }; | |
| 22 | 24 | let dataType = {} as unknown as DataType; |
| 23 | 25 | |
| 24 | 26 | switch (type) { |
| ... | ... | @@ -62,3 +64,27 @@ export function transfromToStructJSON(value: StructFormValue): StructJSON { |
| 62 | 64 | } |
| 63 | 65 | return { ...basic, dataType }; |
| 64 | 66 | } |
| 67 | + | |
| 68 | +export const excludeIdInStructJSON = (struct: DataType) => { | |
| 69 | + const _value = cloneDeep(struct); | |
| 70 | + const { specs } = _value; | |
| 71 | + const list = [specs]; | |
| 72 | + | |
| 73 | + while (list.length) { | |
| 74 | + for (const item of list) { | |
| 75 | + if (isArray(item)) { | |
| 76 | + (item as StructJSON[]).forEach((temp) => { | |
| 77 | + if (temp.dataType?.specs) { | |
| 78 | + list.push(temp.dataType.specs); | |
| 79 | + } | |
| 80 | + Reflect.deleteProperty(temp, 'id'); | |
| 81 | + }); | |
| 82 | + } else { | |
| 83 | + Reflect.deleteProperty(item as Recordable, 'id'); | |
| 84 | + } | |
| 85 | + list.shift(); | |
| 86 | + } | |
| 87 | + } | |
| 88 | + | |
| 89 | + return _value; | |
| 90 | +}; | ... | ... |
| 1 | 1 | <template> |
| 2 | 2 | <BasicDrawer v-bind="$attrs" title="产品详情" @register="register" width="60%" destroy-on-close> |
| 3 | - <Tabs :animated="true" v-model:activeKey="activeKey" @change="handlePanelChange"> | |
| 4 | - <TabPane key="product" tab="产品"> | |
| 3 | + <Tabs v-model:activeKey="activeKey" @change="handlePanelChange"> | |
| 4 | + <Tabs.TabPane key="product" tab="产品"> | |
| 5 | 5 | <div class="relative"> |
| 6 | 6 | <DeviceConfigurationStep :ifShowBtn="false" ref="DevConStRef" /> |
| 7 | 7 | <div class="absolute w-full h-full top-0 cursor-not-allowed"></div> |
| 8 | 8 | </div> |
| 9 | - </TabPane> | |
| 10 | - <TabPane key="transport" tab="传输配置"> | |
| 9 | + </Tabs.TabPane> | |
| 10 | + <Tabs.TabPane key="transport" tab="传输配置"> | |
| 11 | 11 | <div class="relative"> |
| 12 | 12 | <TransportConfigurationStep :ifShowBtn="false" ref="TransConStRef" /> |
| 13 | 13 | <div class="absolute w-full h-full top-0 cursor-not-allowed"></div> |
| 14 | 14 | </div> |
| 15 | - </TabPane> | |
| 16 | - <TabPane key="modelOfMatter" tab="物模型管理"> | |
| 15 | + </Tabs.TabPane> | |
| 16 | + <Tabs.TabPane key="modelOfMatter" tab="物模型管理"> | |
| 17 | 17 | <PhysicalModelManagementStep :record="record" /> |
| 18 | - </TabPane> | |
| 18 | + </Tabs.TabPane> | |
| 19 | 19 | </Tabs> |
| 20 | 20 | </BasicDrawer> |
| 21 | 21 | </template> |
| 22 | 22 | <script lang="ts" setup> |
| 23 | 23 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
| 24 | - import { Tabs, TabPane } from 'ant-design-vue'; | |
| 24 | + import { Tabs } from 'ant-design-vue'; | |
| 25 | 25 | import DeviceConfigurationStep from './step/DeviceConfigurationStep.vue'; |
| 26 | 26 | import TransportConfigurationStep from './step/TransportConfigurationStep.vue'; |
| 27 | 27 | import PhysicalModelManagementStep from './step/PhysicalModelManagementStep.vue'; | ... | ... |
| ... | ... | @@ -35,23 +35,23 @@ |
| 35 | 35 | :disabled="$props.record.transportType === 'TCP'" |
| 36 | 36 | /> |
| 37 | 37 | </Tabs> |
| 38 | - <Attribute v-show="activeKey === FunctionType.PROPERTIES" ref="AttrRef" /> | |
| 38 | + <Attribute v-if="activeKey === FunctionType.PROPERTIES" ref="AttrRef" /> | |
| 39 | 39 | <Service |
| 40 | - v-show="activeKey === FunctionType.SERVICE" | |
| 40 | + v-if="activeKey === FunctionType.SERVICE" | |
| 41 | 41 | :record="$props.record" |
| 42 | 42 | ref="ServiceRef" |
| 43 | 43 | /> |
| 44 | - <Events v-show="activeKey === FunctionType.EVENTS" ref="EventsRef" /> | |
| 44 | + <Events v-if="activeKey === FunctionType.EVENTS" ref="EventsRef" /> | |
| 45 | 45 | <div |
| 46 | 46 | v-if="openModalMode === OpenModelMode.VIEW" |
| 47 | - class="absolute w-full h-full top-0 cursor-not-allowed" | |
| 47 | + class="absolute w-full h-full top-0 cursor-not-allowed z-50" | |
| 48 | 48 | ></div> |
| 49 | 49 | </div> |
| 50 | 50 | </BasicModal> |
| 51 | 51 | </div> |
| 52 | 52 | </template> |
| 53 | 53 | <script lang="ts" setup> |
| 54 | - import { ref, unref } from 'vue'; | |
| 54 | + import { ref, unref, nextTick } from 'vue'; | |
| 55 | 55 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
| 56 | 56 | import { Tabs, TabPane, Typography, TypographyParagraph } from 'ant-design-vue'; |
| 57 | 57 | import Attribute from './cpns/Attribute.vue'; |
| ... | ... | @@ -109,16 +109,13 @@ |
| 109 | 109 | if (record) { |
| 110 | 110 | functionType.value = data.record.functionType; |
| 111 | 111 | activeKey.value = data.record.functionType; |
| 112 | + await nextTick(); | |
| 112 | 113 | setFormData(record.functionType, record as unknown as ModelOfMatterParams); |
| 113 | 114 | } |
| 114 | 115 | if (unref(openModalMode) === OpenModelMode.VIEW) { |
| 115 | 116 | setModalProps({ showOkBtn: false, showCancelBtn: false, title: '查看物模型' }); |
| 116 | - // setFormData(functionType.value, record); | |
| 117 | 117 | } else { |
| 118 | 118 | const title = unref(openModalMode) === OpenModelMode.UPDATE ? '编辑物模型' : '新增物模型'; |
| 119 | - if (OpenModelMode.UPDATE) { | |
| 120 | - // setFormData(functionType.value, record); | |
| 121 | - } | |
| 122 | 119 | setModalProps({ title, showOkBtn: true, showCancelBtn: true }); |
| 123 | 120 | } |
| 124 | 121 | } | ... | ... |
| ... | ... | @@ -6,7 +6,10 @@ |
| 6 | 6 | import { DataType, ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; |
| 7 | 7 | import { formSchemas } from '/@/components/Form/src/externalCompns/components/StructForm/config'; |
| 8 | 8 | import { StructFormValue } from '/@/components/Form/src/externalCompns/components/StructForm/type'; |
| 9 | - import { transfromToStructJSON } from '/@/components/Form/src/externalCompns/components/StructForm/util'; | |
| 9 | + import { | |
| 10 | + transfromToStructJSON, | |
| 11 | + excludeIdInStructJSON, | |
| 12 | + } from '/@/components/Form/src/externalCompns/components/StructForm/util'; | |
| 10 | 13 | import { FunctionType } from './config'; |
| 11 | 14 | import { isArray } from 'lodash'; |
| 12 | 15 | |
| ... | ... | @@ -26,6 +29,8 @@ |
| 26 | 29 | if (!_values) return {}; |
| 27 | 30 | const { functionName, remark, identifier, accessMode } = _values; |
| 28 | 31 | const structJSON = transfromToStructJSON(_values); |
| 32 | + const dataType = excludeIdInStructJSON(structJSON.dataType!); | |
| 33 | + | |
| 29 | 34 | const value = { |
| 30 | 35 | functionName, |
| 31 | 36 | functionType: FunctionType.PROPERTIES, |
| ... | ... | @@ -33,7 +38,7 @@ |
| 33 | 38 | identifier, |
| 34 | 39 | accessMode, |
| 35 | 40 | functionJson: { |
| 36 | - dataType: structJSON.dataType, | |
| 41 | + dataType: dataType, | |
| 37 | 42 | }, |
| 38 | 43 | } as ModelOfMatterParams; |
| 39 | 44 | return value; | ... | ... |