Commit ff4e005a78101e5feeac142184417eaf3dad7cfc

Authored by ww
1 parent c3c429ae

pref: 优化设备导入子设备时需根据网关设备协议过滤

... ... @@ -20,6 +20,7 @@ export enum FieldsEnum {
20 20 GATEWAY_TB_DEVICE_ID = 'gateWayTbDeviceId',
21 21 TB_DEVICE_PROFILE_ID = 'tbDeviceProfileId',
22 22 IS_TCP_DEVICE_PROFILE = 'isTcpDeviceProfile',
  23 + TRANSPORT_TYPE = 'transportType',
23 24 }
24 25
25 26 export enum DelimiterEnum {
... ... @@ -150,6 +151,7 @@ export const basicInfoForm: FormSchema[] = [
150 151 });
151 152 clearValidate();
152 153 },
  154 + placeholder: '请选择设备类型',
153 155 };
154 156 },
155 157 },
... ... @@ -174,6 +176,8 @@ export const basicInfoForm: FormSchema[] = [
174 176 ? options.transportType === TransportTypeEnum.TCP
175 177 : false,
176 178 [FieldsEnum.TB_DEVICE_PROFILE_ID]: value ? options.tbProfileId : null,
  179 + [FieldsEnum.GATEWAY_TB_DEVICE_ID]: null,
  180 + [FieldsEnum.TRANSPORT_TYPE]: options?.transportType,
177 181 });
178 182 },
179 183 showSearch: true,
... ... @@ -191,6 +195,7 @@ export const basicInfoForm: FormSchema[] = [
191 195 required: true,
192 196 componentProps: ({ formModel }) => {
193 197 const organizationId = formModel[FieldsEnum.ORGANIZATION_ID];
  198 + const transportType = formModel[FieldsEnum.TRANSPORT_TYPE];
194 199 return {
195 200 api: async () => {
196 201 try {
... ... @@ -199,12 +204,14 @@ export const basicInfoForm: FormSchema[] = [
199 204 deviceType: DeviceTypeEnum.GATEWAY,
200 205 organizationId,
201 206 });
202   - return result.map((item) => {
203   - return {
204   - ...item,
205   - name: item.alias || item.name,
206   - };
207   - });
  207 + return result
  208 + .map((item) => {
  209 + return {
  210 + ...item,
  211 + name: item.alias || item.name,
  212 + };
  213 + })
  214 + .filter((item) => item.transportType === transportType);
208 215 } catch (error) {
209 216 return [];
210 217 }
... ... @@ -216,6 +223,7 @@ export const basicInfoForm: FormSchema[] = [
216 223 filterOption: (inputValue: string, options: Record<'label', string>) => {
217 224 return options.label.includes(inputValue);
218 225 },
  226 + placeholder: '请选择网关设备',
219 227 };
220 228 },
221 229 },
... ...