diff --git a/src/components/Catch/Table/mixin/excel.js b/src/components/Catch/Table/mixin/excel.js index ce24c0c4d9dfc67a8e9940df581c3f5f3d641b19..de204c6dcbc6df139a44c49c248f37e30827cc7a 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 f2b8216a231aa3d83c604c54f4a0e316a808bc95..04ef054218422e9daf3deb0e9ec4bc5ebd8872cd 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) } } }