Commit ec9763126f2e8bf327a7bb0a8ebfd6ddb86d3c4f

Authored by fengtao
2 parents c1efd1f6 db38cf03

Merge branch 'main' into ft_local_dev

... ... @@ -29,8 +29,8 @@ export interface StructJSON {
29 29
30 30 export interface FunctionJson {
31 31 dataType?: DataType | DataType[];
32   - inputData?: DataType[];
33   - outputData?: DataType[];
  32 + inputData?: StructJSON[];
  33 + outputData?: StructJSON[];
34 34 serviceCommand?: string;
35 35 }
36 36
... ...
1 1 <template>
2 2 <div class="wrapper">
3   - <div ref="wrapRef" :style="{ height, width }"> </div>
  3 + <Spin :spinning="spinning">
  4 + <div ref="wrapRef" :style="{ height, width }"> </div>
  5 + </Spin>
4 6 <div class="right-wrap !dark:bg-dark-900">
5 7 <BasicTable
6 8 style="cursor: pointer"
... ... @@ -91,6 +93,7 @@
91 93 import { defaultSchemas } from './cpns/TimePeriodForm/config';
92 94 import { QueryWay, SchemaFiled, AggregateDataEnum } from './cpns/TimePeriodForm/config';
93 95 import { dateUtil } from '/@/utils/dateUtil';
  96 + import { Spin } from 'ant-design-vue';
94 97
95 98 interface DeviceInfo {
96 99 alarmStatus: 0 | 1;
... ... @@ -114,6 +117,7 @@
114 117 DeviceDetailDrawer,
115 118 Loading,
116 119 TimePeriodForm,
  120 + Spin,
117 121 },
118 122 props: {
119 123 width: {
... ... @@ -155,54 +159,56 @@
155 159 showSizeChanger: true,
156 160 },
157 161 afterFetch: async (data: DeviceInfo[]) => {
158   - Promise.resolve().then(() => {
159   - const BMap = (window as any).BMap;
160   - unref(BMapInstance).clearOverlays();
161   - const markerList: MarkerList[] = [];
162   - data.forEach((item) => {
163   - const {
164   - name,
165   - deviceState,
166   - deviceInfo: { longitude, latitude },
167   - } = item;
168   - const point = new BMap.Point(longitude, latitude);
169   - const rivet = deviceState === 'INACTIVE' ? djx : deviceState === 'ONLINE' ? zx : lx;
170   - const myIcon = new BMap.Icon(rivet, new BMap.Size(20, 30));
171   - const marker = new BMap.Marker(point, { icon: myIcon });
172   - const label = new BMap.Label(name, {
173   - position: point,
174   - offset: new BMap.Size(-15, -45),
175   - });
176   - label.setStyle({
177   - color: '#000',
178   - borderRadius: '5px',
179   - borderColor: '#ccc',
180   - padding: '5px',
181   - });
182   - markerList.push({ ...item, marker, label });
183   - });
184   -
185   - markerList.forEach((record) => {
186   - unref(BMapInstance).addOverlay(record.marker);
187   - unref(BMapInstance).addOverlay(record.label);
188   - const isAlarmStatus = !!record.alarmStatus;
189   - if (isAlarmStatus) {
190   - const alarmStatusClassName = 'device-status__alarm';
191   - const className = record.marker.Ec.getAttribute('class');
192   - record.marker.Ec.setAttribute('class', `${className} ${alarmStatusClassName}`);
193   - }
194   -
195   - //标注监听事件
196   - record.marker.addEventListener('click', function () {
197   - createDeviceInfoWindow(record);
198   - });
199   - });
200   - });
201   -
  162 + createMarket(data);
202 163 return data;
203 164 },
204 165 });
205 166
  167 + async function createMarket(data: DeviceInfo[]) {
  168 + const BMap = (window as any).BMap;
  169 + if (!BMap) return;
  170 + unref(BMapInstance).clearOverlays();
  171 + const markerList: MarkerList[] = [];
  172 + data.forEach((item) => {
  173 + const {
  174 + name,
  175 + deviceState,
  176 + deviceInfo: { longitude, latitude },
  177 + } = item;
  178 + const point = new BMap.Point(longitude, latitude);
  179 + const rivet = deviceState === 'INACTIVE' ? djx : deviceState === 'ONLINE' ? zx : lx;
  180 + const myIcon = new BMap.Icon(rivet, new BMap.Size(20, 30));
  181 + const marker = new BMap.Marker(point, { icon: myIcon });
  182 + const label = new BMap.Label(name, {
  183 + position: point,
  184 + offset: new BMap.Size(-15, -45),
  185 + });
  186 + label.setStyle({
  187 + color: '#000',
  188 + borderRadius: '5px',
  189 + borderColor: '#ccc',
  190 + padding: '5px',
  191 + });
  192 + markerList.push({ ...item, marker, label });
  193 + });
  194 +
  195 + markerList.forEach((record) => {
  196 + unref(BMapInstance).addOverlay(record.marker);
  197 + unref(BMapInstance).addOverlay(record.label);
  198 + const isAlarmStatus = !!record.alarmStatus;
  199 + if (isAlarmStatus) {
  200 + const alarmStatusClassName = 'device-status__alarm';
  201 + const className = record.marker.Ec.getAttribute('class');
  202 + record.marker.Ec.setAttribute('class', `${className} ${alarmStatusClassName}`);
  203 + }
  204 +
  205 + //标注监听事件
  206 + record.marker.addEventListener('click', function () {
  207 + createDeviceInfoWindow(record);
  208 + });
  209 + });
  210 + }
  211 +
206 212 async function initMap() {
207 213 await toPromise();
208 214 await nextTick();
... ... @@ -221,6 +227,7 @@
221 227 myCity.get(myFun);
222 228 }
223 229
  230 + const spinning = ref(false);
224 231 const createDeviceInfoWindow = async (record: DeviceInfo) => {
225 232 const BMap = (window as any).BMap;
226 233 entityId = record.tbDeviceId;
... ... @@ -287,7 +294,13 @@
287 294 };
288 295 // 点击表格某一行触发
289 296 const deviceRowClick = async (record) => {
290   - createDeviceInfoWindow(record);
  297 + try {
  298 + spinning.value = true;
  299 + await createDeviceInfoWindow(record);
  300 + } catch (err) {
  301 + } finally {
  302 + spinning.value = false;
  303 + }
291 304 };
292 305
293 306 // 设备信息
... ... @@ -451,6 +464,7 @@
451 464 isNull,
452 465 registerDetailDrawer,
453 466 loading,
  467 + spinning,
454 468 timePeriodRegister,
455 469 handleCancelModal,
456 470 };
... ...
... ... @@ -452,11 +452,6 @@ export const topicTableColumn: BasicColumn[] = [
452 452 width: 100,
453 453 },
454 454 {
455   - title: '操作权限',
456   - dataIndex: 'access',
457   - width: 100,
458   - },
459   - {
460 455 title: '描述',
461 456 dataIndex: 'description',
462 457 width: 100,
... ...
1 1 <script lang="ts" setup>
2 2 import { topicTableColumn } from '../device.profile.data';
3 3 import { BasicTable, useTable } from '/@/components/Table';
  4 + import { buildUUID } from '/@/utils/uuid';
  5 +
  6 + const list = [
  7 + { function: '遥测主题', class: 'v1/devices/me/telemetry' },
  8 + { function: '属性主题', class: 'v1/devices/me/attributes' },
  9 + { function: '设备上报事件主题', class: 'v1/devices/me/attributes' },
  10 + { function: '服务控制设备(RPC)主题', class: 'v1/devices/me/attributes' },
  11 + ];
  12 +
  13 + const dataSource = Array.from({ length: 10 }, (_, index) => {
  14 + const record = list[index % 4];
  15 + return {
  16 + id: buildUUID(),
  17 + ...record,
  18 + description: record.function,
  19 + };
  20 + });
  21 +
4 22 const [register] = useTable({
5 23 title: 'Topic',
  24 + showIndexColumn: false,
  25 + dataSource,
6 26 columns: topicTableColumn,
7 27 bordered: true,
8 28 showTableSetting: true,
... ...
... ... @@ -35,12 +35,16 @@
35 35
36 36 async function getFormData() {
37 37 const _values = (await validate()) as StructFormValue;
38   - const { functionName, remark, identifier, outputData: _outputData, eventType } = _values;
  38 + const { functionName, remark, identifier, outputData: _outputData = [], eventType } = _values;
39 39 if (!_values) return {} as unknown as ModelOfMatterParams;
40 40
41   - const outputData = (_outputData as unknown as StructJSON[]).map((item) =>
42   - excludeIdInStructJSON(item.dataType!)
43   - );
  41 + const outputData = (_outputData as unknown as StructJSON[]).map((item) => {
  42 + const dataType = excludeIdInStructJSON(item.dataType!);
  43 + return {
  44 + ...item,
  45 + dataType,
  46 + };
  47 + });
44 48
45 49 const value = {
46 50 functionName,
... ...
... ... @@ -58,12 +58,20 @@
58 58 } = _values;
59 59 if (!_values) return {};
60 60
61   - const outputData = (_outputData as unknown as StructJSON[]).map((item) =>
62   - excludeIdInStructJSON(item.dataType!)
63   - );
64   - const inputData = (_inputData as unknown as StructJSON[]).map((item) =>
65   - excludeIdInStructJSON(item.dataType!)
66   - );
  61 + const outputData = (_outputData as unknown as StructJSON[]).map((item) => {
  62 + const dataType = excludeIdInStructJSON(item.dataType!);
  63 + return {
  64 + ...item,
  65 + dataType,
  66 + };
  67 + });
  68 + const inputData = (_inputData as unknown as StructJSON[]).map((item) => {
  69 + const dataType = excludeIdInStructJSON(item.dataType!);
  70 + return {
  71 + ...item,
  72 + dataType,
  73 + };
  74 + });
67 75
68 76 const value = {
69 77 functionName,
... ...