Showing
1 changed file
with
37 additions
and
18 deletions
| 1 | import { Options } from './type'; | 1 | import { Options } from './type'; |
| 2 | -import { getDeviceProfile } from '/@/api/alarm/position'; | 2 | +import { queryDeviceProfileBy } from '/@/api/device/deviceManager'; |
| 3 | +import { findDictItemByCode } from '/@/api/system/dict'; | ||
| 3 | import { getOrganizationList } from '/@/api/system/system'; | 4 | import { getOrganizationList } from '/@/api/system/system'; |
| 4 | import { FormSchema } from '/@/components/Form'; | 5 | import { FormSchema } from '/@/components/Form'; |
| 5 | import { BasicColumn } from '/@/components/Table'; | 6 | import { BasicColumn } from '/@/components/Table'; |
| @@ -7,8 +8,8 @@ import { copyTransFun } from '/@/utils/fnUtils'; | @@ -7,8 +8,8 @@ import { copyTransFun } from '/@/utils/fnUtils'; | ||
| 7 | 8 | ||
| 8 | export enum FieldsEnum { | 9 | export enum FieldsEnum { |
| 9 | ORGANIZATION_ID = 'organizationId', | 10 | ORGANIZATION_ID = 'organizationId', |
| 11 | + DEVICE_TYPE = 'deviceTypeEnum', | ||
| 10 | TK_DEVICE_PROFILE_ID = 'tkDeviceProfileId', | 12 | TK_DEVICE_PROFILE_ID = 'tkDeviceProfileId', |
| 11 | - DEVICE_TYPE_ENUM = 'deviceTypeEnum', | ||
| 12 | DEVICE_TYPE_NAME = 'deviceTypeName', | 13 | DEVICE_TYPE_NAME = 'deviceTypeName', |
| 13 | DELIMITER = 'delimiter', | 14 | DELIMITER = 'delimiter', |
| 14 | HEADER = 'header', | 15 | HEADER = 'header', |
| @@ -118,36 +119,54 @@ export const basicInfoForm: FormSchema[] = [ | @@ -118,36 +119,54 @@ export const basicInfoForm: FormSchema[] = [ | ||
| 118 | }, | 119 | }, |
| 119 | }, | 120 | }, |
| 120 | { | 121 | { |
| 122 | + field: FieldsEnum.DEVICE_TYPE, | ||
| 123 | + label: '设备类型', | ||
| 124 | + component: 'ApiSelect', | ||
| 125 | + rules: [{ required: true, message: '设备类型为必填项' }], | ||
| 126 | + componentProps: ({ formActionType }) => { | ||
| 127 | + const { setFieldsValue, submit, clearValidate } = formActionType; | ||
| 128 | + return { | ||
| 129 | + api: findDictItemByCode, | ||
| 130 | + params: { | ||
| 131 | + dictCode: 'device_type', | ||
| 132 | + }, | ||
| 133 | + labelField: 'itemText', | ||
| 134 | + valueField: 'itemValue', | ||
| 135 | + onChange: (value: string, options: Record<'deviceType' | 'label', string>) => { | ||
| 136 | + setFieldsValue({ | ||
| 137 | + [FieldsEnum.DEVICE_TYPE_NAME]: value ? options.label : null, | ||
| 138 | + [FieldsEnum.TK_DEVICE_PROFILE_ID]: null, | ||
| 139 | + }); | ||
| 140 | + submit(); | ||
| 141 | + clearValidate(); | ||
| 142 | + }, | ||
| 143 | + }; | ||
| 144 | + }, | ||
| 145 | + }, | ||
| 146 | + { | ||
| 121 | field: FieldsEnum.TK_DEVICE_PROFILE_ID, | 147 | field: FieldsEnum.TK_DEVICE_PROFILE_ID, |
| 122 | component: 'ApiSelect', | 148 | component: 'ApiSelect', |
| 123 | label: '产品', | 149 | label: '产品', |
| 124 | rules: [{ required: true, message: '产品为必填项' }], | 150 | rules: [{ required: true, message: '产品为必填项' }], |
| 125 | - componentProps: ({ formActionType }) => { | ||
| 126 | - const { submit, setFieldsValue } = formActionType; | 151 | + componentProps: ({ formActionType, formModel }) => { |
| 152 | + const { submit } = formActionType; | ||
| 153 | + const deviceType = Reflect.get(formModel, FieldsEnum.DEVICE_TYPE); | ||
| 127 | return { | 154 | return { |
| 128 | - api: getDeviceProfile, | 155 | + api: queryDeviceProfileBy, |
| 129 | labelField: 'name', | 156 | labelField: 'name', |
| 130 | valueField: 'id', | 157 | valueField: 'id', |
| 131 | placeholder: '请选择产品', | 158 | placeholder: '请选择产品', |
| 159 | + params: { deviceType }, | ||
| 132 | getPopupContainer: () => document.body, | 160 | getPopupContainer: () => document.body, |
| 133 | - onChange: (value: string, options: Record<'deviceType' | 'label', string>) => { | ||
| 134 | - value && | ||
| 135 | - setFieldsValue({ | ||
| 136 | - [FieldsEnum.DEVICE_TYPE_ENUM]: options.deviceType, | ||
| 137 | - [FieldsEnum.DEVICE_TYPE_NAME]: options.label, | ||
| 138 | - }); | ||
| 139 | - submit(); | 161 | + onChange: () => submit(), |
| 162 | + showSearch: true, | ||
| 163 | + filterOption: (inputValue: string, options: Record<'label', string>) => { | ||
| 164 | + return options.label.includes(inputValue); | ||
| 140 | }, | 165 | }, |
| 141 | }; | 166 | }; |
| 142 | }, | 167 | }, |
| 143 | }, | 168 | }, |
| 144 | { | 169 | { |
| 145 | - field: FieldsEnum.DEVICE_TYPE_ENUM, | ||
| 146 | - component: 'Input', | ||
| 147 | - label: '设备类型', | ||
| 148 | - show: false, | ||
| 149 | - }, | ||
| 150 | - { | ||
| 151 | field: FieldsEnum.DEVICE_TYPE_NAME, | 170 | field: FieldsEnum.DEVICE_TYPE_NAME, |
| 152 | component: 'Input', | 171 | component: 'Input', |
| 153 | label: '设备名称', | 172 | label: '设备名称', |