From b9d83ca75e06553db68f682adffb0e451fe4aaa5 Mon Sep 17 00:00:00 2001 From: zjnpy <55363356@qq.com> Date: Tue, 5 Apr 2022 12:22:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dexcel=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BB=A5=E5=8F=8A=E5=90=8E=E7=AB=AF=E4=B8=8D?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AD=97=E6=AE=B5=E7=9A=84=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Catch/Table/mixin/excel.js | 56 ++++++++-------------- src/components/Catch/Table/mixin/import.js | 8 ++-- 2 files changed, 23 insertions(+), 41 deletions(-) diff --git a/src/components/Catch/Table/mixin/excel.js b/src/components/Catch/Table/mixin/excel.js index ce24c0c..de204c6 100644 --- a/src/components/Catch/Table/mixin/excel.js +++ b/src/components/Catch/Table/mixin/excel.js @@ -22,49 +22,31 @@ export default { const importFields = [] const defaultOptions = [{ value: 1, label: '是' }, { value: 2, label: '否' }] const headers = this.filterExcelFields() - headers.forEach(function(header) { - if (header.export === undefined) { - if (header.component !== undefined) { - const name = header.component[0].name - if (name === 'switch_' || name === 'select_') { - importFields.push({ - name: header.label, - field: header.prop, - options: header.component[0].options.length > 0 ? header.component[0].options : defaultOptions - }) - } else { - importFields.push({ - name: header.label, - field: header.prop - }) - } - } else { - importFields.push({ - name: header.label, - field: header.prop - }) + + headers.forEach(header => { + if (header.import !== false) { + const fieldObj = { + name: header.label, + field: header.prop } - } - }) - extraExcelFields.forEach(function(item) { - if (item.import !== undefined) { - if (item.import === true) { - importFields.push({ - name: item.label, - field: item.prop, - options: item.options === undefined ? [] : item.options - }) + if (header.component && header.component[0]) { + const component = header.component[0] + if (component.name === 'switch_' || component.name === 'select_') { + fieldObj.options = component.options.length > 0 ? component.options : defaultOptions + } } - } else { - importFields.push({ - name: item.label, - field: item.prop, - options: item.options === undefined ? [] : item.options - }) + importFields.push(fieldObj) } }) + extraExcelFields.forEach(item => { + item.import !== false && importFields.push({ + name: item.label, + field: item.prop, + options: item.options === undefined ? [] : item.options + }) + }) return importFields }, diff --git a/src/components/Catch/Table/mixin/import.js b/src/components/Catch/Table/mixin/import.js index f2b8216..04ef054 100644 --- a/src/components/Catch/Table/mixin/import.js +++ b/src/components/Catch/Table/mixin/import.js @@ -42,13 +42,13 @@ export default { }, importSuccess(response, file, fileList) { this.importLoading = false - if (response.data.code === 10000) { - this.importVisible = false - this.importList = [] + this.importVisible = false + this.importList = [] + if (response.code === 10000) { this.$emit('ok') this.$message.success('导入成功') } else { - this.$message.error(response.data.message) + this.$message.error(response.message) } } } -- Gitee