Commit 53af0ee28639ea72f2df4ad01de4270d2f5673a0

Authored by fengwotao
2 parents 3c2c0c00 6fe01003

Merge branch 'main_dev' into ft

Showing 31 changed files with 129 additions and 66 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 {
@@ -162,9 +162,10 @@ export const step1Schemas: FormSchema[] = [ @@ -162,9 +162,10 @@ export const step1Schemas: FormSchema[] = [
162 changeEvent: 'update:value', 162 changeEvent: 'update:value',
163 valueField: 'value', 163 valueField: 'value',
164 componentProps: { 164 componentProps: {
165 - type: AddressTypeEnum.HEX,  
166 - maxValue: Number(247).toString(16), 165 + type: AddressTypeEnum.DEC,
  166 + maxValue: 247,
167 minValue: 0, 167 minValue: 0,
  168 + disabledSwitch: true,
168 }, 169 },
169 ifShow: ({ values }) => { 170 ifShow: ({ values }) => {
170 return ( 171 return (
@@ -389,7 +389,7 @@ @@ -389,7 +389,7 @@
389 setFieldsValue({ 389 setFieldsValue({
390 ...data, 390 ...data,
391 code: data?.code, 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,7 +398,12 @@
398 return { 398 return {
399 ...value, 399 ...value,
400 ...(value?.code || value?.addressCode 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,6 +18,7 @@
18 minValue?: number | string; 18 minValue?: number | string;
19 type?: string; 19 type?: string;
20 toUpperCase?: boolean; 20 toUpperCase?: boolean;
  21 + disabledSwitch?: boolean;
21 }>(), 22 }>(),
22 { 23 {
23 inputProps: () => ({}), 24 inputProps: () => ({}),
@@ -113,7 +114,7 @@ @@ -113,7 +114,7 @@
113 114
114 const validate = (value: string | number) => { 115 const validate = (value: string | number) => {
115 if (unref(inputType) === AddressTypeEnum.DEC) { 116 if (unref(inputType) === AddressTypeEnum.DEC) {
116 - return /^[1-9]\d*$/.test(value.toString()); 117 + return /^[0-9]\d*$/.test(value.toString());
117 } else { 118 } else {
118 return /(0x)?[0-9a-fA-F]+/.test(value.toString()); 119 return /(0x)?[0-9a-fA-F]+/.test(value.toString());
119 } 120 }
@@ -142,12 +143,12 @@ @@ -142,12 +143,12 @@
142 <template> 143 <template>
143 <InputGroup compact class="!flex"> 144 <InputGroup compact class="!flex">
144 <Select 145 <Select
  146 + v-if="!disabledSwitch"
145 v-model:value="inputType" 147 v-model:value="inputType"
146 :options="addressTypeOptions" 148 :options="addressTypeOptions"
147 :disabled="disabled" 149 :disabled="disabled"
148 class="bg-gray-200 max-w-20" 150 class="bg-gray-200 max-w-20"
149 /> 151 />
150 -  
151 <Input 152 <Input
152 :value="getInputValue" 153 :value="getInputValue"
153 @change="handleSyncValue" 154 @change="handleSyncValue"
@@ -27,7 +27,7 @@ export enum TaskTargetNameEnum { @@ -27,7 +27,7 @@ export enum TaskTargetNameEnum {
27 27
28 export enum TaskTypeEnum { 28 export enum TaskTypeEnum {
29 CUSTOM = 'CUSTOM', 29 CUSTOM = 'CUSTOM',
30 - MODBUS = 'MODBUS', 30 + MODBUS = 'MODBUS_RTU',
31 } 31 }
32 32
33 export enum TaskTypeNameEnum { 33 export enum TaskTypeNameEnum {
@@ -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 () => {
@@ -15,31 +15,37 @@ @@ -15,31 +15,37 @@
15 import { MultipleDataFetchUpdateFn } from '../../../hook/socket/useSocket.type'; 15 import { MultipleDataFetchUpdateFn } from '../../../hook/socket/useSocket.type';
16 16
17 interface IList { 17 interface IList {
18 - [key: string]: string | number; 18 + [key: string]: string | number | object;
19 } 19 }
20 20
21 const props = defineProps<{ 21 const props = defineProps<{
22 config: ComponentPropsConfigType<typeof option>; 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 width: 80, 41 width: 80,
36 ellipsis: true, 42 ellipsis: true,
37 format(text, record) { 43 format(text, record) {
38 const value = text ? text + (record.unit || '') : ''; 44 const value = text ? text + (record.unit || '') : '';
39 return value; 45 return value;
40 }, 46 },
41 - }));  
42 - columns.push({ 47 + },
  48 + {
43 title: '时间', 49 title: '时间',
44 dataIndex: 'time', 50 dataIndex: 'time',
45 width: 110, 51 width: 110,
@@ -47,9 +53,37 @@ @@ -47,9 +53,37 @@
47 format(text) { 53 format(text) {
48 return formatToDateTime(text, 'YYYY-MM-DD HH:mm:ss'); 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 return { 85 return {
52 - columns, 86 + uniqueArr,
53 dataSource: dataSource?.map((item) => { 87 dataSource: dataSource?.map((item) => {
54 const { unit, showDeviceName } = item.componentInfo || {}; 88 const { unit, showDeviceName } = item.componentInfo || {};
55 const { attribute, attributeName, attributeRename, deviceName, deviceRename, deviceId } = 89 const { attribute, attributeName, attributeRename, deviceName, deviceRename, deviceId } =
@@ -57,11 +91,9 @@ @@ -57,11 +91,9 @@
57 return { 91 return {
58 unit: unit ?? presetUnit, 92 unit: unit ?? presetUnit,
59 attribute, 93 attribute,
60 - attributeRename,  
61 - attributeName, 94 + attributeName: attributeRename || attributeName,
62 showDeviceName: showDeviceName ?? presetShowDeviceName, 95 showDeviceName: showDeviceName ?? presetShowDeviceName,
63 - deviceName,  
64 - deviceRename, 96 + deviceName: deviceRename || deviceName,
65 id: deviceId, 97 id: deviceId,
66 }; 98 };
67 }), 99 }),
@@ -73,29 +105,30 @@ @@ -73,29 +105,30 @@
73 105
74 const updateFn: MultipleDataFetchUpdateFn = async (message, deviceId, attribute) => { 106 const updateFn: MultipleDataFetchUpdateFn = async (message, deviceId, attribute) => {
75 const list: IList = {}; 107 const list: IList = {};
  108 + const list1: IList = {};
76 forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { 109 forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => {
77 - list[attribute] = getNumberValue(value); 110 + list[deviceId + attribute] = getNumberValue(value);
78 list.time = timespan || list.time; 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 await nextTick(); 121 await nextTick();
81 - setTableData([list, ...toRaw(unref(getDataSource()))]); 122 + setTableData([...Object.values(list1), ...toRaw(unref(getDataSource()))]);
82 }; 123 };
83 124
84 useMultipleDataFetch(props, updateFn); 125 useMultipleDataFetch(props, updateFn);
85 onMounted(async () => { 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 !props.config.option.dataSource && 127 !props.config.option.dataSource &&
95 setTableData([ 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 await nextTick(); 134 await nextTick();
@@ -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 }