zhizhijie
2 小时以前 799ec6799ad9e994f7d369f059ca7682962f648f
traffic-audit-web/src/views/DataImport.vue
@@ -56,9 +56,9 @@
                  <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>
@@ -155,6 +155,7 @@
      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: '',
@@ -318,6 +319,7 @@
    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)
@@ -336,12 +338,14 @@
      }
      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 = {
@@ -364,7 +368,7 @@
        this.importType = ''
        this.files[type] = null
        this.$delete(this.fileNames, type)
      })
      }).finally(() => { this.importing = false })
    },
    fileCount(type) { return (this.files[type] || []).length },
    fileNamesText(type) {
@@ -380,7 +384,7 @@
      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) {