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 | 80 | * 查询设备配置 |
| 81 | 81 | * @param params pageSize page name |
| 82 | 82 | */ |
| 83 | -export const deviceProfile = () => { | |
| 83 | +export const deviceProfile = (params) => { | |
| 84 | 84 | return defHttp.get({ |
| 85 | 85 | url: DeviceManagerApi.DEVICE_PROFILE_URL_ME, |
| 86 | + params, | |
| 86 | 87 | }); |
| 87 | 88 | }; |
| 88 | 89 | ... | ... |
| ... | ... | @@ -21,7 +21,7 @@ enum ScreenManagerApi { |
| 21 | 21 | // GET_ATTRBUTELIST = '/device/keys', |
| 22 | 22 | GET_ATTRBUTELIST = '/device/attributes/', |
| 23 | 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 | 125 | }) => { |
| 126 | 126 | const { organizationId, deviceProfileId } = params; |
| 127 | 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 | 132 | //TODO-fengtao | ... | ... |
| ... | ... | @@ -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 | 1 | <script lang="ts" setup> |
| 2 | - import { topicTableColumn } from '../device.profile.data'; | |
| 3 | 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 | 5 | const [register] = useTable({ |
| 82 | 6 | title: 'Topic', |
| 83 | 7 | showIndexColumn: false, |
| 84 | - dataSource, | |
| 8 | + dataSource: list, | |
| 85 | 9 | columns: topicTableColumn, |
| 86 | 10 | bordered: true, |
| 87 | 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 | 131 | selectOptions.value = items.map((item) => { |
| 132 | 132 | if (item.deviceType !== 'GATEWAY') |
| 133 | 133 | return { |
| 134 | - label: item.name, | |
| 134 | + label: item.alias ? item.alias : item.name, | |
| 135 | 135 | value: item.tbDeviceId, |
| 136 | 136 | id: item.id, |
| 137 | 137 | deviceProfileId: item.deviceProfileId, |
| ... | ... | @@ -291,7 +291,7 @@ |
| 291 | 291 | selectOptions.value = items.map((item) => { |
| 292 | 292 | if (item.deviceType !== 'GATEWAY') |
| 293 | 293 | return { |
| 294 | - label: item.name, | |
| 294 | + label: item.alias ? item.alias : item.name, | |
| 295 | 295 | value: item.tbDeviceId, |
| 296 | 296 | id: item.id, |
| 297 | 297 | deviceProfileId: item.deviceProfileId, |
| ... | ... | @@ -316,7 +316,7 @@ |
| 316 | 316 | }); |
| 317 | 317 | return { |
| 318 | 318 | ...T, |
| 319 | - label: item.name, | |
| 319 | + label: item.alias ? item.alias : item.name, | |
| 320 | 320 | value: item.device, |
| 321 | 321 | attributes: item.attributes, |
| 322 | 322 | }; | ... | ... |
| ... | ... | @@ -245,6 +245,7 @@ |
| 245 | 245 | operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType, |
| 246 | 246 | detail: trigger?.triggerCondition?.alarmDetails, |
| 247 | 247 | entityId: trigger?.entityId, |
| 248 | + deviceType: trigger?.deviceType, | |
| 248 | 249 | deviceProfileId: trigger?.deviceProfileId, |
| 249 | 250 | replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
| 250 | 251 | time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
| ... | ... | @@ -325,6 +326,7 @@ |
| 325 | 326 | operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType, |
| 326 | 327 | detail: condition?.triggerCondition?.alarmDetails, |
| 327 | 328 | entityId: condition?.entityId, |
| 329 | + deviceType: condition?.deviceType, | |
| 328 | 330 | deviceProfileId: condition?.deviceProfileId, |
| 329 | 331 | replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
| 330 | 332 | time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, |
| ... | ... | @@ -397,6 +399,7 @@ |
| 397 | 399 | deviceId: action.deviceId, |
| 398 | 400 | alarm_config: action.alarmProfileId, |
| 399 | 401 | alarm_level: action.doContext.alarmLevel, |
| 402 | + deviceType: action.deviceType, | |
| 400 | 403 | }); |
| 401 | 404 | // 如果是设备输出设置脚本值 |
| 402 | 405 | if (action.outTarget === 'DEVICE_OUT') { |
| ... | ... | @@ -436,6 +439,7 @@ |
| 436 | 439 | .valueType, |
| 437 | 440 | detail: action.doContext.clearRule[index].triggerCondition.alarmDetails, |
| 438 | 441 | entityId: action.doContext.clearRule[index].entityId, |
| 442 | + deviceType: action.doContext.clearRule[index].entityId?.deviceType, | |
| 439 | 443 | deviceProfileId: action.doContext.clearRule[index]?.deviceProfileId, |
| 440 | 444 | replaceValue: |
| 441 | 445 | action.doContext.clearRule[index].triggerCondition.condition.spec.predicate | ... | ... |
| ... | ... | @@ -193,6 +193,7 @@ export const trigger_condition_schema: FormSchema[] = [ |
| 193 | 193 | field: 'triggered', |
| 194 | 194 | label: '', |
| 195 | 195 | component: 'Select', |
| 196 | + defaultValue: 'SIMPLE', | |
| 196 | 197 | componentProps: { |
| 197 | 198 | placeholder: '请选择触发类型', |
| 198 | 199 | options: [ |
| ... | ... | @@ -204,14 +205,44 @@ export const trigger_condition_schema: FormSchema[] = [ |
| 204 | 205 | colProps: { span: 6 }, |
| 205 | 206 | }, |
| 206 | 207 | { |
| 207 | - field: 'deviceProfileId', | |
| 208 | + field: 'deviceType', | |
| 208 | 209 | label: '', |
| 209 | 210 | component: 'ApiSelect', |
| 210 | 211 | colProps: { span: 6 }, |
| 212 | + defaultValue: 'SENSOR', | |
| 211 | 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 | 238 | const { updateSchema, setFieldsValue } = formActionType; |
| 239 | + const deviceType = formModel['deviceType']; | |
| 213 | 240 | return { |
| 214 | 241 | api: deviceProfile, |
| 242 | + params: { | |
| 243 | + deviceType, | |
| 244 | + }, | |
| 245 | + showSearch: true, | |
| 215 | 246 | placeholder: '请选择产品', |
| 216 | 247 | labelField: 'name', |
| 217 | 248 | valueField: 'id', |
| ... | ... | @@ -372,14 +403,38 @@ export const actionSchema: FormSchema[] = [ |
| 372 | 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 | 426 | field: 'deviceProfileId', |
| 376 | 427 | label: '', |
| 377 | 428 | component: 'ApiSelect', |
| 378 | 429 | colProps: { span: 6 }, |
| 379 | - componentProps: ({ formActionType }) => { | |
| 430 | + componentProps: ({ formActionType, formModel }) => { | |
| 380 | 431 | const { setFieldsValue } = formActionType; |
| 432 | + const deviceType = formModel['deviceType']; | |
| 381 | 433 | return { |
| 382 | 434 | api: deviceProfile, |
| 435 | + params: { | |
| 436 | + deviceType, | |
| 437 | + }, | |
| 383 | 438 | placeholder: '请选择产品', |
| 384 | 439 | labelField: 'name', |
| 385 | 440 | valueField: 'id', | ... | ... |
| ... | ... | @@ -18,6 +18,7 @@ export const genTriggerOrConditionData = (triggerData) => { |
| 18 | 18 | timeUnit, |
| 19 | 19 | replaceValue, |
| 20 | 20 | deviceProfileId, |
| 21 | + deviceType, | |
| 21 | 22 | } = triggerData; |
| 22 | 23 | const mapPredicate = predicate?.map((item) => { |
| 23 | 24 | return { |
| ... | ... | @@ -45,6 +46,7 @@ export const genTriggerOrConditionData = (triggerData) => { |
| 45 | 46 | triggerType, |
| 46 | 47 | entityType: device, |
| 47 | 48 | entityId: entityId?.length ? entityId : null, |
| 49 | + deviceType, | |
| 48 | 50 | triggerCondition: { |
| 49 | 51 | alarmDetails: detail, |
| 50 | 52 | condition: { |
| ... | ... | @@ -83,6 +85,7 @@ export const genActionData = (actionData) => { |
| 83 | 85 | callType, |
| 84 | 86 | service, |
| 85 | 87 | thingsModelId, |
| 88 | + deviceType, | |
| 86 | 89 | } = actionData; |
| 87 | 90 | const clearRule = clearRules.map((item) => { |
| 88 | 91 | const mapPredicate = item.predicate.map((pred) => { |
| ... | ... | @@ -117,6 +120,7 @@ export const genActionData = (actionData) => { |
| 117 | 120 | triggerType: item.triggerType, |
| 118 | 121 | entityType: item.device, |
| 119 | 122 | entityId: item.device === 'PART' ? item.entityId : null, |
| 123 | + deviceType, | |
| 120 | 124 | deviceProfileId: item.deviceProfileId, |
| 121 | 125 | triggerCondition: { |
| 122 | 126 | alarmDetails: item.detail, |
| ... | ... | @@ -138,6 +142,7 @@ export const genActionData = (actionData) => { |
| 138 | 142 | { |
| 139 | 143 | alarmProfileId: alarm_config, |
| 140 | 144 | outTarget, |
| 145 | + deviceType, | |
| 141 | 146 | entityType: device ?? 'ALL', |
| 142 | 147 | deviceId: device === 'PART' ? deviceId : null, |
| 143 | 148 | deviceProfileId, | ... | ... |
| ... | ... | @@ -103,7 +103,7 @@ |
| 103 | 103 | params: '', |
| 104 | 104 | output: '', |
| 105 | 105 | dataType: 'HEX', |
| 106 | - saveOriginalData: 'false', | |
| 106 | + saveOriginalData: 'true', | |
| 107 | 107 | }); |
| 108 | 108 | const reportTypeOptions = reactive({ |
| 109 | 109 | typeOptions: [], |
| ... | ... | @@ -114,6 +114,10 @@ |
| 114 | 114 | const { clipboardRef, copiedRef } = useCopyToClipboard(); |
| 115 | 115 | const aceEditor = ref(); |
| 116 | 116 | const aceRef = ref(); |
| 117 | + const setDefaultRadio = (p1, p2) => { | |
| 118 | + scriptForm.dataType = p1; | |
| 119 | + scriptForm.saveOriginalData = p2; | |
| 120 | + }; | |
| 117 | 121 | onMounted(async () => { |
| 118 | 122 | const res: any = await findDictItemByCode({ |
| 119 | 123 | dictCode: 'report_data_type', |
| ... | ... | @@ -127,8 +131,6 @@ |
| 127 | 131 | reportTypeOptions.originalOptions = resOriginal.map((m) => { |
| 128 | 132 | return { label: m.itemText, value: m.itemValue }; |
| 129 | 133 | }); |
| 130 | - scriptForm.dataType = 'HEX'; | |
| 131 | - scriptForm.saveOriginalData = 'false'; | |
| 132 | 134 | }); |
| 133 | 135 | // 初始化编辑器 |
| 134 | 136 | const initEditor = (jsScript?: string) => { |
| ... | ... | @@ -202,7 +204,7 @@ |
| 202 | 204 | setTimeout(() => { |
| 203 | 205 | scriptForm.saveOriginalData = v.saveOriginalData === false ? 'false' : 'true'; |
| 204 | 206 | scriptForm.dataType = v.dataType; |
| 205 | - }, 500); | |
| 207 | + }, 10); | |
| 206 | 208 | }); |
| 207 | 209 | aceEditor.value.setValue(v.convertJs); |
| 208 | 210 | handleFormat(); |
| ... | ... | @@ -229,6 +231,7 @@ |
| 229 | 231 | setFormData, |
| 230 | 232 | setScriptContentData, |
| 231 | 233 | setScriptOutputData, |
| 234 | + setDefaultRadio, | |
| 232 | 235 | }); |
| 233 | 236 | </script> |
| 234 | 237 | <style lang="less" scoped> | ... | ... |
| ... | ... | @@ -56,6 +56,9 @@ |
| 56 | 56 | ? '新增转换脚本' |
| 57 | 57 | : '测试转换脚本'; |
| 58 | 58 | const okText = isText.value == 'test' ? '测试' : '确定'; |
| 59 | + if (unref(isTitle) == 'add') { | |
| 60 | + converScriptRef.value?.setDefaultRadio('HEX', 'true'); | |
| 61 | + } | |
| 59 | 62 | if (unref(isTitle) == 'edit') { |
| 60 | 63 | converScriptRef.value?.setFormData(data.record); |
| 61 | 64 | } | ... | ... |