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