Showing
26 changed files
with
51 additions
and
28 deletions
@@ -126,6 +126,7 @@ export interface MasterDeviceList { | @@ -126,6 +126,7 @@ export interface MasterDeviceList { | ||
126 | name: string; | 126 | name: string; |
127 | label?: string; | 127 | label?: string; |
128 | value?: string; | 128 | value?: string; |
129 | + alias?: string; | ||
129 | } | 130 | } |
130 | 131 | ||
131 | export interface ComponentInfoDetail { | 132 | export interface ComponentInfoDetail { |
@@ -135,11 +135,11 @@ | @@ -135,11 +135,11 @@ | ||
135 | time: 0, | 135 | time: 0, |
136 | }; | 136 | }; |
137 | }) as any; | 137 | }) as any; |
138 | - const { data } = message; | ||
139 | - const alarmList = data?.data; | 138 | + const { data, update } = message; |
139 | + const alarmList = data?.data || update; | ||
140 | const uniData = getReduce(alarmList); //去重得到最新的事件对象 | 140 | const uniData = getReduce(alarmList); //去重得到最新的事件对象 |
141 | 141 | ||
142 | - if (!data?.data.length) return; | 142 | + // if (!data?.data.length) return; |
143 | uniData.forEach((item) => { | 143 | uniData.forEach((item) => { |
144 | alarmStatusList.value?.forEach((item1) => { | 144 | alarmStatusList.value?.forEach((item1) => { |
145 | if (item.entityId.id == item1.id) { | 145 | if (item.entityId.id == item1.id) { |
@@ -147,8 +147,9 @@ | @@ -147,8 +147,9 @@ | ||
147 | 147 | ||
148 | const updateFn = (message: ReceiveAlarmDataCmdsMessageType) => { | 148 | const updateFn = (message: ReceiveAlarmDataCmdsMessageType) => { |
149 | const { data } = message || {}; | 149 | const { data } = message || {}; |
150 | + if (!data?.data) return; | ||
150 | const tableList = ref<any>( | 151 | const tableList = ref<any>( |
151 | - data?.data.map((item) => { | 152 | + data?.data?.map((item) => { |
152 | return { | 153 | return { |
153 | time: item.createdTime, | 154 | time: item.createdTime, |
154 | device: item.originatorName, | 155 | device: item.originatorName, |
@@ -104,7 +104,7 @@ | @@ -104,7 +104,7 @@ | ||
104 | const updateFn: MultipleDataFetchUpdateFn = async (message, deviceId, attribute) => { | 104 | const updateFn: MultipleDataFetchUpdateFn = async (message, deviceId, attribute) => { |
105 | forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { | 105 | forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { |
106 | controlList.value.forEach((item) => { | 106 | controlList.value.forEach((item) => { |
107 | - if (item.id === deviceId && item.attribute === attribute) { | 107 | + if (item.id === deviceId && item.attribute === attribute && value) { |
108 | item.checked = Boolean(getNumberValue(value)); | 108 | item.checked = Boolean(getNumberValue(value)); |
109 | } | 109 | } |
110 | }); | 110 | }); |
@@ -79,6 +79,7 @@ | @@ -79,6 +79,7 @@ | ||
79 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 79 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
80 | const { data = {} } = message; | 80 | const { data = {} } = message; |
81 | const [latest] = data[attribute] || []; | 81 | const [latest] = data[attribute] || []; |
82 | + if (!latest.length) return; | ||
82 | const [timespan, value] = latest; | 83 | const [timespan, value] = latest; |
83 | time.value = timespan; | 84 | time.value = timespan; |
84 | currentValue.value = Number(value); | 85 | currentValue.value = Number(value); |
@@ -70,6 +70,7 @@ | @@ -70,6 +70,7 @@ | ||
70 | const { data = {} } = message; | 70 | const { data = {} } = message; |
71 | const [latest] = data[attribute] || []; | 71 | const [latest] = data[attribute] || []; |
72 | const [timespan, value] = latest; | 72 | const [timespan, value] = latest; |
73 | + if (!latest.length) return; | ||
73 | time.value = timespan; | 74 | time.value = timespan; |
74 | currentValue.value = Number(value); | 75 | currentValue.value = Number(value); |
75 | }; | 76 | }; |
@@ -50,6 +50,7 @@ | @@ -50,6 +50,7 @@ | ||
50 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 50 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
51 | const { data = {} } = message; | 51 | const { data = {} } = message; |
52 | const [latest] = data[attribute] || []; | 52 | const [latest] = data[attribute] || []; |
53 | + if (!latest.length) return; | ||
53 | const [timespan, value] = latest; | 54 | const [timespan, value] = latest; |
54 | time.value = timespan; | 55 | time.value = timespan; |
55 | 56 |
@@ -65,6 +65,7 @@ | @@ -65,6 +65,7 @@ | ||
65 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 65 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
66 | const { data = {} } = message; | 66 | const { data = {} } = message; |
67 | const [latest] = data[attribute] || []; | 67 | const [latest] = data[attribute] || []; |
68 | + if (!latest.length) return; | ||
68 | const [timespan, value] = latest; | 69 | const [timespan, value] = latest; |
69 | time.value = timespan; | 70 | time.value = timespan; |
70 | currentValue.value = isNaN(value as unknown as number) ? 0 : Number(value); | 71 | currentValue.value = isNaN(value as unknown as number) ? 0 : Number(value); |
@@ -166,6 +166,7 @@ | @@ -166,6 +166,7 @@ | ||
166 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 166 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
167 | const { data = {} } = message; | 167 | const { data = {} } = message; |
168 | const [latest] = data[attribute] || []; | 168 | const [latest] = data[attribute] || []; |
169 | + if (!latest.length) return; | ||
169 | const [timespan, value] = latest; | 170 | const [timespan, value] = latest; |
170 | time.value = timespan; | 171 | time.value = timespan; |
171 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); | 172 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); |
@@ -177,6 +177,7 @@ | @@ -177,6 +177,7 @@ | ||
177 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 177 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
178 | const { data = {} } = message; | 178 | const { data = {} } = message; |
179 | const [latest] = data[attribute] || []; | 179 | const [latest] = data[attribute] || []; |
180 | + if (!latest.length) return; | ||
180 | const [timespan, value] = latest; | 181 | const [timespan, value] = latest; |
181 | time.value = timespan; | 182 | time.value = timespan; |
182 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); | 183 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); |
@@ -261,7 +261,7 @@ | @@ -261,7 +261,7 @@ | ||
261 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { | 261 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
262 | forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { | 262 | forEachGroupMessage(message, deviceId, attribute, (attribute, value) => { |
263 | series.value.forEach((item) => { | 263 | series.value.forEach((item) => { |
264 | - if (item.id === deviceId && item.attribute === attribute) { | 264 | + if (item.id === deviceId && item.attribute === attribute && value) { |
265 | item.value = getNumberValue(value); | 265 | item.value = getNumberValue(value); |
266 | // time.value = timespan; | 266 | // time.value = timespan; |
267 | } | 267 | } |
@@ -148,6 +148,7 @@ | @@ -148,6 +148,7 @@ | ||
148 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 148 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
149 | const { data = {} } = message; | 149 | const { data = {} } = message; |
150 | const [latest] = data[attribute] || []; | 150 | const [latest] = data[attribute] || []; |
151 | + if (!latest.length) return; | ||
151 | const [timespan, value] = latest; | 152 | const [timespan, value] = latest; |
152 | time.value = timespan; | 153 | time.value = timespan; |
153 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); | 154 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); |
@@ -181,6 +181,7 @@ | @@ -181,6 +181,7 @@ | ||
181 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 181 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
182 | const { data = {} } = message; | 182 | const { data = {} } = message; |
183 | const [latest] = data[attribute] || []; | 183 | const [latest] = data[attribute] || []; |
184 | + if (!latest.length) return; | ||
184 | const [timespan, value] = latest; | 185 | const [timespan, value] = latest; |
185 | time.value = timespan; | 186 | time.value = timespan; |
186 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); | 187 | updateChart(isNaN(value as unknown as number) ? 0 : Number(value)); |
@@ -157,6 +157,7 @@ | @@ -157,6 +157,7 @@ | ||
157 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 157 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
158 | const { data = {} } = message; | 158 | const { data = {} } = message; |
159 | const [latest] = data[attribute] || []; | 159 | const [latest] = data[attribute] || []; |
160 | + if (!latest.length) return; | ||
160 | const [timespan, value] = latest; | 161 | const [timespan, value] = latest; |
161 | time.value = timespan; | 162 | time.value = timespan; |
162 | updateChartFn(isNaN(value as unknown as number) ? 0 : Number(value)); | 163 | updateChartFn(isNaN(value as unknown as number) ? 0 : Number(value)); |
@@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
32 | ); | 32 | ); |
33 | const options = deviceList | 33 | const options = deviceList |
34 | .filter((item) => item.tbDeviceId === deviceRecord.deviceId) | 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 | const attKey = dataSource.map((item) => ({ | 37 | const attKey = dataSource.map((item) => ({ |
38 | ...item, | 38 | ...item, |
@@ -47,6 +47,7 @@ | @@ -47,6 +47,7 @@ | ||
47 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 47 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
48 | const { data = {} } = message; | 48 | const { data = {} } = message; |
49 | const [latest] = data[attribute] || []; | 49 | const [latest] = data[attribute] || []; |
50 | + if (!latest.length) return; | ||
50 | const [timespan, value] = latest; | 51 | const [timespan, value] = latest; |
51 | time.value = timespan; | 52 | time.value = timespan; |
52 | isOpenClose.value = Boolean(getNumberValue(value)); | 53 | isOpenClose.value = Boolean(getNumberValue(value)); |
@@ -49,6 +49,7 @@ | @@ -49,6 +49,7 @@ | ||
49 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 49 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
50 | const { data = {} } = message; | 50 | const { data = {} } = message; |
51 | const [latest] = data[attribute] || []; | 51 | const [latest] = data[attribute] || []; |
52 | + if (!latest.length) return; | ||
52 | const [timespan, value] = latest; | 53 | const [timespan, value] = latest; |
53 | time.value = timespan; | 54 | time.value = timespan; |
54 | isOpenClose.value = Boolean(getNumberValue(value)); | 55 | isOpenClose.value = Boolean(getNumberValue(value)); |
@@ -156,7 +156,6 @@ | @@ -156,7 +156,6 @@ | ||
156 | onMounted(() => { | 156 | onMounted(() => { |
157 | initial(); | 157 | initial(); |
158 | // !props.config.option.uuid && randomFn(); | 158 | // !props.config.option.uuid && randomFn(); |
159 | - !props.config.option.uuid; | ||
160 | }); | 159 | }); |
161 | 160 | ||
162 | const resize = async () => { | 161 | const resize = async () => { |
@@ -13,12 +13,12 @@ | @@ -13,12 +13,12 @@ | ||
13 | component: 'Input', | 13 | component: 'Input', |
14 | defaultValue: option.unit, | 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 | showActionButtonGroup: false, | 23 | showActionButtonGroup: false, |
24 | labelWidth: 120, | 24 | labelWidth: 120, |
@@ -86,7 +86,11 @@ | @@ -86,7 +86,11 @@ | ||
86 | const getDesign = computed(() => { | 86 | const getDesign = computed(() => { |
87 | const { persetOption, option } = props.config; | 87 | const { persetOption, option } = props.config; |
88 | const { dataSource = [] } = option || {}; | 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 | return { | 95 | return { |
92 | dataSource: dataSource?.map((item) => { | 96 | dataSource: dataSource?.map((item) => { |
@@ -97,12 +101,11 @@ | @@ -97,12 +101,11 @@ | ||
97 | unit: unit ?? presetUnit, | 101 | unit: unit ?? presetUnit, |
98 | fontColor: fontColor ?? presetFontColor, | 102 | fontColor: fontColor ?? presetFontColor, |
99 | attribute, | 103 | attribute, |
100 | - attributeName, | ||
101 | - attributeRename, | 104 | + attributeName: attributeRename || attributeName, |
102 | showDeviceName, | 105 | showDeviceName, |
103 | - deviceName, | ||
104 | - deviceRename, | 106 | + deviceName: deviceRename || deviceName, |
105 | id: deviceId, | 107 | id: deviceId, |
108 | + // lineColor: lineColor || persetLineColor, | ||
106 | }; | 109 | }; |
107 | }), | 110 | }), |
108 | }; | 111 | }; |
@@ -117,12 +120,16 @@ | @@ -117,12 +120,16 @@ | ||
117 | unref(getDesign).dataSource.map((item) => { | 120 | unref(getDesign).dataSource.map((item) => { |
118 | return { | 121 | return { |
119 | type: 'line', | 122 | type: 'line', |
120 | - name: `${item.showDeviceName || item.deviceRename || item.deviceName} - ${ | ||
121 | - item.attributeRename || item.attributeName | ||
122 | - }`, | 123 | + name: `${item.deviceName} - ${item.attributeName}`, |
123 | data: [] as { name: string; value: number }[], | 124 | data: [] as { name: string; value: number }[], |
124 | id: item.id, | 125 | id: item.id, |
125 | attribute: item.attribute, | 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,15 +138,13 @@ | ||
131 | 138 | ||
132 | const updateFn: MultipleDataFetchUpdateFn = async (message, deviceId, attribute) => { | 139 | const updateFn: MultipleDataFetchUpdateFn = async (message, deviceId, attribute) => { |
133 | legendData.value = unref(getDesign).dataSource.map((item) => { | 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 | const list: IList | any = {}; | 143 | const list: IList | any = {}; |
139 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { | 144 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
140 | list.time = timespan || list.time; | 145 | list.time = timespan || list.time; |
141 | series.value.forEach((item) => { | 146 | series.value.forEach((item) => { |
142 | - if (item.id === deviceId && item.attribute === attribute) { | 147 | + if (item.id === deviceId && item.attribute === attribute && value) { |
143 | item.data.push({ | 148 | item.data.push({ |
144 | name: formatToDateTime(list.time, 'HH:mm:ss'), | 149 | name: formatToDateTime(list.time, 'HH:mm:ss'), |
145 | value: value, | 150 | value: value, |
@@ -169,6 +174,8 @@ | @@ -169,6 +174,8 @@ | ||
169 | type, | 174 | type, |
170 | name, | 175 | name, |
171 | data, | 176 | data, |
177 | + // itemStyle, | ||
178 | + // lineStyle, | ||
172 | }; | 179 | }; |
173 | }) | 180 | }) |
174 | ), | 181 | ), |
@@ -31,6 +31,7 @@ | @@ -31,6 +31,7 @@ | ||
31 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 31 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
32 | const { data = {} } = message; | 32 | const { data = {} } = message; |
33 | const [latest] = data[attribute] || []; | 33 | const [latest] = data[attribute] || []; |
34 | + if (!latest.length) return; | ||
34 | const [_, value] = latest; | 35 | const [_, value] = latest; |
35 | currentValue.value = value; | 36 | currentValue.value = value; |
36 | }; | 37 | }; |
@@ -34,6 +34,7 @@ | @@ -34,6 +34,7 @@ | ||
34 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 34 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
35 | const { data = {} } = message; | 35 | const { data = {} } = message; |
36 | const [info] = data[attribute] || []; | 36 | const [info] = data[attribute] || []; |
37 | + if (!info.length) return; | ||
37 | const [timespan, value] = info; | 38 | const [timespan, value] = info; |
38 | currentValue.value = value; | 39 | currentValue.value = value; |
39 | time.value = timespan; | 40 | time.value = timespan; |
@@ -43,6 +43,7 @@ | @@ -43,6 +43,7 @@ | ||
43 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 43 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
44 | const { data = {} } = message; | 44 | const { data = {} } = message; |
45 | const [latest] = data[attribute] || []; | 45 | const [latest] = data[attribute] || []; |
46 | + if (!latest.length) return; | ||
46 | const [timespan, value] = latest; | 47 | const [timespan, value] = latest; |
47 | currentValue.value = value; | 48 | currentValue.value = value; |
48 | time.value = timespan; | 49 | time.value = timespan; |
@@ -40,6 +40,7 @@ | @@ -40,6 +40,7 @@ | ||
40 | const updateFn: DataFetchUpdateFn = (message, attribute) => { | 40 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
41 | const { data = {} } = message; | 41 | const { data = {} } = message; |
42 | const [info] = data[attribute] || []; | 42 | const [info] = data[attribute] || []; |
43 | + if (!info.length) return; | ||
43 | const [_, value] = info; | 44 | const [_, value] = info; |
44 | currentValue.value = value; | 45 | currentValue.value = value; |
45 | }; | 46 | }; |
@@ -89,7 +89,7 @@ | @@ -89,7 +89,7 @@ | ||
89 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { | 89 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
90 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { | 90 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
91 | percentList.value.forEach((item) => { | 91 | percentList.value.forEach((item) => { |
92 | - if (item.id === deviceId && item.attribute === attribute) { | 92 | + if (item.id === deviceId && item.attribute === attribute && value) { |
93 | item.value = getNumberValue(value); | 93 | item.value = getNumberValue(value); |
94 | time.value = timespan; | 94 | time.value = timespan; |
95 | } | 95 | } |
@@ -75,7 +75,7 @@ | @@ -75,7 +75,7 @@ | ||
75 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { | 75 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
76 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { | 76 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
77 | updateSvgList.value.forEach((item) => { | 77 | updateSvgList.value.forEach((item) => { |
78 | - if (item.id === deviceId && item.attribute === attribute) { | 78 | + if (item.id === deviceId && item.attribute === attribute && value) { |
79 | item.value = getNumberValue(value); | 79 | item.value = getNumberValue(value); |
80 | time.value = timespan; | 80 | time.value = timespan; |
81 | } | 81 | } |