Commit edffa26c72df20492cbb2c98ca3ef988131b1048

Authored by fengtao
1 parent 43ba5387

feat:设备配置 收集物模型表单数据

@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 </div> 35 </div>
36 </template> 36 </template>
37 <script lang="ts" setup> 37 <script lang="ts" setup>
38 - import { ref, unref, reactive } from 'vue'; 38 + import { ref, unref, reactive, nextTick } from 'vue';
39 import { BasicModal, useModalInner } from '/@/components/Modal'; 39 import { BasicModal, useModalInner } from '/@/components/Modal';
40 import { Tabs, TabPane, Typography, TypographyParagraph } from 'ant-design-vue'; 40 import { Tabs, TabPane, Typography, TypographyParagraph } from 'ant-design-vue';
41 import Attribute from './cpns/Attribute.vue'; 41 import Attribute from './cpns/Attribute.vue';
@@ -70,19 +70,25 @@ @@ -70,19 +70,25 @@
70 if (!unref(isViewDetail)) { 70 if (!unref(isViewDetail)) {
71 const title = !unref(isUpdate) ? '编辑物模型' : '新增物模型'; 71 const title = !unref(isUpdate) ? '编辑物模型' : '新增物模型';
72 if (!unref(isUpdate)) { 72 if (!unref(isUpdate)) {
73 - AttrRef.value?.setFormData(mockData.properties); 73 + nextTick(() => {
  74 + AttrRef.value?.setFormData(mockData.properties);
  75 + ServiceRef.value?.setFormData(mockData.services);
  76 + EventsRef.value?.setFormData(mockData.events);
  77 + });
74 } 78 }
75 setModalProps({ title, showOkBtn: true, showCancelBtn: true }); 79 setModalProps({ title, showOkBtn: true, showCancelBtn: true });
76 - if (!unref(isUpdate)) {  
77 - }  
78 } else { 80 } else {
79 setModalProps({ showOkBtn: false, showCancelBtn: false, title: '查看物模型' }); 81 setModalProps({ showOkBtn: false, showCancelBtn: false, title: '查看物模型' });
80 AttrRef.value?.setFormData(mockData.properties); 82 AttrRef.value?.setFormData(mockData.properties);
  83 + ServiceRef.value?.setFormData(mockData.services);
  84 + EventsRef.value?.setFormData(mockData.events);
81 } 85 }
82 setModalProps({ loading: false }); 86 setModalProps({ loading: false });
83 }); 87 });
84 const handleCancel = (flag) => { 88 const handleCancel = (flag) => {
85 AttrRef.value?.resetFormData(); 89 AttrRef.value?.resetFormData();
  90 + ServiceRef.value?.resetFormData();
  91 + EventsRef.value?.resetFormData();
86 activeKey.value = '1'; 92 activeKey.value = '1';
87 allData.properties = []; 93 allData.properties = [];
88 allData.events = []; 94 allData.events = [];
@@ -92,9 +98,16 @@ @@ -92,9 +98,16 @@
92 } 98 }
93 }; 99 };
94 const handleSubmit = async () => { 100 const handleSubmit = async () => {
95 - const value = await AttrRef.value?.getFormData();  
96 - if (!value) return;  
97 - allData.properties.push(value); 101 + if (activeKey.value == '1') {
  102 + const valueAttr = await AttrRef.value?.getFormData();
  103 + allData.properties.push(valueAttr);
  104 + } else if (activeKey.value == '2') {
  105 + const valueService = await ServiceRef.value?.getFormData();
  106 + allData.services.push(valueService);
  107 + } else {
  108 + const valueEvents = await EventsRef.value?.getFormData();
  109 + allData.events.push(valueEvents);
  110 + }
98 console.log('搜集值', allData); 111 console.log('搜集值', allData);
99 closeModal(); 112 closeModal();
100 }; 113 };
@@ -50,9 +50,11 @@ @@ -50,9 +50,11 @@
50 import InputParamItem from './components/InputParamItem.vue'; 50 import InputParamItem from './components/InputParamItem.vue';
51 import AddParamsModal from './components/AddParamsModal.vue'; 51 import AddParamsModal from './components/AddParamsModal.vue';
52 import { Input } from 'ant-design-vue'; 52 import { Input } from 'ant-design-vue';
53 - import { useMessage } from '/@/hooks/web/useMessage'; 53 + // import { useMessage } from '/@/hooks/web/useMessage';
  54 + import { validateValueRangeAndStep } from '../hook/useValidateParital';
  55 + import { buildUUID } from '/@/utils/uuid';
54 56
55 - const { createMessage } = useMessage(); 57 + // const { createMessage } = useMessage();
56 const outputParamData: any = ref([]); 58 const outputParamData: any = ref([]);
57 const minMaxObj = reactive({ 59 const minMaxObj = reactive({
58 min: '', 60 min: '',
@@ -79,10 +81,11 @@ @@ -79,10 +81,11 @@
79 81
80 const getData = (d, f) => { 82 const getData = (d, f) => {
81 if (f == 'output') { 83 if (f == 'output') {
82 - unref(outputParamData).push(d);  
83 if (d.id !== null) { 84 if (d.id !== null) {
84 - const findIndex = unref(outputParamData).findIndex((f) => f.id !== d.id);  
85 - if (findIndex !== -1) unref(outputParamData).splice(findIndex, 1); 85 + const findIndex = unref(outputParamData).findIndex((f) => f.id == d.id);
  86 + if (findIndex !== -1) unref(outputParamData).splice(findIndex, 1, d);
  87 + } else {
  88 + unref(outputParamData).push({ ...d, id: buildUUID() });
86 } 89 }
87 } 90 }
88 }; 91 };
@@ -91,7 +94,7 @@ @@ -91,7 +94,7 @@
91 openModal(true, { 94 openModal(true, {
92 isUpdate: true, 95 isUpdate: true,
93 flag: 'output', 96 flag: 'output',
94 - excludeStruct: true, 97 + excludeStruct: false,
95 }); 98 });
96 }; 99 };
97 100
@@ -103,7 +106,7 @@ @@ -103,7 +106,7 @@
103 isUpdate: false, 106 isUpdate: false,
104 record: item, 107 record: item,
105 flag: 'output', 108 flag: 'output',
106 - excludeStruct: true, 109 + excludeStruct: false,
107 }); 110 });
108 }; 111 };
109 112
@@ -111,13 +114,10 @@ @@ -111,13 +114,10 @@
111 const setFormData = (v) => { 114 const setFormData = (v) => {
112 setFieldsValue(v[0]); 115 setFieldsValue(v[0]);
113 const { dataSpecsList } = v[0]; 116 const { dataSpecsList } = v[0];
114 - outputParamData.value = [...new Array(dataSpecsList.length).keys()];  
115 - outputParamData.value = v[0].dataSpecsList;  
116 - // dataSpecsList.forEach((item, index) => {  
117 - // nextTick(() => {  
118 - // unref(dynamicBindRef.outputParamItemRef)[index].setFormData(dataSpecsList)  
119 - // })  
120 - // }); 117 + if (dataSpecsList !== undefined) {
  118 + outputParamData.value = [...new Array(dataSpecsList.length).keys()];
  119 + outputParamData.value = dataSpecsList;
  120 + }
121 }; 121 };
122 //获取数据 122 //获取数据
123 const getStructList = () => { 123 const getStructList = () => {
@@ -129,14 +129,7 @@ @@ -129,14 +129,7 @@
129 const values = await validate(); 129 const values = await validate();
130 if (!values) return; 130 if (!values) return;
131 const dataSpecsList = getStructList(); 131 const dataSpecsList = getStructList();
132 - if (Number(minMaxObj.min) > Number(minMaxObj.max)) {  
133 - createMessage.error('最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16');  
134 - throw '最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16';  
135 - }  
136 - if (Number(values.step) > Number(minMaxObj.max) - Number(minMaxObj.min)) {  
137 - createMessage.error('步长不能大于取值范围的差值');  
138 - throw '步长不能大于取值范围的差值';  
139 - } 132 + validateValueRangeAndStep(Number(minMaxObj.min), Number(values.step), Number(minMaxObj.max));
140 const isStruct = values.dataType === 'STRUCT'; 133 const isStruct = values.dataType === 'STRUCT';
141 const dataSpecs = { 134 const dataSpecs = {
142 ...minMaxObj, 135 ...minMaxObj,
@@ -144,12 +137,13 @@ @@ -144,12 +137,13 @@
144 ...{ unit: values.unit }, 137 ...{ unit: values.unit },
145 ...{ dataType: values.dataType }, 138 ...{ dataType: values.dataType },
146 }; 139 };
147 - Reflect.deleteProperty(values, 'valueRange');  
148 - Reflect.deleteProperty(values, 'step');  
149 - Reflect.deleteProperty(values, 'unit');  
150 - Reflect.deleteProperty(values, 'outputParam'); 140 + const { valueRange, step, unit, outputParam, ...value } = values;
  141 + console.log(valueRange);
  142 + console.log(step);
  143 + console.log(unit);
  144 + console.log(outputParam);
151 return { 145 return {
152 - ...values, 146 + ...value,
153 ...{ dataSpecs: isStruct ? null : dataSpecs }, 147 ...{ dataSpecs: isStruct ? null : dataSpecs },
154 ...{ dataSpecsList: isStruct ? dataSpecsList : null }, 148 ...{ dataSpecsList: isStruct ? dataSpecsList : null },
155 }; 149 };
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 <template v-for="(item, index) in outputParamData" :key="item"> 6 <template v-for="(item, index) in outputParamData" :key="item">
7 <span style="display: none">{{ item }}</span> 7 <span style="display: none">{{ item }}</span>
8 <InputParamItem 8 <InputParamItem
9 - :title="item.configName" 9 + :title="item.name"
10 :item="item" 10 :item="item"
11 class="mt-4" 11 class="mt-4"
12 :index="index" 12 :index="index"
@@ -32,6 +32,7 @@ @@ -32,6 +32,7 @@
32 import { useModal } from '/@/components/Modal'; 32 import { useModal } from '/@/components/Modal';
33 import InputParamItem from './components/InputParamItem.vue'; 33 import InputParamItem from './components/InputParamItem.vue';
34 import AddParamsModal from './components/AddParamsModal.vue'; 34 import AddParamsModal from './components/AddParamsModal.vue';
  35 + import { buildUUID } from '/@/utils/uuid';
35 36
36 const outputParamData: any = ref([]); 37 const outputParamData: any = ref([]);
37 const dynamicBindRef = { 38 const dynamicBindRef = {
@@ -50,10 +51,11 @@ @@ -50,10 +51,11 @@
50 }); 51 });
51 const getData = (d, f) => { 52 const getData = (d, f) => {
52 if (f == 'output') { 53 if (f == 'output') {
53 - unref(outputParamData).push(d);  
54 if (d.id !== null) { 54 if (d.id !== null) {
55 - const findIndex = unref(outputParamData).findIndex((f) => f.id !== d.id);  
56 - if (findIndex !== -1) unref(outputParamData).splice(findIndex, 1); 55 + const findIndex = unref(outputParamData).findIndex((f) => f.id == d.id);
  56 + if (findIndex !== -1) unref(outputParamData).splice(findIndex, 1, d);
  57 + } else {
  58 + unref(outputParamData).push({ ...d, id: buildUUID() });
57 } 59 }
58 } 60 }
59 }; 61 };
@@ -76,13 +78,29 @@ @@ -76,13 +78,29 @@
76 }; 78 };
77 //回显数据 79 //回显数据
78 const setFormData = (v) => { 80 const setFormData = (v) => {
79 - setFieldsValue(v); 81 + setFieldsValue(v[0]);
  82 + const { outputData } = v[0];
  83 + if (outputData !== undefined) {
  84 + outputParamData.value = [...new Array(outputData.length).keys()];
  85 + outputParamData.value = outputData;
  86 + }
80 }; 87 };
81 //获取数据 88 //获取数据
  89 + const getStructList = () => {
  90 + const val = unref(dynamicBindRef.outputParamItemRef)?.map((item: any) => item.getFormData());
  91 + return val;
  92 + };
  93 +
82 async function getFormData() { 94 async function getFormData() {
83 const values = await validate(); 95 const values = await validate();
84 if (!values) return; 96 if (!values) return;
85 - return values; 97 + const outputData = getStructList();
  98 + const { outputParam, ...value } = values;
  99 + console.log(outputParam);
  100 + return {
  101 + ...value,
  102 + ...{ outputData },
  103 + };
86 } 104 }
87 //清空数据 105 //清空数据
88 const resetFormData = () => { 106 const resetFormData = () => {
@@ -52,6 +52,7 @@ @@ -52,6 +52,7 @@
52 import { useModal } from '/@/components/Modal'; 52 import { useModal } from '/@/components/Modal';
53 import InputParamItem from './components/InputParamItem.vue'; 53 import InputParamItem from './components/InputParamItem.vue';
54 import AddParamsModal from './components/AddParamsModal.vue'; 54 import AddParamsModal from './components/AddParamsModal.vue';
  55 + import { buildUUID } from '/@/utils/uuid';
55 56
56 const inputParamData: any = ref([]); 57 const inputParamData: any = ref([]);
57 const outputParamData: any = ref([]); 58 const outputParamData: any = ref([]);
@@ -74,16 +75,18 @@ @@ -74,16 +75,18 @@
74 75
75 const getData = (d, f) => { 76 const getData = (d, f) => {
76 if (f == 'input') { 77 if (f == 'input') {
77 - unref(inputParamData).push(d);  
78 if (d.id !== null) { 78 if (d.id !== null) {
79 - const findIndex = unref(inputParamData).findIndex((f) => f.id !== d.id);  
80 - if (findIndex !== -1) unref(inputParamData).splice(findIndex, 1); 79 + const findIndex = unref(inputParamData).findIndex((f) => f.id == d.id);
  80 + if (findIndex !== -1) unref(inputParamData).splice(findIndex, 1, d);
  81 + } else {
  82 + unref(inputParamData).push({ ...d, id: buildUUID() });
81 } 83 }
82 } else { 84 } else {
83 - unref(outputParamData).push(d);  
84 if (d.id !== null) { 85 if (d.id !== null) {
85 - const findIndex = unref(outputParamData).findIndex((f) => f.id !== d.id);  
86 - if (findIndex !== -1) unref(outputParamData).splice(findIndex, 1); 86 + const findIndex = unref(outputParamData).findIndex((f) => f.id == d.id);
  87 + if (findIndex !== -1) unref(outputParamData).splice(findIndex, 1, d);
  88 + } else {
  89 + unref(outputParamData).push({ ...d, id: buildUUID() });
87 } 90 }
88 } 91 }
89 }; 92 };
@@ -126,13 +129,41 @@ @@ -126,13 +129,41 @@
126 129
127 //回显数据 130 //回显数据
128 const setFormData = (v) => { 131 const setFormData = (v) => {
129 - setFieldsValue(v); 132 + console.log(v[0]);
  133 + setFieldsValue(v[0]);
  134 + const { inputParams, outputParams } = v[0];
  135 + if (outputParams !== undefined) {
  136 + outputParamData.value = [...new Array(outputParams.length).keys()];
  137 + outputParamData.value = outputParams;
  138 + }
  139 + if (inputParams !== undefined) {
  140 + inputParamData.value = [...new Array(inputParams.length).keys()];
  141 + inputParamData.value = inputParams;
  142 + }
  143 + };
  144 + const getInputStructList = () => {
  145 + const val = unref(dynamicBindRef.inputParamItemRef)?.map((item: any) => item.getFormData());
  146 + return val;
130 }; 147 };
  148 + const getOutputStructList = () => {
  149 + const val = unref(dynamicBindRef.outputParamItemRef)?.map((item: any) => item.getFormData());
  150 + return val;
  151 + };
  152 +
131 //获取数据 153 //获取数据
132 async function getFormData() { 154 async function getFormData() {
133 const values = await validate(); 155 const values = await validate();
134 if (!values) return; 156 if (!values) return;
135 - return values; 157 + const inputParams = getInputStructList();
  158 + const outputParams = getOutputStructList();
  159 + const { inputParam, outputParam, ...value } = values;
  160 + console.log(outputParam);
  161 + console.log(inputParam);
  162 + return {
  163 + ...value,
  164 + ...{ inputParams },
  165 + ...{ outputParams },
  166 + };
136 } 167 }
137 //清空数据 168 //清空数据
138 const resetFormData = () => { 169 const resetFormData = () => {
@@ -33,17 +33,18 @@ @@ -33,17 +33,18 @@
33 </div> 33 </div>
34 </template> 34 </template>
35 <script lang="ts" setup> 35 <script lang="ts" setup>
36 - import { reactive, ref, unref } from 'vue'; 36 + import { reactive, ref, unref, nextTick } from 'vue';
37 import { BasicForm, useForm } from '/@/components/Form'; 37 import { BasicForm, useForm } from '/@/components/Form';
38 import { addParamsSchemas } from '../config'; 38 import { addParamsSchemas } from '../config';
39 import { useModal } from '/@/components/Modal'; 39 import { useModal } from '/@/components/Modal';
40 import InputParamItem from './InputParamItem.vue'; 40 import InputParamItem from './InputParamItem.vue';
41 import AddParamsModal from './AddParamsModal.vue'; 41 import AddParamsModal from './AddParamsModal.vue';
42 import { findDictItemByCode } from '/@/api/system/dict'; 42 import { findDictItemByCode } from '/@/api/system/dict';
43 - import { useMessage } from '/@/hooks/web/useMessage'; 43 + // import { useMessage } from '/@/hooks/web/useMessage';
  44 + import { validateValueRangeAndStep } from '../../hook/useValidateParital';
44 45
45 defineEmits(['register']); 46 defineEmits(['register']);
46 - const { createMessage } = useMessage(); 47 + // const { createMessage } = useMessage();
47 const outputParamData: any = ref([]); 48 const outputParamData: any = ref([]);
48 const dynamicBindRef = { 49 const dynamicBindRef = {
49 outputParamItemRef: ref([]), 50 outputParamItemRef: ref([]),
@@ -126,30 +127,21 @@ @@ -126,30 +127,21 @@
126 const getFormData = async () => { 127 const getFormData = async () => {
127 const values = await validate(); 128 const values = await validate();
128 if (!values) return; 129 if (!values) return;
129 - if (Number(minMaxObj.min) > Number(minMaxObj.max)) {  
130 - createMessage.error('最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16');  
131 - throw '最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16';  
132 - }  
133 - if (Number(values.step) > Number(minMaxObj.max) - Number(minMaxObj.min)) {  
134 - createMessage.error('步长不能大于取值范围的差值');  
135 - throw '步长不能大于取值范围的差值';  
136 - } 130 + validateValueRangeAndStep(Number(minMaxObj.min), Number(values.step), Number(minMaxObj.max));
137 const childSpecsDTO = { 131 const childSpecsDTO = {
138 dataType: values.dataType, 132 dataType: values.dataType,
139 - max: values.max,  
140 - min: values.min,  
141 - step: values.step,  
142 - unit: values.unit,  
143 - };  
144 - const dataSpecs = {  
145 - dataType: values.dataType,  
146 - max: values.max,  
147 - min: values.min, 133 + max: minMaxObj.max,
  134 + min: minMaxObj.min,
148 step: values.step, 135 step: values.step,
149 unit: values.unit, 136 unit: values.unit,
150 }; 137 };
  138 + const dataSpecs = childSpecsDTO;
  139 + const { step, unit, valueRange, ...value } = values;
  140 + console.log(valueRange);
  141 + console.log(step);
  142 + console.log(unit);
151 return { 143 return {
152 - ...values, 144 + ...value,
153 ...{ dataSpecs }, 145 ...{ dataSpecs },
154 ...{ childSpecsDTO }, 146 ...{ childSpecsDTO },
155 ...{ 147 ...{
@@ -160,6 +152,13 @@ @@ -160,6 +152,13 @@
160 }; 152 };
161 const setFormData = (v) => { 153 const setFormData = (v) => {
162 setFieldsValue(v); 154 setFieldsValue(v);
  155 + setFieldsValue({
  156 + ...v.dataSpecs,
  157 + });
  158 + nextTick(() => {
  159 + minMaxObj.min = v?.dataSpecs?.min;
  160 + minMaxObj.max = v?.dataSpecs?.max;
  161 + });
163 }; 162 };
164 const resetFormData = () => { 163 const resetFormData = () => {
165 resetFields(); 164 resetFields();
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 isUpdate.value = data.isUpdate; 34 isUpdate.value = data.isUpdate;
35 isFlag.value = data.flag; 35 isFlag.value = data.flag;
36 excludeStruct.value = data.excludeStruct; 36 excludeStruct.value = data.excludeStruct;
37 - AddParamFormRef.value?.setFormData(data.record); 37 + !isUpdate.value ? AddParamFormRef.value?.setFormData(data.record) : '';
38 setEditData.getEditData = data.record; 38 setEditData.getEditData = data.record;
39 setModalProps({ loading: false }); 39 setModalProps({ loading: false });
40 if (excludeStruct.value) { 40 if (excludeStruct.value) {
@@ -14,8 +14,6 @@ @@ -14,8 +14,6 @@
14 </div> 14 </div>
15 </template> 15 </template>
16 <script lang="ts" setup> 16 <script lang="ts" setup>
17 - import { buildUUID } from '/@/utils/uuid';  
18 -  
19 const emit = defineEmits(['delete', 'edit']); 17 const emit = defineEmits(['delete', 'edit']);
20 const props = defineProps({ 18 const props = defineProps({
21 index: { 19 index: {
@@ -38,7 +36,6 @@ @@ -38,7 +36,6 @@
38 const handleEdit = (item, index) => { 36 const handleEdit = (item, index) => {
39 const value = { 37 const value = {
40 ...item, 38 ...item,
41 - ...{ id: buildUUID() },  
42 ...{ index }, 39 ...{ index },
43 }; 40 };
44 emit('edit', value); 41 emit('edit', value);
@@ -47,9 +44,6 @@ @@ -47,9 +44,6 @@
47 const getFormData = () => { 44 const getFormData = () => {
48 return props.item; 45 return props.item;
49 }; 46 };
50 - // const setFormData = (v) => {  
51 - // console.log(v)  
52 - // }  
53 defineExpose({ 47 defineExpose({
54 getFormData, 48 getFormData,
55 }); 49 });
  1 +import { buildUUID } from '/@/utils/uuid';
  2 +
1 export const mockData = { 3 export const mockData = {
2 _ppk: {}, 4 _ppk: {},
3 - events: [], 5 + events: [
  6 + {
  7 + createTs: 1666344382193,
  8 + custom: true,
  9 + description: '33',
  10 + eventName: '事件1',
  11 + eventType: 'ALERT_EVENT_TYPE',
  12 + identifier: 'i1',
  13 + outputData: [
  14 + {
  15 + id: buildUUID(),
  16 + custom: true,
  17 + dataSpecs: {
  18 + dataType: 'INT',
  19 + max: '20',
  20 + min: '10',
  21 + step: '3',
  22 + unit: 'W/㎡',
  23 + unitName: '太阳总辐射',
  24 + },
  25 + dataType: 'INT',
  26 + direction: 'PARAM_OUTPUT',
  27 + identifier: 'i1',
  28 + name: '参数1',
  29 + paraOrder: 0,
  30 + },
  31 + ],
  32 + productKey: 'hsrnXEfGFDv',
  33 + required: false,
  34 + },
  35 + ],
4 productKey: 'hsrnXEfGFDv', 36 productKey: 'hsrnXEfGFDv',
5 properties: [ 37 properties: [
6 { 38 {
@@ -9,6 +41,7 @@ export const mockData = { @@ -9,6 +41,7 @@ export const mockData = {
9 customFlag: true, 41 customFlag: true,
10 dataSpecsList: [ 42 dataSpecsList: [
11 { 43 {
  44 + id: buildUUID(),
12 childDataType: 'INT', 45 childDataType: 'INT',
13 childName: '测试参数1', 46 childName: '测试参数1',
14 childSpecsDTO: { 47 childSpecsDTO: {
@@ -34,6 +67,7 @@ export const mockData = { @@ -34,6 +67,7 @@ export const mockData = {
34 name: '测试参数1', 67 name: '测试参数1',
35 }, 68 },
36 { 69 {
  70 + id: buildUUID(),
37 childDataType: 'INT', 71 childDataType: 'INT',
38 childName: '测试参数2', 72 childName: '测试参数2',
39 childSpecsDTO: { 73 childSpecsDTO: {
@@ -69,5 +103,251 @@ export const mockData = { @@ -69,5 +103,251 @@ export const mockData = {
69 std: false, 103 std: false,
70 }, 104 },
71 ], 105 ],
72 - services: [], 106 + services: [
  107 + {
  108 + callType: 'ASYNC',
  109 + createTs: 1666343456853,
  110 + custom: true,
  111 + description: '4343',
  112 + identifier: 'Iide1',
  113 + inputParams: [
  114 + {
  115 + id: buildUUID(),
  116 + custom: true,
  117 + dataSpecs: {
  118 + dataType: 'INT',
  119 + max: '20',
  120 + min: '10',
  121 + step: '2',
  122 + unit: 'dS/m',
  123 + unitName: '土壤EC值',
  124 + },
  125 + dataType: 'INT',
  126 + direction: 'PARAM_INPUT',
  127 + identifier: 'i1',
  128 + name: '参数名字1',
  129 + paraOrder: 0,
  130 + },
  131 + ],
  132 + outputParams: [
  133 + {
  134 + id: buildUUID(),
  135 + custom: true,
  136 + dataSpecs: {
  137 + dataType: 'INT',
  138 + max: '20',
  139 + min: '10',
  140 + step: '3',
  141 + unit: 'pH',
  142 + unitName: 'PH值',
  143 + },
  144 + dataType: 'INT',
  145 + direction: 'PARAM_OUTPUT',
  146 + identifier: 'i2',
  147 + name: '输出参数2',
  148 + paraOrder: 0,
  149 + },
  150 + ],
  151 + productKey: 'hsrnXEfGFDv',
  152 + required: false,
  153 + serviceName: '服务1',
  154 + },
  155 + ],
73 }; 156 };
  157 +
  158 +// {
  159 +// _ppk: {},
  160 +// events: [],
  161 +// productKey: 'hsrnXEfGFDv',
  162 +// properties: [
  163 +// {
  164 +// createTs: 1666259889029,
  165 +// custom: true,
  166 +// customFlag: true,
  167 +// dataSpecsList: [
  168 +// {
  169 +// id: buildUUID(),
  170 +// childDataType: 'INT',
  171 +// childName: '测试参数1',
  172 +// childSpecsDTO: {
  173 +// dataType: 'INT',
  174 +// max: '30',
  175 +// min: '20',
  176 +// step: '1',
  177 +// unit: 'mm/hour',
  178 +// unitName: '降雨量',
  179 +// },
  180 +// custom: true,
  181 +// dataSpecs: {
  182 +// dataType: 'INT',
  183 +// max: '30',
  184 +// min: '20',
  185 +// step: '1',
  186 +// unit: 'mm/hour',
  187 +// unitName: '降雨量',
  188 +// },
  189 +// dataType: 'STRUCT',
  190 +// identifier: 'iden2',
  191 +// isStd: 0,
  192 +// name: '测试参数1',
  193 +// },
  194 +// {
  195 +// id: buildUUID(),
  196 +// childDataType: 'INT',
  197 +// childName: '测试参数2',
  198 +// childSpecsDTO: {
  199 +// dataType: 'INT',
  200 +// max: '40',
  201 +// min: '30',
  202 +// step: '2',
  203 +// unit: 'pH',
  204 +// unitName: 'PH值',
  205 +// },
  206 +// custom: true,
  207 +// dataSpecs: {
  208 +// dataType: 'INT',
  209 +// max: '40',
  210 +// min: '30',
  211 +// step: '2',
  212 +// unit: 'pH',
  213 +// unitName: 'PH值',
  214 +// },
  215 +// dataType: 'STRUCT',
  216 +// identifier: 'idne2',
  217 +// isStd: 0,
  218 +// name: '测试参数2',
  219 +// },
  220 +// ],
  221 +// dataType: 'STRUCT',
  222 +// description: '21212',
  223 +// identifier: 'iden1',
  224 +// name: '测试功能',
  225 +// productKey: 'hsrnXEfGFDv',
  226 +// required: false,
  227 +// rwFlag: 'READ_WRITE',
  228 +// std: false,
  229 +// },
  230 +// ],
  231 +// services: [],
  232 +// };
  233 +
  234 +// {
  235 +// "_ppk": {},
  236 +// "events": [],
  237 +// "productKey": "hsrnXEfGFDv",
  238 +// "properties": [
  239 +// {
  240 +// "createTs": 1666259889029,
  241 +// "custom": true,
  242 +// "customFlag": true,
  243 +// "dataSpecsList": [
  244 +// {
  245 +// "childDataType": "INT",
  246 +// "childName": "测试参数1",
  247 +// "childSpecsDTO": {
  248 +// "dataType": "INT",
  249 +// "max": "30",
  250 +// "min": "20",
  251 +// "step": "1",
  252 +// "unit": "mm/hour",
  253 +// "unitName": "降雨量"
  254 +// },
  255 +// "custom": true,
  256 +// "dataSpecs": {
  257 +// "dataType": "INT",
  258 +// "max": "30",
  259 +// "min": "20",
  260 +// "step": "1",
  261 +// "unit": "mm/hour",
  262 +// "unitName": "降雨量"
  263 +// },
  264 +// "dataType": "STRUCT",
  265 +// "identifier": "iden2",
  266 +// "isStd": 0,
  267 +// "name": "测试参数1"
  268 +// },
  269 +// {
  270 +// "childDataType": "INT",
  271 +// "childName": "测试参数2",
  272 +// "childSpecsDTO": {
  273 +// "dataType": "INT",
  274 +// "max": "40",
  275 +// "min": "30",
  276 +// "step": "2",
  277 +// "unit": "pH",
  278 +// "unitName": "PH值"
  279 +// },
  280 +// "custom": true,
  281 +// "dataSpecs": {
  282 +// "dataType": "INT",
  283 +// "max": "40",
  284 +// "min": "30",
  285 +// "step": "2",
  286 +// "unit": "pH",
  287 +// "unitName": "PH值"
  288 +// },
  289 +// "dataType": "STRUCT",
  290 +// "identifier": "idne2",
  291 +// "isStd": 0,
  292 +// "name": "测试参数2"
  293 +// }
  294 +// ],
  295 +// "dataType": "STRUCT",
  296 +// "description": "21212",
  297 +// "identifier": "iden1",
  298 +// "name": "测试功能",
  299 +// "productKey": "hsrnXEfGFDv",
  300 +// "required": false,
  301 +// "rwFlag": "READ_WRITE",
  302 +// "std": false
  303 +// }
  304 +// ],
  305 +// "services": [
  306 +// {
  307 +// "callType": "ASYNC",
  308 +// "createTs": 1666343456853,
  309 +// "custom": true,
  310 +// "description": "4343",
  311 +// "identifier": "Iide1",
  312 +// "inputParams": [
  313 +// {
  314 +// "custom": true,
  315 +// "dataSpecs": {
  316 +// "dataType": "INT",
  317 +// "max": "20",
  318 +// "min": "10",
  319 +// "step": "2",
  320 +// "unit": "dS/m",
  321 +// "unitName": "土壤EC值"
  322 +// },
  323 +// "dataType": "INT",
  324 +// "direction": "PARAM_INPUT",
  325 +// "identifier": "i1",
  326 +// "name": "参数名字1",
  327 +// "paraOrder": 0
  328 +// }
  329 +// ],
  330 +// "outputParams": [
  331 +// {
  332 +// "custom": true,
  333 +// "dataSpecs": {
  334 +// "dataType": "INT",
  335 +// "max": "20",
  336 +// "min": "10",
  337 +// "step": "3",
  338 +// "unit": "pH",
  339 +// "unitName": "PH值"
  340 +// },
  341 +// "dataType": "INT",
  342 +// "direction": "PARAM_OUTPUT",
  343 +// "identifier": "i2",
  344 +// "name": "输出参数2",
  345 +// "paraOrder": 0
  346 +// }
  347 +// ],
  348 +// "productKey": "hsrnXEfGFDv",
  349 +// "required": false,
  350 +// "serviceName": "服务1"
  351 +// }
  352 +// ]
  353 +// }
@@ -157,7 +157,7 @@ export const attrSchemas: FormSchema[] = [ @@ -157,7 +157,7 @@ export const attrSchemas: FormSchema[] = [
157 colProps: { 157 colProps: {
158 span: 24, 158 span: 24,
159 }, 159 },
160 - defaultValue: 'readonly', 160 + defaultValue: 'READ_ONLY',
161 componentProps: { 161 componentProps: {
162 placeholder: '请选择读写类型', 162 placeholder: '请选择读写类型',
163 api: findDictItemByCode, 163 api: findDictItemByCode,
@@ -263,7 +263,7 @@ export const serviceSchemas: FormSchema[] = [ @@ -263,7 +263,7 @@ export const serviceSchemas: FormSchema[] = [
263 263
264 export const eventSchemas: FormSchema[] = [ 264 export const eventSchemas: FormSchema[] = [
265 { 265 {
266 - field: 'configName', 266 + field: 'eventName',
267 label: '功能名称', 267 label: '功能名称',
268 required: true, 268 required: true,
269 component: 'Input', 269 component: 'Input',
@@ -276,7 +276,7 @@ export const eventSchemas: FormSchema[] = [ @@ -276,7 +276,7 @@ export const eventSchemas: FormSchema[] = [
276 }, 276 },
277 }, 277 },
278 { 278 {
279 - field: 'configName1', 279 + field: 'identifier',
280 label: '标识符', 280 label: '标识符',
281 required: true, 281 required: true,
282 component: 'Input', 282 component: 'Input',
@@ -289,7 +289,7 @@ export const eventSchemas: FormSchema[] = [ @@ -289,7 +289,7 @@ export const eventSchemas: FormSchema[] = [
289 }, 289 },
290 }, 290 },
291 { 291 {
292 - field: 'brand', 292 + field: 'eventType',
293 component: 'ApiRadioGroup', 293 component: 'ApiRadioGroup',
294 label: '事件类型', 294 label: '事件类型',
295 required: true, 295 required: true,
  1 +/**
  2 + * 校验部分字段
  3 + */
  4 +import { useMessage } from '/@/hooks/web/useMessage';
  5 +const { createMessage } = useMessage();
  6 +
  7 +export const validateValueRangeAndStep = (min, step, max) => {
  8 + if (min > max) {
  9 + createMessage.error('最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16');
  10 + throw '最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16';
  11 + }
  12 + if (step > max - min) {
  13 + createMessage.error('步长不能大于取值范围的差值');
  14 + throw '步长不能大于取值范围的差值';
  15 + }
  16 +};
@@ -46,11 +46,11 @@ @@ -46,11 +46,11 @@
46 const selectOptions: Ref<SelectTypes['options']> = ref([ 46 const selectOptions: Ref<SelectTypes['options']> = ref([
47 { 47 {
48 label: '电表转换脚本', 48 label: '电表转换脚本',
49 - value: 1, 49 + value: '2dadsasd212asddafd1',
50 }, 50 },
51 { 51 {
52 label: '水表转换脚本', 52 label: '水表转换脚本',
53 - value: 2, 53 + value: 'dasdads776216dasdb1212sx',
54 }, 54 },
55 ]); 55 ]);
56 onMounted(() => {}); 56 onMounted(() => {});
@@ -78,7 +78,14 @@ @@ -78,7 +78,14 @@
78 }; 78 };
79 79
80 const getFormData = () => { 80 const getFormData = () => {
81 - return selectScript; 81 + const value = {
  82 + ...{
  83 + scriptId: selectScript.script,
  84 + dataFormat: 'HEX',
  85 + type: 'TCP',
  86 + },
  87 + };
  88 + return value;
82 }; 89 };
83 const resetFormData = () => { 90 const resetFormData = () => {
84 selectScript.script = null; 91 selectScript.script = null;
@@ -16,6 +16,11 @@ @@ -16,6 +16,11 @@
16 <a-input v-if="ifAdd" v-model:value="scriptForm.scriptName" placeholder="请输入脚本名称" /> 16 <a-input v-if="ifAdd" v-model:value="scriptForm.scriptName" placeholder="请输入脚本名称" />
17 <a-input v-else v-model:value="scriptForm.inputParams" placeholder="请输入参数" /> 17 <a-input v-else v-model:value="scriptForm.inputParams" placeholder="请输入参数" />
18 </a-form-item> 18 </a-form-item>
  19 + <a-form-item label="上报数据类型" name="reportType">
  20 + <a-space direction="vertical">
  21 + <a-radio-group v-model:value="scriptForm.reportType" :options="typeOptions" />
  22 + </a-space>
  23 + </a-form-item>
19 <a-form-item 24 <a-form-item
20 label="脚本内容" 25 label="脚本内容"
21 name="scriptContent" 26 name="scriptContent"
@@ -55,7 +60,7 @@ @@ -55,7 +60,7 @@
55 </div> 60 </div>
56 </template> 61 </template>
57 <script setup lang="ts"> 62 <script setup lang="ts">
58 - import { ref, unref, reactive } from 'vue'; 63 + import { ref, unref, reactive, onMounted, toRef } from 'vue';
59 import ace from 'ace-builds'; 64 import ace from 'ace-builds';
60 import { Card, Button } from 'ant-design-vue'; 65 import { Card, Button } from 'ant-design-vue';
61 import 'ace-builds/src-noconflict/theme-chrome'; // 默认设置的主题 66 import 'ace-builds/src-noconflict/theme-chrome'; // 默认设置的主题
@@ -64,6 +69,7 @@ @@ -64,6 +69,7 @@
64 import { CopyOutlined } from '@ant-design/icons-vue'; 69 import { CopyOutlined } from '@ant-design/icons-vue';
65 import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; 70 import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
66 import { useMessage } from '/@/hooks/web/useMessage'; 71 import { useMessage } from '/@/hooks/web/useMessage';
  72 + import { findDictItemByCode } from '/@/api/system/dict';
67 73
68 defineEmits(['register']); 74 defineEmits(['register']);
69 defineProps({ 75 defineProps({
@@ -75,11 +81,24 @@ @@ -75,11 +81,24 @@
75 scriptContent: '', 81 scriptContent: '',
76 inputParams: '', 82 inputParams: '',
77 outputParams: '', 83 outputParams: '',
  84 + reportType: ['define 16'],
  85 + });
  86 + const reportTypeOptions = reactive({
  87 + typeOptions: [],
78 }); 88 });
  89 + const typeOptions = toRef(reportTypeOptions, 'typeOptions');
79 const { createMessage } = useMessage(); 90 const { createMessage } = useMessage();
80 const { clipboardRef, copiedRef } = useCopyToClipboard(); 91 const { clipboardRef, copiedRef } = useCopyToClipboard();
81 const aceEditor = ref(); 92 const aceEditor = ref();
82 const aceRef = ref(); 93 const aceRef = ref();
  94 + onMounted(async () => {
  95 + const res: any = await findDictItemByCode({
  96 + dictCode: 'report_data_type',
  97 + });
  98 + reportTypeOptions.typeOptions = res.map((m) => {
  99 + return { label: m.itemText, value: m.itemValue };
  100 + });
  101 + });
83 // 初始化编辑器 102 // 初始化编辑器
84 const initEditor = (jsScript?: string) => { 103 const initEditor = (jsScript?: string) => {
85 aceEditor.value = ace.edit(aceRef.value, { 104 aceEditor.value = ace.edit(aceRef.value, {
@@ -2,6 +2,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; @@ -2,6 +2,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table';
2 import moment from 'moment'; 2 import moment from 'moment';
3 import { h } from 'vue'; 3 import { h } from 'vue';
4 import { Tag } from 'ant-design-vue'; 4 import { Tag } from 'ant-design-vue';
  5 +import { findDictItemByCode } from '/@/api/system/dict';
5 6
6 // 表格配置 7 // 表格配置
7 export const columns: BasicColumn[] = [ 8 export const columns: BasicColumn[] = [
@@ -83,6 +84,23 @@ export const formSchema: FormSchema[] = [ @@ -83,6 +84,23 @@ export const formSchema: FormSchema[] = [
83 colProps: { span: 24 }, 84 colProps: { span: 24 },
84 }, 85 },
85 { 86 {
  87 + field: 'unit',
  88 + label: '上报数据类型',
  89 + component: 'ApiSelect',
  90 + colProps: {
  91 + span: 23,
  92 + },
  93 + componentProps: {
  94 + placeholder: '请上报数据类型',
  95 + api: findDictItemByCode,
  96 + params: {
  97 + dictCode: 'report_data_type',
  98 + },
  99 + labelField: 'itemText',
  100 + valueField: 'itemValue',
  101 + },
  102 + },
  103 + {
86 field: 'remark', 104 field: 'remark',
87 label: '', 105 label: '',
88 required: true, 106 required: true,