Showing
6 changed files
with
54 additions
and
77 deletions
@@ -56,7 +56,7 @@ | @@ -56,7 +56,7 @@ | ||
56 | const serveiceDisable = ref(false); | 56 | const serveiceDisable = ref(false); |
57 | const eventDisable = ref(false); | 57 | const eventDisable = ref(false); |
58 | const blockContent = `属性一般是设备的运行状态,如当前温度等;服务是设备可被调用的方法,支持定义参数,如执行某项任务;事件则是设备上报的 | 58 | const blockContent = `属性一般是设备的运行状态,如当前温度等;服务是设备可被调用的方法,支持定义参数,如执行某项任务;事件则是设备上报的 |
59 | -通知,如告警,需要被及时处理。`; | 59 | + 通知,如告警,需要被及时处理。`; |
60 | const activeKey = ref('1'); | 60 | const activeKey = ref('1'); |
61 | const size = ref('small'); | 61 | const size = ref('small'); |
62 | const AttrRef = ref<InstanceType<typeof Attribute>>(); | 62 | const AttrRef = ref<InstanceType<typeof Attribute>>(); |
@@ -86,28 +86,28 @@ | @@ -86,28 +86,28 @@ | ||
86 | let F = enums[val]; | 86 | let F = enums[val]; |
87 | F(data); | 87 | F(data); |
88 | } | 88 | } |
89 | + function dynamicDisable(a, s, e) { | ||
90 | + attrDisable.value = a; | ||
91 | + serveiceDisable.value = s; | ||
92 | + eventDisable.value = e; | ||
93 | + } | ||
94 | + function dynamicActive(n, callback) { | ||
95 | + activeKey.value = n; | ||
96 | + callback; | ||
97 | + } | ||
89 | const dynamicData = (t, a, s, e) => { | 98 | const dynamicData = (t, a, s, e) => { |
90 | switch (t) { | 99 | switch (t) { |
91 | case 'attr': | 100 | case 'attr': |
92 | - activeKey.value = '1'; | ||
93 | - action(t, a); | ||
94 | - attrDisable.value = false; | ||
95 | - serveiceDisable.value = true; | ||
96 | - eventDisable.value = true; | 101 | + dynamicActive('1', action(t, a)); |
102 | + dynamicDisable(false, true, true); | ||
97 | break; | 103 | break; |
98 | case 'service': | 104 | case 'service': |
99 | - activeKey.value = '2'; | ||
100 | - action(t, s); | ||
101 | - attrDisable.value = true; | ||
102 | - serveiceDisable.value = false; | ||
103 | - eventDisable.value = true; | 105 | + dynamicActive('2', action(t, s)); |
106 | + dynamicDisable(true, false, true); | ||
104 | break; | 107 | break; |
105 | case 'events': | 108 | case 'events': |
106 | - activeKey.value = '3'; | ||
107 | - action(t, e); | ||
108 | - attrDisable.value = true; | ||
109 | - serveiceDisable.value = true; | ||
110 | - eventDisable.value = false; | 109 | + dynamicActive('3', action(t, e)); |
110 | + dynamicDisable(true, true, false); | ||
111 | break; | 111 | break; |
112 | } | 112 | } |
113 | }; | 113 | }; |
@@ -22,8 +22,7 @@ | @@ -22,8 +22,7 @@ | ||
22 | import { attrSchemas } from './config'; | 22 | import { attrSchemas } from './config'; |
23 | import { useModal } from '/@/components/Modal'; | 23 | import { useModal } from '/@/components/Modal'; |
24 | import { validateValueStruct } from '../hook/useValidateParital'; | 24 | import { validateValueStruct } from '../hook/useValidateParital'; |
25 | - import { useChangeTypeGetTypeForm } from '../hook/useTypeGetForm'; | ||
26 | - import { buildUUID } from '/@/utils/uuid'; | 25 | + import { useChangeTypeGetTypeForm, useGetInOrOutData } from '../hook/useTypeGetForm'; |
27 | import AddParamsModal from './components/AddParamsModal.vue'; | 26 | import AddParamsModal from './components/AddParamsModal.vue'; |
28 | import CommomParam from './components/CommomParam.vue'; | 27 | import CommomParam from './components/CommomParam.vue'; |
29 | 28 | ||
@@ -44,16 +43,7 @@ | @@ -44,16 +43,7 @@ | ||
44 | showActionButtonGroup: false, | 43 | showActionButtonGroup: false, |
45 | }); | 44 | }); |
46 | 45 | ||
47 | - const getData = (d, f) => { | ||
48 | - if (f == 'input') { | ||
49 | - if (d.id !== null) { | ||
50 | - const findIndex = unref(inputParamData).findIndex((f) => f.id == d.id); | ||
51 | - if (findIndex !== -1) unref(inputParamData).splice(findIndex, 1, d); | ||
52 | - } else { | ||
53 | - unref(inputParamData).push({ ...d, id: buildUUID() }); | ||
54 | - } | ||
55 | - } | ||
56 | - }; | 46 | + const getData = (d, f) => useGetInOrOutData(d, f, unref(inputParamData), []); |
57 | 47 | ||
58 | const handleAddInParam = (b, o) => openModal(b, o); | 48 | const handleAddInParam = (b, o) => openModal(b, o); |
59 | 49 | ||
@@ -83,8 +73,7 @@ | @@ -83,8 +73,7 @@ | ||
83 | //回显结构体数据 | 73 | //回显结构体数据 |
84 | const { dataSpecsList } = v[0]; | 74 | const { dataSpecsList } = v[0]; |
85 | if (dataSpecsList !== undefined) { | 75 | if (dataSpecsList !== undefined) { |
86 | - inputParamData.value = [...new Array(dataSpecsList.length).keys()]; | ||
87 | - inputParamData.value = dataSpecsList; | 76 | + inputParamData.value = [...new Array(dataSpecsList.length).keys()] && dataSpecsList; |
88 | } | 77 | } |
89 | } catch (e) { | 78 | } catch (e) { |
90 | console.log('Attribute error info', e); | 79 | console.log('Attribute error info', e); |
@@ -21,9 +21,9 @@ | @@ -21,9 +21,9 @@ | ||
21 | import { BasicForm, useForm } from '/@/components/Form'; | 21 | import { BasicForm, useForm } from '/@/components/Form'; |
22 | import { eventSchemas } from './config'; | 22 | import { eventSchemas } from './config'; |
23 | import { useModal } from '/@/components/Modal'; | 23 | import { useModal } from '/@/components/Modal'; |
24 | - import { buildUUID } from '/@/utils/uuid'; | ||
25 | import AddParamsModal from './components/AddParamsModal.vue'; | 24 | import AddParamsModal from './components/AddParamsModal.vue'; |
26 | import CommomParam from './components/CommomParam.vue'; | 25 | import CommomParam from './components/CommomParam.vue'; |
26 | + import { useGetInOrOutData } from '../hook/useTypeGetForm'; | ||
27 | 27 | ||
28 | const inputParamData: any = ref([]); | 28 | const inputParamData: any = ref([]); |
29 | 29 | ||
@@ -42,16 +42,7 @@ | @@ -42,16 +42,7 @@ | ||
42 | showActionButtonGroup: false, | 42 | showActionButtonGroup: false, |
43 | }); | 43 | }); |
44 | 44 | ||
45 | - const getData = (d, f) => { | ||
46 | - if (f == 'input') { | ||
47 | - if (d.id !== null) { | ||
48 | - const findIndex = unref(inputParamData).findIndex((f) => f.id == d.id); | ||
49 | - if (findIndex !== -1) unref(inputParamData).splice(findIndex, 1, d); | ||
50 | - } else { | ||
51 | - unref(inputParamData).push({ ...d, id: buildUUID() }); | ||
52 | - } | ||
53 | - } | ||
54 | - }; | 45 | + const getData = (d, f) => useGetInOrOutData(d, f, unref(inputParamData), []); |
55 | 46 | ||
56 | const handleAddInParam = (b, o) => openModal(b, o); | 47 | const handleAddInParam = (b, o) => openModal(b, o); |
57 | 48 | ||
@@ -64,8 +55,7 @@ | @@ -64,8 +55,7 @@ | ||
64 | setFieldsValue(v[0]); | 55 | setFieldsValue(v[0]); |
65 | const { outputData } = v[0]; | 56 | const { outputData } = v[0]; |
66 | if (outputData !== undefined) { | 57 | if (outputData !== undefined) { |
67 | - inputParamData.value = [...new Array(outputData.length).keys()]; | ||
68 | - inputParamData.value = outputData; | 58 | + inputParamData.value = [...new Array(outputData.length).keys()] && outputData; |
69 | } | 59 | } |
70 | }; | 60 | }; |
71 | 61 |
@@ -32,14 +32,16 @@ | @@ -32,14 +32,16 @@ | ||
32 | import { BasicForm, useForm } from '/@/components/Form'; | 32 | import { BasicForm, useForm } from '/@/components/Form'; |
33 | import { serviceSchemas } from './config'; | 33 | import { serviceSchemas } from './config'; |
34 | import { useModal } from '/@/components/Modal'; | 34 | import { useModal } from '/@/components/Modal'; |
35 | - import { buildUUID } from '/@/utils/uuid'; | ||
36 | import AddParamsModal from './components/AddParamsModal.vue'; | 35 | import AddParamsModal from './components/AddParamsModal.vue'; |
37 | import CommomParam from './components/CommomParam.vue'; | 36 | import CommomParam from './components/CommomParam.vue'; |
37 | + import { useGetInOrOutData } from '../hook/useTypeGetForm'; | ||
38 | 38 | ||
39 | const inputParamData: any = ref([]); | 39 | const inputParamData: any = ref([]); |
40 | + | ||
40 | const outputParamData: any = ref([]); | 41 | const outputParamData: any = ref([]); |
41 | 42 | ||
42 | const CommomParamInParamRef = ref<InstanceType<typeof CommomParam>>(); | 43 | const CommomParamInParamRef = ref<InstanceType<typeof CommomParam>>(); |
44 | + | ||
43 | const CommomParamOutParamRef = ref<InstanceType<typeof CommomParam>>(); | 45 | const CommomParamOutParamRef = ref<InstanceType<typeof CommomParam>>(); |
44 | 46 | ||
45 | const [registerModal, { openModal }] = useModal(); | 47 | const [registerModal, { openModal }] = useModal(); |
@@ -55,23 +57,7 @@ | @@ -55,23 +57,7 @@ | ||
55 | showActionButtonGroup: false, | 57 | showActionButtonGroup: false, |
56 | }); | 58 | }); |
57 | 59 | ||
58 | - const getData = (d, f) => { | ||
59 | - if (f == 'input') { | ||
60 | - if (d.id !== null) { | ||
61 | - const findIndex = unref(inputParamData).findIndex((f) => f.id == d.id); | ||
62 | - if (findIndex !== -1) unref(inputParamData).splice(findIndex, 1, d); | ||
63 | - } else { | ||
64 | - unref(inputParamData).push({ ...d, id: buildUUID() }); | ||
65 | - } | ||
66 | - } else { | ||
67 | - if (d.id !== null) { | ||
68 | - const findIndex = unref(outputParamData).findIndex((f) => f.id == d.id); | ||
69 | - if (findIndex !== -1) unref(outputParamData).splice(findIndex, 1, d); | ||
70 | - } else { | ||
71 | - unref(outputParamData).push({ ...d, id: buildUUID() }); | ||
72 | - } | ||
73 | - } | ||
74 | - }; | 60 | + const getData = (d, f) => useGetInOrOutData(d, f, unref(inputParamData), unref(outputParamData)); |
75 | 61 | ||
76 | const handleAddInParam = (b, o) => openModal(b, o); | 62 | const handleAddInParam = (b, o) => openModal(b, o); |
77 | 63 | ||
@@ -90,12 +76,10 @@ | @@ -90,12 +76,10 @@ | ||
90 | setFieldsValue(v[0]); | 76 | setFieldsValue(v[0]); |
91 | const { inputParams, outputParams } = v[0]; | 77 | const { inputParams, outputParams } = v[0]; |
92 | if (outputParams !== undefined) { | 78 | if (outputParams !== undefined) { |
93 | - outputParamData.value = [...new Array(outputParams.length).keys()]; | ||
94 | - outputParamData.value = outputParams; | 79 | + outputParamData.value = [...new Array(outputParams.length).keys()] && outputParams; |
95 | } | 80 | } |
96 | if (inputParams !== undefined) { | 81 | if (inputParams !== undefined) { |
97 | - inputParamData.value = [...new Array(inputParams.length).keys()]; | ||
98 | - inputParamData.value = inputParams; | 82 | + inputParamData.value = [...new Array(inputParams.length).keys()] && inputParams; |
99 | } | 83 | } |
100 | }; | 84 | }; |
101 | 85 |
@@ -21,8 +21,11 @@ | @@ -21,8 +21,11 @@ | ||
21 | import { BasicForm, useForm } from '/@/components/Form'; | 21 | import { BasicForm, useForm } from '/@/components/Form'; |
22 | import { addParamsSchemas } from '../config'; | 22 | import { addParamsSchemas } from '../config'; |
23 | import { useModal } from '/@/components/Modal'; | 23 | import { useModal } from '/@/components/Modal'; |
24 | - import { buildUUID } from '/@/utils/uuid'; | ||
25 | - import { useChangeTypeGetTypeForm, useUpdateFormExcludeStruct } from '../../hook/useTypeGetForm'; | 24 | + import { |
25 | + useChangeTypeGetTypeForm, | ||
26 | + useGetInOrOutData, | ||
27 | + useUpdateFormExcludeStruct, | ||
28 | + } from '../../hook/useTypeGetForm'; | ||
26 | import AddParamsModal from './AddParamsModal.vue'; | 29 | import AddParamsModal from './AddParamsModal.vue'; |
27 | import CommomParam from './CommomParam.vue'; | 30 | import CommomParam from './CommomParam.vue'; |
28 | 31 | ||
@@ -45,16 +48,7 @@ | @@ -45,16 +48,7 @@ | ||
45 | showActionButtonGroup: false, | 48 | showActionButtonGroup: false, |
46 | }); | 49 | }); |
47 | 50 | ||
48 | - const getData = (d, f) => { | ||
49 | - if (f === 'input') { | ||
50 | - if (d.id !== null) { | ||
51 | - const findIndex = unref(inputParamData).findIndex((f) => f.id == d.id); | ||
52 | - if (findIndex !== -1) unref(inputParamData).splice(findIndex, 1, d); | ||
53 | - } else { | ||
54 | - unref(inputParamData).push({ ...d, id: buildUUID() }); | ||
55 | - } | ||
56 | - } | ||
57 | - }; | 51 | + const getData = (d, f) => useGetInOrOutData(d, f, unref(inputParamData), []); |
58 | 52 | ||
59 | const handleAddInParam = (b, o) => openModal(b, o); | 53 | const handleAddInParam = (b, o) => openModal(b, o); |
60 | 54 |
1 | import { validateValueBool, validateValueRangeAndStep } from './useValidateParital'; | 1 | import { validateValueBool, validateValueRangeAndStep } from './useValidateParital'; |
2 | import { findDictItemByCode } from '/@/api/system/dict'; | 2 | import { findDictItemByCode } from '/@/api/system/dict'; |
3 | +import { buildUUID } from '/@/utils/uuid'; | ||
3 | 4 | ||
4 | ///根据不同数据类型得到不同表单数据 | 5 | ///根据不同数据类型得到不同表单数据 |
5 | type TForm = { | 6 | type TForm = { |
@@ -94,3 +95,22 @@ export const useUpdateFormExcludeStruct = async (F, U) => { | @@ -94,3 +95,22 @@ export const useUpdateFormExcludeStruct = async (F, U) => { | ||
94 | }, | 95 | }, |
95 | }); | 96 | }); |
96 | }; | 97 | }; |
98 | + | ||
99 | +//获取输入参数或者输出参数弹窗数据 | ||
100 | +export const useGetInOrOutData = (d, f, inputData, outputData) => { | ||
101 | + if (f == 'input') { | ||
102 | + if (d.id !== null) { | ||
103 | + const findIndex = inputData.findIndex((f) => f.id == d.id); | ||
104 | + if (findIndex !== -1) inputData.splice(findIndex, 1, d); | ||
105 | + } else { | ||
106 | + inputData.push({ ...d, id: buildUUID() }); | ||
107 | + } | ||
108 | + } else { | ||
109 | + if (d.id !== null) { | ||
110 | + const findIndex = outputData.findIndex((f) => f.id == d.id); | ||
111 | + if (findIndex !== -1) outputData.splice(findIndex, 1, d); | ||
112 | + } else { | ||
113 | + outputData.push({ ...d, id: buildUUID() }); | ||
114 | + } | ||
115 | + } | ||
116 | +}; |