Showing
6 changed files
with
76 additions
and
16 deletions
| ... | ... | @@ -413,13 +413,25 @@ export const customerForm: FormSchema[] = [ |
| 413 | 413 | |
| 414 | 414 | export const orgForm: FormSchema[] = [ |
| 415 | 415 | { |
| 416 | + field: 'sensorOrganizationId', | |
| 417 | + label: '依据网关设备请求的组织数组', | |
| 418 | + component: 'Input', | |
| 419 | + ifShow: false, | |
| 420 | + }, | |
| 421 | + { | |
| 416 | 422 | field: 'organizationId', |
| 417 | 423 | component: 'OrgTreeSelect', |
| 418 | 424 | helpMessage: updateOrgHelpMessage, |
| 419 | 425 | label: '选择组织', |
| 420 | 426 | required: true, |
| 421 | - componentProps: { | |
| 422 | - placeholder: '请选择', | |
| 427 | + componentProps: ({ formModel }) => { | |
| 428 | + return { | |
| 429 | + apiTreeSelectProps: { | |
| 430 | + params: { | |
| 431 | + organizationId: formModel?.sensorOrganizationId, | |
| 432 | + }, | |
| 433 | + }, | |
| 434 | + }; | |
| 423 | 435 | }, |
| 424 | 436 | }, |
| 425 | 437 | ]; | ... | ... |
| ... | ... | @@ -15,11 +15,11 @@ |
| 15 | 15 | </template> |
| 16 | 16 | |
| 17 | 17 | <script lang="ts"> |
| 18 | - import { defineComponent, ref } from 'vue'; | |
| 18 | + import { defineComponent, ref, nextTick } from 'vue'; | |
| 19 | 19 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
| 20 | 20 | import { BasicForm, useForm } from '/@/components/Form'; |
| 21 | 21 | import { orgForm } from '../../config/detail.config'; |
| 22 | - import { doBatchUpdateDevice } from '/@/api/device/deviceManager'; | |
| 22 | + import { doBatchUpdateDevice, getGATEWAY } from '/@/api/device/deviceManager'; | |
| 23 | 23 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 24 | 24 | |
| 25 | 25 | export default defineComponent({ |
| ... | ... | @@ -34,11 +34,28 @@ |
| 34 | 34 | |
| 35 | 35 | const record = ref([]); |
| 36 | 36 | |
| 37 | - const [registerModal, { closeModal, setModalProps }] = useModalInner((data) => { | |
| 37 | + const [registerModal, { closeModal, setModalProps }] = useModalInner(async (data) => { | |
| 38 | + await nextTick(); | |
| 38 | 39 | record.value = data; |
| 40 | + // 如果是网关子设备 | |
| 41 | + const deviceTypeFilterSensor = data | |
| 42 | + .filter((filterItem) => filterItem.deviceType === 'SENSOR') | |
| 43 | + .map((mapItem) => mapItem.tbDeviceId); | |
| 44 | + // 根据gatewayId获取网关所属组织 | |
| 45 | + for (let item of deviceTypeFilterSensor) { | |
| 46 | + await getGATEWAYByTbDeviceId(item); | |
| 47 | + } | |
| 39 | 48 | }); |
| 40 | 49 | |
| 41 | - const [registerForm, { validate, resetFields }] = useForm({ | |
| 50 | + const getGATEWAYByTbDeviceId = async (tbDeviceId: string) => { | |
| 51 | + const result = await getGATEWAY(tbDeviceId); | |
| 52 | + if (!result) return; | |
| 53 | + setFieldsValue({ | |
| 54 | + sensorOrganizationId: result.organizationId, | |
| 55 | + }); | |
| 56 | + }; | |
| 57 | + | |
| 58 | + const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({ | |
| 42 | 59 | labelWidth: 100, |
| 43 | 60 | showActionButtonGroup: false, |
| 44 | 61 | schemas: orgForm, | ... | ... |
| ... | ... | @@ -70,7 +70,7 @@ |
| 70 | 70 | text: '批量修改组织', |
| 71 | 71 | icon: 'ant-design:wallet-outlined', |
| 72 | 72 | event: '', |
| 73 | - disabled: !batchPrivateFlag, | |
| 73 | + disabled: !batchPrivateFlag || batchSensorFlag || diffBatchSensorFlag, | |
| 74 | 74 | onClick: handleBatchOrg.bind(null), |
| 75 | 75 | }, |
| 76 | 76 | ]" |
| ... | ... | @@ -360,6 +360,10 @@ |
| 360 | 360 | |
| 361 | 361 | const batchPrivateFlag = ref(true); |
| 362 | 362 | |
| 363 | + const batchSensorFlag = ref(false); | |
| 364 | + | |
| 365 | + const diffBatchSensorFlag = ref(false); | |
| 366 | + | |
| 363 | 367 | const [ |
| 364 | 368 | registerTable, |
| 365 | 369 | { |
| ... | ... | @@ -420,6 +424,14 @@ |
| 420 | 424 | !selectedRows.every((item) => (item as DeviceRecord).deviceType === deviceType); |
| 421 | 425 | |
| 422 | 426 | batchPrivateFlag.value = selectedRows.some((item: DeviceRecord) => !item?.customerId); |
| 427 | + const filterSensor = selectedRows.map((filterItem: DeviceRecord) => filterItem.deviceType); | |
| 428 | + batchSensorFlag.value = | |
| 429 | + filterSensor.includes('SENSOR') && | |
| 430 | + (filterSensor.includes('DIRECT_CONNECTION') || filterSensor.includes('GATEWAY')); // 网关子和直连设备或者网关设备,则禁用组织修改 | |
| 431 | + const filterGatewayId = selectedRows | |
| 432 | + .filter((filterItem: DeviceRecord) => filterItem.deviceType === 'SENSOR') | |
| 433 | + .map((mapItem: DeviceRecord) => mapItem.gatewayId); | |
| 434 | + diffBatchSensorFlag.value = [...new Set(filterGatewayId)].length > 1; // 数组长度大于1,说明选择的网关子设备所属网关为多个,则禁用组织修改 | |
| 423 | 435 | isPublicAndPrivateFlag.value = |
| 424 | 436 | selectedRows.some((item: DeviceRecord) => !item?.customerId) && |
| 425 | 437 | selectedRows.some((item: DeviceRecord) => item?.customerAdditionalInfo?.isPublic); |
| ... | ... | @@ -432,6 +444,14 @@ |
| 432 | 444 | !selectedRows.every((item) => (item as DeviceRecord).deviceType === deviceType); |
| 433 | 445 | |
| 434 | 446 | batchPrivateFlag.value = selectedRows.some((item) => !item?.customerId); |
| 447 | + const filterSensor = selectedRows.map((filterItem) => filterItem.deviceType); | |
| 448 | + batchSensorFlag.value = | |
| 449 | + filterSensor.includes('SENSOR') && | |
| 450 | + (filterSensor.includes('DIRECT_CONNECTION') || filterSensor.includes('GATEWAY')); // 网关子和直连设备或者网关设备,则禁用组织修改 | |
| 451 | + const filterGatewayId = selectedRows | |
| 452 | + .filter((filterItem: DeviceRecord) => filterItem.deviceType === 'SENSOR') | |
| 453 | + .map((mapItem: DeviceRecord) => mapItem.gatewayId); | |
| 454 | + diffBatchSensorFlag.value = [...new Set(filterGatewayId)].length > 1; // 数组长度大于1,说明选择的网关子设备所属网关为多个,则禁用组织修改 | |
| 435 | 455 | isPublicAndPrivateFlag.value = |
| 436 | 456 | selectedRows.some((item) => !item?.customerId) && |
| 437 | 457 | selectedRows.some((item) => item?.customerAdditionalInfo?.isPublic); | ... | ... |
| ... | ... | @@ -108,13 +108,20 @@ export const formSchema: FormSchema[] = [ |
| 108 | 108 | label: '消息类型', |
| 109 | 109 | required: true, |
| 110 | 110 | component: 'ApiSelect', |
| 111 | - componentProps: { | |
| 112 | - api: findDictItemByCode, | |
| 113 | - params: { | |
| 114 | - dictCode: 'message_type', | |
| 115 | - }, | |
| 116 | - labelField: 'itemText', | |
| 117 | - valueField: 'itemValue', | |
| 111 | + componentProps({ formActionType }) { | |
| 112 | + return { | |
| 113 | + api: findDictItemByCode, | |
| 114 | + params: { | |
| 115 | + dictCode: 'message_type', | |
| 116 | + }, | |
| 117 | + labelField: 'itemText', | |
| 118 | + valueField: 'itemValue', | |
| 119 | + onChange() { | |
| 120 | + formActionType.setFieldsValue({ | |
| 121 | + platformType: null, | |
| 122 | + }); | |
| 123 | + }, | |
| 124 | + }; | |
| 118 | 125 | }, |
| 119 | 126 | }, |
| 120 | 127 | { |
| ... | ... | @@ -130,7 +137,10 @@ export const formSchema: FormSchema[] = [ |
| 130 | 137 | const messageType = Reflect.get(formModel, 'messageType'); |
| 131 | 138 | if (isMessage(messageType)) |
| 132 | 139 | return result.filter( |
| 133 | - (item) => item.itemValue !== 'DING_TALK' && item.itemValue !== 'ALI_VOICE' | |
| 140 | + (item) => | |
| 141 | + item.itemValue !== 'DING_TALK' && | |
| 142 | + item.itemValue !== 'ALI_VOICE' && | |
| 143 | + item.itemValue !== 'ENTERPRISE_WECHAT' | |
| 134 | 144 | ); |
| 135 | 145 | |
| 136 | 146 | if (isEnterpriseWechat(messageType)) { | ... | ... |