Commit b9db5add67703ad893a21e08ae51dc7933f346d3
1 parent
f1a8447d
feat: linkedge action add service command
Showing
6 changed files
with
163 additions
and
70 deletions
| @@ -10,6 +10,8 @@ enum ModelOfMatter { | @@ -10,6 +10,8 @@ enum ModelOfMatter { | ||
| 10 | TSL = '/things_model', | 10 | TSL = '/things_model', |
| 11 | LIST = '/things_model/page', | 11 | LIST = '/things_model/page', |
| 12 | RELEASE = '/things_model', | 12 | RELEASE = '/things_model', |
| 13 | + | ||
| 14 | + GET_MODEL_SERVICE = '/things_model/get_services', | ||
| 13 | } | 15 | } |
| 14 | 16 | ||
| 15 | export const getModelList = ( | 17 | export const getModelList = ( |
| @@ -60,3 +62,10 @@ export const releaseModel = (deviceProfileId: string) => { | @@ -60,3 +62,10 @@ export const releaseModel = (deviceProfileId: string) => { | ||
| 60 | url: `${ModelOfMatter.RELEASE}/${deviceProfileId}`, | 62 | url: `${ModelOfMatter.RELEASE}/${deviceProfileId}`, |
| 61 | }); | 63 | }); |
| 62 | }; | 64 | }; |
| 65 | + | ||
| 66 | +export const getModelServices = (params: { deviceProfileId: string }) => { | ||
| 67 | + const { deviceProfileId } = params; | ||
| 68 | + return defHttp.get({ | ||
| 69 | + url: `${ModelOfMatter.GET_MODEL_SERVICE}/${deviceProfileId}`, | ||
| 70 | + }); | ||
| 71 | +}; |
| @@ -112,9 +112,14 @@ export const getAttribute = (orgId, deviceIds) => { | @@ -112,9 +112,14 @@ export const getAttribute = (orgId, deviceIds) => { | ||
| 112 | * 获取主设备列表(exclude子设备)---执行动作 | 112 | * 获取主设备列表(exclude子设备)---执行动作 |
| 113 | * @param params organizationId | 113 | * @param params organizationId |
| 114 | */ | 114 | */ |
| 115 | -export const byOganizationIdGetMasterDevice = (params) => { | 115 | +export const byOrganizationIdGetMasterDevice = (params: { |
| 116 | + organizationId: string; | ||
| 117 | + deviceProfileId?: string; | ||
| 118 | +}) => { | ||
| 119 | + const { organizationId, deviceProfileId } = params; | ||
| 116 | return defHttp.get({ | 120 | return defHttp.get({ |
| 117 | - url: ScreenManagerApi.MASTER_GET_DEVICE + '/' + params, | 121 | + url: `${ScreenManagerApi.MASTER_GET_DEVICE}/${organizationId}`, |
| 122 | + params: { deviceProfileId }, | ||
| 118 | }); | 123 | }); |
| 119 | }; | 124 | }; |
| 120 | //TODO-fengtao | 125 | //TODO-fengtao |
| @@ -116,9 +116,9 @@ | @@ -116,9 +116,9 @@ | ||
| 116 | <script lang="ts" setup> | 116 | <script lang="ts" setup> |
| 117 | import { ref, watch, unref, computed, nextTick } from 'vue'; | 117 | import { ref, watch, unref, computed, nextTick } from 'vue'; |
| 118 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 118 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
| 119 | - import { formSchema, organizationId } from './config/config.data.ts'; | 119 | + import { formSchema, organizationId as organizationIdRef } from './config/config.data'; |
| 120 | import { BasicForm, useForm } from '/@/components/Form'; | 120 | import { BasicForm, useForm } from '/@/components/Form'; |
| 121 | - import { genTriggerOrConditionData, genActionData } from './config/formatData.ts'; | 121 | + import { genTriggerOrConditionData, genActionData } from './config/formatData'; |
| 122 | import { Divider } from 'ant-design-vue'; | 122 | import { Divider } from 'ant-design-vue'; |
| 123 | import { PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons-vue'; | 123 | import { PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons-vue'; |
| 124 | import { useMessage } from '/@/hooks/web/useMessage'; | 124 | import { useMessage } from '/@/hooks/web/useMessage'; |
| @@ -126,11 +126,10 @@ | @@ -126,11 +126,10 @@ | ||
| 126 | screenLinkPageAddApi, | 126 | screenLinkPageAddApi, |
| 127 | screenLinkPageByDeptIdGetDevice, | 127 | screenLinkPageByDeptIdGetDevice, |
| 128 | getOrganizationAlarmConfig, | 128 | getOrganizationAlarmConfig, |
| 129 | - byOganizationIdGetMasterDevice, | ||
| 130 | } from '/@/api/ruleengine/ruleengineApi'; | 129 | } from '/@/api/ruleengine/ruleengineApi'; |
| 131 | import TriggerOrCondition from './cpns/Trigger-Condition.vue'; | 130 | import TriggerOrCondition from './cpns/Trigger-Condition.vue'; |
| 132 | import Action from './cpns/Action.vue'; | 131 | import Action from './cpns/Action.vue'; |
| 133 | - import { findOperation } from './config/formatData.ts'; | 132 | + import { findOperation } from './config/formatData'; |
| 134 | import { formatToDateTime } from '/@/utils/dateUtil'; | 133 | import { formatToDateTime } from '/@/utils/dateUtil'; |
| 135 | 134 | ||
| 136 | const emit = defineEmits(['register', 'success']); | 135 | const emit = defineEmits(['register', 'success']); |
| @@ -179,6 +178,7 @@ | @@ -179,6 +178,7 @@ | ||
| 179 | doConditions, | 178 | doConditions, |
| 180 | doActions, | 179 | doActions, |
| 181 | } = data.record; | 180 | } = data.record; |
| 181 | + organizationIdRef.value = organizationId; | ||
| 182 | // 赋值 | 182 | // 赋值 |
| 183 | await setFieldsValue(data.record); | 183 | await setFieldsValue(data.record); |
| 184 | id.value = recordId; | 184 | id.value = recordId; |
| @@ -186,7 +186,7 @@ | @@ -186,7 +186,7 @@ | ||
| 186 | //TODO-fengtao-把组织id传给子组件 | 186 | //TODO-fengtao-把组织id传给子组件 |
| 187 | provideOrgid.value = organizationId; | 187 | provideOrgid.value = organizationId; |
| 188 | //TODO-fengtao获取当前执行动作下的设备(master那个接口) | 188 | //TODO-fengtao获取当前执行动作下的设备(master那个接口) |
| 189 | - getMasterDeviceList.value = await byOganizationIdGetMasterDevice(organizationId); | 189 | + // getMasterDeviceList.value = await byOrganizationIdGetMasterDevice(organizationId); |
| 190 | //TODO-fengtao | 190 | //TODO-fengtao |
| 191 | // 获取当前组织下的设备列表 | 191 | // 获取当前组织下的设备列表 |
| 192 | const options = await screenLinkPageByDeptIdGetDevice({ | 192 | const options = await screenLinkPageByDeptIdGetDevice({ |
| @@ -394,6 +394,7 @@ | @@ -394,6 +394,7 @@ | ||
| 394 | const selectDeviceId = ref(''); | 394 | const selectDeviceId = ref(''); |
| 395 | // 设置执行动作外层值 | 395 | // 设置执行动作外层值 |
| 396 | unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ | 396 | unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ |
| 397 | + ...action, | ||
| 397 | outTarget: action.outTarget, | 398 | outTarget: action.outTarget, |
| 398 | device: action.entityType, | 399 | device: action.entityType, |
| 399 | deviceId: action.deviceId, | 400 | deviceId: action.deviceId, |
| @@ -451,12 +452,12 @@ | @@ -451,12 +452,12 @@ | ||
| 451 | } | 452 | } |
| 452 | //fengtao-把设备id回传给子组件 | 453 | //fengtao-把设备id回传给子组件 |
| 453 | item.updateFieldAttributeFunc(selectDeviceId.value, provideOrgid.value); | 454 | item.updateFieldAttributeFunc(selectDeviceId.value, provideOrgid.value); |
| 454 | - item.updateFieldDeviceId( | ||
| 455 | - deviceList.value, | ||
| 456 | - provideOrgid.value, | ||
| 457 | - isUpdate.value, | ||
| 458 | - getMasterDeviceList.value | ||
| 459 | - ); | 455 | + // item.updateFieldDeviceId( |
| 456 | + // deviceList.value, | ||
| 457 | + // provideOrgid.value, | ||
| 458 | + // isUpdate.value, | ||
| 459 | + // getMasterDeviceList.value | ||
| 460 | + // ); | ||
| 460 | //fengtao | 461 | //fengtao |
| 461 | // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME | 462 | // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME |
| 462 | item.operationType = | 463 | item.operationType = |
| @@ -533,12 +534,12 @@ | @@ -533,12 +534,12 @@ | ||
| 533 | }); | 534 | }); |
| 534 | 535 | ||
| 535 | // 设置设备的options | 536 | // 设置设备的options |
| 536 | - const setEditFields = (linkAge, deviceList) => { | ||
| 537 | - unref(linkAge).map((item) => { | ||
| 538 | - //TODO-fengtao | ||
| 539 | - item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | ||
| 540 | - //TODO-fengtao | ||
| 541 | - }); | 537 | + const setEditFields = (_linkAge, _deviceList) => { |
| 538 | + // unref(linkAge).map((item) => { | ||
| 539 | + //TODO-fengtao | ||
| 540 | + // item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | ||
| 541 | + //TODO-fengtao | ||
| 542 | + // }); | ||
| 542 | }; | 543 | }; |
| 543 | // 设置告警配置options | 544 | // 设置告警配置options |
| 544 | const setEditAlarmConfig = (linkAge, alarmConfigList) => { | 545 | const setEditAlarmConfig = (linkAge, alarmConfigList) => { |
| @@ -554,16 +555,20 @@ | @@ -554,16 +555,20 @@ | ||
| 554 | //FT add 2022-10-27 | 555 | //FT add 2022-10-27 |
| 555 | const addOrgId = ref(''); | 556 | const addOrgId = ref(''); |
| 556 | //FT add 2022-10-27 | 557 | //FT add 2022-10-27 |
| 557 | - watch(organizationId, async (newValue: string) => { | 558 | + watch(organizationIdRef, async (newValue: string) => { |
| 558 | if (!newValue) return; | 559 | if (!newValue) return; |
| 559 | //FT add 2022-10-27 | 560 | //FT add 2022-10-27 |
| 560 | addOrgId.value = newValue; | 561 | addOrgId.value = newValue; |
| 561 | //FT add 2022-10-27 | 562 | //FT add 2022-10-27 |
| 562 | const { items = [] } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); | 563 | const { items = [] } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); |
| 563 | //TODO fengtao | 564 | //TODO fengtao |
| 564 | - getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue); | 565 | + // getMasterDeviceList.value = await byOrganizationIdGetMasterDevice(newValue); |
| 565 | //TODO fengtao | 566 | //TODO fengtao |
| 566 | - deviceList.value = (items || []).map((item) => ({ label: item.name, value: item.tbDeviceId })); | 567 | + deviceList.value = (items || []).map((item) => ({ |
| 568 | + ...item, | ||
| 569 | + label: item.name, | ||
| 570 | + value: item.tbDeviceId, | ||
| 571 | + })); | ||
| 567 | //TODO fengtao | 572 | //TODO fengtao |
| 568 | orgId.value = newValue; | 573 | orgId.value = newValue; |
| 569 | //TODO fengtao | 574 | //TODO fengtao |
| @@ -595,7 +600,7 @@ | @@ -595,7 +600,7 @@ | ||
| 595 | unref(linkAge).map((item) => { | 600 | unref(linkAge).map((item) => { |
| 596 | isOrganizationChange && item.resetFieldsValueFunc(); | 601 | isOrganizationChange && item.resetFieldsValueFunc(); |
| 597 | //TODO fengtao | 602 | //TODO fengtao |
| 598 | - item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | 603 | + // item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); |
| 599 | if (isUpdate.value) { | 604 | if (isUpdate.value) { |
| 600 | item.updateEditFieldAlarmConfig(editAlarmConfigData); | 605 | item.updateEditFieldAlarmConfig(editAlarmConfigData); |
| 601 | } else { | 606 | } else { |
| @@ -661,6 +666,8 @@ | @@ -661,6 +666,8 @@ | ||
| 661 | createMessage.error('请添加触发器或者执行条件'); | 666 | createMessage.error('请添加触发器或者执行条件'); |
| 662 | throw '请添加触发器或者执行条件'; | 667 | throw '请添加触发器或者执行条件'; |
| 663 | } | 668 | } |
| 669 | + | ||
| 670 | + // return; | ||
| 664 | //新增的代码2022-11-22 | 671 | //新增的代码2022-11-22 |
| 665 | const postAddOrEditData = { | 672 | const postAddOrEditData = { |
| 666 | ...basicFormValue, | 673 | ...basicFormValue, |
| @@ -722,7 +729,7 @@ | @@ -722,7 +729,7 @@ | ||
| 722 | const handleClose = () => { | 729 | const handleClose = () => { |
| 723 | id.value = undefined; | 730 | id.value = undefined; |
| 724 | tenantId.value = undefined; | 731 | tenantId.value = undefined; |
| 725 | - organizationId.value = undefined; | 732 | + organizationIdRef.value = undefined; |
| 726 | isView.value = true; | 733 | isView.value = true; |
| 727 | getTriggerFormValue.value = []; | 734 | getTriggerFormValue.value = []; |
| 728 | getConditionFormValue.value = []; | 735 | getConditionFormValue.value = []; |
| 1 | -import { ref } from 'vue'; | 1 | +import { ref, unref } from 'vue'; |
| 2 | import { BasicColumn, FormSchema } from '/@/components/Table'; | 2 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
| 3 | -import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi'; | 3 | +import { |
| 4 | + byOrganizationIdGetMasterDevice, | ||
| 5 | + screenLinkOrganizationGetApi, | ||
| 6 | +} from '/@/api/ruleengine/ruleengineApi'; | ||
| 4 | import { scheduleOptions } from './formatData'; | 7 | import { scheduleOptions } from './formatData'; |
| 5 | import { copyTransFun } from '/@/utils/fnUtils'; | 8 | import { copyTransFun } from '/@/utils/fnUtils'; |
| 6 | import { numberAndNonegativeRule } from '/@/utils/rules'; | 9 | import { numberAndNonegativeRule } from '/@/utils/rules'; |
| 7 | import { findDictItemByCode } from '/@/api/system/dict'; | 10 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 11 | +import { deviceProfile } from '/@/api/device/deviceManager'; | ||
| 12 | +import { getModelServices } from '/@/api/device/modelOfMatter'; | ||
| 13 | +import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; | ||
| 8 | 14 | ||
| 9 | /** | 15 | /** |
| 10 | * 所使用的枚举值 | 16 | * 所使用的枚举值 |
| @@ -167,10 +173,10 @@ const isPartOrAll = (type: string) => { | @@ -167,10 +173,10 @@ const isPartOrAll = (type: string) => { | ||
| 167 | return type === 'ALL' || type === 'PART'; | 173 | return type === 'ALL' || type === 'PART'; |
| 168 | }; | 174 | }; |
| 169 | const isService = (type: string) => { | 175 | const isService = (type: string) => { |
| 170 | - return type === 'service'; | 176 | + return Number(type) === 1; |
| 171 | }; | 177 | }; |
| 172 | const isDefine = (type: string) => { | 178 | const isDefine = (type: string) => { |
| 173 | - return type === 'custom_define'; | 179 | + return Number(type) === 0; |
| 174 | }; | 180 | }; |
| 175 | //新增代码2022-11-23 | 181 | //新增代码2022-11-23 |
| 176 | 182 | ||
| @@ -319,95 +325,147 @@ export const actionSchema: FormSchema[] = [ | @@ -319,95 +325,147 @@ export const actionSchema: FormSchema[] = [ | ||
| 319 | colProps: { span: 6 }, | 325 | colProps: { span: 6 }, |
| 320 | }, | 326 | }, |
| 321 | { | 327 | { |
| 328 | + field: 'deviceProfileId', | ||
| 329 | + label: '', | ||
| 330 | + component: 'ApiSelect', | ||
| 331 | + colProps: { span: 6 }, | ||
| 332 | + componentProps: ({ formActionType }) => { | ||
| 333 | + const { setFieldsValue } = formActionType; | ||
| 334 | + return { | ||
| 335 | + api: deviceProfile, | ||
| 336 | + placeholder: '请选择产品', | ||
| 337 | + labelField: 'name', | ||
| 338 | + valueField: 'id', | ||
| 339 | + getPopupContainer: () => document.body, | ||
| 340 | + onChange: () => { | ||
| 341 | + setFieldsValue({ deviceId: [] }); | ||
| 342 | + }, | ||
| 343 | + }; | ||
| 344 | + }, | ||
| 345 | + ifShow: ({ values }) => isDeviceOut(values.outTarget), | ||
| 346 | + }, | ||
| 347 | + { | ||
| 322 | field: 'device', | 348 | field: 'device', |
| 323 | label: '', | 349 | label: '', |
| 324 | component: 'Select', | 350 | component: 'Select', |
| 325 | - componentProps: { | ||
| 326 | - placeholder: '请选择设备', | ||
| 327 | - options: [ | ||
| 328 | - { label: '全部', value: 'ALL' }, | ||
| 329 | - { label: '部分', value: 'PART' }, | ||
| 330 | - ], | 351 | + componentProps: ({ formActionType }) => { |
| 352 | + const { setFieldsValue } = formActionType; | ||
| 353 | + return { | ||
| 354 | + placeholder: '请选择设备', | ||
| 355 | + options: [ | ||
| 356 | + { label: '全部', value: 'ALL' }, | ||
| 357 | + { label: '部分', value: 'PART' }, | ||
| 358 | + ], | ||
| 359 | + onChange: () => { | ||
| 360 | + setFieldsValue({ deviceId: [], thingsModelId: null }); | ||
| 361 | + }, | ||
| 362 | + }; | ||
| 331 | }, | 363 | }, |
| 332 | - ifShow: ({ values }) => isDeviceOut(values.outTarget), | 364 | + ifShow: ({ values }) => isDeviceOut(values.outTarget) && values['deviceProfileId'], |
| 333 | colProps: { span: 6 }, | 365 | colProps: { span: 6 }, |
| 334 | }, | 366 | }, |
| 335 | { | 367 | { |
| 336 | field: 'deviceId', | 368 | field: 'deviceId', |
| 337 | label: '', | 369 | label: '', |
| 338 | - component: 'Select', | ||
| 339 | - componentProps: { | ||
| 340 | - placeholder: '请选择设备', | ||
| 341 | - mode: 'multiple', | 370 | + component: 'ApiSelect', |
| 371 | + componentProps: ({ formModel }) => { | ||
| 372 | + const deviceProfileId = formModel['deviceProfileId']; | ||
| 373 | + return { | ||
| 374 | + placeholder: '请选择设备', | ||
| 375 | + mode: 'multiple', | ||
| 376 | + api: byOrganizationIdGetMasterDevice, | ||
| 377 | + params: { | ||
| 378 | + organizationId: unref(organizationId), | ||
| 379 | + deviceProfileId, | ||
| 380 | + }, | ||
| 381 | + labelField: 'name', | ||
| 382 | + valueField: 'id', | ||
| 383 | + }; | ||
| 342 | }, | 384 | }, |
| 343 | ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget), | 385 | ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget), |
| 344 | colProps: { span: 6 }, | 386 | colProps: { span: 6 }, |
| 345 | }, | 387 | }, |
| 346 | //新增代码2022-11-23 | 388 | //新增代码2022-11-23 |
| 347 | { | 389 | { |
| 348 | - field: 'customDefine', | 390 | + field: 'commandType', |
| 349 | label: '', | 391 | label: '', |
| 350 | required: true, | 392 | required: true, |
| 351 | component: 'ApiSelect', | 393 | component: 'ApiSelect', |
| 352 | colProps: { | 394 | colProps: { |
| 353 | span: 6, | 395 | span: 6, |
| 354 | }, | 396 | }, |
| 355 | - defaultValue: 'custom_define', | ||
| 356 | - componentProps: { | ||
| 357 | - placeholder: '请选择类型', | ||
| 358 | - api: findDictItemByCode, | ||
| 359 | - params: { | ||
| 360 | - dictCode: 'custom_define', | ||
| 361 | - }, | ||
| 362 | - labelField: 'itemText', | ||
| 363 | - valueField: 'itemValue', | ||
| 364 | - getPopupContainer: () => document.body, | 397 | + defaultValue: '0', |
| 398 | + componentProps: ({ formActionType }) => { | ||
| 399 | + const { setFieldsValue } = formActionType; | ||
| 400 | + return { | ||
| 401 | + placeholder: '请选择类型', | ||
| 402 | + api: async () => { | ||
| 403 | + const record = await findDictItemByCode({ | ||
| 404 | + dictCode: 'custom_define', | ||
| 405 | + }); | ||
| 406 | + return record.map((item) => ({ ...item, itemValue: Number(item.itemValue) })); | ||
| 407 | + }, | ||
| 408 | + labelField: 'itemText', | ||
| 409 | + valueField: 'itemValue', | ||
| 410 | + getPopupContainer: () => document.body, | ||
| 411 | + onChange: () => { | ||
| 412 | + setFieldsValue({ doContext: null, thingsModelId: null }); | ||
| 413 | + }, | ||
| 414 | + }; | ||
| 365 | }, | 415 | }, |
| 366 | ifShow: ({ values }) => isDeviceOut(values.outTarget) && isPartOrAll(values.device), | 416 | ifShow: ({ values }) => isDeviceOut(values.outTarget) && isPartOrAll(values.device), |
| 367 | }, | 417 | }, |
| 368 | //新增代码2022-11-23 | 418 | //新增代码2022-11-23 |
| 369 | { | 419 | { |
| 370 | - field: 'customMode', | 420 | + field: 'callType', |
| 371 | label: '', | 421 | label: '', |
| 372 | required: true, | 422 | required: true, |
| 373 | component: 'ApiSelect', | 423 | component: 'ApiSelect', |
| 374 | colProps: { | 424 | colProps: { |
| 375 | span: 6, | 425 | span: 6, |
| 376 | }, | 426 | }, |
| 377 | - defaultValue: 'OneWay', | 427 | + defaultValue: 'SYNC', |
| 378 | componentProps: { | 428 | componentProps: { |
| 379 | placeholder: '请选择类型', | 429 | placeholder: '请选择类型', |
| 380 | api: findDictItemByCode, | 430 | api: findDictItemByCode, |
| 381 | params: { | 431 | params: { |
| 382 | - dictCode: 'custom_mode', | 432 | + dictCode: 'call_mode', |
| 383 | }, | 433 | }, |
| 384 | labelField: 'itemText', | 434 | labelField: 'itemText', |
| 385 | valueField: 'itemValue', | 435 | valueField: 'itemValue', |
| 386 | getPopupContainer: () => document.body, | 436 | getPopupContainer: () => document.body, |
| 387 | }, | 437 | }, |
| 388 | ifShow: ({ values }) => | 438 | ifShow: ({ values }) => |
| 389 | - isDeviceOut(values.outTarget) && isPartOrAll(values.device) && isDefine(values.customDefine), | 439 | + isDeviceOut(values.outTarget) && isPartOrAll(values.device) && isDefine(values.commandType), |
| 390 | }, | 440 | }, |
| 391 | //新增代码2022-11-23 | 441 | //新增代码2022-11-23 |
| 392 | { | 442 | { |
| 393 | - field: 'service', | 443 | + field: 'thingsModelId', |
| 394 | label: '', | 444 | label: '', |
| 395 | required: true, | 445 | required: true, |
| 396 | component: 'ApiSelect', | 446 | component: 'ApiSelect', |
| 397 | colProps: { | 447 | colProps: { |
| 398 | span: 6, | 448 | span: 6, |
| 399 | }, | 449 | }, |
| 400 | - componentProps: { | ||
| 401 | - placeholder: '请选择服务', | ||
| 402 | - api: findDictItemByCode, | ||
| 403 | - params: { | ||
| 404 | - dictCode: 'attribute_unit', | ||
| 405 | - }, | ||
| 406 | - labelField: 'itemText', | ||
| 407 | - valueField: 'itemValue', | ||
| 408 | - getPopupContainer: () => document.body, | 450 | + componentProps: ({ formModel, formActionType }) => { |
| 451 | + const { setFieldsValue } = formActionType; | ||
| 452 | + const deviceProfileId = formModel['deviceProfileId']; | ||
| 453 | + return { | ||
| 454 | + placeholder: '请选择服务', | ||
| 455 | + api: getModelServices, | ||
| 456 | + params: { | ||
| 457 | + deviceProfileId, | ||
| 458 | + }, | ||
| 459 | + labelField: 'functionName', | ||
| 460 | + valueField: 'id', | ||
| 461 | + getPopupContainer: () => document.body, | ||
| 462 | + onChange: (_, options: ModelOfMatterParams) => { | ||
| 463 | + // console.log(options); | ||
| 464 | + setFieldsValue({ doContext: { ...options.functionJson, callType: options.callType } }); | ||
| 465 | + }, | ||
| 466 | + }; | ||
| 409 | }, | 467 | }, |
| 410 | - ifShow: ({ values }) => isDeviceOut(values.outTarget) && isService(values.customDefine), | 468 | + ifShow: ({ values }) => isDeviceOut(values.outTarget) && isService(values.commandType), |
| 411 | }, | 469 | }, |
| 412 | //新增代码2022-11-23 | 470 | //新增代码2022-11-23 |
| 413 | { | 471 | { |
| @@ -429,7 +487,7 @@ export const actionSchema: FormSchema[] = [ | @@ -429,7 +487,7 @@ export const actionSchema: FormSchema[] = [ | ||
| 429 | slot: 'doContext', | 487 | slot: 'doContext', |
| 430 | show: ({ values }) => { | 488 | show: ({ values }) => { |
| 431 | return ( | 489 | return ( |
| 432 | - isDeviceOut(values.outTarget) && isPartOrAll(values.device) && isDefine(values.customDefine) | 490 | + isDeviceOut(values.outTarget) && isPartOrAll(values.device) && isDefine(values.commandType) |
| 433 | ); | 491 | ); |
| 434 | }, | 492 | }, |
| 435 | colProps: { | 493 | colProps: { |
| 1 | import { formatToDateTime } from '/@/utils/dateUtil'; | 1 | import { formatToDateTime } from '/@/utils/dateUtil'; |
| 2 | import { Number_Operation, String_Operation, Boolean_Operation } from '/@/enums/operationEnum'; | 2 | import { Number_Operation, String_Operation, Boolean_Operation } from '/@/enums/operationEnum'; |
| 3 | -import { numberAndNonegativeRule } from '/@/utils/rules'; | ||
| 4 | 3 | ||
| 5 | // 生成触发器或执行条件JSON数据 | 4 | // 生成触发器或执行条件JSON数据 |
| 6 | export const genTriggerOrConditionData = (triggerData) => { | 5 | export const genTriggerOrConditionData = (triggerData) => { |
| @@ -77,6 +76,11 @@ export const genActionData = (actionData) => { | @@ -77,6 +76,11 @@ export const genActionData = (actionData) => { | ||
| 77 | doContext, | 76 | doContext, |
| 78 | device, | 77 | device, |
| 79 | deviceId, | 78 | deviceId, |
| 79 | + deviceProfileId, | ||
| 80 | + commandType, | ||
| 81 | + callType, | ||
| 82 | + service, | ||
| 83 | + thingsModelId, | ||
| 80 | } = actionData; | 84 | } = actionData; |
| 81 | const clearRule = clearRules.map((item) => { | 85 | const clearRule = clearRules.map((item) => { |
| 82 | const mapPredicate = item.predicate.map((pred) => { | 86 | const mapPredicate = item.predicate.map((pred) => { |
| @@ -133,6 +137,11 @@ export const genActionData = (actionData) => { | @@ -133,6 +137,11 @@ export const genActionData = (actionData) => { | ||
| 133 | outTarget, | 137 | outTarget, |
| 134 | entityType: device ?? 'ALL', | 138 | entityType: device ?? 'ALL', |
| 135 | deviceId: device === 'PART' ? deviceId : null, | 139 | deviceId: device === 'PART' ? deviceId : null, |
| 140 | + deviceProfileId, | ||
| 141 | + commandType, | ||
| 142 | + callType, | ||
| 143 | + service, | ||
| 144 | + thingsModelId, | ||
| 136 | doContext: clearRule?.length | 145 | doContext: clearRule?.length |
| 137 | ? { | 146 | ? { |
| 138 | alarmLevel: alarm_level, | 147 | alarmLevel: alarm_level, |
| @@ -246,15 +246,20 @@ | @@ -246,15 +246,20 @@ | ||
| 246 | } | 246 | } |
| 247 | //ft-add-2022-11-22 | 247 | //ft-add-2022-11-22 |
| 248 | //TODO-fengtao-设备验证 | 248 | //TODO-fengtao-设备验证 |
| 249 | + const value = getFieldsValue(); | ||
| 250 | + const doContext = unref(jsonInstance)?.get() || {}; | ||
| 249 | return { | 251 | return { |
| 250 | - ...getFieldsValue(), | ||
| 251 | - doContext: unref(jsonInstance.value)?.get(), | 252 | + ...value, |
| 253 | + ...(Number(value.commandType) === 0 ? { doContext } : {}), | ||
| 252 | clearRule, | 254 | clearRule, |
| 253 | }; | 255 | }; |
| 254 | }; | 256 | }; |
| 255 | 257 | ||
| 256 | const setFieldsFormValueFun = (fieldsValue) => { | 258 | const setFieldsFormValueFun = (fieldsValue) => { |
| 257 | - setFieldsValue(fieldsValue); | 259 | + setFieldsValue({ |
| 260 | + ...fieldsValue, | ||
| 261 | + ...(fieldsValue.commandType ? { commandType: String(fieldsValue.commandType) } : {}), | ||
| 262 | + }); | ||
| 258 | }; | 263 | }; |
| 259 | //ft-add | 264 | //ft-add |
| 260 | const resetConditionForm = () => {}; | 265 | const resetConditionForm = () => {}; |