Commit 699f3ff22fc624f3dfa88adc0aa642572df0a140
Merge branch 'ft_local_dev' into 'main'
fix:修改Teambitin上的问题 See merge request huang/yun-teng-iot-front!417
Showing
12 changed files
with
226 additions
and
127 deletions
@@ -80,9 +80,10 @@ export const deleteDevice = (ids: string[]) => { | @@ -80,9 +80,10 @@ export const deleteDevice = (ids: string[]) => { | ||
80 | * 查询设备配置 | 80 | * 查询设备配置 |
81 | * @param params pageSize page name | 81 | * @param params pageSize page name |
82 | */ | 82 | */ |
83 | -export const deviceProfile = () => { | 83 | +export const deviceProfile = (params) => { |
84 | return defHttp.get({ | 84 | return defHttp.get({ |
85 | url: DeviceManagerApi.DEVICE_PROFILE_URL_ME, | 85 | url: DeviceManagerApi.DEVICE_PROFILE_URL_ME, |
86 | + params, | ||
86 | }); | 87 | }); |
87 | }; | 88 | }; |
88 | 89 |
@@ -21,7 +21,7 @@ enum ScreenManagerApi { | @@ -21,7 +21,7 @@ enum ScreenManagerApi { | ||
21 | // GET_ATTRBUTELIST = '/device/keys', | 21 | // GET_ATTRBUTELIST = '/device/keys', |
22 | GET_ATTRBUTELIST = '/device/attributes/', | 22 | GET_ATTRBUTELIST = '/device/attributes/', |
23 | ALARM_PROFILE = '/alarm/profile/', | 23 | ALARM_PROFILE = '/alarm/profile/', |
24 | - MASTER_GET_DEVICE = '/device/list/master', | 24 | + MASTER_GET_DEVICE = '/device/list', |
25 | } | 25 | } |
26 | 26 | ||
27 | /** | 27 | /** |
@@ -125,8 +125,8 @@ export const byOrganizationIdGetMasterDevice = (params: { | @@ -125,8 +125,8 @@ export const byOrganizationIdGetMasterDevice = (params: { | ||
125 | }) => { | 125 | }) => { |
126 | const { organizationId, deviceProfileId } = params; | 126 | const { organizationId, deviceProfileId } = params; |
127 | return defHttp.get({ | 127 | return defHttp.get({ |
128 | - url: `${ScreenManagerApi.MASTER_GET_DEVICE}/${organizationId}`, | ||
129 | - params: { deviceProfileId }, | 128 | + url: `${ScreenManagerApi.MASTER_GET_DEVICE}`, |
129 | + params: { deviceProfileId, organizationId }, | ||
130 | }); | 130 | }); |
131 | }; | 131 | }; |
132 | //TODO-fengtao | 132 | //TODO-fengtao |
@@ -81,6 +81,9 @@ export const columns: BasicColumn[] = [ | @@ -81,6 +81,9 @@ export const columns: BasicColumn[] = [ | ||
81 | title: '名称', | 81 | title: '名称', |
82 | dataIndex: 'name', | 82 | dataIndex: 'name', |
83 | width: 120, | 83 | width: 120, |
84 | + format: (_text: string, record: Recordable) => { | ||
85 | + return record?.alias ? record?.alias : record?.name; | ||
86 | + }, | ||
84 | }, | 87 | }, |
85 | { | 88 | { |
86 | title: '设备状态', | 89 | title: '设备状态', |
@@ -447,39 +447,3 @@ export const formSchema: FormSchema[] = [ | @@ -447,39 +447,3 @@ export const formSchema: FormSchema[] = [ | ||
447 | }, | 447 | }, |
448 | }, | 448 | }, |
449 | ]; | 449 | ]; |
450 | - | ||
451 | -export const topicTableColumn: BasicColumn[] = [ | ||
452 | - { | ||
453 | - title: '功能', | ||
454 | - dataIndex: 'function', | ||
455 | - width: 100, | ||
456 | - }, | ||
457 | - { | ||
458 | - title: '发布主题', | ||
459 | - dataIndex: 'release', | ||
460 | - width: 100, | ||
461 | - }, | ||
462 | - | ||
463 | - { | ||
464 | - title: '订阅主题', | ||
465 | - dataIndex: 'subscribe', | ||
466 | - width: 100, | ||
467 | - }, | ||
468 | - { | ||
469 | - title: '平台', | ||
470 | - dataIndex: 'platform', | ||
471 | - width: 30, | ||
472 | - }, | ||
473 | - | ||
474 | - { | ||
475 | - title: '设备', | ||
476 | - dataIndex: 'device', | ||
477 | - width: 30, | ||
478 | - }, | ||
479 | - | ||
480 | - // { | ||
481 | - // title: '描述', | ||
482 | - // dataIndex: 'description', | ||
483 | - // width: 100, | ||
484 | - // }, | ||
485 | -]; |
1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
2 | - import { topicTableColumn } from '../device.profile.data'; | ||
3 | import { BasicTable, useTable } from '/@/components/Table'; | 2 | import { BasicTable, useTable } from '/@/components/Table'; |
4 | - | ||
5 | - const list = [ | ||
6 | - { | ||
7 | - function: '网关/直连设备遥测', | ||
8 | - release: 'v1/devices/me/telemetry', | ||
9 | - subscribe: 'v1/devices/me/telemetry', | ||
10 | - platform: '订阅', | ||
11 | - device: '发布', | ||
12 | - }, | ||
13 | - { | ||
14 | - function: '服务端命令下发到设备端', | ||
15 | - release: 'v1/devices/me/rpc/request/$request_id', | ||
16 | - subscribe: 'v1/devices/me/rpc/request/+', | ||
17 | - platform: '发布', | ||
18 | - device: '订阅', | ||
19 | - }, | ||
20 | - { | ||
21 | - function: '设备端响应命令到服务端', | ||
22 | - release: 'v1/devices/me/rpc/response/$request_id', | ||
23 | - subscribe: 'v1/devices/me/rpc/response/+', | ||
24 | - platform: '订阅', | ||
25 | - device: '发布', | ||
26 | - }, | ||
27 | - { | ||
28 | - function: '直连设备属性上报', | ||
29 | - release: 'v1/devices/me/attributes', | ||
30 | - subscribe: 'v1/devices/me/attributes', | ||
31 | - platform: '订阅', | ||
32 | - device: '发布', | ||
33 | - }, | ||
34 | - | ||
35 | - { | ||
36 | - function: '设备端请求服务端共享属性及客户端属性', | ||
37 | - release: 'vv1/devices/me/attributes/response/$request_id', | ||
38 | - subscribe: 'v1/devices/me/attributes/response/+', | ||
39 | - platform: '订阅', | ||
40 | - device: '发布', | ||
41 | - }, | ||
42 | - { | ||
43 | - function: '服务端响应共享属性集客户端属性给设备端', | ||
44 | - release: 'v1/devices/me/attributes/response/$request_id', | ||
45 | - subscribe: 'v1/devices/me/attributes/response/+', | ||
46 | - platform: '发布', | ||
47 | - device: '订阅', | ||
48 | - }, | ||
49 | - { | ||
50 | - function: '设备端请求服务端子设备共享属性及客户端属性', | ||
51 | - release: 'v1/gateway/attributes/request', | ||
52 | - subscribe: 'v1/gateway/attributes/request', | ||
53 | - platform: '订阅', | ||
54 | - device: '发布', | ||
55 | - }, | ||
56 | - { | ||
57 | - function: '服务端响应子设备共享属性及客户端属性给设备端', | ||
58 | - release: 'v1/gateway/attributes/response', | ||
59 | - subscribe: 'v1/gateway/attributes/response', | ||
60 | - platform: '发布', | ||
61 | - device: '订阅', | ||
62 | - }, | ||
63 | - { | ||
64 | - function: '设备端上报子设备客户端属性', | ||
65 | - release: 'v1/gateway/attributes', | ||
66 | - subscribe: 'v1/gateway/attributes', | ||
67 | - platform: '订阅', | ||
68 | - device: '发布', | ||
69 | - }, | ||
70 | - { | ||
71 | - function: '网关子设备遥测', | ||
72 | - release: 'v1/gateway/telemetry', | ||
73 | - subscribe: 'v1/gateway/telemetry', | ||
74 | - platform: '订阅', | ||
75 | - device: '发布', | ||
76 | - }, | ||
77 | - ]; | ||
78 | - | ||
79 | - const dataSource = list; | 3 | + import { list, topicTableColumn } from './topic'; |
80 | 4 | ||
81 | const [register] = useTable({ | 5 | const [register] = useTable({ |
82 | title: 'Topic', | 6 | title: 'Topic', |
83 | showIndexColumn: false, | 7 | showIndexColumn: false, |
84 | - dataSource, | 8 | + dataSource: list, |
85 | columns: topicTableColumn, | 9 | columns: topicTableColumn, |
86 | bordered: true, | 10 | bordered: true, |
87 | showTableSetting: true, | 11 | showTableSetting: true, |
src/views/device/profiles/step/topic.tsx
0 → 100644
1 | +import { BasicColumn } from '/@/components/Table/src/types/table'; | ||
2 | + | ||
3 | +export const topicTableColumn: BasicColumn[] = [ | ||
4 | + { | ||
5 | + title: '设备类型', | ||
6 | + dataIndex: 'deviceType', | ||
7 | + width: 50, | ||
8 | + customRender: ({ text, index }: { text: any; index: number }) => { | ||
9 | + const obj: any = { | ||
10 | + children: text, | ||
11 | + attrs: {}, | ||
12 | + }; | ||
13 | + if (index === 0) { | ||
14 | + obj.attrs.rowSpan = 6; | ||
15 | + } | ||
16 | + if (index > 0 && index < 6) { | ||
17 | + obj.attrs.rowSpan = 0; | ||
18 | + } | ||
19 | + if (index > 6) { | ||
20 | + obj.attrs.rowSpan = 0; | ||
21 | + } | ||
22 | + if (index === 6) { | ||
23 | + obj.attrs.rowSpan = 4; | ||
24 | + } | ||
25 | + return obj; | ||
26 | + }, | ||
27 | + }, | ||
28 | + { | ||
29 | + title: '功能', | ||
30 | + dataIndex: 'function', | ||
31 | + width: 100, | ||
32 | + }, | ||
33 | + { | ||
34 | + title: '发布主题', | ||
35 | + dataIndex: 'release', | ||
36 | + width: 120, | ||
37 | + }, | ||
38 | + { | ||
39 | + title: '订阅主题', | ||
40 | + dataIndex: 'subscribe', | ||
41 | + width: 120, | ||
42 | + }, | ||
43 | + { | ||
44 | + title: '平台', | ||
45 | + dataIndex: 'platform', | ||
46 | + width: 30, | ||
47 | + }, | ||
48 | + { | ||
49 | + title: '设备', | ||
50 | + dataIndex: 'device', | ||
51 | + width: 30, | ||
52 | + }, | ||
53 | +]; | ||
54 | + | ||
55 | +export const list = [ | ||
56 | + { | ||
57 | + deviceType: '网关/直连设备', | ||
58 | + function: '网关/直连设备遥测', | ||
59 | + release: 'v1/devices/me/telemetry', | ||
60 | + subscribe: 'v1/devices/me/telemetry', | ||
61 | + platform: '订阅', | ||
62 | + device: '发布', | ||
63 | + }, | ||
64 | + { | ||
65 | + deviceType: '网关/直连设备', | ||
66 | + function: '服务端命令下发到设备端', | ||
67 | + release: 'v1/devices/me/rpc/request/$request_id', | ||
68 | + subscribe: 'v1/devices/me/rpc/request/+', | ||
69 | + platform: '发布', | ||
70 | + device: '订阅', | ||
71 | + }, | ||
72 | + { | ||
73 | + deviceType: '网关/直连设备', | ||
74 | + function: '设备端响应命令到服务端', | ||
75 | + release: 'v1/devices/me/rpc/response/$request_id', | ||
76 | + subscribe: 'v1/devices/me/rpc/response/+', | ||
77 | + platform: '订阅', | ||
78 | + device: '发布', | ||
79 | + }, | ||
80 | + { | ||
81 | + deviceType: '网关/直连设备', | ||
82 | + function: '直连设备属性上报', | ||
83 | + release: 'v1/devices/me/attributes', | ||
84 | + subscribe: 'v1/devices/me/attributes', | ||
85 | + platform: '订阅', | ||
86 | + device: '发布', | ||
87 | + }, | ||
88 | + | ||
89 | + { | ||
90 | + deviceType: '网关/直连设备', | ||
91 | + function: '设备端请求服务端共享属性及客户端属性', | ||
92 | + release: 'v1/devices/me/attributes/response/$request_id', | ||
93 | + subscribe: 'v1/devices/me/attributes/response/+', | ||
94 | + platform: '订阅', | ||
95 | + device: '发布', | ||
96 | + }, | ||
97 | + { | ||
98 | + deviceType: '网关/直连设备', | ||
99 | + function: '服务端响应共享属性集客户端属性给设备端', | ||
100 | + release: 'v1/devices/me/attributes/response/$request_id', | ||
101 | + subscribe: 'v1/devices/me/attributes/response/+', | ||
102 | + platform: '发布', | ||
103 | + device: '订阅', | ||
104 | + }, | ||
105 | + { | ||
106 | + deviceType: '网关子设备', | ||
107 | + function: '设备端请求服务端子设备共享属性及客户端属性', | ||
108 | + release: 'v1/gateway/attributes/request', | ||
109 | + subscribe: 'v1/gateway/attributes/request', | ||
110 | + platform: '订阅', | ||
111 | + device: '发布', | ||
112 | + }, | ||
113 | + { | ||
114 | + deviceType: '网关子设备', | ||
115 | + function: '服务端响应子设备共享属性及客户端属性给设备端', | ||
116 | + release: 'v1/gateway/attributes/response', | ||
117 | + subscribe: 'v1/gateway/attributes/response', | ||
118 | + platform: '发布', | ||
119 | + device: '订阅', | ||
120 | + }, | ||
121 | + { | ||
122 | + deviceType: '网关子设备', | ||
123 | + function: '设备端上报子设备客户端属性', | ||
124 | + release: 'v1/gateway/attributes', | ||
125 | + subscribe: 'v1/gateway/attributes', | ||
126 | + platform: '订阅', | ||
127 | + device: '发布', | ||
128 | + }, | ||
129 | + { | ||
130 | + deviceType: '网关子设备', | ||
131 | + function: '网关子设备遥测', | ||
132 | + release: 'v1/gateway/telemetry', | ||
133 | + subscribe: 'v1/gateway/telemetry', | ||
134 | + platform: '订阅', | ||
135 | + device: '发布', | ||
136 | + }, | ||
137 | +]; |
@@ -131,7 +131,7 @@ | @@ -131,7 +131,7 @@ | ||
131 | selectOptions.value = items.map((item) => { | 131 | selectOptions.value = items.map((item) => { |
132 | if (item.deviceType !== 'GATEWAY') | 132 | if (item.deviceType !== 'GATEWAY') |
133 | return { | 133 | return { |
134 | - label: item.name, | 134 | + label: item.alias ? item.alias : item.name, |
135 | value: item.tbDeviceId, | 135 | value: item.tbDeviceId, |
136 | id: item.id, | 136 | id: item.id, |
137 | deviceProfileId: item.deviceProfileId, | 137 | deviceProfileId: item.deviceProfileId, |
@@ -291,7 +291,7 @@ | @@ -291,7 +291,7 @@ | ||
291 | selectOptions.value = items.map((item) => { | 291 | selectOptions.value = items.map((item) => { |
292 | if (item.deviceType !== 'GATEWAY') | 292 | if (item.deviceType !== 'GATEWAY') |
293 | return { | 293 | return { |
294 | - label: item.name, | 294 | + label: item.alias ? item.alias : item.name, |
295 | value: item.tbDeviceId, | 295 | value: item.tbDeviceId, |
296 | id: item.id, | 296 | id: item.id, |
297 | deviceProfileId: item.deviceProfileId, | 297 | deviceProfileId: item.deviceProfileId, |
@@ -316,7 +316,7 @@ | @@ -316,7 +316,7 @@ | ||
316 | }); | 316 | }); |
317 | return { | 317 | return { |
318 | ...T, | 318 | ...T, |
319 | - label: item.name, | 319 | + label: item.alias ? item.alias : item.name, |
320 | value: item.device, | 320 | value: item.device, |
321 | attributes: item.attributes, | 321 | attributes: item.attributes, |
322 | }; | 322 | }; |
@@ -245,6 +245,7 @@ | @@ -245,6 +245,7 @@ | ||
245 | operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType, | 245 | operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType, |
246 | detail: trigger?.triggerCondition?.alarmDetails, | 246 | detail: trigger?.triggerCondition?.alarmDetails, |
247 | entityId: trigger?.entityId, | 247 | entityId: trigger?.entityId, |
248 | + deviceType: trigger?.deviceType, | ||
248 | deviceProfileId: trigger?.deviceProfileId, | 249 | deviceProfileId: trigger?.deviceProfileId, |
249 | replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | 250 | replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
250 | time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | 251 | time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
@@ -325,6 +326,7 @@ | @@ -325,6 +326,7 @@ | ||
325 | operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType, | 326 | operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType, |
326 | detail: condition?.triggerCondition?.alarmDetails, | 327 | detail: condition?.triggerCondition?.alarmDetails, |
327 | entityId: condition?.entityId, | 328 | entityId: condition?.entityId, |
329 | + deviceType: condition?.deviceType, | ||
328 | deviceProfileId: condition?.deviceProfileId, | 330 | deviceProfileId: condition?.deviceProfileId, |
329 | replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | 331 | replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
330 | time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, | 332 | time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
@@ -397,6 +399,7 @@ | @@ -397,6 +399,7 @@ | ||
397 | deviceId: action.deviceId, | 399 | deviceId: action.deviceId, |
398 | alarm_config: action.alarmProfileId, | 400 | alarm_config: action.alarmProfileId, |
399 | alarm_level: action.doContext.alarmLevel, | 401 | alarm_level: action.doContext.alarmLevel, |
402 | + deviceType: action.deviceType, | ||
400 | }); | 403 | }); |
401 | // 如果是设备输出设置脚本值 | 404 | // 如果是设备输出设置脚本值 |
402 | if (action.outTarget === 'DEVICE_OUT') { | 405 | if (action.outTarget === 'DEVICE_OUT') { |
@@ -436,6 +439,7 @@ | @@ -436,6 +439,7 @@ | ||
436 | .valueType, | 439 | .valueType, |
437 | detail: action.doContext.clearRule[index].triggerCondition.alarmDetails, | 440 | detail: action.doContext.clearRule[index].triggerCondition.alarmDetails, |
438 | entityId: action.doContext.clearRule[index].entityId, | 441 | entityId: action.doContext.clearRule[index].entityId, |
442 | + deviceType: action.doContext.clearRule[index].entityId?.deviceType, | ||
439 | deviceProfileId: action.doContext.clearRule[index]?.deviceProfileId, | 443 | deviceProfileId: action.doContext.clearRule[index]?.deviceProfileId, |
440 | replaceValue: | 444 | replaceValue: |
441 | action.doContext.clearRule[index].triggerCondition.condition.spec.predicate | 445 | action.doContext.clearRule[index].triggerCondition.condition.spec.predicate |
@@ -193,6 +193,7 @@ export const trigger_condition_schema: FormSchema[] = [ | @@ -193,6 +193,7 @@ export const trigger_condition_schema: FormSchema[] = [ | ||
193 | field: 'triggered', | 193 | field: 'triggered', |
194 | label: '', | 194 | label: '', |
195 | component: 'Select', | 195 | component: 'Select', |
196 | + defaultValue: 'SIMPLE', | ||
196 | componentProps: { | 197 | componentProps: { |
197 | placeholder: '请选择触发类型', | 198 | placeholder: '请选择触发类型', |
198 | options: [ | 199 | options: [ |
@@ -204,14 +205,44 @@ export const trigger_condition_schema: FormSchema[] = [ | @@ -204,14 +205,44 @@ export const trigger_condition_schema: FormSchema[] = [ | ||
204 | colProps: { span: 6 }, | 205 | colProps: { span: 6 }, |
205 | }, | 206 | }, |
206 | { | 207 | { |
207 | - field: 'deviceProfileId', | 208 | + field: 'deviceType', |
208 | label: '', | 209 | label: '', |
209 | component: 'ApiSelect', | 210 | component: 'ApiSelect', |
210 | colProps: { span: 6 }, | 211 | colProps: { span: 6 }, |
212 | + defaultValue: 'SENSOR', | ||
211 | componentProps: ({ formActionType }) => { | 213 | componentProps: ({ formActionType }) => { |
214 | + const { setFieldsValue } = formActionType; | ||
215 | + return { | ||
216 | + api: findDictItemByCode, | ||
217 | + params: { | ||
218 | + dictCode: 'device_type', | ||
219 | + }, | ||
220 | + placeholder: '请选择类型', | ||
221 | + labelField: 'itemText', | ||
222 | + valueField: 'itemValue', | ||
223 | + getPopupContainer: () => document.body, | ||
224 | + onChange(e) { | ||
225 | + if (e) { | ||
226 | + setFieldsValue({ deviceProfileId: '' }); | ||
227 | + } | ||
228 | + }, | ||
229 | + }; | ||
230 | + }, | ||
231 | + }, | ||
232 | + { | ||
233 | + field: 'deviceProfileId', | ||
234 | + label: '', | ||
235 | + component: 'ApiSelect', | ||
236 | + colProps: { span: 6 }, | ||
237 | + componentProps: ({ formActionType, formModel }) => { | ||
212 | const { updateSchema, setFieldsValue } = formActionType; | 238 | const { updateSchema, setFieldsValue } = formActionType; |
239 | + const deviceType = formModel['deviceType']; | ||
213 | return { | 240 | return { |
214 | api: deviceProfile, | 241 | api: deviceProfile, |
242 | + params: { | ||
243 | + deviceType, | ||
244 | + }, | ||
245 | + showSearch: true, | ||
215 | placeholder: '请选择产品', | 246 | placeholder: '请选择产品', |
216 | labelField: 'name', | 247 | labelField: 'name', |
217 | valueField: 'id', | 248 | valueField: 'id', |
@@ -372,14 +403,38 @@ export const actionSchema: FormSchema[] = [ | @@ -372,14 +403,38 @@ export const actionSchema: FormSchema[] = [ | ||
372 | colProps: { span: 6 }, | 403 | colProps: { span: 6 }, |
373 | }, | 404 | }, |
374 | { | 405 | { |
406 | + field: 'deviceType', | ||
407 | + label: '', | ||
408 | + component: 'ApiSelect', | ||
409 | + colProps: { span: 6 }, | ||
410 | + defaultValue: 'SENSOR', | ||
411 | + componentProps: () => { | ||
412 | + return { | ||
413 | + api: findDictItemByCode, | ||
414 | + params: { | ||
415 | + dictCode: 'device_type', | ||
416 | + }, | ||
417 | + placeholder: '请选择类型', | ||
418 | + labelField: 'itemText', | ||
419 | + valueField: 'itemValue', | ||
420 | + getPopupContainer: () => document.body, | ||
421 | + }; | ||
422 | + }, | ||
423 | + ifShow: ({ values }) => isDeviceOut(values.outTarget), | ||
424 | + }, | ||
425 | + { | ||
375 | field: 'deviceProfileId', | 426 | field: 'deviceProfileId', |
376 | label: '', | 427 | label: '', |
377 | component: 'ApiSelect', | 428 | component: 'ApiSelect', |
378 | colProps: { span: 6 }, | 429 | colProps: { span: 6 }, |
379 | - componentProps: ({ formActionType }) => { | 430 | + componentProps: ({ formActionType, formModel }) => { |
380 | const { setFieldsValue } = formActionType; | 431 | const { setFieldsValue } = formActionType; |
432 | + const deviceType = formModel['deviceType']; | ||
381 | return { | 433 | return { |
382 | api: deviceProfile, | 434 | api: deviceProfile, |
435 | + params: { | ||
436 | + deviceType, | ||
437 | + }, | ||
383 | placeholder: '请选择产品', | 438 | placeholder: '请选择产品', |
384 | labelField: 'name', | 439 | labelField: 'name', |
385 | valueField: 'id', | 440 | valueField: 'id', |
@@ -18,6 +18,7 @@ export const genTriggerOrConditionData = (triggerData) => { | @@ -18,6 +18,7 @@ export const genTriggerOrConditionData = (triggerData) => { | ||
18 | timeUnit, | 18 | timeUnit, |
19 | replaceValue, | 19 | replaceValue, |
20 | deviceProfileId, | 20 | deviceProfileId, |
21 | + deviceType, | ||
21 | } = triggerData; | 22 | } = triggerData; |
22 | const mapPredicate = predicate?.map((item) => { | 23 | const mapPredicate = predicate?.map((item) => { |
23 | return { | 24 | return { |
@@ -45,6 +46,7 @@ export const genTriggerOrConditionData = (triggerData) => { | @@ -45,6 +46,7 @@ export const genTriggerOrConditionData = (triggerData) => { | ||
45 | triggerType, | 46 | triggerType, |
46 | entityType: device, | 47 | entityType: device, |
47 | entityId: entityId?.length ? entityId : null, | 48 | entityId: entityId?.length ? entityId : null, |
49 | + deviceType, | ||
48 | triggerCondition: { | 50 | triggerCondition: { |
49 | alarmDetails: detail, | 51 | alarmDetails: detail, |
50 | condition: { | 52 | condition: { |
@@ -83,6 +85,7 @@ export const genActionData = (actionData) => { | @@ -83,6 +85,7 @@ export const genActionData = (actionData) => { | ||
83 | callType, | 85 | callType, |
84 | service, | 86 | service, |
85 | thingsModelId, | 87 | thingsModelId, |
88 | + deviceType, | ||
86 | } = actionData; | 89 | } = actionData; |
87 | const clearRule = clearRules.map((item) => { | 90 | const clearRule = clearRules.map((item) => { |
88 | const mapPredicate = item.predicate.map((pred) => { | 91 | const mapPredicate = item.predicate.map((pred) => { |
@@ -117,6 +120,7 @@ export const genActionData = (actionData) => { | @@ -117,6 +120,7 @@ export const genActionData = (actionData) => { | ||
117 | triggerType: item.triggerType, | 120 | triggerType: item.triggerType, |
118 | entityType: item.device, | 121 | entityType: item.device, |
119 | entityId: item.device === 'PART' ? item.entityId : null, | 122 | entityId: item.device === 'PART' ? item.entityId : null, |
123 | + deviceType, | ||
120 | deviceProfileId: item.deviceProfileId, | 124 | deviceProfileId: item.deviceProfileId, |
121 | triggerCondition: { | 125 | triggerCondition: { |
122 | alarmDetails: item.detail, | 126 | alarmDetails: item.detail, |
@@ -138,6 +142,7 @@ export const genActionData = (actionData) => { | @@ -138,6 +142,7 @@ export const genActionData = (actionData) => { | ||
138 | { | 142 | { |
139 | alarmProfileId: alarm_config, | 143 | alarmProfileId: alarm_config, |
140 | outTarget, | 144 | outTarget, |
145 | + deviceType, | ||
141 | entityType: device ?? 'ALL', | 146 | entityType: device ?? 'ALL', |
142 | deviceId: device === 'PART' ? deviceId : null, | 147 | deviceId: device === 'PART' ? deviceId : null, |
143 | deviceProfileId, | 148 | deviceProfileId, |
@@ -103,7 +103,7 @@ | @@ -103,7 +103,7 @@ | ||
103 | params: '', | 103 | params: '', |
104 | output: '', | 104 | output: '', |
105 | dataType: 'HEX', | 105 | dataType: 'HEX', |
106 | - saveOriginalData: 'false', | 106 | + saveOriginalData: 'true', |
107 | }); | 107 | }); |
108 | const reportTypeOptions = reactive({ | 108 | const reportTypeOptions = reactive({ |
109 | typeOptions: [], | 109 | typeOptions: [], |
@@ -114,6 +114,10 @@ | @@ -114,6 +114,10 @@ | ||
114 | const { clipboardRef, copiedRef } = useCopyToClipboard(); | 114 | const { clipboardRef, copiedRef } = useCopyToClipboard(); |
115 | const aceEditor = ref(); | 115 | const aceEditor = ref(); |
116 | const aceRef = ref(); | 116 | const aceRef = ref(); |
117 | + const setDefaultRadio = (p1, p2) => { | ||
118 | + scriptForm.dataType = p1; | ||
119 | + scriptForm.saveOriginalData = p2; | ||
120 | + }; | ||
117 | onMounted(async () => { | 121 | onMounted(async () => { |
118 | const res: any = await findDictItemByCode({ | 122 | const res: any = await findDictItemByCode({ |
119 | dictCode: 'report_data_type', | 123 | dictCode: 'report_data_type', |
@@ -127,8 +131,6 @@ | @@ -127,8 +131,6 @@ | ||
127 | reportTypeOptions.originalOptions = resOriginal.map((m) => { | 131 | reportTypeOptions.originalOptions = resOriginal.map((m) => { |
128 | return { label: m.itemText, value: m.itemValue }; | 132 | return { label: m.itemText, value: m.itemValue }; |
129 | }); | 133 | }); |
130 | - scriptForm.dataType = 'HEX'; | ||
131 | - scriptForm.saveOriginalData = 'false'; | ||
132 | }); | 134 | }); |
133 | // 初始化编辑器 | 135 | // 初始化编辑器 |
134 | const initEditor = (jsScript?: string) => { | 136 | const initEditor = (jsScript?: string) => { |
@@ -202,7 +204,7 @@ | @@ -202,7 +204,7 @@ | ||
202 | setTimeout(() => { | 204 | setTimeout(() => { |
203 | scriptForm.saveOriginalData = v.saveOriginalData === false ? 'false' : 'true'; | 205 | scriptForm.saveOriginalData = v.saveOriginalData === false ? 'false' : 'true'; |
204 | scriptForm.dataType = v.dataType; | 206 | scriptForm.dataType = v.dataType; |
205 | - }, 500); | 207 | + }, 10); |
206 | }); | 208 | }); |
207 | aceEditor.value.setValue(v.convertJs); | 209 | aceEditor.value.setValue(v.convertJs); |
208 | handleFormat(); | 210 | handleFormat(); |
@@ -229,6 +231,7 @@ | @@ -229,6 +231,7 @@ | ||
229 | setFormData, | 231 | setFormData, |
230 | setScriptContentData, | 232 | setScriptContentData, |
231 | setScriptOutputData, | 233 | setScriptOutputData, |
234 | + setDefaultRadio, | ||
232 | }); | 235 | }); |
233 | </script> | 236 | </script> |
234 | <style lang="less" scoped> | 237 | <style lang="less" scoped> |
@@ -56,6 +56,9 @@ | @@ -56,6 +56,9 @@ | ||
56 | ? '新增转换脚本' | 56 | ? '新增转换脚本' |
57 | : '测试转换脚本'; | 57 | : '测试转换脚本'; |
58 | const okText = isText.value == 'test' ? '测试' : '确定'; | 58 | const okText = isText.value == 'test' ? '测试' : '确定'; |
59 | + if (unref(isTitle) == 'add') { | ||
60 | + converScriptRef.value?.setDefaultRadio('HEX', 'true'); | ||
61 | + } | ||
59 | if (unref(isTitle) == 'edit') { | 62 | if (unref(isTitle) == 'edit') { |
60 | converScriptRef.value?.setFormData(data.record); | 63 | converScriptRef.value?.setFormData(data.record); |
61 | } | 64 | } |