Commit b4d06540b784ee69a3b20d266c5c4172cbe0c1a9

Authored by ww
1 parent 2af1562a

perf: 设备列表批量导入设备新增设备类型筛选,设备名称新增筛选

1 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 4 import { getOrganizationList } from '/@/api/system/system';
4 5 import { FormSchema } from '/@/components/Form';
5 6 import { BasicColumn } from '/@/components/Table';
... ... @@ -7,8 +8,8 @@ import { copyTransFun } from '/@/utils/fnUtils';
7 8
8 9 export enum FieldsEnum {
9 10 ORGANIZATION_ID = 'organizationId',
  11 + DEVICE_TYPE = 'deviceTypeEnum',
10 12 TK_DEVICE_PROFILE_ID = 'tkDeviceProfileId',
11   - DEVICE_TYPE_ENUM = 'deviceTypeEnum',
12 13 DEVICE_TYPE_NAME = 'deviceTypeName',
13 14 DELIMITER = 'delimiter',
14 15 HEADER = 'header',
... ... @@ -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 147 field: FieldsEnum.TK_DEVICE_PROFILE_ID,
122 148 component: 'ApiSelect',
123 149 label: '产品',
124 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 154 return {
128   - api: getDeviceProfile,
  155 + api: queryDeviceProfileBy,
129 156 labelField: 'name',
130 157 valueField: 'id',
131 158 placeholder: '请选择产品',
  159 + params: { deviceType },
132 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 170 field: FieldsEnum.DEVICE_TYPE_NAME,
152 171 component: 'Input',
153 172 label: '设备名称',
... ...