Commit b007f48c7e7efd2caa8b7a9dcebeb8a62b256f5a

Authored by xp.Huang
2 parents edcb1a63 62734be2

Merge branch 'cherry-pick-d23423e2' into 'main_dev'

fix:设备批量导入产品类型错误

See merge request yunteng/thingskit-front!1109
@@ -48,8 +48,8 @@ @@ -48,8 +48,8 @@
48 } 48 }
49 }; 49 };
50 50
51 - const insertDeviceTypeName = (  
52 - deviceTypeName: string, 51 + const insertProductionName = (
  52 + productionName: string,
53 fileParseValue: UploadFileParseValue, 53 fileParseValue: UploadFileParseValue,
54 columns: Record<'type', string>[] 54 columns: Record<'type', string>[]
55 ): { file: string; columns: Record<'type', string>[] } => { 55 ): { file: string; columns: Record<'type', string>[] } => {
@@ -58,11 +58,11 @@ @@ -58,11 +58,11 @@
58 58
59 const csvArray = content.map((item) => header.map((key) => item[key]) as string[]); 59 const csvArray = content.map((item) => header.map((key) => item[key]) as string[]);
60 for (const item of csvArray) { 60 for (const item of csvArray) {
61 - item.splice(insertIndex, 0, deviceTypeName); 61 + item.splice(insertIndex, 0, productionName);
62 } 62 }
63 63
64 const _header = [...header]; 64 const _header = [...header];
65 - _header.splice(insertIndex, 0, deviceTypeName); 65 + _header.splice(insertIndex, 0, productionName);
66 csvArray.unshift(_header); 66 csvArray.unshift(_header);
67 const file = csvArray.map((item) => item.join(DelimiterEnum.COMMA)).join('\n'); 67 const file = csvArray.map((item) => item.join(DelimiterEnum.COMMA)).join('\n');
68 68
@@ -80,14 +80,14 @@ @@ -80,14 +80,14 @@
80 tkDeviceProfileId, 80 tkDeviceProfileId,
81 organizationId, 81 organizationId,
82 deviceTypeEnum, 82 deviceTypeEnum,
83 - deviceTypeName, 83 + productionName,
84 gateWayTbDeviceId, 84 gateWayTbDeviceId,
85 tbDeviceProfileId, 85 tbDeviceProfileId,
86 isTcpDeviceProfile, 86 isTcpDeviceProfile,
87 } = basicInfo; 87 } = basicInfo;
88 88
89 - const { file, columns } = insertDeviceTypeName(  
90 - deviceTypeName, 89 + const { file, columns } = insertProductionName(
  90 + productionName,
91 fileParseValue, 91 fileParseValue,
92 columnConfiguration 92 columnConfiguration
93 ); 93 );
@@ -22,6 +22,7 @@ export enum FieldsEnum { @@ -22,6 +22,7 @@ export enum FieldsEnum {
22 TB_DEVICE_PROFILE_ID = 'tbDeviceProfileId', 22 TB_DEVICE_PROFILE_ID = 'tbDeviceProfileId',
23 IS_TCP_DEVICE_PROFILE = 'isTcpDeviceProfile', 23 IS_TCP_DEVICE_PROFILE = 'isTcpDeviceProfile',
24 TRANSPORT_TYPE = 'transportType', 24 TRANSPORT_TYPE = 'transportType',
  25 + PRODUCTION_NAME = 'productionName',
25 } 26 }
26 27
27 export enum DelimiterEnum { 28 export enum DelimiterEnum {
@@ -171,7 +172,7 @@ export const basicInfoForm: FormSchema[] = [ @@ -171,7 +172,7 @@ export const basicInfoForm: FormSchema[] = [
171 placeholder: '请选择产品', 172 placeholder: '请选择产品',
172 params: { deviceType }, 173 params: { deviceType },
173 getPopupContainer: () => document.body, 174 getPopupContainer: () => document.body,
174 - onChange(value: string, options: DeviceRecord) { 175 + onChange(value: string, options: DeviceRecord & Record<'label', string>) {
175 setFieldsValue({ 176 setFieldsValue({
176 [FieldsEnum.IS_TCP_DEVICE_PROFILE]: value 177 [FieldsEnum.IS_TCP_DEVICE_PROFILE]: value
177 ? options.transportType === TransportTypeEnum.TCP 178 ? options.transportType === TransportTypeEnum.TCP
@@ -179,6 +180,7 @@ export const basicInfoForm: FormSchema[] = [ @@ -179,6 +180,7 @@ export const basicInfoForm: FormSchema[] = [
179 [FieldsEnum.TB_DEVICE_PROFILE_ID]: value ? options.tbProfileId : null, 180 [FieldsEnum.TB_DEVICE_PROFILE_ID]: value ? options.tbProfileId : null,
180 [FieldsEnum.GATEWAY_TB_DEVICE_ID]: null, 181 [FieldsEnum.GATEWAY_TB_DEVICE_ID]: null,
181 [FieldsEnum.TRANSPORT_TYPE]: options?.transportType, 182 [FieldsEnum.TRANSPORT_TYPE]: options?.transportType,
  183 + [FieldsEnum.PRODUCTION_NAME]: options?.label,
182 }); 184 });
183 }, 185 },
184 showSearch: true, 186 showSearch: true,
@@ -195,6 +197,12 @@ export const basicInfoForm: FormSchema[] = [ @@ -195,6 +197,12 @@ export const basicInfoForm: FormSchema[] = [
195 show: false, 197 show: false,
196 }, 198 },
197 { 199 {
  200 + field: FieldsEnum.PRODUCTION_NAME,
  201 + label: '',
  202 + component: 'Input',
  203 + show: false,
  204 + },
  205 + {
198 field: FieldsEnum.GATEWAY_TB_DEVICE_ID, 206 field: FieldsEnum.GATEWAY_TB_DEVICE_ID,
199 component: 'ApiSelect', 207 component: 'ApiSelect',
200 label: '网关设备', 208 label: '网关设备',
@@ -26,6 +26,7 @@ export type BasicInfoRecord = Record< @@ -26,6 +26,7 @@ export type BasicInfoRecord = Record<
26 | 'deviceTypeName' 26 | 'deviceTypeName'
27 | 'gateWayTbDeviceId' 27 | 'gateWayTbDeviceId'
28 | 'gateWayTkDeviceId' 28 | 'gateWayTkDeviceId'
  29 + | 'productionName'
29 | 'tbDeviceProfileId', 30 | 'tbDeviceProfileId',
30 string 31 string
31 > & 32 > &