Showing
10 changed files
with
118 additions
and
29 deletions
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <BasicModal | 3 | <BasicModal |
4 | :maskClosable="false" | 4 | :maskClosable="false" |
5 | v-bind="$attrs" | 5 | v-bind="$attrs" |
6 | - width="60rem" | 6 | + :width="dynamicWidth" |
7 | @register="register" | 7 | @register="register" |
8 | @ok="handleSubmit" | 8 | @ok="handleSubmit" |
9 | @cancel="handleCancel" | 9 | @cancel="handleCancel" |
@@ -86,6 +86,7 @@ | @@ -86,6 +86,7 @@ | ||
86 | profileData: {}, | 86 | profileData: {}, |
87 | }); | 87 | }); |
88 | const transportTypeStr = ref(''); | 88 | const transportTypeStr = ref(''); |
89 | + const dynamicWidth = ref('55rem'); | ||
89 | const [register, { closeModal, setModalProps }] = useModalInner(async (data) => { | 90 | const [register, { closeModal, setModalProps }] = useModalInner(async (data) => { |
90 | setModalProps({ confirmLoading: false }); | 91 | setModalProps({ confirmLoading: false }); |
91 | current.value = 0; | 92 | current.value = 0; |
@@ -95,6 +96,7 @@ | @@ -95,6 +96,7 @@ | ||
95 | isEditId.value = data.record !== undefined ? data.record.id : null; | 96 | isEditId.value = data.record !== undefined ? data.record.id : null; |
96 | isEditCreatTime.value = data.record !== undefined ? data.record.createTime : null; | 97 | isEditCreatTime.value = data.record !== undefined ? data.record.createTime : null; |
97 | if (!unref(isViewDetail)) { | 98 | if (!unref(isViewDetail)) { |
99 | + dynamicWidth.value = 55 + 'rem'; | ||
98 | const title = !unref(isUpdate) ? '编辑设备配置' : '新增设备配置'; | 100 | const title = !unref(isUpdate) ? '编辑设备配置' : '新增设备配置'; |
99 | setModalProps({ title, showOkBtn: true, showCancelBtn: true }); | 101 | setModalProps({ title, showOkBtn: true, showCancelBtn: true }); |
100 | if (!unref(isUpdate)) { | 102 | if (!unref(isUpdate)) { |
@@ -103,6 +105,7 @@ | @@ -103,6 +105,7 @@ | ||
103 | handleStepNext(false, res); | 105 | handleStepNext(false, res); |
104 | } | 106 | } |
105 | } else { | 107 | } else { |
108 | + dynamicWidth.value = 60 + 'rem'; | ||
106 | setModalProps({ showOkBtn: false, showCancelBtn: false, title: '设备配置详情' }); | 109 | setModalProps({ showOkBtn: false, showCancelBtn: false, title: '设备配置详情' }); |
107 | await setDeviceConfEditFormData(res); | 110 | await setDeviceConfEditFormData(res); |
108 | await setTransConfEditFormData(res); | 111 | await setTransConfEditFormData(res); |
@@ -21,6 +21,11 @@ export const steps = [ | @@ -21,6 +21,11 @@ export const steps = [ | ||
21 | 21 | ||
22 | export const physicalColumn: BasicColumn[] = [ | 22 | export const physicalColumn: BasicColumn[] = [ |
23 | { | 23 | { |
24 | + title: '功能类型', | ||
25 | + dataIndex: 'dType', | ||
26 | + width: 90, | ||
27 | + }, | ||
28 | + { | ||
24 | title: '功能名称', | 29 | title: '功能名称', |
25 | dataIndex: 'name', | 30 | dataIndex: 'name', |
26 | width: 90, | 31 | width: 90, |
@@ -410,6 +415,7 @@ export const formSchema: FormSchema[] = [ | @@ -410,6 +415,7 @@ export const formSchema: FormSchema[] = [ | ||
410 | export const mockData: any = async () => { | 415 | export const mockData: any = async () => { |
411 | const res = await [ | 416 | const res = await [ |
412 | { | 417 | { |
418 | + dType: 'events', | ||
413 | name: '亮度百分比', | 419 | name: '亮度百分比', |
414 | type: 'Brightness', | 420 | type: 'Brightness', |
415 | transportType: 'int32(整数型)', | 421 | transportType: 'int32(整数型)', |
@@ -420,6 +426,7 @@ export const mockData: any = async () => { | @@ -420,6 +426,7 @@ export const mockData: any = async () => { | ||
420 | createTime: '2022-10-20 10:24:22', | 426 | createTime: '2022-10-20 10:24:22', |
421 | }, | 427 | }, |
422 | { | 428 | { |
429 | + dType: 'service', | ||
423 | name: '运行状态', | 430 | name: '运行状态', |
424 | type: 'RunningState', | 431 | type: 'RunningState', |
425 | transportType: 'bool(布尔型)', | 432 | transportType: 'bool(布尔型)', |
@@ -430,6 +437,7 @@ export const mockData: any = async () => { | @@ -430,6 +437,7 @@ export const mockData: any = async () => { | ||
430 | createTime: '2022-10-20 10:24:22', | 437 | createTime: '2022-10-20 10:24:22', |
431 | }, | 438 | }, |
432 | { | 439 | { |
440 | + dType: 'attr', | ||
433 | name: '设备运行状态', | 441 | name: '设备运行状态', |
434 | type: 'E_Status_UP', | 442 | type: 'E_Status_UP', |
435 | transportType: 'text(字符串)', | 443 | transportType: 'text(字符串)', |
@@ -440,6 +448,7 @@ export const mockData: any = async () => { | @@ -440,6 +448,7 @@ export const mockData: any = async () => { | ||
440 | createTime: '2022-10-20 10:24:22', | 448 | createTime: '2022-10-20 10:24:22', |
441 | }, | 449 | }, |
442 | { | 450 | { |
451 | + dType: 'attr', | ||
443 | name: '过流告警使能', | 452 | name: '过流告警使能', |
444 | type: 'OverCurrentEnable', | 453 | type: 'OverCurrentEnable', |
445 | transportType: 'struct(结构体)', | 454 | transportType: 'struct(结构体)', |
@@ -450,6 +459,7 @@ export const mockData: any = async () => { | @@ -450,6 +459,7 @@ export const mockData: any = async () => { | ||
450 | createTime: '2022-10-20 10:24:22', | 459 | createTime: '2022-10-20 10:24:22', |
451 | }, | 460 | }, |
452 | { | 461 | { |
462 | + dType: 'events', | ||
453 | name: '变频器运行状态1', | 463 | name: '变频器运行状态1', |
454 | type: 'Brightness', | 464 | type: 'Brightness', |
455 | transportType: 'int32(整数型)', | 465 | transportType: 'int32(整数型)', |
@@ -460,6 +470,7 @@ export const mockData: any = async () => { | @@ -460,6 +470,7 @@ export const mockData: any = async () => { | ||
460 | createTime: '2022-10-20 10:24:22', | 470 | createTime: '2022-10-20 10:24:22', |
461 | }, | 471 | }, |
462 | { | 472 | { |
473 | + dType: 'service', | ||
463 | name: '产品序列号', | 474 | name: '产品序列号', |
464 | type: 'SerialNo', | 475 | type: 'SerialNo', |
465 | transportType: 'text(字符串)', | 476 | transportType: 'text(字符串)', |
@@ -470,6 +481,7 @@ export const mockData: any = async () => { | @@ -470,6 +481,7 @@ export const mockData: any = async () => { | ||
470 | createTime: '2022-10-20 10:24:22', | 481 | createTime: '2022-10-20 10:24:22', |
471 | }, | 482 | }, |
472 | { | 483 | { |
484 | + dType: 'service', | ||
473 | name: '音量百分比', | 485 | name: '音量百分比', |
474 | type: 'Volume', | 486 | type: 'Volume', |
475 | transportType: 'int32(整数型)', | 487 | transportType: 'int32(整数型)', |
@@ -480,6 +492,7 @@ export const mockData: any = async () => { | @@ -480,6 +492,7 @@ export const mockData: any = async () => { | ||
480 | createTime: '2022-10-20 10:24:22', | 492 | createTime: '2022-10-20 10:24:22', |
481 | }, | 493 | }, |
482 | { | 494 | { |
495 | + dType: 'attr', | ||
483 | name: '易释放氰化物', | 496 | name: '易释放氰化物', |
484 | type: 'easy_release_cyanide', | 497 | type: 'easy_release_cyanide', |
485 | transportType: 'double(双精度浮点型)', | 498 | transportType: 'double(双精度浮点型)', |
@@ -490,6 +503,7 @@ export const mockData: any = async () => { | @@ -490,6 +503,7 @@ export const mockData: any = async () => { | ||
490 | createTime: '2022-10-20 10:24:22', | 503 | createTime: '2022-10-20 10:24:22', |
491 | }, | 504 | }, |
492 | { | 505 | { |
506 | + dType: 'attr', | ||
493 | name: '湿度', | 507 | name: '湿度', |
494 | type: 'Humidity', | 508 | type: 'Humidity', |
495 | transportType: 'float(单精度浮点型)', | 509 | transportType: 'float(单精度浮点型)', |
@@ -500,6 +514,7 @@ export const mockData: any = async () => { | @@ -500,6 +514,7 @@ export const mockData: any = async () => { | ||
500 | createTime: '2022-10-20 10:24:22', | 514 | createTime: '2022-10-20 10:24:22', |
501 | }, | 515 | }, |
502 | { | 516 | { |
517 | + dType: 'attr', | ||
503 | name: '设备固件版本', | 518 | name: '设备固件版本', |
504 | type: 'FirmwareVersion', | 519 | type: 'FirmwareVersion', |
505 | transportType: 'text(字符串)', | 520 | transportType: 'text(字符串)', |
@@ -510,6 +525,7 @@ export const mockData: any = async () => { | @@ -510,6 +525,7 @@ export const mockData: any = async () => { | ||
510 | createTime: '2022-10-20 10:24:22', | 525 | createTime: '2022-10-20 10:24:22', |
511 | }, | 526 | }, |
512 | { | 527 | { |
528 | + dType: 'events', | ||
513 | name: '用电量', | 529 | name: '用电量', |
514 | type: 'PowerConsumption', | 530 | type: 'PowerConsumption', |
515 | transportType: 'float(单精度浮点型)', | 531 | transportType: 'float(单精度浮点型)', |
@@ -10,6 +10,8 @@ | @@ -10,6 +10,8 @@ | ||
10 | > | 10 | > |
11 | <div v-if="isViewDetail"> | 11 | <div v-if="isViewDetail"> |
12 | <Attribute v-show="activeKey === '1'" ref="AttrRef" /> | 12 | <Attribute v-show="activeKey === '1'" ref="AttrRef" /> |
13 | + <Service v-show="activeKey === '2'" ref="ServiceRef" /> | ||
14 | + <Events v-show="activeKey === '3'" ref="EventsRef" /> | ||
13 | </div> | 15 | </div> |
14 | <div v-if="!isViewDetail"> | 16 | <div v-if="!isViewDetail"> |
15 | <div> | 17 | <div> |
@@ -20,13 +22,19 @@ | @@ -20,13 +22,19 @@ | ||
20 | </Typography> | 22 | </Typography> |
21 | </div> | 23 | </div> |
22 | <Tabs type="card" v-model:activeKey="activeKey" :size="size"> | 24 | <Tabs type="card" v-model:activeKey="activeKey" :size="size"> |
23 | - <TabPane forceRender key="1" tab="属性"> | 25 | + <TabPane :disabled="attrDisable" forceRender key="1" tab="属性"> |
24 | <Attribute v-show="activeKey === '1'" ref="AttrRef" /> | 26 | <Attribute v-show="activeKey === '1'" ref="AttrRef" /> |
25 | </TabPane> | 27 | </TabPane> |
26 | - <TabPane forceRender key="2" tab="服务"> | 28 | + <TabPane :disabled="serveiceDisable" forceRender key="2" tab="服务"> |
27 | <Service v-show="activeKey === '2'" ref="ServiceRef" /> | 29 | <Service v-show="activeKey === '2'" ref="ServiceRef" /> |
28 | </TabPane> | 30 | </TabPane> |
29 | - <TabPane forceRender key="3" v-show="activeKey === '3'" tab="事件"> | 31 | + <TabPane |
32 | + :disabled="eventDisable" | ||
33 | + forceRender | ||
34 | + key="3" | ||
35 | + v-show="activeKey === '3'" | ||
36 | + tab="事件" | ||
37 | + > | ||
30 | <Events v-show="activeKey === '3'" ref="EventsRef" /> | 38 | <Events v-show="activeKey === '3'" ref="EventsRef" /> |
31 | </TabPane> | 39 | </TabPane> |
32 | </Tabs> | 40 | </Tabs> |
@@ -44,6 +52,9 @@ | @@ -44,6 +52,9 @@ | ||
44 | import { mockData } from '../physical/cpns/components/mock'; | 52 | import { mockData } from '../physical/cpns/components/mock'; |
45 | 53 | ||
46 | defineEmits(['register']); | 54 | defineEmits(['register']); |
55 | + const attrDisable = ref(false); | ||
56 | + const serveiceDisable = ref(false); | ||
57 | + const eventDisable = ref(false); | ||
47 | const blockContent = `属性一般是设备的运行状态,如当前温度等;服务是设备可被调用的方法,支持定义参数,如执行某项任务;事件则是设备上报的 | 58 | const blockContent = `属性一般是设备的运行状态,如当前温度等;服务是设备可被调用的方法,支持定义参数,如执行某项任务;事件则是设备上报的 |
48 | 通知,如告警,需要被及时处理。`; | 59 | 通知,如告警,需要被及时处理。`; |
49 | const activeKey = ref('1'); | 60 | const activeKey = ref('1'); |
@@ -54,6 +65,7 @@ | @@ -54,6 +65,7 @@ | ||
54 | const isUpdate = ref(false); | 65 | const isUpdate = ref(false); |
55 | const isViewDetail = ref(''); | 66 | const isViewDetail = ref(''); |
56 | const isText = ref(''); | 67 | const isText = ref(''); |
68 | + const dType = ref(''); | ||
57 | const allData: any = reactive({ | 69 | const allData: any = reactive({ |
58 | properties: [], | 70 | properties: [], |
59 | events: [], | 71 | events: [], |
@@ -61,28 +73,63 @@ | @@ -61,28 +73,63 @@ | ||
61 | productKey: '', | 73 | productKey: '', |
62 | _ppk: {}, | 74 | _ppk: {}, |
63 | }); | 75 | }); |
76 | + | ||
77 | + const setAttrFormData = (data: {}) => AttrRef.value?.setFormData(data); | ||
78 | + const setServiceFormData = (data: {}) => ServiceRef.value?.setFormData(data); | ||
79 | + const setEventsFormData = (data: {}) => EventsRef.value?.setFormData(data); | ||
80 | + const enums = { | ||
81 | + attr: setAttrFormData, | ||
82 | + service: setServiceFormData, | ||
83 | + events: setEventsFormData, | ||
84 | + }; | ||
85 | + function action(val, data) { | ||
86 | + let F = enums[val]; | ||
87 | + F(data); | ||
88 | + } | ||
89 | + const dynamicData = (t, a, s, e) => { | ||
90 | + switch (t) { | ||
91 | + case 'attr': | ||
92 | + activeKey.value = '1'; | ||
93 | + action(t, a); | ||
94 | + attrDisable.value = false; | ||
95 | + serveiceDisable.value = true; | ||
96 | + eventDisable.value = true; | ||
97 | + break; | ||
98 | + case 'service': | ||
99 | + activeKey.value = '2'; | ||
100 | + action(t, s); | ||
101 | + attrDisable.value = true; | ||
102 | + serveiceDisable.value = false; | ||
103 | + eventDisable.value = true; | ||
104 | + break; | ||
105 | + case 'events': | ||
106 | + activeKey.value = '3'; | ||
107 | + action(t, e); | ||
108 | + attrDisable.value = true; | ||
109 | + serveiceDisable.value = true; | ||
110 | + eventDisable.value = false; | ||
111 | + break; | ||
112 | + } | ||
113 | + }; | ||
64 | const [register, { closeModal, setModalProps }] = useModalInner(async (data) => { | 114 | const [register, { closeModal, setModalProps }] = useModalInner(async (data) => { |
65 | setModalProps({ loading: true }); | 115 | setModalProps({ loading: true }); |
66 | handleCancel(false); | 116 | handleCancel(false); |
67 | isUpdate.value = data.isUpdate; | 117 | isUpdate.value = data.isUpdate; |
68 | isViewDetail.value = data.isView; | 118 | isViewDetail.value = data.isView; |
69 | isText.value = data.isText; | 119 | isText.value = data.isText; |
120 | + dType.value = data.record?.dType; | ||
70 | if (!unref(isViewDetail)) { | 121 | if (!unref(isViewDetail)) { |
71 | const title = !unref(isUpdate) ? '编辑物模型' : '新增物模型'; | 122 | const title = !unref(isUpdate) ? '编辑物模型' : '新增物模型'; |
72 | if (!unref(isUpdate)) { | 123 | if (!unref(isUpdate)) { |
73 | nextTick(() => { | 124 | nextTick(() => { |
74 | - AttrRef.value?.setFormData(mockData.properties); | ||
75 | - ServiceRef.value?.setFormData(mockData.services); | ||
76 | - EventsRef.value?.setFormData(mockData.events); | 125 | + dynamicData(dType.value, mockData.properties, mockData.services, mockData.events); |
77 | }); | 126 | }); |
78 | } | 127 | } |
79 | setModalProps({ title, showOkBtn: true, showCancelBtn: true }); | 128 | setModalProps({ title, showOkBtn: true, showCancelBtn: true }); |
80 | } else { | 129 | } else { |
81 | setModalProps({ showOkBtn: false, showCancelBtn: false, title: '查看物模型' }); | 130 | setModalProps({ showOkBtn: false, showCancelBtn: false, title: '查看物模型' }); |
82 | nextTick(() => { | 131 | nextTick(() => { |
83 | - AttrRef.value?.setFormData(mockData.properties); | ||
84 | - ServiceRef.value?.setFormData(mockData.services); | ||
85 | - EventsRef.value?.setFormData(mockData.events); | 132 | + dynamicData(dType.value, mockData.properties, mockData.services, mockData.events); |
86 | }); | 133 | }); |
87 | } | 134 | } |
88 | setModalProps({ loading: false }); | 135 | setModalProps({ loading: false }); |
@@ -95,6 +142,9 @@ | @@ -95,6 +142,9 @@ | ||
95 | allData.properties = []; | 142 | allData.properties = []; |
96 | allData.events = []; | 143 | allData.events = []; |
97 | allData.services = []; | 144 | allData.services = []; |
145 | + attrDisable.value = false; | ||
146 | + serveiceDisable.value = false; | ||
147 | + eventDisable.value = false; | ||
98 | if (flag) { | 148 | if (flag) { |
99 | closeModal(); | 149 | closeModal(); |
100 | } | 150 | } |
@@ -5,14 +5,14 @@ | @@ -5,14 +5,14 @@ | ||
5 | <div style="display: flex"> | 5 | <div style="display: flex"> |
6 | <Input | 6 | <Input |
7 | type="number" | 7 | type="number" |
8 | - v-model:vlaue="minMaxObj.min" | 8 | + v-model:value="minMaxObj.min" |
9 | placeholder="最小值" | 9 | placeholder="最小值" |
10 | @blur="onInputBlurMin" | 10 | @blur="onInputBlurMin" |
11 | /> | 11 | /> |
12 | <span>~</span> | 12 | <span>~</span> |
13 | <Input | 13 | <Input |
14 | type="number" | 14 | type="number" |
15 | - v-model:vlaue="minMaxObj.max" | 15 | + v-model:value="minMaxObj.max" |
16 | placeholder="最大值" | 16 | placeholder="最大值" |
17 | @blur="onInputBlurMax" | 17 | @blur="onInputBlurMax" |
18 | /> | 18 | /> |
@@ -185,6 +185,7 @@ | @@ -185,6 +185,7 @@ | ||
185 | //清空数据 | 185 | //清空数据 |
186 | const resetFormData = () => { | 186 | const resetFormData = () => { |
187 | resetFields(); | 187 | resetFields(); |
188 | + outputParamData.value = []; | ||
188 | Reflect.set(minMaxObj, 'min', ''); | 189 | Reflect.set(minMaxObj, 'min', ''); |
189 | Reflect.set(minMaxObj, 'max', ''); | 190 | Reflect.set(minMaxObj, 'max', ''); |
190 | }; | 191 | }; |
@@ -3,9 +3,9 @@ | @@ -3,9 +3,9 @@ | ||
3 | <BasicForm @register="registerForm"> | 3 | <BasicForm @register="registerForm"> |
4 | <template #valueRangeSlot> | 4 | <template #valueRangeSlot> |
5 | <div style="display: flex"> | 5 | <div style="display: flex"> |
6 | - <a-input v-model:vlaue="minMaxObj.min" placeholder="最小值" @blur="onInputBlurMin" /> | 6 | + <Input v-model:value="minMaxObj.min" placeholder="最小值" @blur="onInputBlurMin" /> |
7 | <span>~</span> | 7 | <span>~</span> |
8 | - <a-input v-model:vlaue="minMaxObj.max" placeholder="最大值" @blur="onInputBlurMax" /> | 8 | + <Input v-model:value="minMaxObj.max" placeholder="最大值" @blur="onInputBlurMax" /> |
9 | </div> | 9 | </div> |
10 | </template> | 10 | </template> |
11 | <template #structSlot> | 11 | <template #structSlot> |
@@ -42,6 +42,7 @@ | @@ -42,6 +42,7 @@ | ||
42 | import { findDictItemByCode } from '/@/api/system/dict'; | 42 | import { findDictItemByCode } from '/@/api/system/dict'; |
43 | import { validateValueRangeAndStep, validateValueBool } from '../../hook/useValidateParital'; | 43 | import { validateValueRangeAndStep, validateValueBool } from '../../hook/useValidateParital'; |
44 | import { buildUUID } from '/@/utils/uuid'; | 44 | import { buildUUID } from '/@/utils/uuid'; |
45 | + import { Input } from 'ant-design-vue'; | ||
45 | 46 | ||
46 | defineEmits(['register']); | 47 | defineEmits(['register']); |
47 | const outputParamData: any = ref([]); | 48 | const outputParamData: any = ref([]); |
@@ -152,13 +153,13 @@ | @@ -152,13 +153,13 @@ | ||
152 | const childEnumSpecsDTO = [ | 153 | const childEnumSpecsDTO = [ |
153 | { | 154 | { |
154 | dataType: values.dataType, | 155 | dataType: values.dataType, |
155 | - name: '0', | ||
156 | - value: values.boolClose, | 156 | + name: values.boolClose, |
157 | + value: 0, | ||
157 | }, | 158 | }, |
158 | { | 159 | { |
159 | dataType: values.dataType, | 160 | dataType: values.dataType, |
160 | - name: '1', | ||
161 | - value: values.boolOpen, | 161 | + name: values.boolOpen, |
162 | + value: 1, | ||
162 | }, | 163 | }, |
163 | ]; | 164 | ]; |
164 | const dataSpecsList = childEnumSpecsDTO; | 165 | const dataSpecsList = childEnumSpecsDTO; |
@@ -200,7 +201,7 @@ | @@ -200,7 +201,7 @@ | ||
200 | }; | 201 | }; |
201 | }; | 202 | }; |
202 | const setFormData = (v) => { | 203 | const setFormData = (v) => { |
203 | - console.log(v); | 204 | + console.log('回显', v); |
204 | setFieldsValue(v); | 205 | setFieldsValue(v); |
205 | setFieldsValue({ | 206 | setFieldsValue({ |
206 | ...v.dataSpecs, | 207 | ...v.dataSpecs, |
@@ -39,7 +39,9 @@ | @@ -39,7 +39,9 @@ | ||
39 | import { Select } from 'ant-design-vue'; | 39 | import { Select } from 'ant-design-vue'; |
40 | import { useModal } from '/@/components/Modal'; | 40 | import { useModal } from '/@/components/Modal'; |
41 | import ConverScriptModal from './ConverScriptModal.vue'; | 41 | import ConverScriptModal from './ConverScriptModal.vue'; |
42 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
42 | 43 | ||
44 | + const { createMessage } = useMessage(); | ||
43 | const selectScript = reactive({ | 45 | const selectScript = reactive({ |
44 | script: null, | 46 | script: null, |
45 | }); | 47 | }); |
@@ -78,6 +80,10 @@ | @@ -78,6 +80,10 @@ | ||
78 | }; | 80 | }; |
79 | 81 | ||
80 | const getFormData = () => { | 82 | const getFormData = () => { |
83 | + if (!selectScript.script) { | ||
84 | + createMessage.error('请选择转换脚本'); | ||
85 | + throw '请选择转换脚本'; | ||
86 | + } | ||
81 | const value = { | 87 | const value = { |
82 | ...{ | 88 | ...{ |
83 | scriptId: selectScript.script, | 89 | scriptId: selectScript.script, |
@@ -16,16 +16,16 @@ | @@ -16,16 +16,16 @@ | ||
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"> | 19 | + <a-form-item |
20 | + label="上报数据类型" | ||
21 | + name="reportType" | ||
22 | + :rules="[{ required: true, message: '请选择上报数据类型' }]" | ||
23 | + > | ||
20 | <a-space direction="vertical"> | 24 | <a-space direction="vertical"> |
21 | <a-radio-group v-model:value="scriptForm.reportType" :options="typeOptions" /> | 25 | <a-radio-group v-model:value="scriptForm.reportType" :options="typeOptions" /> |
22 | </a-space> | 26 | </a-space> |
23 | </a-form-item> | 27 | </a-form-item> |
24 | - <a-form-item | ||
25 | - label="脚本内容" | ||
26 | - name="scriptContent" | ||
27 | - :rules="[{ required: true, message: '请输入脚本内容' }]" | ||
28 | - > | 28 | + <a-form-item label="脚本内容" name="scriptContent"> |
29 | <Card title="脚本内容" :bodyStyle="{ padding: 0, height: '280px' }"> | 29 | <Card title="脚本内容" :bodyStyle="{ padding: 0, height: '280px' }"> |
30 | <template #extra> | 30 | <template #extra> |
31 | <a-button @click="handleFormat" size="small">格式化</a-button> | 31 | <a-button @click="handleFormat" size="small">格式化</a-button> |
@@ -60,7 +60,7 @@ | @@ -60,7 +60,7 @@ | ||
60 | </div> | 60 | </div> |
61 | </template> | 61 | </template> |
62 | <script setup lang="ts"> | 62 | <script setup lang="ts"> |
63 | - import { ref, unref, reactive, onMounted, toRef } from 'vue'; | 63 | + import { ref, unref, reactive, onMounted, toRefs } from 'vue'; |
64 | import ace from 'ace-builds'; | 64 | import ace from 'ace-builds'; |
65 | import { Card, Button } from 'ant-design-vue'; | 65 | import { Card, Button } from 'ant-design-vue'; |
66 | import 'ace-builds/src-noconflict/theme-chrome'; // 默认设置的主题 | 66 | import 'ace-builds/src-noconflict/theme-chrome'; // 默认设置的主题 |
@@ -81,12 +81,12 @@ | @@ -81,12 +81,12 @@ | ||
81 | scriptContent: '', | 81 | scriptContent: '', |
82 | inputParams: '', | 82 | inputParams: '', |
83 | outputParams: '', | 83 | outputParams: '', |
84 | - reportType: ['define 16'], | 84 | + reportType: 'HEX', |
85 | }); | 85 | }); |
86 | const reportTypeOptions = reactive({ | 86 | const reportTypeOptions = reactive({ |
87 | typeOptions: [], | 87 | typeOptions: [], |
88 | }); | 88 | }); |
89 | - const typeOptions = toRef(reportTypeOptions, 'typeOptions'); | 89 | + const { typeOptions } = toRefs(reportTypeOptions); |
90 | const { createMessage } = useMessage(); | 90 | const { createMessage } = useMessage(); |
91 | const { clipboardRef, copiedRef } = useCopyToClipboard(); | 91 | const { clipboardRef, copiedRef } = useCopyToClipboard(); |
92 | const aceEditor = ref(); | 92 | const aceEditor = ref(); |
@@ -144,8 +144,16 @@ | @@ -144,8 +144,16 @@ | ||
144 | const formRef = ref(); | 144 | const formRef = ref(); |
145 | const getFormData = async () => { | 145 | const getFormData = async () => { |
146 | const value = await formRef.value.validateFields(); | 146 | const value = await formRef.value.validateFields(); |
147 | + scriptForm.scriptContent = aceEditor.value.getValue(); | ||
148 | + if (scriptForm.scriptContent == '') { | ||
149 | + createMessage.error('请编写脚本内容'); | ||
150 | + throw '请编写脚本内容'; | ||
151 | + } | ||
147 | if (!value) return; | 152 | if (!value) return; |
148 | - return value; | 153 | + return { |
154 | + ...value, | ||
155 | + ...{ scriptContent: scriptForm.scriptContent }, | ||
156 | + }; | ||
149 | }; | 157 | }; |
150 | const setFormData = (v) => { | 158 | const setFormData = (v) => { |
151 | for (let i in scriptForm) { | 159 | for (let i in scriptForm) { |
@@ -90,6 +90,7 @@ export const formSchema: FormSchema[] = [ | @@ -90,6 +90,7 @@ export const formSchema: FormSchema[] = [ | ||
90 | colProps: { | 90 | colProps: { |
91 | span: 23, | 91 | span: 23, |
92 | }, | 92 | }, |
93 | + defaultValue: 'HEX', | ||
93 | componentProps: { | 94 | componentProps: { |
94 | placeholder: '请上报数据类型', | 95 | placeholder: '请上报数据类型', |
95 | api: findDictItemByCode, | 96 | api: findDictItemByCode, |