Commit 458e31438f91751fd28fedaeb3da6d33edd6e661
1 parent
f3a33e1a
fix:DEFECT-958 创建设备别名,然后去此设备存在的场景联动编辑时,别名未修改,未生效
Showing
1 changed file
with
66 additions
and
26 deletions
| @@ -279,19 +279,39 @@ export const trigger_condition_schema: FormSchema[] = [ | @@ -279,19 +279,39 @@ export const trigger_condition_schema: FormSchema[] = [ | ||
| 279 | component: 'ApiSelect', | 279 | component: 'ApiSelect', |
| 280 | componentProps: ({ formModel }) => { | 280 | componentProps: ({ formModel }) => { |
| 281 | const deviceProfileId = formModel['deviceProfileId']; | 281 | const deviceProfileId = formModel['deviceProfileId']; |
| 282 | - if (unref(organizationId)) { | ||
| 283 | - return { | ||
| 284 | - placeholder: '请选择设备', | ||
| 285 | - mode: 'multiple', | ||
| 286 | - api: byOrganizationIdGetMasterDevice, | ||
| 287 | - params: { | ||
| 288 | - organizationId: unref(organizationId), | ||
| 289 | - deviceProfileId, | ||
| 290 | - }, | ||
| 291 | - labelField: 'name', | ||
| 292 | - valueField: 'tbDeviceId', | ||
| 293 | - }; | ||
| 294 | - } | 282 | + return { |
| 283 | + mode: 'multiple', | ||
| 284 | + api: async () => { | ||
| 285 | + if (unref(organizationId)) { | ||
| 286 | + try { | ||
| 287 | + const data = await byOrganizationIdGetMasterDevice({ | ||
| 288 | + organizationId: unref(organizationId), | ||
| 289 | + deviceProfileId, | ||
| 290 | + }); | ||
| 291 | + if (data) | ||
| 292 | + return data.map((item) => ({ | ||
| 293 | + ...item, | ||
| 294 | + label: item.alias || item.name, | ||
| 295 | + value: item.tbDeviceId, | ||
| 296 | + })); | ||
| 297 | + } catch (error) {} | ||
| 298 | + } | ||
| 299 | + return []; | ||
| 300 | + }, | ||
| 301 | + placeholder: '请选择设备', | ||
| 302 | + getPopupContainer: () => document.body, | ||
| 303 | + }; | ||
| 304 | + // return { | ||
| 305 | + // placeholder: '请选择设备', | ||
| 306 | + // mode: 'multiple', | ||
| 307 | + // api: byOrganizationIdGetMasterDevice, | ||
| 308 | + // params: { | ||
| 309 | + // organizationId: unref(organizationId), | ||
| 310 | + // deviceProfileId, | ||
| 311 | + // }, | ||
| 312 | + // labelField: 'name', | ||
| 313 | + // valueField: 'tbDeviceId', | ||
| 314 | + // }; | ||
| 295 | }, | 315 | }, |
| 296 | ifShow: ({ values }) => isPart(values.device), | 316 | ifShow: ({ values }) => isPart(values.device), |
| 297 | colProps: { span: 6 }, | 317 | colProps: { span: 6 }, |
| @@ -473,19 +493,39 @@ export const actionSchema: FormSchema[] = [ | @@ -473,19 +493,39 @@ export const actionSchema: FormSchema[] = [ | ||
| 473 | component: 'ApiSelect', | 493 | component: 'ApiSelect', |
| 474 | componentProps: ({ formModel }) => { | 494 | componentProps: ({ formModel }) => { |
| 475 | const deviceProfileId = formModel['deviceProfileId']; | 495 | const deviceProfileId = formModel['deviceProfileId']; |
| 476 | - if (unref(organizationId)) { | ||
| 477 | - return { | ||
| 478 | - placeholder: '请选择设备', | ||
| 479 | - mode: 'multiple', | ||
| 480 | - api: byOrganizationIdGetMasterDevice, | ||
| 481 | - params: { | ||
| 482 | - organizationId: unref(organizationId), | ||
| 483 | - deviceProfileId, | ||
| 484 | - }, | ||
| 485 | - labelField: 'name', | ||
| 486 | - valueField: 'tbDeviceId', | ||
| 487 | - }; | ||
| 488 | - } | 496 | + return { |
| 497 | + mode: 'multiple', | ||
| 498 | + api: async () => { | ||
| 499 | + if (unref(organizationId)) { | ||
| 500 | + try { | ||
| 501 | + const data = await byOrganizationIdGetMasterDevice({ | ||
| 502 | + organizationId: unref(organizationId), | ||
| 503 | + deviceProfileId, | ||
| 504 | + }); | ||
| 505 | + if (data) | ||
| 506 | + return data.map((item) => ({ | ||
| 507 | + ...item, | ||
| 508 | + label: item.alias || item.name, | ||
| 509 | + value: item.tbDeviceId, | ||
| 510 | + })); | ||
| 511 | + } catch (error) {} | ||
| 512 | + } | ||
| 513 | + return []; | ||
| 514 | + }, | ||
| 515 | + placeholder: '请选择设备', | ||
| 516 | + getPopupContainer: () => document.body, | ||
| 517 | + }; | ||
| 518 | + // return { | ||
| 519 | + // placeholder: '请选择设备', | ||
| 520 | + // mode: 'multiple', | ||
| 521 | + // api: byOrganizationIdGetMasterDevice, | ||
| 522 | + // params: { | ||
| 523 | + // organizationId: unref(organizationId), | ||
| 524 | + // deviceProfileId, | ||
| 525 | + // }, | ||
| 526 | + // labelField: 'name', | ||
| 527 | + // valueField: 'tbDeviceId', | ||
| 528 | + // }; | ||
| 489 | }, | 529 | }, |
| 490 | ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget), | 530 | ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget), |
| 491 | colProps: { span: 6 }, | 531 | colProps: { span: 6 }, |