haiwei-ui 1.0.94 → 1.0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -149,6 +149,7 @@
|
|
|
149
149
|
<script>
|
|
150
150
|
import dialog from '../../../../mixins/components/dialog'
|
|
151
151
|
import { mapState } from 'vuex'
|
|
152
|
+
import token from '../../../../utils/token'
|
|
152
153
|
export default {
|
|
153
154
|
mixins: [dialog],
|
|
154
155
|
data() {
|
|
@@ -201,8 +202,11 @@
|
|
|
201
202
|
return baseURL + path
|
|
202
203
|
},
|
|
203
204
|
headers() {
|
|
205
|
+
// 从token模块获取token
|
|
206
|
+
const t = token.get()
|
|
207
|
+
const accessToken = t && t.accessToken ? t.accessToken : ''
|
|
204
208
|
return {
|
|
205
|
-
'Authorization': `Bearer ${
|
|
209
|
+
'Authorization': `Bearer ${accessToken}`
|
|
206
210
|
}
|
|
207
211
|
},
|
|
208
212
|
uploadData() {
|
|
@@ -270,9 +274,24 @@
|
|
|
270
274
|
|
|
271
275
|
/**上传成功 */
|
|
272
276
|
onUploadSuccess(response, file, fileList) {
|
|
273
|
-
|
|
277
|
+
// 检查响应格式
|
|
278
|
+
if (response && response.code === 1) {
|
|
274
279
|
this.fileInfo = response.data.basicInfo
|
|
275
|
-
this.parseResult =
|
|
280
|
+
this.parseResult = {
|
|
281
|
+
basicInfo: response.data.basicInfo,
|
|
282
|
+
columns: response.data.headers.map((header, index) => ({
|
|
283
|
+
name: `col${index}`,
|
|
284
|
+
label: header.name,
|
|
285
|
+
width: 120
|
|
286
|
+
})),
|
|
287
|
+
previewData: response.data.data.map(row => {
|
|
288
|
+
const obj = {}
|
|
289
|
+
response.data.headers.forEach((header, colIndex) => {
|
|
290
|
+
obj[`col${colIndex}`] = row[colIndex]
|
|
291
|
+
})
|
|
292
|
+
return obj
|
|
293
|
+
})
|
|
294
|
+
}
|
|
276
295
|
this.initColumnMapping()
|
|
277
296
|
this._success('文件上传成功')
|
|
278
297
|
} else {
|
|
@@ -347,10 +366,13 @@
|
|
|
347
366
|
formData.append('skipEmptyRows', this.model.skipEmptyRows)
|
|
348
367
|
|
|
349
368
|
// 使用axios直接发送请求,避免$api可能为undefined的问题
|
|
369
|
+
// 从token模块获取token
|
|
370
|
+
const t = token.get()
|
|
371
|
+
const accessToken = t && t.accessToken ? t.accessToken : ''
|
|
350
372
|
const config = {
|
|
351
373
|
headers: {
|
|
352
374
|
'Content-Type': 'multipart/form-data',
|
|
353
|
-
'Authorization': `Bearer ${
|
|
375
|
+
'Authorization': `Bearer ${accessToken}`
|
|
354
376
|
}
|
|
355
377
|
}
|
|
356
378
|
|
|
@@ -364,9 +386,24 @@
|
|
|
364
386
|
const path = 'admin/excel/parseexcel'.replace(/^\//, '')
|
|
365
387
|
this.$http.post(baseURL + path, formData, config)
|
|
366
388
|
.then(response => {
|
|
367
|
-
|
|
389
|
+
// 检查响应格式
|
|
390
|
+
if (response.data && response.data.code === 1) {
|
|
368
391
|
this.fileInfo = response.data.data.basicInfo
|
|
369
|
-
this.parseResult =
|
|
392
|
+
this.parseResult = {
|
|
393
|
+
basicInfo: response.data.data.basicInfo,
|
|
394
|
+
columns: response.data.data.headers.map((header, index) => ({
|
|
395
|
+
name: `col${index}`,
|
|
396
|
+
label: header.name,
|
|
397
|
+
width: 120
|
|
398
|
+
})),
|
|
399
|
+
previewData: response.data.data.data.map(row => {
|
|
400
|
+
const obj = {}
|
|
401
|
+
response.data.data.headers.forEach((header, colIndex) => {
|
|
402
|
+
obj[`col${colIndex}`] = row[colIndex]
|
|
403
|
+
})
|
|
404
|
+
return obj
|
|
405
|
+
})
|
|
406
|
+
}
|
|
370
407
|
this.initColumnMapping()
|
|
371
408
|
this._success('文件解析成功')
|
|
372
409
|
} else {
|