xyc
9 小时以前 5b41c8896ef7850be2672e45b69bb58e149729ec
traffic-audit-web/src/views/DataImport.vue
@@ -10,6 +10,7 @@
          <el-menu-item index="/explain">企业解释</el-menu-item>
          <el-menu-item index="/audit">审核结果</el-menu-item>
          <el-menu-item index="/report">报表生成</el-menu-item>
          <el-menu-item index="/ledger-audit">事后核查</el-menu-item>
          <el-submenu index="/special-stats">
            <template slot="title">专项统计</template>
            <el-menu-item index="/holiday-stat">节假日</el-menu-item>
@@ -51,6 +52,20 @@
                             @click="downloadTemplate">下载模板</el-link>
                    <span v-if="importType === 'cityTaxiAuth'" class="slow-tip">该类型约 4 万+ 行,预计耗时 1 分钟以内</span>
                  </div>
                  <template v-if="moduleSel[g.key] === 'trackMileage'">
                    <span class="source-label">数据来源</span>
                    <el-select v-model="trackMileageSource" size="small" style="width:150px" @change="onTrackSourceChange">
                      <el-option label="省重载平台" value="PROVINCIAL"></el-option>
                      <el-option label="市州第三方" value="CITY_THIRD_PARTY"></el-option>
                    </el-select>
                    <template v-if="trackMileageSource === 'CITY_THIRD_PARTY'">
                      <span class="source-label">市州</span>
                      <el-select v-model="trackMileageCity" size="small" style="width:130px" filterable
                                 placeholder="选择市州">
                        <el-option v-for="city in cities" :key="city" :label="city" :value="city"></el-option>
                      </el-select>
                    </template>
                  </template>
                </div>
                <div v-if="isCityDirType(moduleSel[g.key])" class="module-file">
                  <div class="tip">无需选文件:自动扫描 docs/投资/输入/…/{{ period ? Number(period.slice(5)) : 'X' }}月 目录下全部市州报表,逐文件容错解析入库(项目主档+月度,含本月完成/建设阶段/形象进度;十五五项目自动标记)。</div>
@@ -59,6 +74,7 @@
                </div>
                <div v-else-if="moduleSel[g.key] && !isDirOnlyType(moduleSel[g.key])" class="module-file">
                  <div class="file-name" :title="fileNamesText(moduleSel[g.key])">{{ fileNamesText(moduleSel[g.key]) || '未选择文件' }}</div>
                  <div v-if="isTrackCity(moduleSel[g.key])" class="tip" style="margin:0 0 6px">同一企业的多个文件、多个页签会合并计算,车牌去重;本次会整体覆盖所选市州同报表期的第三方轨迹里程。审核测算时,孝感规上企业一律采用本市第三方数据,不采用省重载平台;其他市州按“有效轨迹里程÷有轨迹车辆数”择优。</div>
                  <div v-if="moduleSel[g.key] === 'h202'" class="tip" style="margin:0 0 6px">选择文件夹后,自动识别并导入目录内符合 H202 命名规则的全部 .xlsx 文件。</div>
                  <div class="file-btns">
                    <el-upload action="#" :auto-upload="false" :show-file-list="false" multiple :accept="acceptOf(moduleSel[g.key])"
@@ -71,7 +87,7 @@
                               :disabled="importing" title="选择文件夹后自动批量导入"
                               @click="pickH202Folder(g.key)">选择文件夹并导入</el-button>
                    <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>
                               @click="importNow(g.key)">{{ importButtonText(moduleSel[g.key]) }}</el-button>
                  </div>
                </div>
              </div>
@@ -215,10 +231,12 @@
  H2032: 'H203-2月报', H2031: 'H203-1旅客月报', H204: 'H204能耗季报', PASSENGER_AUTH: '旅客运政车辆数',
  PASSENGER_INDIVIDUAL: '个体客运量/周转量', ENERGY_AUTH: '能耗车辆运政信息', TRANSPORT_AUTH: '运政车辆',
  TRACK_MILEAGE: '轨迹里程', SCALE_SPLIT: '规上规下拆分', FREIGHT_TURNOVER: '货运量周转量',
  TRACK_MILEAGE_CITY: '市州第三方轨迹里程',
  INVEST_SYSTEM: '投资系统导出', CITY_BUS: '城市公交月报', CITY_TAXI: '巡游出租月报', CITY_TAXI_AUTH: '出租车运政车辆', WYC_TOTAL: '网约车总数', WYC_ORDER: '网约车订单及全省总量', WYC_ORDER_REPORT: '网约车订单报告'
}
const BATCH_TYPE_MAP = {
  H2032: 'h2032', H202: 'h202', TRANSPORT_AUTH: 'transportAuth', TRACK_MILEAGE: 'trackMileage',
  TRACK_MILEAGE_CITY: 'trackMileage',
  SCALE_SPLIT: 'scaleSplit', FREIGHT_TURNOVER: 'freightTurnover',
  H2031: 'passengerMonthly', PASSENGER_AUTH: 'passengerAuth', PASSENGER_INDIVIDUAL: 'passengerIndividual',
  H204: 'energyMonthly', ENERGY_AUTH: 'energyAuth',
@@ -248,6 +266,10 @@
      batchLoading: false,
      moduleSel: { freight: 'h2032', passenger: '', city: '', energy: '', invest: '' },
      activeModule: 'freight',
      trackMileageSource: 'PROVINCIAL',
      trackMileageCity: '',
      cities: ['武汉市', '黄石市', '十堰市', '宜昌市', '襄阳市', '鄂州市', '荆门市', '孝感市', '荆州市', '黄冈市',
        '咸宁市', '随州市', '恩施州', '仙桃市', '潜江市', '天门市', '神农架林区'],
      files: {},
      fileNames: {},
      overview: {},
@@ -364,7 +386,7 @@
        freightTurnover: '模板_货运量周转量.xlsx',
        passengerMonthly: '公路旅客运输月度生产情况.xlsx(含运政车辆数sheet)',
        passengerAuth: '模板_公路旅客运政车辆数.xls(支持 企业代码/企业名称/车辆数/载客位数 与 运政库导出 OWNERNAME/总车辆数/客位数)',
        passengerIndividual: '个体客运量汇总.xlsx(列:所属地区/企业代码/企业名称/个体客运量/个体旅客周转量)',
        passengerIndividual: '模板_个体客运(2026.7).xlsx(标题月份需与报表期一致;列:市州/个体车辆数/个体客运量/个体旅客周转量)',
        energyMonthly: '道路货运车辆能源消耗情况(2026年).xlsx(能耗明细+运政车辆信息两sheet)',
        energyAuth: '模板_能耗车辆运政信息.xlsx(列:车牌号/车辆类型/燃料类型/标记吨位/准牵引质量)',
        investment: '7月客运站投资明细表(市州汇总大表,给领导).xlsx',
@@ -391,7 +413,7 @@
        freightTurnover: '货运/模板_货运量周转量.xlsx',
        passengerMonthly: '公路旅客/模板_交企统H203-1表_公路旅客运输月度生产情况.xlsx',
        passengerAuth: '公路旅客/模板_公路旅客运政车辆数.xls',
        passengerIndividual: '公路旅客/个体客运量汇总.xlsx',
        passengerIndividual: '公路旅客/模板_个体客运(2026.7).xlsx',
        energyMonthly: '能耗/模板_道路货运车辆能源消耗情况(2026).xlsx',
        energyAuth: '能耗/模板_能耗车辆运政信息.xlsx',
        cityBus: '城市客运/生成_城市公交客运量分市州明细.xlsx',
@@ -439,6 +461,24 @@
    },
    onModuleChange(key) {
      this.importType = this.moduleSel[key] || ''
    },
    onTrackSourceChange() {
      this.clearTrackMileageFiles()
    },
    isTrackCity(type) {
      return type === 'trackMileage' && this.trackMileageSource === 'CITY_THIRD_PARTY'
    },
    importButtonText(type) {
      const count = this.fileCount(type)
      if (this.isTrackCity(type)) return count > 1 ? '合并导入 ' + count + ' 个文件' : '合并导入'
      return count > 1 ? '批量导入 ' + count + ' 个文件' : '立即导入'
    },
    clearTrackMileageFiles() {
      this.$set(this.files, 'trackMileage', [])
      this.$set(this.fileNames, 'trackMileage', [])
      const refs = this.$refs.upfreight
      const up = Array.isArray(refs) ? refs[0] : refs
      if (up && up.clearFiles) up.clearFiles()
    },
    onModuleSwitch() {
      this.importType = this.moduleSel[this.activeModule] || ''
@@ -524,6 +564,16 @@
      if (!fileList.length) { this.$message.warning('请先为该类型选择文件'); return }
      if (!this.period) { this.$message.warning('请先选择报表期'); return }
      if (this.importing) { this.$message.warning('正在导入中,请稍候…'); return }
      if (this.isTrackCity(type)) {
        if (!this.trackMileageCity) { this.$message.warning('请先选择市州'); return }
        this.importing = true
        this.importCityTrackMileage(fileList).finally(() => { this.importing = false })
        return
      }
      if (type === 'trackMileage' && fileList.length > 1) {
        this.$message.warning('省重载平台轨迹里程一次只能导入 1 个文件;多个文件合并请选择“市州第三方”。')
        return
      }
      this.importing = true
      if (fileList.length > 1 || type === 'investment' || type === 'investmentLogistics') {
        this.batchImport(type, key, fileList).finally(() => { this.importing = false })
@@ -559,6 +609,36 @@
    fileNamesText(type) {
      const list = this.fileNames[type] || []
      return list.length ? '已选 ' + list.length + ' 个文件:' + list.join('、') : ''
    },
    importCityTrackMileage(fileList) {
      const fd = new FormData()
      fd.append('period', this.period)
      fd.append('city', this.trackMileageCity)
      fileList.forEach(f => fd.append('files', f))
      this.$message({ message: '正在合并导入 ' + fileList.length + ' 个市州轨迹文件…', duration: 3000 })
      return api.post('/import/trackMileageCity', fd, { timeout: 600000 })
        .then(res => {
          if (res && res.code !== undefined && res.code !== 200) {
            this.showResultDialog({
              title: '市州第三方轨迹里程导入失败',
              html: this.escapeHtml(res.message || '导入失败').replace(/\n/g, '<br>'),
              level: 'error'
            })
            return
          }
          this.$message.success((res && res.data) || '市州第三方轨迹里程导入成功')
          this.afterImport()
          this.clearTrackMileageFiles()
        })
        .catch(e => {
          if (e && e._toast) return
          const message = (e.response && e.response.data && e.response.data.message) || e.message || '导入失败'
          this.showResultDialog({
            title: '市州第三方轨迹里程导入失败',
            html: this.escapeHtml(message).replace(/\n/g, '<br>'),
            level: 'error'
          })
        })
    },
    batchImport(type, key, fileList) {
      if (!this.period) { this.$message.warning('请先选择报表期'); return }
@@ -918,6 +998,7 @@
.card-head { font-weight: 600; margin-bottom: 6px; }
.module-sel { max-width: 1100px; }
.module-sel-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.source-label { font-size: 13px; color: #606266; font-weight: 600; white-space: nowrap; }
.tpl-box { display: flex; align-items: center; gap: 8px; min-width: 0; color: #606266; font-size: 13px; }
.tpl-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 480px; }
.group-label { font-size: 13px; color: #606266; font-weight: 600; margin-bottom: 6px; padding-left: 6px; border-left: 3px solid #409EFF; }