Commit 53b385e5924cb08549006a5bb5371b7cc9e1eec7

Authored by loveumiko
1 parent 9f4289b3

perf: 看板组件地图新增选择单数据源结构体时选择经纬度

... ... @@ -10,7 +10,8 @@
10 10
11 11 const alert = {
12 12 [PackagesCategoryEnum.MAP]: [
13   - '地图组件,需绑定两个数据源,且数据源为同一设备。第一数据源为经度,第二数据源为纬度,否则地图组件不能正常显示。',
  13 + '1、绑定一种数据源,选择属性为结构体时,可以自行选择结构体里的值作为经纬度',
  14 + '2、绑定两个数据源,且数据源为同一设备。第一数据源为经度,第二数据源为纬度,否则地图组件不能正常显示。',
14 15 ],
15 16 };
16 17
... ...
... ... @@ -34,14 +34,6 @@
34 34 const { unit, fontColor, showDeviceName } = item.componentInfo || {};
35 35 const { deviceName, deviceRename, attribute, attributeRename, deviceId, attributeName } =
36 36 item;
37   - // return {
38   - // unit: unit ?? persetUnit,
39   - // fontColor: fontColor ?? persetFontColor,
40   - // showDeviceName: showDeviceName ?? persetShowDeviceName,
41   - // attribute,
42   - // deviceName,
43   - // deviceRename,
44   - // };
45 37 return {
46 38 unit: unit ?? presetUnit,
47 39 fontColor: fontColor ?? presetFontColor,
... ... @@ -58,7 +50,6 @@
58 50 });
59 51
60 52 const getOffset = (length: number, index: number) => {
61   - // try {
62 53 const offsetList = ref<any>([]);
63 54 switch (length) {
64 55 case 1:
... ... @@ -147,7 +138,6 @@
147 138 break;
148 139 }
149 140 return unref(offsetList);
150   - // } catch {}
151 141 };
152 142
153 143 const series = ref(
... ... @@ -263,7 +253,6 @@
263 253 series.value.forEach((item) => {
264 254 if (item.id === deviceId && item.attribute === attribute && value) {
265 255 item.value = getNumberValue(value);
266   - // time.value = timespan;
267 256 }
268 257 });
269 258 });
... ...
... ... @@ -62,7 +62,6 @@
62 62 const options = (): EChartsOption => {
63 63 const { unit, fontColor, pointerColor, maxNumber, valueSize } = unref(getDesign);
64 64
65   - // getStageColor(gradientInfo);
66 65 return {
67 66 series: [
68 67 {
... ... @@ -103,14 +102,6 @@
103 102 color: pointerColor,
104 103 },
105 104 },
106   - // anchor: {
107   - // show: true,
108   - // showAbove: true,
109   - // size: 10,
110   - // itemStyle: {
111   - // borderWidth: 4,
112   - // },
113   - // },
114 105 title: {
115 106 show: false,
116 107 },
... ...
... ... @@ -19,6 +19,9 @@
19 19 ],
20 20 });
21 21
  22 + const loading = ref(false);
  23 + const getDesign = ref();
  24 +
22 25 const getTwoMap = async (dataSource) => {
23 26 if (dataSource.length < 2) return;
24 27 dataSource = dataSource.splice(0, 2);
... ... @@ -87,8 +90,6 @@
87 90 });
88 91 };
89 92
90   - const getDesign = ref();
91   -
92 93 const [registerModal, { closeModal }] = useModalInner(async (dataSource: DataSource[]) => {
93 94 try {
94 95 getDesign.value = dataSource;
... ... @@ -133,6 +134,7 @@
133 134 return track;
134 135 };
135 136
  137 + // 单数据源选择结构体
136 138 const getSingleDataSource = async (res) => {
137 139 const [keys] = Object.keys(res);
138 140 const track: Record<'lng' | 'lat', number>[] = [];
... ... @@ -152,7 +154,7 @@
152 154 list.push(item.value);
153 155 }
154 156 });
155   - const { latitude, longitude } = unref(getDesign)?.[0]; //获取选择经纬度选项
  157 + const { latitude, longitude } = unref(getDesign)?.[0]; //获取选择经纬度选项
156 158
157 159 list.forEach((item) => {
158 160 const lng = item[longitude];
... ... @@ -165,7 +167,6 @@
165 167 const validEffective = (value = '') => {
166 168 return !!(value && !isNaN(value as unknown as number));
167 169 };
168   - const loading = ref(false);
169 170 const handleOk = async () => {
170 171 try {
171 172 await validate();
... ... @@ -179,7 +180,7 @@
179 180 ...value,
180 181 [SchemaFiled.KEYS]: value[SchemaFiled.KEYS].join(','),
181 182 });
182   - const ifSingle = unref(getDesign).length === 1 && unref(getDesign)?.[0]?.lal;
  183 + const ifSingle = unref(getDesign)?.length === 1 && unref(getDesign)?.[0]?.lal;
183 184
184 185 const track = ifSingle ? await getSingleDataSource(res) : await getMultipleDataSource(res);
185 186 emit('ok', { track, value } as HistoryModalOkEmitParams);
... ...
... ... @@ -78,7 +78,7 @@
78 78 const bindMessage = data[deviceId];
79 79 const [, values] = attribute && bindMessage?.[attribute][0];
80 80
81   - const mapValues = values ? JSON.parse(values) : [];
  81 + const mapValues = values ? JSON.parse(values) : {};
82 82 const lng = longitude && mapValues[longitude];
83 83 const lat = latitude && mapValues[latitude];
84 84
... ... @@ -89,9 +89,8 @@
89 89
90 90 const updateFn: MultipleDataFetchUpdateFn = (message, deviceId) => {
91 91 const { lal } = unref(getDesign)?.dataSource?.[0] || {};
92   -
93   - // 属性选择结构体时
94   - if (lal) {
  92 + // 属性选择结构体类型时
  93 + if (lal && unref(getDesign)?.dataSource?.length == 1) {
95 94 getOneMap(message, deviceId);
96 95 return;
97 96 }
... ... @@ -137,11 +136,3 @@
137 136 <div v-show="!loading" ref="wrapRef" :id="wrapId" class="w-full h-full no-drag"> </div>
138 137 </main>
139 138 </template>
140   -
141   -<style lang="less" scoped>
142   - // .map-spin-wrapper {
143   - // :deep(.ant-spin-container) {
144   - // @apply justify-center items-center p-2 w-full h-full;
145   - // }
146   - // }
147   -</style>
... ...