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