| | |
| | | <div class="file-btns"> |
| | | <el-upload action="#" :auto-upload="false" :show-file-list="false" multiple accept=".xlsx,.xls,.et" |
| | | :ref="'up' + g.key" :on-change="f => onFilePicked(g.key, f)" style="display:inline-block"> |
| | | <el-button size="mini" type="primary" plain icon="el-icon-folder-opened">选择文件</el-button> |
| | | <el-button size="mini" type="primary" plain icon="el-icon-folder-opened" :disabled="importing">选择文件</el-button> |
| | | </el-upload> |
| | | <el-button size="mini" type="primary" icon="el-icon-upload2" :disabled="!fileCount(moduleSel[g.key])" |
| | | <el-button size="mini" type="primary" icon="el-icon-upload2" :loading="importing" :disabled="importing || !fileCount(moduleSel[g.key])" |
| | | @click="importNow(g.key)">{{ fileCount(moduleSel[g.key]) > 1 ? '批量导入 ' + fileCount(moduleSel[g.key]) + ' 个文件' : '立即导入' }}</el-button> |
| | | </div> |
| | | </div> |
| | |
| | | importType: 'h2032', |
| | | period: (() => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') })(), |
| | | cityDirLoading: false, |
| | | importing: false, |
| | | sideOpen: false, |
| | | result: '', |
| | | error: '', |
| | |
| | | onFilePicked(key, file) { |
| | | const type = this.moduleSel[key] |
| | | if (!type) return |
| | | if (this.importing) { this.$message.warning('正在导入中,请稍候再选择文件'); return } |
| | | const list = (this.files[type] || []).filter(f => f.name !== file.name) |
| | | list.push(file.raw) |
| | | this.$set(this.files, type, list) |
| | |
| | | } |
| | | const fileList = this.files[type] || [] |
| | | if (!fileList.length) { this.$message.warning('请先为该类型选择文件'); return } |
| | | if (!this.period) { this.$message.warning('请先选择报表期'); return } |
| | | if (this.importing) { this.$message.warning('正在导入中,请稍候…'); return } |
| | | this.importing = true |
| | | if (fileList.length > 1 || type === 'investment' || type === 'investmentLogistics') { |
| | | this.batchImport(type, key, fileList) |
| | | this.batchImport(type, key, fileList).finally(() => { this.importing = false }) |
| | | return |
| | | } |
| | | const file = fileList[0] |
| | | if (!this.period) { this.$message.warning('请先选择报表期'); return } |
| | | const g = this.groups.find(x => x.key === key) |
| | | const t = g.types.find(x => x.value === type) |
| | | const row = { |
| | |
| | | this.importType = '' |
| | | this.files[type] = null |
| | | this.$delete(this.fileNames, type) |
| | | }) |
| | | }).finally(() => { this.importing = false }) |
| | | }, |
| | | fileCount(type) { return (this.files[type] || []).length }, |
| | | fileNamesText(type) { |
| | |
| | | const g = this.groups.find(x => x.key === key) |
| | | const label = g ? g.name : type |
| | | this.$message({ message: '正在批量导入 ' + fileList.length + ' 个文件…', duration: 3000 }) |
| | | api.post('/import/batch', fd, { timeout: 600000 }) |
| | | return api.post('/import/batch', fd, { timeout: 600000 }) |
| | | .then(res => { |
| | | const d = (res && res.data) || {} |
| | | if (!d.files) { |