Commit 4b0f97d1188bd6dca84e85ed75abcd22ac30eee6
Merge branch 'main_dev' of http://git.yunteng.com/yunteng/thingskit-front into fix/rule-chain-field
Showing
12 changed files
with
146 additions
and
76 deletions
@@ -14,6 +14,8 @@ | @@ -14,6 +14,8 @@ | ||
14 | import { OpenModalMode, OpenModalParams, StructRecord } from './type'; | 14 | import { OpenModalMode, OpenModalParams, StructRecord } from './type'; |
15 | import { cloneDeep } from 'lodash-es'; | 15 | import { cloneDeep } from 'lodash-es'; |
16 | import { isArray } from '/@/utils/is'; | 16 | import { isArray } from '/@/utils/is'; |
17 | + import { FormField } from '/@/views/device/profiles/step/cpns/physical/cpns/config'; | ||
18 | + import { DataTypeEnum } from '/@/enums/objectModelEnum'; | ||
17 | 19 | ||
18 | const emit = defineEmits(['update:value']); | 20 | const emit = defineEmits(['update:value']); |
19 | 21 | ||
@@ -53,7 +55,10 @@ | @@ -53,7 +55,10 @@ | ||
53 | const handleUpdate = (value: StructRecord) => { | 55 | const handleUpdate = (value: StructRecord) => { |
54 | openModal(true, { | 56 | openModal(true, { |
55 | mode: OpenModalMode.UPDATE, | 57 | mode: OpenModalMode.UPDATE, |
56 | - record: value, | 58 | + record: { |
59 | + ...value, | ||
60 | + [FormField.HAS_STRUCT_FROM]: value?.dataType?.type === DataTypeEnum.STRUCT, | ||
61 | + }, | ||
57 | } as OpenModalParams); | 62 | } as OpenModalParams); |
58 | }; | 63 | }; |
59 | 64 | ||
@@ -90,15 +95,10 @@ | @@ -90,15 +95,10 @@ | ||
90 | <div>参数名称: {{ item.functionName }}</div> | 95 | <div>参数名称: {{ item.functionName }}</div> |
91 | <div class="flex"> | 96 | <div class="flex"> |
92 | <Button class="!p-0" type="link" @click="handleUpdate(item)"> | 97 | <Button class="!p-0" type="link" @click="handleUpdate(item)"> |
93 | - <span>{{ $props.disabled ? '查看' : '编辑' }}</span> | 98 | + <span>{{ disabled ? '查看' : '编辑' }}</span> |
94 | </Button> | 99 | </Button> |
95 | <Divider type="vertical" /> | 100 | <Divider type="vertical" /> |
96 | - <Button | ||
97 | - :disabled="$props.disabled" | ||
98 | - class="!p-0" | ||
99 | - type="link" | ||
100 | - @click="handleDelete(item)" | ||
101 | - > | 101 | + <Button :disabled="disabled" class="!p-0" type="link" @click="handleDelete(item)"> |
102 | <span>删除</span> | 102 | <span>删除</span> |
103 | </Button> | 103 | </Button> |
104 | </div> | 104 | </div> |
@@ -114,7 +114,7 @@ | @@ -114,7 +114,7 @@ | ||
114 | <StructFormModel | 114 | <StructFormModel |
115 | :has-struct-form="hasStructForm!" | 115 | :has-struct-form="hasStructForm!" |
116 | :hidden-access-mode="hiddenAccessMode" | 116 | :hidden-access-mode="hiddenAccessMode" |
117 | - :disabled="$props.disabled" | 117 | + :disabled="disabled" |
118 | :value-list="getValue" | 118 | :value-list="getValue" |
119 | @register="registerModal" | 119 | @register="registerModal" |
120 | @submit="handleSaveStruct" | 120 | @submit="handleSaveStruct" |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | import { formSchemas } from './config'; | 8 | import { formSchemas } from './config'; |
9 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 9 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
10 | import { OpenModalMode, OpenModalParams, StructRecord } from './type'; | 10 | import { OpenModalMode, OpenModalParams, StructRecord } from './type'; |
11 | - import { ref, unref } from 'vue'; | 11 | + import { computed, ref, unref } from 'vue'; |
12 | import { transfromToStructJSON } from './util'; | 12 | import { transfromToStructJSON } from './util'; |
13 | import { cloneDeep } from 'lodash-es'; | 13 | import { cloneDeep } from 'lodash-es'; |
14 | import { DataType, StructJSON } from '/@/api/device/model/modelOfMatterModel'; | 14 | import { DataType, StructJSON } from '/@/api/device/model/modelOfMatterModel'; |
@@ -32,7 +32,6 @@ | @@ -32,7 +32,6 @@ | ||
32 | 32 | ||
33 | const [register, { validate, setFieldsValue, setProps }] = useForm({ | 33 | const [register, { validate, setFieldsValue, setProps }] = useForm({ |
34 | labelWidth: 100, | 34 | labelWidth: 100, |
35 | - schemas: formSchemas(props.hasStructForm, props.hiddenAccessMode), | ||
36 | actionColOptions: { | 35 | actionColOptions: { |
37 | span: 14, | 36 | span: 14, |
38 | }, | 37 | }, |
@@ -42,6 +41,14 @@ | @@ -42,6 +41,14 @@ | ||
42 | showActionButtonGroup: false, | 41 | showActionButtonGroup: false, |
43 | }); | 42 | }); |
44 | 43 | ||
44 | + const getFormSchemas = computed(() => { | ||
45 | + const { hasStructForm, hiddenAccessMode } = props; | ||
46 | + return formSchemas({ | ||
47 | + hasStructForm, | ||
48 | + hiddenAccessMode, | ||
49 | + }); | ||
50 | + }); | ||
51 | + | ||
45 | const [registerModal, { closeModal }] = useModalInner((record: OpenModalParams) => { | 52 | const [registerModal, { closeModal }] = useModalInner((record: OpenModalParams) => { |
46 | modalReceiveRecord.value = record; | 53 | modalReceiveRecord.value = record; |
47 | const data = record.record || {}; | 54 | const data = record.record || {}; |
@@ -97,7 +104,7 @@ | @@ -97,7 +104,7 @@ | ||
97 | destroy-on-close | 104 | destroy-on-close |
98 | :show-ok-btn="!$props.disabled" | 105 | :show-ok-btn="!$props.disabled" |
99 | > | 106 | > |
100 | - <BasicForm @register="register" /> | 107 | + <BasicForm @register="register" :schemas="getFormSchemas" /> |
101 | </BasicModal> | 108 | </BasicModal> |
102 | </template> | 109 | </template> |
103 | 110 |
@@ -21,11 +21,17 @@ export const validateJSON = (_rule, value = [] as ModelOfMatterParams[], _callba | @@ -21,11 +21,17 @@ export const validateJSON = (_rule, value = [] as ModelOfMatterParams[], _callba | ||
21 | return Promise.reject('JSON对象不能为空'); | 21 | return Promise.reject('JSON对象不能为空'); |
22 | }; | 22 | }; |
23 | 23 | ||
24 | -export const formSchemas = ( | ||
25 | - hasStructForm: boolean, | ||
26 | - hiddenAccessMode: boolean, | ||
27 | - isTcp = false | ||
28 | -): FormSchema[] => { | 24 | +interface StructFormSchemasParmasType { |
25 | + hasStructForm: boolean; | ||
26 | + hiddenAccessMode: boolean; | ||
27 | + isTcp?: boolean; | ||
28 | +} | ||
29 | + | ||
30 | +export const formSchemas = ({ | ||
31 | + hasStructForm, | ||
32 | + hiddenAccessMode, | ||
33 | + isTcp = false, | ||
34 | +}: StructFormSchemasParmasType): FormSchema[] => { | ||
29 | return [ | 35 | return [ |
30 | { | 36 | { |
31 | field: FormField.FUNCTION_NAME, | 37 | field: FormField.FUNCTION_NAME, |
@@ -54,6 +60,12 @@ export const formSchemas = ( | @@ -54,6 +60,12 @@ export const formSchemas = ( | ||
54 | }, | 60 | }, |
55 | }, | 61 | }, |
56 | { | 62 | { |
63 | + field: FormField.HAS_STRUCT_FROM, | ||
64 | + label: '是否已存在结构体', | ||
65 | + component: 'Input', | ||
66 | + ifShow: false, | ||
67 | + }, | ||
68 | + { | ||
57 | field: FormField.TYPE, | 69 | field: FormField.TYPE, |
58 | label: '数据类型', | 70 | label: '数据类型', |
59 | required: true, | 71 | required: true, |
@@ -63,7 +75,7 @@ export const formSchemas = ( | @@ -63,7 +75,7 @@ export const formSchemas = ( | ||
63 | }, | 75 | }, |
64 | defaultValue: 'INT', | 76 | defaultValue: 'INT', |
65 | componentProps: ({ formActionType }) => { | 77 | componentProps: ({ formActionType }) => { |
66 | - const { updateSchema, setFieldsValue } = formActionType; | 78 | + const { setFieldsValue } = formActionType; |
67 | return { | 79 | return { |
68 | placeholder: '请选择数据类型', | 80 | placeholder: '请选择数据类型', |
69 | api: async (params: Recordable) => { | 81 | api: async (params: Recordable) => { |
@@ -84,13 +96,7 @@ export const formSchemas = ( | @@ -84,13 +96,7 @@ export const formSchemas = ( | ||
84 | getPopupContainer: () => document.body, | 96 | getPopupContainer: () => document.body, |
85 | onChange: (value: string) => { | 97 | onChange: (value: string) => { |
86 | if (value == DataTypeEnum.STRUCT) { | 98 | if (value == DataTypeEnum.STRUCT) { |
87 | - updateSchema({ | ||
88 | - field: FormField.SPECS_LIST, | ||
89 | - componentProps: { | ||
90 | - hasStructForm: true, | ||
91 | - }, | ||
92 | - }); | ||
93 | - setFieldsValue({ [FormField.SPECS_LIST]: [] }); | 99 | + setFieldsValue({ [FormField.SPECS_LIST]: [], [FormField.HAS_STRUCT_FROM]: true }); |
94 | } | 100 | } |
95 | }, | 101 | }, |
96 | }; | 102 | }; |
@@ -316,6 +322,11 @@ export const formSchemas = ( | @@ -316,6 +322,11 @@ export const formSchemas = ( | ||
316 | colProps: { span: 24 }, | 322 | colProps: { span: 24 }, |
317 | ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.STRUCT, | 323 | ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.STRUCT, |
318 | rules: [{ required: true, validator: validateJSON }], | 324 | rules: [{ required: true, validator: validateJSON }], |
325 | + componentProps: ({ formModel }) => { | ||
326 | + return { | ||
327 | + hasStructForm: formModel[FormField.HAS_STRUCT_FROM], | ||
328 | + }; | ||
329 | + }, | ||
319 | }, | 330 | }, |
320 | { | 331 | { |
321 | field: FormField.REFARK, | 332 | field: FormField.REFARK, |
@@ -147,7 +147,7 @@ export const formSchema: FormSchema[] = [ | @@ -147,7 +147,7 @@ export const formSchema: FormSchema[] = [ | ||
147 | }, | 147 | }, |
148 | { | 148 | { |
149 | field: 'enableTemplate', //前端控制 | 149 | field: 'enableTemplate', //前端控制 |
150 | - label: '启用模版', | 150 | + label: '启用模板', |
151 | component: 'Switch', | 151 | component: 'Switch', |
152 | defaultValue: 0, | 152 | defaultValue: 0, |
153 | componentProps: ({ formActionType }) => { | 153 | componentProps: ({ formActionType }) => { |
@@ -62,7 +62,7 @@ export const columns: BasicColumn[] = [ | @@ -62,7 +62,7 @@ export const columns: BasicColumn[] = [ | ||
62 | export const searchFormSchema: FormSchema[] = [ | 62 | export const searchFormSchema: FormSchema[] = [ |
63 | { | 63 | { |
64 | field: 'name', | 64 | field: 'name', |
65 | - label: '模板', | 65 | + label: '模板名称', |
66 | component: 'Input', | 66 | component: 'Input', |
67 | colProps: { span: 8 }, | 67 | colProps: { span: 8 }, |
68 | componentProps: { | 68 | componentProps: { |
@@ -25,7 +25,7 @@ | @@ -25,7 +25,7 @@ | ||
25 | const [register, { reload }] = useCardList({ | 25 | const [register, { reload }] = useCardList({ |
26 | api: getPage, | 26 | api: getPage, |
27 | useSearchForm: true, | 27 | useSearchForm: true, |
28 | - title: '模版', | 28 | + title: '模板列表', |
29 | gutter: 4, | 29 | gutter: 4, |
30 | formConfig: { | 30 | formConfig: { |
31 | schemas: searchFormSchema, | 31 | schemas: searchFormSchema, |
@@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
58 | }, | 58 | }, |
59 | selections: { | 59 | selections: { |
60 | beforeSelectValidate: (record: ProfileRecord) => { | 60 | beforeSelectValidate: (record: ProfileRecord) => { |
61 | - return !record.default; | 61 | + return !record.default && record?.name !== 'default'; |
62 | }, | 62 | }, |
63 | onSelect: (_record, _flag, allSelecteds) => { | 63 | onSelect: (_record, _flag, allSelecteds) => { |
64 | disabledDeleteFlag.value = !allSelecteds.length; | 64 | disabledDeleteFlag.value = !allSelecteds.length; |
@@ -188,7 +188,7 @@ | @@ -188,7 +188,7 @@ | ||
188 | popconfirm: { | 188 | popconfirm: { |
189 | title: '是否确认删除操作?', | 189 | title: '是否确认删除操作?', |
190 | onConfirm: handleDelete.bind(null, [item.id]), | 190 | onConfirm: handleDelete.bind(null, [item.id]), |
191 | - disabled: item.default, | 191 | + disabled: item.default || item.name == 'default', |
192 | }, | 192 | }, |
193 | disabled: item.default || item.name == 'default', | 193 | disabled: item.default || item.name == 'default', |
194 | }, | 194 | }, |
@@ -5,48 +5,27 @@ | @@ -5,48 +5,27 @@ | ||
5 | destroyOnClose | 5 | destroyOnClose |
6 | v-bind="$attrs" | 6 | v-bind="$attrs" |
7 | width="25rem" | 7 | width="25rem" |
8 | + :min-height="150" | ||
8 | @register="register" | 9 | @register="register" |
9 | @cancel="handleCancel" | 10 | @cancel="handleCancel" |
10 | :showOkBtn="false" | 11 | :showOkBtn="false" |
11 | > | 12 | > |
12 | - <div class="w-full h-full" ref="loadingRef"> | ||
13 | - <div class="flex justify-end"> | ||
14 | - <Button @click="handleTemplateDownload" type="link">excel模板下载</Button> | ||
15 | - </div> | ||
16 | - <div class="flex justify-evenly items-center h-50 !w-full"> | ||
17 | - <Upload | ||
18 | - accept=".json," | ||
19 | - :show-upload-list="false" | ||
20 | - :customRequest="handleImportModel" | ||
21 | - class="flex justify-center items-center" | ||
22 | - > | ||
23 | - <div class="flex flex-col justify-center items-center"> | ||
24 | - <Tooltip> | ||
25 | - <template #title>请使用从物模型TSL导出的JSON文件在进行导入</template> | ||
26 | - <img :src="JSONImage" alt="avatar" class="w-20 h-20" /> | ||
27 | - </Tooltip> | ||
28 | - </div> | ||
29 | - </Upload> | ||
30 | - <Upload | ||
31 | - accept=".csv,.xls,.xlsx" | ||
32 | - :show-upload-list="false" | ||
33 | - :customRequest="handleCSVImport" | ||
34 | - class="flex justify-center items-center" | ||
35 | - > | ||
36 | - <div class="flex flex-col justify-center items-center"> | ||
37 | - <Tooltip> | ||
38 | - <template #title>请使用下载的模板编辑之后在进行导入</template> | ||
39 | - <img :src="CSVImage" alt="avatar" class="w-20 h-20" /> | ||
40 | - </Tooltip> | ||
41 | - </div> | ||
42 | - </Upload> | ||
43 | - </div> | ||
44 | - </div> | 13 | + <BasicForm @register="registerForm"> |
14 | + <template #importType="{ model }"> | ||
15 | + <RadioGroup v-model:value="model.importType"> | ||
16 | + <Radio value="2">JSON导入</Radio> | ||
17 | + <Radio value="1">Excel导入</Radio> | ||
18 | + </RadioGroup> | ||
19 | + <div v-if="model.importType === '1'" class="absolute -left-28"> | ||
20 | + <Button @click="handleTemplateDownload" type="link">excel模板下载</Button> | ||
21 | + </div> | ||
22 | + </template> | ||
23 | + </BasicForm> | ||
45 | </BasicModal> | 24 | </BasicModal> |
46 | </template> | 25 | </template> |
47 | <script lang="ts" setup> | 26 | <script lang="ts" setup> |
48 | import { ref, unref } from 'vue'; | 27 | import { ref, unref } from 'vue'; |
49 | - import { Upload, Tooltip, Button } from 'ant-design-vue'; | 28 | + import { Button, Radio, RadioGroup } from 'ant-design-vue'; |
50 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 29 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
51 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; | 30 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; |
52 | import { useMessage } from '/@/hooks/web/useMessage'; | 31 | import { useMessage } from '/@/hooks/web/useMessage'; |
@@ -59,8 +38,7 @@ | @@ -59,8 +38,7 @@ | ||
59 | excelExport, | 38 | excelExport, |
60 | } from '/@/api/device/modelOfMatter'; | 39 | } from '/@/api/device/modelOfMatter'; |
61 | import { useLoading } from '/@/components/Loading'; | 40 | import { useLoading } from '/@/components/Loading'; |
62 | - import JSONImage from '/@/assets/svg/JSON.svg'; | ||
63 | - import CSVImage from '/@/assets/svg/excel.svg'; | 41 | + import { BasicForm, useForm } from '/@/components/Form'; |
64 | 42 | ||
65 | const emits = defineEmits(['register', 'handleImportCSV', 'handleReload']); | 43 | const emits = defineEmits(['register', 'handleImportCSV', 'handleReload']); |
66 | 44 | ||
@@ -85,6 +63,48 @@ | @@ -85,6 +63,48 @@ | ||
85 | const [register, { closeModal }] = useModalInner(async (data) => { | 63 | const [register, { closeModal }] = useModalInner(async (data) => { |
86 | ImportInfo.value = data; | 64 | ImportInfo.value = data; |
87 | }); | 65 | }); |
66 | + | ||
67 | + const [registerForm, {}] = useForm({ | ||
68 | + schemas: [ | ||
69 | + { | ||
70 | + field: 'importType', | ||
71 | + label: '导入类型', | ||
72 | + component: 'RadioGroup', | ||
73 | + defaultValue: '2', | ||
74 | + slot: 'importType', | ||
75 | + helpMessage: | ||
76 | + 'JSON导入请使用从物模型TSL导出的JSON文件在进行导入,Excel导入请使用下载的模板编辑之后在进行导入', | ||
77 | + required: true, | ||
78 | + }, | ||
79 | + { | ||
80 | + field: 'apiId', | ||
81 | + label: '', | ||
82 | + component: 'ApiUpload', | ||
83 | + componentProps: ({ formModel }) => { | ||
84 | + return { | ||
85 | + maxFileLimit: 1, | ||
86 | + accept: formModel.importType == 2 ? '.json,' : '.csv,.xls,.xlsx', | ||
87 | + api: async (file: File) => { | ||
88 | + try { | ||
89 | + if (formModel.importType == 2) { | ||
90 | + handleImportModel(file); | ||
91 | + } else { | ||
92 | + handleCSVImport(file); | ||
93 | + } | ||
94 | + return { | ||
95 | + uid: '', | ||
96 | + name: '', | ||
97 | + }; | ||
98 | + } catch {} | ||
99 | + }, | ||
100 | + }; | ||
101 | + }, | ||
102 | + }, | ||
103 | + ], | ||
104 | + labelWidth: 100, | ||
105 | + showActionButtonGroup: false, | ||
106 | + }); | ||
107 | + | ||
88 | // 导入loading | 108 | // 导入loading |
89 | const importLoading = ref(false); | 109 | const importLoading = ref(false); |
90 | 110 | ||
@@ -101,7 +121,7 @@ | @@ -101,7 +121,7 @@ | ||
101 | }; | 121 | }; |
102 | 122 | ||
103 | // JSON导入 | 123 | // JSON导入 |
104 | - const handleImportModel = async (data: { file: File }) => { | 124 | + const handleImportModel = async (file: File) => { |
105 | const fileReader = new FileReader(); | 125 | const fileReader = new FileReader(); |
106 | const { isCateGory, id } = unref(ImportInfo); | 126 | const { isCateGory, id } = unref(ImportInfo); |
107 | 127 | ||
@@ -148,11 +168,11 @@ | @@ -148,11 +168,11 @@ | ||
148 | } | 168 | } |
149 | }; | 169 | }; |
150 | 170 | ||
151 | - fileReader.readAsText(data.file, 'utf-8'); | 171 | + fileReader.readAsText(file, 'utf-8'); |
152 | }; | 172 | }; |
153 | 173 | ||
154 | // CSV导入 | 174 | // CSV导入 |
155 | - const handleCSVImport = async ({ file }) => { | 175 | + const handleCSVImport = async (file) => { |
156 | const { isCateGory, id } = unref(ImportInfo); | 176 | const { isCateGory, id } = unref(ImportInfo); |
157 | 177 | ||
158 | try { | 178 | try { |
@@ -200,4 +220,8 @@ | @@ -200,4 +220,8 @@ | ||
200 | }; | 220 | }; |
201 | </script> | 221 | </script> |
202 | 222 | ||
203 | -<style lang="less" scope></style> | 223 | +<style lang="less" scoped> |
224 | + :deep(.ant-form-item) { | ||
225 | + margin-bottom: 28px !important; | ||
226 | + } | ||
227 | +</style> |
@@ -14,12 +14,17 @@ | @@ -14,12 +14,17 @@ | ||
14 | import { OpenModelMode } from '../types'; | 14 | import { OpenModelMode } from '../types'; |
15 | import { formSchemas } from '/@/components/Form/src/externalCompns/components/StructForm/config'; | 15 | import { formSchemas } from '/@/components/Form/src/externalCompns/components/StructForm/config'; |
16 | import { TransportTypeEnum } from '../../../../components/TransportDescript/const'; | 16 | import { TransportTypeEnum } from '../../../../components/TransportDescript/const'; |
17 | + import { DataTypeEnum } from '/@/enums/objectModelEnum'; | ||
17 | 18 | ||
18 | const props = defineProps<{ openModalMode: OpenModelMode; transportType?: string | undefined }>(); | 19 | const props = defineProps<{ openModalMode: OpenModelMode; transportType?: string | undefined }>(); |
19 | 20 | ||
20 | const [register, { validate, resetFields, setFieldsValue, setProps }] = useForm({ | 21 | const [register, { validate, resetFields, setFieldsValue, setProps }] = useForm({ |
21 | labelWidth: 100, | 22 | labelWidth: 100, |
22 | - schemas: formSchemas(false, false, props.transportType === TransportTypeEnum.TCP), | 23 | + schemas: formSchemas({ |
24 | + hasStructForm: false, | ||
25 | + hiddenAccessMode: false, | ||
26 | + isTcp: props.transportType === TransportTypeEnum.TCP, | ||
27 | + }), | ||
23 | actionColOptions: { | 28 | actionColOptions: { |
24 | span: 14, | 29 | span: 14, |
25 | }, | 30 | }, |
@@ -67,7 +72,9 @@ | @@ -67,7 +72,9 @@ | ||
67 | ...functionJson, | 72 | ...functionJson, |
68 | ...dataType, | 73 | ...dataType, |
69 | ...(isArray(specs) ? specs : { ...specs }), | 74 | ...(isArray(specs) ? specs : { ...specs }), |
75 | + hasStructForm: (record?.functionJson?.dataType as DataType)?.type === DataTypeEnum.STRUCT, | ||
70 | }; | 76 | }; |
77 | + | ||
71 | setFieldsValue(value); | 78 | setFieldsValue(value); |
72 | }; | 79 | }; |
73 | 80 |
@@ -3,13 +3,15 @@ | @@ -3,13 +3,15 @@ | ||
3 | </template> | 3 | </template> |
4 | <script lang="ts" setup> | 4 | <script lang="ts" setup> |
5 | import { BasicForm, useForm } from '/@/components/Form'; | 5 | import { BasicForm, useForm } from '/@/components/Form'; |
6 | - import { serviceSchemas } from './config'; | 6 | + import { FormField, serviceSchemas } from './config'; |
7 | import { FunctionType } from './config'; | 7 | import { FunctionType } from './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 { ModelOfMatterParams, StructJSON } from '/@/api/device/model/modelOfMatterModel'; | 9 | import { ModelOfMatterParams, StructJSON } from '/@/api/device/model/modelOfMatterModel'; |
10 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; | 10 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; |
11 | import { excludeIdInStructJSON } from '/@/components/Form/src/externalCompns/components/StructForm/util'; | 11 | import { excludeIdInStructJSON } from '/@/components/Form/src/externalCompns/components/StructForm/util'; |
12 | import { OpenModelMode } from '../types'; | 12 | import { OpenModelMode } from '../types'; |
13 | + import { isArray } from '/@/utils/is'; | ||
14 | + import { DataTypeEnum } from '/@/enums/objectModelEnum'; | ||
13 | 15 | ||
14 | const props = defineProps<{ | 16 | const props = defineProps<{ |
15 | record: DeviceRecord; | 17 | record: DeviceRecord; |
@@ -48,6 +50,14 @@ | @@ -48,6 +50,14 @@ | ||
48 | serviceCommand, | 50 | serviceCommand, |
49 | callType, | 51 | callType, |
50 | }; | 52 | }; |
53 | + | ||
54 | + if ( | ||
55 | + isArray(inputData) && | ||
56 | + inputData.find((item) => item?.dataType?.type === DataTypeEnum.STRUCT) | ||
57 | + ) { | ||
58 | + Reflect.set(value, FormField.HAS_STRUCT_FROM, true); | ||
59 | + } | ||
60 | + | ||
51 | setFieldsValue(value); | 61 | setFieldsValue(value); |
52 | }; | 62 | }; |
53 | 63 |
@@ -28,6 +28,8 @@ export enum FormField { | @@ -28,6 +28,8 @@ export enum FormField { | ||
28 | REGISTER_ADDRESS = 'registerAddress', | 28 | REGISTER_ADDRESS = 'registerAddress', |
29 | EXTENSION_DESC = 'extensionDesc', | 29 | EXTENSION_DESC = 'extensionDesc', |
30 | STRUCT = 'struct', | 30 | STRUCT = 'struct', |
31 | + | ||
32 | + HAS_STRUCT_FROM = 'hasStructForm', | ||
31 | } | 33 | } |
32 | 34 | ||
33 | export enum FunctionType { | 35 | export enum FunctionType { |
@@ -125,6 +127,12 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => { | @@ -125,6 +127,12 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => { | ||
125 | }, | 127 | }, |
126 | }, | 128 | }, |
127 | { | 129 | { |
130 | + field: FormField.HAS_STRUCT_FROM, | ||
131 | + component: 'Input', | ||
132 | + label: '是否已存在结构体', | ||
133 | + ifShow: false, | ||
134 | + }, | ||
135 | + { | ||
128 | field: FormField.INPUT_PARAM, | 136 | field: FormField.INPUT_PARAM, |
129 | label: '输入参数', | 137 | label: '输入参数', |
130 | component: 'StructForm', | 138 | component: 'StructForm', |
@@ -133,8 +141,11 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => { | @@ -133,8 +141,11 @@ export const serviceSchemas = (tcpDeviceFlag: boolean): FormSchema[] => { | ||
133 | rules: [{ message: '输入参数为必填项', required: true, type: 'array' }], | 141 | rules: [{ message: '输入参数为必填项', required: true, type: 'array' }], |
134 | ifShow: !tcpDeviceFlag, | 142 | ifShow: !tcpDeviceFlag, |
135 | colProps: { span: 24 }, | 143 | colProps: { span: 24 }, |
136 | - componentProps: { | ||
137 | - hiddenAccessMode: true, | 144 | + componentProps: ({ formModel }) => { |
145 | + return { | ||
146 | + hiddenAccessMode: true, | ||
147 | + hasStructForm: formModel[FormField.HAS_STRUCT_FROM], | ||
148 | + }; | ||
138 | }, | 149 | }, |
139 | }, | 150 | }, |
140 | { | 151 | { |
@@ -185,8 +185,8 @@ export const list = [ | @@ -185,8 +185,8 @@ export const list = [ | ||
185 | { | 185 | { |
186 | deviceType: '网关/直连/网关子设备', | 186 | deviceType: '网关/直连/网关子设备', |
187 | function: '事件上报', | 187 | function: '事件上报', |
188 | - release: 'v1/devices/event/${deviceId}/${identifier}', | ||
189 | - subscribe: 'v1/devices/event/${deviceId}/${identifier}', | 188 | + release: 'v1/devices/event/${deviceId}||${deviceName}/${identifier}', |
189 | + subscribe: 'v1/devices/event/${deviceId}||${deviceName}/${identifier}', | ||
190 | platform: '订阅', | 190 | platform: '订阅', |
191 | device: '发布', | 191 | device: '发布', |
192 | }, | 192 | }, |