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 | import { DateTypeEnum } from './config'; | 2 | import { DateTypeEnum } from './config'; |
2 | import { StructFormValue } from './type'; | 3 | import { StructFormValue } from './type'; |
3 | import { DataType, ModelOfMatterParams, StructJSON } from '/@/api/device/model/modelOfMatterModel'; | 4 | import { DataType, ModelOfMatterParams, StructJSON } from '/@/api/device/model/modelOfMatterModel'; |
5 | +import { isArray } from '/@/utils/is'; | ||
4 | 6 | ||
5 | export function transfromToStructJSON(value: StructFormValue): StructJSON { | 7 | export function transfromToStructJSON(value: StructFormValue): StructJSON { |
6 | const { | 8 | const { |
@@ -16,9 +18,9 @@ export function transfromToStructJSON(value: StructFormValue): StructJSON { | @@ -16,9 +18,9 @@ export function transfromToStructJSON(value: StructFormValue): StructJSON { | ||
16 | identifier, | 18 | identifier, |
17 | remark, | 19 | remark, |
18 | specs, | 20 | specs, |
19 | - assessMode, | 21 | + accessMode, |
20 | } = value; | 22 | } = value; |
21 | - const basic = { functionName, identifier, remark, assessMode }; | 23 | + const basic = { functionName, identifier, remark, accessMode }; |
22 | let dataType = {} as unknown as DataType; | 24 | let dataType = {} as unknown as DataType; |
23 | 25 | ||
24 | switch (type) { | 26 | switch (type) { |
@@ -62,3 +64,27 @@ export function transfromToStructJSON(value: StructFormValue): StructJSON { | @@ -62,3 +64,27 @@ export function transfromToStructJSON(value: StructFormValue): StructJSON { | ||
62 | } | 64 | } |
63 | return { ...basic, dataType }; | 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 | <template> | 1 | <template> |
2 | <BasicDrawer v-bind="$attrs" title="产品详情" @register="register" width="60%" destroy-on-close> | 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 | <div class="relative"> | 5 | <div class="relative"> |
6 | <DeviceConfigurationStep :ifShowBtn="false" ref="DevConStRef" /> | 6 | <DeviceConfigurationStep :ifShowBtn="false" ref="DevConStRef" /> |
7 | <div class="absolute w-full h-full top-0 cursor-not-allowed"></div> | 7 | <div class="absolute w-full h-full top-0 cursor-not-allowed"></div> |
8 | </div> | 8 | </div> |
9 | - </TabPane> | ||
10 | - <TabPane key="transport" tab="传输配置"> | 9 | + </Tabs.TabPane> |
10 | + <Tabs.TabPane key="transport" tab="传输配置"> | ||
11 | <div class="relative"> | 11 | <div class="relative"> |
12 | <TransportConfigurationStep :ifShowBtn="false" ref="TransConStRef" /> | 12 | <TransportConfigurationStep :ifShowBtn="false" ref="TransConStRef" /> |
13 | <div class="absolute w-full h-full top-0 cursor-not-allowed"></div> | 13 | <div class="absolute w-full h-full top-0 cursor-not-allowed"></div> |
14 | </div> | 14 | </div> |
15 | - </TabPane> | ||
16 | - <TabPane key="modelOfMatter" tab="物模型管理"> | 15 | + </Tabs.TabPane> |
16 | + <Tabs.TabPane key="modelOfMatter" tab="物模型管理"> | ||
17 | <PhysicalModelManagementStep :record="record" /> | 17 | <PhysicalModelManagementStep :record="record" /> |
18 | - </TabPane> | 18 | + </Tabs.TabPane> |
19 | </Tabs> | 19 | </Tabs> |
20 | </BasicDrawer> | 20 | </BasicDrawer> |
21 | </template> | 21 | </template> |
22 | <script lang="ts" setup> | 22 | <script lang="ts" setup> |
23 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 23 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
24 | - import { Tabs, TabPane } from 'ant-design-vue'; | 24 | + import { Tabs } from 'ant-design-vue'; |
25 | import DeviceConfigurationStep from './step/DeviceConfigurationStep.vue'; | 25 | import DeviceConfigurationStep from './step/DeviceConfigurationStep.vue'; |
26 | import TransportConfigurationStep from './step/TransportConfigurationStep.vue'; | 26 | import TransportConfigurationStep from './step/TransportConfigurationStep.vue'; |
27 | import PhysicalModelManagementStep from './step/PhysicalModelManagementStep.vue'; | 27 | import PhysicalModelManagementStep from './step/PhysicalModelManagementStep.vue'; |
@@ -35,23 +35,23 @@ | @@ -35,23 +35,23 @@ | ||
35 | :disabled="$props.record.transportType === 'TCP'" | 35 | :disabled="$props.record.transportType === 'TCP'" |
36 | /> | 36 | /> |
37 | </Tabs> | 37 | </Tabs> |
38 | - <Attribute v-show="activeKey === FunctionType.PROPERTIES" ref="AttrRef" /> | 38 | + <Attribute v-if="activeKey === FunctionType.PROPERTIES" ref="AttrRef" /> |
39 | <Service | 39 | <Service |
40 | - v-show="activeKey === FunctionType.SERVICE" | 40 | + v-if="activeKey === FunctionType.SERVICE" |
41 | :record="$props.record" | 41 | :record="$props.record" |
42 | ref="ServiceRef" | 42 | ref="ServiceRef" |
43 | /> | 43 | /> |
44 | - <Events v-show="activeKey === FunctionType.EVENTS" ref="EventsRef" /> | 44 | + <Events v-if="activeKey === FunctionType.EVENTS" ref="EventsRef" /> |
45 | <div | 45 | <div |
46 | v-if="openModalMode === OpenModelMode.VIEW" | 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 | ></div> | 48 | ></div> |
49 | </div> | 49 | </div> |
50 | </BasicModal> | 50 | </BasicModal> |
51 | </div> | 51 | </div> |
52 | </template> | 52 | </template> |
53 | <script lang="ts" setup> | 53 | <script lang="ts" setup> |
54 | - import { ref, unref } from 'vue'; | 54 | + import { ref, unref, nextTick } from 'vue'; |
55 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 55 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
56 | import { Tabs, TabPane, Typography, TypographyParagraph } from 'ant-design-vue'; | 56 | import { Tabs, TabPane, Typography, TypographyParagraph } from 'ant-design-vue'; |
57 | import Attribute from './cpns/Attribute.vue'; | 57 | import Attribute from './cpns/Attribute.vue'; |
@@ -109,16 +109,13 @@ | @@ -109,16 +109,13 @@ | ||
109 | if (record) { | 109 | if (record) { |
110 | functionType.value = data.record.functionType; | 110 | functionType.value = data.record.functionType; |
111 | activeKey.value = data.record.functionType; | 111 | activeKey.value = data.record.functionType; |
112 | + await nextTick(); | ||
112 | setFormData(record.functionType, record as unknown as ModelOfMatterParams); | 113 | setFormData(record.functionType, record as unknown as ModelOfMatterParams); |
113 | } | 114 | } |
114 | if (unref(openModalMode) === OpenModelMode.VIEW) { | 115 | if (unref(openModalMode) === OpenModelMode.VIEW) { |
115 | setModalProps({ showOkBtn: false, showCancelBtn: false, title: '查看物模型' }); | 116 | setModalProps({ showOkBtn: false, showCancelBtn: false, title: '查看物模型' }); |
116 | - // setFormData(functionType.value, record); | ||
117 | } else { | 117 | } else { |
118 | const title = unref(openModalMode) === OpenModelMode.UPDATE ? '编辑物模型' : '新增物模型'; | 118 | const title = unref(openModalMode) === OpenModelMode.UPDATE ? '编辑物模型' : '新增物模型'; |
119 | - if (OpenModelMode.UPDATE) { | ||
120 | - // setFormData(functionType.value, record); | ||
121 | - } | ||
122 | setModalProps({ title, showOkBtn: true, showCancelBtn: true }); | 119 | setModalProps({ title, showOkBtn: true, showCancelBtn: true }); |
123 | } | 120 | } |
124 | } | 121 | } |
@@ -6,7 +6,10 @@ | @@ -6,7 +6,10 @@ | ||
6 | import { DataType, ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; | 6 | import { DataType, ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; |
7 | import { formSchemas } from '/@/components/Form/src/externalCompns/components/StructForm/config'; | 7 | import { formSchemas } from '/@/components/Form/src/externalCompns/components/StructForm/config'; |
8 | import { StructFormValue } from '/@/components/Form/src/externalCompns/components/StructForm/type'; | 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 | import { FunctionType } from './config'; | 13 | import { FunctionType } from './config'; |
11 | import { isArray } from 'lodash'; | 14 | import { isArray } from 'lodash'; |
12 | 15 | ||
@@ -26,6 +29,8 @@ | @@ -26,6 +29,8 @@ | ||
26 | if (!_values) return {}; | 29 | if (!_values) return {}; |
27 | const { functionName, remark, identifier, accessMode } = _values; | 30 | const { functionName, remark, identifier, accessMode } = _values; |
28 | const structJSON = transfromToStructJSON(_values); | 31 | const structJSON = transfromToStructJSON(_values); |
32 | + const dataType = excludeIdInStructJSON(structJSON.dataType!); | ||
33 | + | ||
29 | const value = { | 34 | const value = { |
30 | functionName, | 35 | functionName, |
31 | functionType: FunctionType.PROPERTIES, | 36 | functionType: FunctionType.PROPERTIES, |
@@ -33,7 +38,7 @@ | @@ -33,7 +38,7 @@ | ||
33 | identifier, | 38 | identifier, |
34 | accessMode, | 39 | accessMode, |
35 | functionJson: { | 40 | functionJson: { |
36 | - dataType: structJSON.dataType, | 41 | + dataType: dataType, |
37 | }, | 42 | }, |
38 | } as ModelOfMatterParams; | 43 | } as ModelOfMatterParams; |
39 | return value; | 44 | return value; |
@@ -46,6 +46,7 @@ | @@ -46,6 +46,7 @@ | ||
46 | const { functionName, remark, identifier, inputData, outputData, serviceCommand, callType } = | 46 | const { functionName, remark, identifier, inputData, outputData, serviceCommand, callType } = |
47 | _values; | 47 | _values; |
48 | if (!_values) return {}; | 48 | if (!_values) return {}; |
49 | + | ||
49 | const value = { | 50 | const value = { |
50 | functionName, | 51 | functionName, |
51 | identifier, | 52 | identifier, |