Showing
31 changed files
with
129 additions
and
66 deletions
... | ... | @@ -162,9 +162,10 @@ export const step1Schemas: FormSchema[] = [ |
162 | 162 | changeEvent: 'update:value', |
163 | 163 | valueField: 'value', |
164 | 164 | componentProps: { |
165 | - type: AddressTypeEnum.HEX, | |
166 | - maxValue: Number(247).toString(16), | |
165 | + type: AddressTypeEnum.DEC, | |
166 | + maxValue: 247, | |
167 | 167 | minValue: 0, |
168 | + disabledSwitch: true, | |
168 | 169 | }, |
169 | 170 | ifShow: ({ values }) => { |
170 | 171 | return ( | ... | ... |
... | ... | @@ -389,7 +389,7 @@ |
389 | 389 | setFieldsValue({ |
390 | 390 | ...data, |
391 | 391 | code: data?.code, |
392 | - addressCode: data?.code, | |
392 | + addressCode: parseInt(data?.code || '', 16), | |
393 | 393 | }); |
394 | 394 | } |
395 | 395 | // 父组件调用获取字段值的方法 |
... | ... | @@ -398,7 +398,12 @@ |
398 | 398 | return { |
399 | 399 | ...value, |
400 | 400 | ...(value?.code || value?.addressCode |
401 | - ? { code: value?.codeType === TaskTypeEnum.CUSTOM ? value?.code : value?.addressCode } | |
401 | + ? { | |
402 | + code: | |
403 | + value?.codeType === TaskTypeEnum.CUSTOM | |
404 | + ? value?.code | |
405 | + : (value?.addressCode || '').toString(16).padStart(2, '0').toUpperCase(), | |
406 | + } | |
402 | 407 | : {}), |
403 | 408 | }; |
404 | 409 | } | ... | ... |
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | minValue?: number | string; |
19 | 19 | type?: string; |
20 | 20 | toUpperCase?: boolean; |
21 | + disabledSwitch?: boolean; | |
21 | 22 | }>(), |
22 | 23 | { |
23 | 24 | inputProps: () => ({}), |
... | ... | @@ -113,7 +114,7 @@ |
113 | 114 | |
114 | 115 | const validate = (value: string | number) => { |
115 | 116 | if (unref(inputType) === AddressTypeEnum.DEC) { |
116 | - return /^[1-9]\d*$/.test(value.toString()); | |
117 | + return /^[0-9]\d*$/.test(value.toString()); | |
117 | 118 | } else { |
118 | 119 | return /(0x)?[0-9a-fA-F]+/.test(value.toString()); |
119 | 120 | } |
... | ... | @@ -142,12 +143,12 @@ |
142 | 143 | <template> |
143 | 144 | <InputGroup compact class="!flex"> |
144 | 145 | <Select |
146 | + v-if="!disabledSwitch" | |
145 | 147 | v-model:value="inputType" |
146 | 148 | :options="addressTypeOptions" |
147 | 149 | :disabled="disabled" |
148 | 150 | class="bg-gray-200 max-w-20" |
149 | 151 | /> |
150 | - | |
151 | 152 | <Input |
152 | 153 | :value="getInputValue" |
153 | 154 | @change="handleSyncValue" | ... | ... |
... | ... | @@ -135,11 +135,11 @@ |
135 | 135 | time: 0, |
136 | 136 | }; |
137 | 137 | }) as any; |
138 | - const { data } = message; | |
139 | - const alarmList = data?.data; | |
138 | + const { data, update } = message; | |
139 | + const alarmList = data?.data || update; | |
140 | 140 | const uniData = getReduce(alarmList); //去重得到最新的事件对象 |
141 | 141 | |
142 | - if (!data?.data.length) return; | |
142 | + // if (!data?.data.length) return; | |
143 | 143 | uniData.forEach((item) => { |
144 | 144 | alarmStatusList.value?.forEach((item1) => { |
145 | 145 | if (item.entityId.id == item1.id) { | ... | ... |
... | ... | @@ -147,8 +147,9 @@ |
147 | 147 | |
148 | 148 | const updateFn = (message: ReceiveAlarmDataCmdsMessageType) => { |
149 | 149 | const { data } = message || {}; |
150 | + if (!data?.data) return; | |
150 | 151 | const tableList = ref<any>( |
151 | - data?.data.map((item) => { | |
152 | + data?.data?.map((item) => { | |
152 | 153 | return { |
153 | 154 | time: item.createdTime, |
154 | 155 | device: item.originatorName, | ... | ... |
... | ... | @@ -104,7 +104,7 @@ |
104 | 104 | const updateFn: MultipleDataFetchUpdateFn = async (message, deviceId, attribute) => { |
105 | 105 | forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { |
106 | 106 | controlList.value.forEach((item) => { |
107 | - if (item.id === deviceId && item.attribute === attribute) { | |
107 | + if (item.id === deviceId && item.attribute === attribute && value) { | |
108 | 108 | item.checked = Boolean(getNumberValue(value)); |
109 | 109 | } |
110 | 110 | }); | ... | ... |
... | ... | @@ -79,6 +79,7 @@ |
79 | 79 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
80 | 80 | const { data = {} } = message; |
81 | 81 | const [latest] = data[attribute] || []; |
82 | + if (!latest.length) return; | |
82 | 83 | const [timespan, value] = latest; |
83 | 84 | time.value = timespan; |
84 | 85 | currentValue.value = Number(value); | ... | ... |
... | ... | @@ -65,6 +65,7 @@ |
65 | 65 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
66 | 66 | const { data = {} } = message; |
67 | 67 | const [latest] = data[attribute] || []; |
68 | + if (!latest.length) return; | |
68 | 69 | const [timespan, value] = latest; |
69 | 70 | time.value = timespan; |
70 | 71 | currentValue.value = isNaN(value as unknown as number) ? 0 : Number(value); | ... | ... |
... | ... | @@ -166,6 +166,7 @@ |
166 | 166 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
167 | 167 | const { data = {} } = message; |
168 | 168 | const [latest] = data[attribute] || []; |
169 | + if (!latest.length) return; | |
169 | 170 | const [timespan, value] = latest; |
170 | 171 | time.value = timespan; |
171 | 172 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); | ... | ... |
... | ... | @@ -177,6 +177,7 @@ |
177 | 177 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
178 | 178 | const { data = {} } = message; |
179 | 179 | const [latest] = data[attribute] || []; |
180 | + if (!latest.length) return; | |
180 | 181 | const [timespan, value] = latest; |
181 | 182 | time.value = timespan; |
182 | 183 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); | ... | ... |
... | ... | @@ -261,7 +261,7 @@ |
261 | 261 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
262 | 262 | forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { |
263 | 263 | series.value.forEach((item) => { |
264 | - if (item.id === deviceId && item.attribute === attribute) { | |
264 | + if (item.id === deviceId && item.attribute === attribute && value) { | |
265 | 265 | item.value = getNumberValue(value); |
266 | 266 | // time.value = timespan; |
267 | 267 | } | ... | ... |
... | ... | @@ -148,6 +148,7 @@ |
148 | 148 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
149 | 149 | const { data = {} } = message; |
150 | 150 | const [latest] = data[attribute] || []; |
151 | + if (!latest.length) return; | |
151 | 152 | const [timespan, value] = latest; |
152 | 153 | time.value = timespan; |
153 | 154 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); | ... | ... |
... | ... | @@ -181,6 +181,7 @@ |
181 | 181 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
182 | 182 | const { data = {} } = message; |
183 | 183 | const [latest] = data[attribute] || []; |
184 | + if (!latest.length) return; | |
184 | 185 | const [timespan, value] = latest; |
185 | 186 | time.value = timespan; |
186 | 187 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); | ... | ... |
... | ... | @@ -157,6 +157,7 @@ |
157 | 157 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
158 | 158 | const { data = {} } = message; |
159 | 159 | const [latest] = data[attribute] || []; |
160 | + if (!latest.length) return; | |
160 | 161 | const [timespan, value] = latest; |
161 | 162 | time.value = timespan; |
162 | 163 | updateChartFn(isNaN(value as unknown as number) ? 0 : Number(value)); | ... | ... |
... | ... | @@ -32,7 +32,7 @@ |
32 | 32 | ); |
33 | 33 | const options = deviceList |
34 | 34 | .filter((item) => item.tbDeviceId === deviceRecord.deviceId) |
35 | - .map((item) => ({ ...item, label: item.name, value: item.tbDeviceId })); | |
35 | + .map((item) => ({ ...item, label: item.alias || item.name, value: item.tbDeviceId })); | |
36 | 36 | |
37 | 37 | const attKey = dataSource.map((item) => ({ |
38 | 38 | ...item, | ... | ... |
... | ... | @@ -47,6 +47,7 @@ |
47 | 47 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
48 | 48 | const { data = {} } = message; |
49 | 49 | const [latest] = data[attribute] || []; |
50 | + if (!latest.length) return; | |
50 | 51 | const [timespan, value] = latest; |
51 | 52 | time.value = timespan; |
52 | 53 | isOpenClose.value = Boolean(getNumberValue(value)); | ... | ... |
... | ... | @@ -49,6 +49,7 @@ |
49 | 49 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
50 | 50 | const { data = {} } = message; |
51 | 51 | const [latest] = data[attribute] || []; |
52 | + if (!latest.length) return; | |
52 | 53 | const [timespan, value] = latest; |
53 | 54 | time.value = timespan; |
54 | 55 | isOpenClose.value = Boolean(getNumberValue(value)); | ... | ... |
... | ... | @@ -15,31 +15,37 @@ |
15 | 15 | import { MultipleDataFetchUpdateFn } from '../../../hook/socket/useSocket.type'; |
16 | 16 | |
17 | 17 | interface IList { |
18 | - [key: string]: string | number; | |
18 | + [key: string]: string | number | object; | |
19 | 19 | } |
20 | 20 | |
21 | 21 | const props = defineProps<{ |
22 | 22 | config: ComponentPropsConfigType<typeof option>; |
23 | 23 | }>(); |
24 | 24 | |
25 | - const [registerTable, { setTableData, setColumns, getDataSource, redoHeight, setProps }] = | |
26 | - useTable({ showIndexColumn: false, showTableSetting: false, canResize: true, size: 'small' }); | |
27 | - | |
28 | - const getDesign = computed(() => { | |
29 | - const { persetOption, option } = props.config; | |
30 | - const { dataSource = [] } = option || {}; | |
31 | - const { unit: presetUnit, showDeviceName: presetShowDeviceName } = persetOption || {}; | |
32 | - const columns: BasicColumn[] = dataSource.map((item) => ({ | |
33 | - title: item.attributeRename || item.attributeName || item.attribute, | |
34 | - dataIndex: item.attribute, | |
25 | + const columns: BasicColumn[] = [ | |
26 | + { | |
27 | + title: '设备属性', | |
28 | + dataIndex: 'attribute', | |
29 | + width: 80, | |
30 | + ellipsis: true, | |
31 | + format(text) { | |
32 | + if (props.config.option.mode == 'SELECT_PREVIEW') return text; | |
33 | + const { uniqueArr } = unref(getDesign); | |
34 | + const values = uniqueArr.filter((item) => item[text])[0][text]; | |
35 | + return values; | |
36 | + }, | |
37 | + }, | |
38 | + { | |
39 | + title: '值', | |
40 | + dataIndex: 'value', | |
35 | 41 | width: 80, |
36 | 42 | ellipsis: true, |
37 | 43 | format(text, record) { |
38 | 44 | const value = text ? text + (record.unit || '') : ''; |
39 | 45 | return value; |
40 | 46 | }, |
41 | - })); | |
42 | - columns.push({ | |
47 | + }, | |
48 | + { | |
43 | 49 | title: '时间', |
44 | 50 | dataIndex: 'time', |
45 | 51 | width: 110, |
... | ... | @@ -47,9 +53,37 @@ |
47 | 53 | format(text) { |
48 | 54 | return formatToDateTime(text, 'YYYY-MM-DD HH:mm:ss'); |
49 | 55 | }, |
56 | + }, | |
57 | + ]; | |
58 | + | |
59 | + const [registerTable, { setTableData, getDataSource, redoHeight, setProps }] = useTable({ | |
60 | + showIndexColumn: false, | |
61 | + showTableSetting: false, | |
62 | + canResize: true, | |
63 | + size: 'small', | |
64 | + columns, | |
65 | + }); | |
66 | + | |
67 | + const getDesign = computed(() => { | |
68 | + const { persetOption, option } = props.config; | |
69 | + const { dataSource = [] } = option || {}; | |
70 | + const { unit: presetUnit, showDeviceName: presetShowDeviceName } = persetOption || {}; | |
71 | + const convert = dataSource.map((item) => { | |
72 | + return { | |
73 | + [item.attribute + '-' + item.deviceId]: item.deviceName + '-' + item.attributeName, | |
74 | + id: item.deviceId, | |
75 | + }; | |
76 | + }); | |
77 | + | |
78 | + const uniqueSet = new Set(); | |
79 | + const uniqueArr = convert.filter((obj) => { | |
80 | + const jsonString = JSON.stringify(obj); | |
81 | + const isUnique = !uniqueSet.has(jsonString); | |
82 | + uniqueSet.add(jsonString); | |
83 | + return isUnique; | |
50 | 84 | }); |
51 | 85 | return { |
52 | - columns, | |
86 | + uniqueArr, | |
53 | 87 | dataSource: dataSource?.map((item) => { |
54 | 88 | const { unit, showDeviceName } = item.componentInfo || {}; |
55 | 89 | const { attribute, attributeName, attributeRename, deviceName, deviceRename, deviceId } = |
... | ... | @@ -57,11 +91,9 @@ |
57 | 91 | return { |
58 | 92 | unit: unit ?? presetUnit, |
59 | 93 | attribute, |
60 | - attributeRename, | |
61 | - attributeName, | |
94 | + attributeName: attributeRename || attributeName, | |
62 | 95 | showDeviceName: showDeviceName ?? presetShowDeviceName, |
63 | - deviceName, | |
64 | - deviceRename, | |
96 | + deviceName: deviceRename || deviceName, | |
65 | 97 | id: deviceId, |
66 | 98 | }; |
67 | 99 | }), |
... | ... | @@ -73,29 +105,30 @@ |
73 | 105 | |
74 | 106 | const updateFn: MultipleDataFetchUpdateFn = async (message, deviceId, attribute) => { |
75 | 107 | const list: IList = {}; |
108 | + const list1: IList = {}; | |
76 | 109 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
77 | - list[attribute] = getNumberValue(value); | |
110 | + list[deviceId + attribute] = getNumberValue(value); | |
78 | 111 | list.time = timespan || list.time; |
112 | + | |
113 | + if (timespan && value) { | |
114 | + list1[attribute + '-' + deviceId] = { | |
115 | + attribute: attribute + '-' + deviceId, | |
116 | + value: value ? getNumberValue(value) : value, | |
117 | + time: timespan, | |
118 | + }; | |
119 | + } | |
79 | 120 | }); |
80 | 121 | await nextTick(); |
81 | - setTableData([list, ...toRaw(unref(getDataSource()))]); | |
122 | + setTableData([...Object.values(list1), ...toRaw(unref(getDataSource()))]); | |
82 | 123 | }; |
83 | 124 | |
84 | 125 | useMultipleDataFetch(props, updateFn); |
85 | 126 | onMounted(async () => { |
86 | - setColumns( | |
87 | - props.config.option.dataSource | |
88 | - ? unref(getDesign).columns | |
89 | - : [ | |
90 | - { title: '属性', dataIndex: 'attribute', width: 80, ellipsis: true }, | |
91 | - { title: '时间', dataIndex: 'time', width: 80, ellipsis: true }, | |
92 | - ] | |
93 | - ); | |
94 | 127 | !props.config.option.dataSource && |
95 | 128 | setTableData([ |
96 | - { attribute: '温度', time: '2023-06-29' }, | |
97 | - { attribute: '湿度', time: '2023-06-29' }, | |
98 | - { attribute: '湿度', time: '2023-06-29' }, | |
129 | + { attribute: '温度', value: 1, time: '2023-06-29' }, | |
130 | + { attribute: '湿度', value: 1, time: '2023-06-29' }, | |
131 | + { attribute: '湿度', value: 1, time: '2023-06-29' }, | |
99 | 132 | ]); |
100 | 133 | |
101 | 134 | await nextTick(); | ... | ... |
... | ... | @@ -13,12 +13,12 @@ |
13 | 13 | component: 'Input', |
14 | 14 | defaultValue: option.unit, |
15 | 15 | }, |
16 | - { | |
17 | - field: ComponentConfigFieldEnum.SHOW_DEVICE_NAME, | |
18 | - label: '显示设备名称', | |
19 | - component: 'Checkbox', | |
20 | - defaultValue: option.showDeviceName, | |
21 | - }, | |
16 | + // { | |
17 | + // field: ComponentConfigFieldEnum.SHOW_DEVICE_NAME, | |
18 | + // label: '显示设备名称', | |
19 | + // component: 'Checkbox', | |
20 | + // defaultValue: option.showDeviceName, | |
21 | + // }, | |
22 | 22 | ], |
23 | 23 | showActionButtonGroup: false, |
24 | 24 | labelWidth: 120, | ... | ... |
... | ... | @@ -86,7 +86,11 @@ |
86 | 86 | const getDesign = computed(() => { |
87 | 87 | const { persetOption, option } = props.config; |
88 | 88 | const { dataSource = [] } = option || {}; |
89 | - const { unit: presetUnit, fontColor: presetFontColor } = persetOption || {}; | |
89 | + const { | |
90 | + unit: presetUnit, | |
91 | + fontColor: presetFontColor, | |
92 | + // lineColor: persetLineColor, | |
93 | + } = persetOption || {}; | |
90 | 94 | |
91 | 95 | return { |
92 | 96 | dataSource: dataSource?.map((item) => { |
... | ... | @@ -97,12 +101,11 @@ |
97 | 101 | unit: unit ?? presetUnit, |
98 | 102 | fontColor: fontColor ?? presetFontColor, |
99 | 103 | attribute, |
100 | - attributeName, | |
101 | - attributeRename, | |
104 | + attributeName: attributeRename || attributeName, | |
102 | 105 | showDeviceName, |
103 | - deviceName, | |
104 | - deviceRename, | |
106 | + deviceName: deviceRename || deviceName, | |
105 | 107 | id: deviceId, |
108 | + // lineColor: lineColor || persetLineColor, | |
106 | 109 | }; |
107 | 110 | }), |
108 | 111 | }; |
... | ... | @@ -117,12 +120,16 @@ |
117 | 120 | unref(getDesign).dataSource.map((item) => { |
118 | 121 | return { |
119 | 122 | type: 'line', |
120 | - name: `${item.showDeviceName || item.deviceRename || item.deviceName} - ${ | |
121 | - item.attributeRename || item.attributeName | |
122 | - }`, | |
123 | + name: `${item.deviceName} - ${item.attributeName}`, | |
123 | 124 | data: [] as { name: string; value: number }[], |
124 | 125 | id: item.id, |
125 | 126 | attribute: item.attribute, |
127 | + // itemStyle: { | |
128 | + // color: item.lineColor, | |
129 | + // }, | |
130 | + // lineStyle: { | |
131 | + // color: item.lineColor, | |
132 | + // }, | |
126 | 133 | }; |
127 | 134 | }) |
128 | 135 | ); |
... | ... | @@ -131,15 +138,13 @@ |
131 | 138 | |
132 | 139 | const updateFn: MultipleDataFetchUpdateFn = async (message, deviceId, attribute) => { |
133 | 140 | legendData.value = unref(getDesign).dataSource.map((item) => { |
134 | - return `${item.deviceRename || item.deviceName} - ${ | |
135 | - item.attributeRename || item.attributeName | |
136 | - }`; | |
141 | + return `${item.deviceName} - ${item.attributeName}`; | |
137 | 142 | }); |
138 | 143 | const list: IList | any = {}; |
139 | 144 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
140 | 145 | list.time = timespan || list.time; |
141 | 146 | series.value.forEach((item) => { |
142 | - if (item.id === deviceId && item.attribute === attribute) { | |
147 | + if (item.id === deviceId && item.attribute === attribute && value) { | |
143 | 148 | item.data.push({ |
144 | 149 | name: formatToDateTime(list.time, 'HH:mm:ss'), |
145 | 150 | value: value, |
... | ... | @@ -169,6 +174,8 @@ |
169 | 174 | type, |
170 | 175 | name, |
171 | 176 | data, |
177 | + // itemStyle, | |
178 | + // lineStyle, | |
172 | 179 | }; |
173 | 180 | }) |
174 | 181 | ), | ... | ... |
... | ... | @@ -34,6 +34,7 @@ |
34 | 34 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
35 | 35 | const { data = {} } = message; |
36 | 36 | const [info] = data[attribute] || []; |
37 | + if (!info.length) return; | |
37 | 38 | const [timespan, value] = info; |
38 | 39 | currentValue.value = value; |
39 | 40 | time.value = timespan; | ... | ... |
... | ... | @@ -43,6 +43,7 @@ |
43 | 43 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
44 | 44 | const { data = {} } = message; |
45 | 45 | const [latest] = data[attribute] || []; |
46 | + if (!latest.length) return; | |
46 | 47 | const [timespan, value] = latest; |
47 | 48 | currentValue.value = value; |
48 | 49 | time.value = timespan; | ... | ... |
... | ... | @@ -89,7 +89,7 @@ |
89 | 89 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
90 | 90 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
91 | 91 | percentList.value.forEach((item) => { |
92 | - if (item.id === deviceId && item.attribute === attribute) { | |
92 | + if (item.id === deviceId && item.attribute === attribute && value) { | |
93 | 93 | item.value = getNumberValue(value); |
94 | 94 | time.value = timespan; |
95 | 95 | } | ... | ... |
... | ... | @@ -75,7 +75,7 @@ |
75 | 75 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
76 | 76 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
77 | 77 | updateSvgList.value.forEach((item) => { |
78 | - if (item.id === deviceId && item.attribute === attribute) { | |
78 | + if (item.id === deviceId && item.attribute === attribute && value) { | |
79 | 79 | item.value = getNumberValue(value); |
80 | 80 | time.value = timespan; |
81 | 81 | } | ... | ... |