| | |
| | | <template> |
| | | <el-container direction="vertical"> |
| | | <app-header title="交通统计报表审核系统 - 数据导入"></app-header> |
| | | <el-container> |
| | |
| | | <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> |
| | | </el-submenu> |
| | | <el-menu-item index="/rules">规则管理</el-menu-item> |
| | | <el-menu-item index="/users">用户管理</el-menu-item> |
| | | </el-menu> |
| | | <el-menu-item v-if="operatorIsAdmin" index="/system-config">系统配置</el-menu-item> |
| | | </el-menu> |
| | | </el-aside> |
| | | <el-main> |
| | | <div class="page-scroll"> |
| | |
| | | <div class="import-main"> <el-card shadow="hover" class="import-card" style="margin-bottom:15px"> |
| | | <div class="card-head">报表期</div> |
| | | <el-date-picker v-model="period" type="month" placeholder="选择月份" value-format="yyyy-MM" |
| | | style="width:240px" @change="onPeriodChange"></el-date-picker> |
| | | style="width:240px" :picker-options="periodPickerOptions" @change="onPeriodChange"></el-date-picker> |
| | | <div v-if="periodHint" class="tip" style="margin-top:6px">{{ periodHint }}</div> |
| | | </el-card> |
| | | |
| | | |
| | |
| | | <div class="module-sel-row"> |
| | | <el-select v-model="moduleSel[g.key]" placeholder="选择数据类型" style="width:260px" |
| | | @change="onModuleChange(g.key)" clearable> |
| | | <el-option v-for="t in g.types" :key="t.value" :label="t.label" :value="t.value"></el-option> |
| | | <el-option v-for="t in typeList(g)" :key="t.value" :label="t.label" :value="t.value"></el-option> |
| | | </el-select> |
| | | <div v-if="importType" class="tpl-box"> |
| | | <span class="tpl-name">模板:{{ templateName }}</span> |
| | | <el-link v-if="templateUrl" type="primary" icon="el-icon-download" :underline="false" |
| | | @click="downloadTemplate">下载模板</el-link> |
| | | <span v-if="importType === 'cityTaxiAuth'" class="slow-tip">该类型约 4 万+ 行,预计耗时 5 分钟左右</span> |
| | | <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> |
| | |
| | | </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])" |
| | | :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" :disabled="importing">选择文件</el-button> |
| | | </el-upload> |
| | | <input v-if="moduleSel[g.key] === 'h202'" :ref="'folder' + g.key" type="file" webkitdirectory directory multiple accept=".xlsx" |
| | | style="display:none" @change="onFolderPicked(g.key, $event)"> |
| | | <el-button v-if="moduleSel[g.key] === 'h202'" size="mini" type="primary" icon="el-icon-folder-opened" |
| | | :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> |
| | |
| | | 导入结果({{ period || '全部报表期' }}) |
| | | <el-button type="text" icon="el-icon-refresh" style="float:right" @click="loadData">刷新</el-button> |
| | | </div> |
| | | <div v-if="period" class="tip" style="margin-bottom:6px">仅显示当前报表期({{ period }})的导入记录;把上方报表期清空可查看全部期次。</div> |
| | | <div v-if="failBatches.length" class="tip" style="margin-bottom:6px">共 {{ failBatches.length }} 个批次存在失败数据,失败明细共 {{ failRowsFlat.length }} 条:</div> |
| | | <el-table v-if="failBatches.length" :data="failRowsFlat" border size="small" v-loading="batchLoading" style="width:100%"> |
| | | <el-table-column label="导入类型" width="140"> |
| | |
| | | </el-table-column> |
| | | </el-table> |
| | | <div v-else class="empty-tip">暂无导入失败记录</div> |
| | | <div v-if="warnRowsFlat.length" class="tip" style="margin:12px 0 6px"> |
| | | 共 {{ warnBatches.length }} 个批次含提醒,共 {{ warnRowsFlat.length }} 条(不阻断导入,供核对): |
| | | </div> |
| | | <el-table v-if="warnRowsFlat.length" :data="warnRowsFlat" border size="small" style="width:100%"> |
| | | <el-table-column label="导入类型" width="140"> |
| | | <template slot-scope="s">{{ typeLabel(s.row.importType) }}</template> |
| | | </el-table-column> |
| | | <el-table-column prop="reportPeriod" label="报表期" width="90"></el-table-column> |
| | | <el-table-column label="文件名" min-width="200" show-overflow-tooltip> |
| | | <template slot-scope="s">{{ s.row.fileName }}</template> |
| | | </el-table-column> |
| | | <el-table-column label="位置" width="230"> |
| | | <template slot-scope="s"><span v-if="s.row.position">{{ s.row.position }}</span><span v-else>—</span></template> |
| | | </el-table-column> |
| | | <el-table-column label="提醒内容" min-width="300"> |
| | | <template slot-scope="s">{{ s.row.reason }}</template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-card> |
| | | </div> |
| | | <div class="import-side" :class="{ 'side-open': sideOpen }"> |
| | |
| | | <div v-else class="overview-grid"> |
| | | <div class="ov-row" v-for="g in visibleGroups" :key="g.key"> |
| | | <div class="ov-group">{{ g.name }}</div> |
| | | <div class="ov-item" v-for="t in g.types" :key="t.value" :class="overviewState(t.value).cls"> |
| | | <div class="ov-item" v-for="t in typeList(g)" :key="t.value" :class="overviewState(t.value).cls"> |
| | | <div class="ov-name">{{ t.label }}</div> |
| | | <div class="ov-status">{{ overviewState(t.value).text }}</div> |
| | | </div> |
| | |
| | | <div v-if="clearScope === 'types'" class="clear-types"> |
| | | <el-select v-model="clearTypes" multiple filterable collapse-tags placeholder="选择要清空的数据类型" style="width:100%"> |
| | | <el-option-group v-for="g in clearableGroups()" :key="g.key" :label="g.name"> |
| | | <el-option v-for="t in g.types" :key="t.value" :value="t.value" |
| | | <el-option v-for="t in typeList(g)" :key="t.value" :value="t.value" |
| | | :label="t.label + '(' + overviewState(t.value).text + ')'"></el-option> |
| | | </el-option-group> |
| | | </el-select> |
| | |
| | | :disabled="clearScope === 'types' && !clearTypes.length" @click="confirmClear">确认清空</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | <!-- 导入结果弹窗:可拖动、内容区滚动、底部按钮固定可见(原 $alert 内容长时底部按钮会被挤出屏幕) --> |
| | | <el-dialog :title="resultDialog.title" :visible.sync="resultDialog.visible" width="860px" top="5vh" |
| | | append-to-body :close-on-click-modal="true" :close-on-press-escape="true" |
| | | custom-class="import-result-dialog" v-dialog-drag> |
| | | <div v-if="resultDialog.level" class="ird-level" :class="'ird-' + resultDialog.level"> |
| | | {{ resultDialog.level === 'error' ? '导入失败' : (resultDialog.level === 'warning' ? '存在需要确认的内容' : '导入成功') }} |
| | | </div> |
| | | <div class="ird-body" v-html="resultDialog.html"></div> |
| | | <span slot="footer"> |
| | | <el-button v-if="resultDialog.rows.length" size="small" icon="el-icon-download" |
| | | @click="exportResultDialog">导出明细</el-button> |
| | | <el-button type="primary" @click="resultDialog.visible = false">确认</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </el-main> |
| | | </el-container> |
| | | </el-container> |
| | |
| | | <script> |
| | | import AppHeader from '@/components/AppHeader.vue' |
| | | import api from '@/api' |
| | | import { granularityOfMany, disabledDateFor, granularityHint, snapPeriod } from '@/utils/periodGranularity' |
| | | const TYPE_LABELS = { |
| | | h2032: 'H203-2月报', transportAuth: '运政车辆', trackMileage: '轨迹里程', scaleSplit: '规上规下拆分', |
| | | h2032: 'H203-2月报', h202: 'H202车辆拥有情况', transportAuth: '运政车辆', trackMileage: '轨迹里程', scaleSplit: '规上规下拆分', |
| | | freightTurnover: '货运量周转量', passengerMonthly: 'H203-1旅客月报', passengerIndividual: '个体客运量/周转量', |
| | | passengerAuth: '旅客运政车辆数', energyMonthly: 'H204能耗季报', energyAuth: '能耗车辆运政信息', |
| | | investment: '投资月报(客运站场)', investmentLogistics: '投资月报(物流园区)', investmentSystem: '投资系统导出', |
| | |
| | | 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', TRANSPORT_AUTH: 'transportAuth', TRACK_MILEAGE: 'trackMileage', |
| | | 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', |
| | |
| | | WYC_TOTAL: 'wycTotal', WYC_ORDER: 'wycOrder', WYC_ORDER_REPORT: 'wycOrderReport', |
| | | INVEST_SYSTEM: 'investmentSystem' |
| | | } |
| | | const H202_FOLDER_FILE_PATTERN = /^RP_JTB_FreightVehicle_.+\.xlsx$/i |
| | | export default { |
| | | components: { AppHeader }, |
| | | name: 'DataImport', |
| | |
| | | clearDialog: false, |
| | | clearScope: 'all', |
| | | clearTypes: [], |
| | | resultDialog: { visible: false, title: '', html: '', rows: [], columns: [], fileName: '', level: '' }, |
| | | sideOpen: false, |
| | | result: '', |
| | | error: '', |
| | |
| | | batchLoading: false, |
| | | moduleSel: { freight: 'h2032', passenger: '', city: '', energy: '', invest: '' }, |
| | | activeModule: 'freight', |
| | | trackMileageSource: 'PROVINCIAL', |
| | | trackMileageCity: '', |
| | | cities: ['武汉市', '黄石市', '十堰市', '宜昌市', '襄阳市', '鄂州市', '荆门市', '孝感市', '荆州市', '黄冈市', |
| | | '咸宁市', '随州市', '恩施州', '仙桃市', '潜江市', '天门市', '神农架林区'], |
| | | files: {}, |
| | | fileNames: {}, |
| | | overview: {}, |
| | |
| | | { |
| | | key: 'freight', name: '道路货运', types: [ |
| | | { value: 'h2032', label: '道路货物运输月度生产情况' }, |
| | | { value: 'h202', label: '公路货物营运车辆拥有情况(H202)' }, |
| | | { value: 'transportAuth', label: '运政车辆' }, |
| | | { value: 'trackMileage', label: '轨迹里程' }, |
| | | { value: 'scaleSplit', label: '规上规下拆分' }, |
| | |
| | | { value: 'cityTaxi', label: '巡游出租汽车运营服务情况月报' }, |
| | | { value: 'cityTaxiAuth', label: '出租车运政车辆' }, |
| | | { value: 'wycTotal', label: '网约车总数' }, |
| | | { value: 'wycOrder', label: '网约车订单及全省总量' }, |
| | | { value: 'wycOrder', label: '网约车订单及全省总量', hidden: true }, |
| | | { value: 'wycOrderReport', label: '网约车订单报告' } |
| | | ] |
| | | }, |
| | |
| | | } |
| | | }, |
| | | computed: { |
| | | selectedImportTypes() { |
| | | const out = [] |
| | | if (this.importType) out.push(this.importType) |
| | | Object.keys(this.moduleSel || {}).forEach(k => { if (this.moduleSel[k]) out.push(this.moduleSel[k]) }) |
| | | return out |
| | | }, |
| | | periodGranularity() { return granularityOfMany(this.selectedImportTypes) }, |
| | | periodPickerOptions() { |
| | | const d = disabledDateFor(this.periodGranularity) |
| | | return d ? { disabledDate: d } : {} |
| | | }, |
| | | periodHint() { return granularityHint(this.periodGranularity) }, |
| | | // 年报暂不开放:隐藏入口(数据保留,后端实现后可移除 hidden) |
| | | visibleGroups() { return this.groups.filter(g => !g.hidden) }, |
| | | failBatches() { return this.batches.filter(b => b.failRows > 0) }, |
| | | // 含提醒的批次:errorDetail 里有「【提醒 N 处】」段(未知码等,不阻断导入) |
| | | warnBatches() { return this.batches.filter(b => b.errorDetail && String(b.errorDetail).indexOf('【提醒 ') >= 0) }, |
| | | failRowsFlat() { |
| | | const out = [] |
| | | for (const b of this.failBatches) { |
| | | const rows = this.parseFailDetails(b) |
| | | const rows = this.parseFailDetails({ errorDetail: this.failDetailText(b) }) |
| | | if (!rows.length) { |
| | | out.push({ importType: b.importType, reportPeriod: b.reportPeriod, fileName: b.fileName, position: '', reason: b.errorDetail || '该批次无失败明细' }) |
| | | out.push({ importType: b.importType, reportPeriod: b.reportPeriod, fileName: b.fileName, position: '', reason: this.failDetailText(b) || '该批次无失败明细' }) |
| | | } else { |
| | | rows.forEach(r => out.push({ importType: b.importType, reportPeriod: b.reportPeriod, fileName: b.fileName, position: r.position, reason: r.reason })) |
| | | } |
| | | } |
| | | return out |
| | | }, |
| | | warnRowsFlat() { |
| | | const out = [] |
| | | for (const b of this.warnBatches) { |
| | | const rows = this.parseFailDetails({ errorDetail: this.warnDetailText(b) }) |
| | | if (!rows.length) { |
| | | out.push({ importType: b.importType, reportPeriod: b.reportPeriod, fileName: b.fileName, position: '', reason: this.warnDetailText(b) || '该批次含提醒' }) |
| | | } else { |
| | | rows.forEach(r => out.push({ importType: b.importType, reportPeriod: b.reportPeriod, fileName: b.fileName, position: r.position, reason: r.reason })) |
| | | } |
| | |
| | | templateName() { |
| | | const map = { |
| | | h2032: '模板_交企统H203-2表_道路货物运输月度生产情况.xlsx', |
| | | h202: 'RP_JTB_FreightVehicle_全省.xlsx(导入前将文件名“全省”和表内 L3 报表日期改为实际地区、报表期末日期)', |
| | | transportAuth: '模板_运政车辆.xlsx', |
| | | trackMileage: '模板_轨迹里程.xlsx', |
| | | scaleSplit: '模板_规上规下拆分运输量.xlsx', |
| | | freightTurnover: '模板_货运量周转量.xlsx', |
| | | passengerMonthly: '公路旅客运输月度生产情况.xlsx(含运政车辆数sheet)', |
| | | passengerAuth: '模板_公路旅客运政车辆数.xls(支持 企业代码/企业名称/车辆数/载客位数 与 运政库导出 OWNERNAME/总车辆数/客位数)', |
| | | passengerIndividual: '个体客运量汇总.xlsx(列:所属地区/企业代码/企业名称/个体客运量/个体旅客周转量)', |
| | | passengerIndividual: '模板_个体客运(2026.7).xlsx(标题月份需与报表期一致;列:市州/个体车辆数/个体客运量/个体旅客周转量)', |
| | | energyMonthly: '道路货运车辆能源消耗情况(2026年).xlsx(能耗明细+运政车辆信息两sheet)', |
| | | energyAuth: '模板_能耗车辆运政信息.xlsx(列:车牌号/车辆类型/燃料类型/标记吨位/准牵引质量)', |
| | | investment: '7月客运站投资明细表(市州汇总大表,给领导).xlsx', |
| | |
| | | templateUrl() { |
| | | const map = { |
| | | h2032: '货运/模板_交企统H203-2表_道路货物运输月度生产情况.xlsx', |
| | | h202: '货运/RP_JTB_FreightVehicle_全省.xlsx', |
| | | transportAuth: '货运/模板_运政车辆.xlsx', |
| | | trackMileage: '货运/模板_轨迹里程.xlsx', |
| | | scaleSplit: '货运/模板_规上规下拆分运输量.xlsx', |
| | | freightTurnover: '货运/模板_货运量周转量.xlsx', |
| | | passengerMonthly: '公路旅客/模板_交企统H203-1表_公路旅客运输月度生产情况.xlsx', |
| | | passengerAuth: '公路旅客/模板_公路旅客运政车辆数.xls', |
| | | passengerIndividual: '公路旅客/个体客运量汇总.xlsx', |
| | | passengerIndividual: '公路旅客/模板_个体客运(2026.7).xlsx', |
| | | energyMonthly: '能耗/模板_道路货运车辆能源消耗情况(2026).xlsx', |
| | | energyAuth: '能耗/模板_能耗车辆运政信息.xlsx', |
| | | cityBus: '城市客运/生成_城市公交客运量分市州明细.xlsx', |
| | |
| | | return map[this.importType] || '' |
| | | } |
| | | }, |
| | | watch: { |
| | | // 期次粒度跟着数据类型走:选到能耗季报时自动把报表期对齐到季度末月 |
| | | periodGranularity() { |
| | | const snapped = snapPeriod(this.period, this.periodGranularity) |
| | | if (snapped && snapped !== this.period) { |
| | | this.period = snapped |
| | | const hint = granularityHint(this.periodGranularity) |
| | | if (hint) this.$message.warning(hint + '(已自动调整为 ' + snapped + ')') |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | typeLabel(t) { return TYPE_LABELS[t] || t }, |
| | | downloadTemplate() { |
| | | if (!this.templateUrl) return |
| | | window.open('/api/templates/' + this.templateUrl) |
| | | const name = this.templateUrl.split('/').pop() |
| | | api.get('/templates/' + this.templateUrl, { responseType: 'blob' }) |
| | | .then(res => { |
| | | const blob = res instanceof Blob ? res : new Blob([res]) |
| | | const url = window.URL.createObjectURL(blob) |
| | | const a = document.createElement('a') |
| | | a.href = url |
| | | a.download = name |
| | | document.body.appendChild(a) |
| | | a.click() |
| | | window.URL.revokeObjectURL(url) |
| | | document.body.removeChild(a) |
| | | }) |
| | | .catch(() => this.$message.error('模板下载失败,请稍后重试')) |
| | | }, |
| | | 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] || '' |
| | |
| | | endpoint(t) { |
| | | const map = { |
| | | h2032: '/import/h2032', |
| | | h202: '/import/h202', |
| | | transportAuth: '/import/transportAuth', |
| | | trackMileage: '/import/trackMileage', |
| | | scaleSplit: '/import/scaleSplit', |
| | |
| | | wycOrderReport: '/import/wycOrderReport' |
| | | } |
| | | return map[t] || '' |
| | | }, |
| | | pickH202Folder(key) { |
| | | if (this.importing) { this.$message.warning('正在导入中,请稍候再选择文件夹'); return } |
| | | if (!this.period) { this.$message.warning('请先选择报表期'); return } |
| | | const ref = this.$refs['folder' + key] |
| | | const input = Array.isArray(ref) ? ref[0] : ref |
| | | if (!input) { this.$message.error('文件夹选择控件未就绪,请刷新页面后重试'); return } |
| | | input.value = '' |
| | | input.click() |
| | | }, |
| | | onFolderPicked(key, event) { |
| | | const input = event && event.target |
| | | const selected = Array.from((input && input.files) || []) |
| | | if (input) input.value = '' |
| | | const type = this.moduleSel[key] |
| | | if (type !== 'h202' || !selected.length) return |
| | | if (this.importing) { this.$message.warning('正在导入中,请稍候再选择文件夹'); return } |
| | | if (!this.period) { this.$message.warning('请先选择报表期'); return } |
| | | const fileList = selected |
| | | .filter(f => H202_FOLDER_FILE_PATTERN.test(f.name)) |
| | | .sort((a, b) => String(a.webkitRelativePath || a.name).localeCompare(String(b.webkitRelativePath || b.name), 'zh-CN')) |
| | | const ignored = selected.length - fileList.length |
| | | if (!fileList.length) { |
| | | this.$message.warning('所选文件夹中没有符合 H202 命名规则的 .xlsx 文件') |
| | | return |
| | | } |
| | | this.$set(this.files, type, fileList) |
| | | this.$set(this.fileNames, type, fileList.map(f => f.name)) |
| | | if (ignored > 0) this.$message.warning('已忽略 ' + ignored + ' 个不符合 H202 命名规则的文件') |
| | | this.importing = true |
| | | this.batchImport(type, key, fileList).finally(() => { this.importing = false }) |
| | | }, |
| | | onFilePicked(key, file) { |
| | | const type = this.moduleSel[key] |
| | |
| | | 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 }) |
| | |
| | | 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 } |
| | | const fd = new FormData() |
| | |
| | | (f.city ? '(' + f.city + ')' : '') + ':解析 ' + (f.success || 0) + ' 条' + |
| | | (f.error ? ' <span style="color:#F56C6C">' + f.error + '</span>' : '') + '</div>' |
| | | ).join('') |
| | | this.$alert(html, (label || type) + ' 批量导入完成:共 ' + d.total + ' 个文件' + |
| | | (d.fail > 0 ? ',失败 ' + d.fail + ' 条' : '') + '(成功 ' + d.success + ' 条)', { |
| | | dangerouslyUseHTMLString: true, |
| | | type: errCount > 0 ? 'warning' : 'success', |
| | | confirmButtonText: '知道了' |
| | | this.showResultDialog({ |
| | | title: (label || type) + ' 批量导入完成:共 ' + d.total + ' 个文件' + |
| | | (d.fail > 0 ? ',失败 ' + d.fail + ' 条' : '') + '(成功 ' + d.success + ' 条)', |
| | | html: html, |
| | | level: errCount > 0 ? 'warning' : 'success', |
| | | columns: [{ key: 'fileName', label: '文件名' }, { key: 'city', label: '市州' }, |
| | | { key: 'success', label: '解析条数' }, { key: 'error', label: '错误' }], |
| | | rows: files.map(f => ({ fileName: f.fileName || '', city: f.city || '', success: f.success || 0, error: f.error || '' })), |
| | | fileName: (label || '批量导入') + '_' + this.period + '_导入结果' |
| | | }) |
| | | if (type === 'investment' || type === 'investmentLogistics') { |
| | | this.checkInvest(this.period) |
| | |
| | | (f.city ? '(' + f.city + ')' : '') + ':解析 ' + (f.success || 0) + ' 个项目' + |
| | | (f.error ? ' <span style="color:#F56C6C">' + f.error + '</span>' : '') + '</div>' |
| | | ).join('') |
| | | this.$alert(html, '市州单表批量导入完成:共 ' + d.total + ' 条,成功 ' + d.success + ' 条' + |
| | | (d.fail > 0 ? ',失败 ' + d.fail + ' 条' : '') + |
| | | '(十五五项目匹配 ' + d.fiveYearMatched + '/' + d.fiveYearTemplateProjects + ')', { |
| | | dangerouslyUseHTMLString: true, |
| | | type: errCount > 0 ? 'warning' : 'success', |
| | | confirmButtonText: '知道了' |
| | | this.showResultDialog({ |
| | | title: '市州单表批量导入完成:共 ' + d.total + ' 条,成功 ' + d.success + ' 条' + |
| | | (d.fail > 0 ? ',失败 ' + d.fail + ' 条' : '') + |
| | | '(十五五项目匹配 ' + d.fiveYearMatched + '/' + d.fiveYearTemplateProjects + ')', |
| | | html: html, |
| | | level: errCount > 0 ? 'warning' : 'success', |
| | | columns: [{ key: 'fileName', label: '文件名' }, { key: 'city', label: '市州' }, |
| | | { key: 'success', label: '解析项目数' }, { key: 'error', label: '错误' }], |
| | | rows: files.map(f => ({ fileName: f.fileName || '', city: f.city || '', success: f.success || 0, error: f.error || '' })), |
| | | fileName: '市州单表导入结果_' + this.period |
| | | }) |
| | | this.afterImport() |
| | | }) |
| | |
| | | showImportResult(row) { |
| | | if (!row || !row.status) return |
| | | const msg = (row.message || '').toString() |
| | | if (row.status === 'success') { |
| | | const text = (msg && msg.indexOf('导入') !== -1) ? msg : '数据导入成功' |
| | | this.$message({ message: text, type: 'success', duration: 5000 }) |
| | | } else { |
| | | this.$alert((msg || '数据导入失败,详见下方失败记录').replace(/\n/g, '<br>'), '数据导入失败', { |
| | | dangerouslyUseHTMLString: true, |
| | | type: 'error', |
| | | confirmButtonText: '知道了' |
| | | if (row.status !== 'success') { |
| | | this.showResultDialog({ |
| | | title: '数据导入失败', |
| | | html: this.escapeHtml(msg || '数据导入失败,详见下方失败记录').replace(/\n/g, '<br>'), |
| | | level: 'error' |
| | | }) |
| | | return |
| | | } |
| | | const lines = msg.split('\n').map(s => s.trim()).filter(s => s) |
| | | const head = lines.length ? lines[0] : '数据导入成功' |
| | | // 全部成功:只给一条短提示,不弹窗(能耗等成功导入不该打扰); |
| | | // 长文本塞进 el-message 会被撑成横贯屏幕的长条,所以这里也只取首行。 |
| | | const failMatch = msg.match(/失败\s*(\d+)\s*条/) |
| | | const failCount = failMatch ? Number(failMatch[1]) : 0 |
| | | if (failCount > 0) { |
| | | // 有失败行:保留详情弹窗(含行号),满足"导入失败要在页面显示行号" |
| | | this.showResultDialog({ |
| | | title: '导入完成(部分失败,见明细)', |
| | | html: lines.map(l => this.escapeHtml(l)).join('<br>'), |
| | | level: 'warning' |
| | | }) |
| | | return |
| | | } |
| | | const warnMatch = msg.match(/以下\s*(\d+)\s*处为提醒/) |
| | | let text = head |
| | | if (warnMatch) text += ';另有 ' + warnMatch[1] + ' 处提醒' |
| | | this.$message({ message: text, type: warnMatch ? 'warning' : 'success', duration: 4000 }) |
| | | }, |
| | | /** 弹窗内容用 v-html 渲染,统一转义,避免消息里的 < > & 破坏 DOM */ |
| | | escapeHtml(v) { |
| | | return String(v === null || v === undefined ? '' : v) |
| | | .replace(/&/g, '&') |
| | | .replace(/</g, '<') |
| | | .replace(/>/g, '>') |
| | | .replace(/"/g, '"') |
| | | .replace(/'/g, ''') |
| | | }, |
| | | importOne(row) { |
| | | if (!this.period) { this.$message.warning('请先选择报表期'); return Promise.resolve() } |
| | |
| | | fd.append('category', row.type === 'investment' ? '客运站场' : '物流园区') |
| | | } |
| | | return api.post(this.endpoint(row.type), fd, { headers: { 'Content-Type': 'multipart/form-data' }, timeout: 600000 }) |
| | | .then(res => { row.status = 'success'; row.message = res.data || '导入成功' }) |
| | | .then(res => { |
| | | // axios 拦截器只拆出 response.data(业务包 Result),必须自行判 code: |
| | | // 后端解析/校验异常时返回 code=500 且原因在 message 里,旧写法会把失败显示成「导入成功」。 |
| | | if (res && res.code !== undefined && res.code !== 200) { |
| | | row.status = 'fail' |
| | | row.message = res.message || '导入失败' |
| | | } else { |
| | | row.status = 'success' |
| | | row.message = (res && res.data) || '导入成功' |
| | | } |
| | | }) |
| | | .catch(e => { row.status = 'fail'; row.message = (e.response && e.response.data && e.response.data.message) || '导入失败' }) |
| | | .finally(() => {}) |
| | | }, |
| | |
| | | }, |
| | | clearableGroups() { |
| | | return this.groups.filter(g => !g.hidden) |
| | | }, |
| | | // 单个数据类型也可隐藏(hidden: true):入口、概览、清空下拉统一过滤 |
| | | typeList(g) { |
| | | return (g && g.types ? g.types : []).filter(t => !t.hidden) |
| | | }, |
| | | confirmClear() { |
| | | if (!this.period) { this.$message.warning('请先选择报表期'); return } |
| | |
| | | '<br/>实际:' + (x.actualValue || '') + ' 基准:' + (x.thresholdValue || '') + |
| | | '<br/>差异:' + (x.deviation || '') + '</div>' |
| | | }).join('') |
| | | this.$alert(html, '投资数据与投资系统不一致(' + pending.length + ' 条)', { |
| | | dangerouslyUseHTMLString: true, type: 'warning', confirmButtonText: '知道了' |
| | | this.showResultDialog({ |
| | | title: '投资数据与投资系统不一致(' + pending.length + ' 条)', |
| | | html: html, |
| | | level: 'warning', |
| | | columns: [{ key: 'rule', label: '规则' }, { key: 'name', label: '项目/企业' }, |
| | | { key: 'actual', label: '实际值' }, { key: 'base', label: '基准值' }, { key: 'dev', label: '差异' }], |
| | | rows: pending.map(x => ({ |
| | | rule: x.ruleName || '', |
| | | name: x.enterpriseName || x.actualValue || '', |
| | | actual: x.actualValue || '', |
| | | base: x.thresholdValue || '', |
| | | dev: x.deviation || '' |
| | | })), |
| | | fileName: '投资数据与投资系统不一致_' + this.period |
| | | }) |
| | | } else { |
| | | this.$message.success('已与投资系统核对,本月数据一致') |
| | | } |
| | | }) |
| | | .catch(() => {}) |
| | | }, |
| | | showResultDialog(opts) { |
| | | const o = opts || {} |
| | | this.resultDialog = { |
| | | visible: true, |
| | | title: o.title || '导入结果', |
| | | html: o.html || '', |
| | | level: o.level || '', |
| | | rows: o.rows || [], |
| | | columns: o.columns || [], |
| | | fileName: o.fileName || ('导入结果_' + (this.period || '')) |
| | | } |
| | | }, |
| | | exportResultDialog() { |
| | | const cols = this.resultDialog.columns || [] |
| | | const rows = this.resultDialog.rows || [] |
| | | if (!cols.length || !rows.length) { this.$message.warning('没有可导出的明细'); return } |
| | | const esc = v => '"' + String(v === null || v === undefined ? '' : v).replace(/"/g, '""') + '"' |
| | | const lines = [cols.map(c => esc(c.label)).join(',')] |
| | | rows.forEach(r => lines.push(cols.map(c => esc(r[c.key])).join(','))) |
| | | const blob = new Blob(['\ufeff' + lines.join('\r\n')], { type: 'text/csv;charset=utf-8' }) |
| | | const url = URL.createObjectURL(blob) |
| | | const a = document.createElement('a') |
| | | a.href = url |
| | | a.download = this.resultDialog.fileName + '.csv' |
| | | document.body.appendChild(a) |
| | | a.click() |
| | | document.body.removeChild(a) |
| | | URL.revokeObjectURL(url) |
| | | }, |
| | | /** 失败明细文本(去掉「【提醒 N 处】」及其后的提醒段) */ |
| | | failDetailText(b) { |
| | | const t = String((b && b.errorDetail) || '') |
| | | const i = t.indexOf('【提醒 ') |
| | | return (i >= 0 ? t.slice(0, i) : t).trim() |
| | | }, |
| | | /** 提醒明细文本(「【提醒 N 处】」之后的部分) */ |
| | | warnDetailText(b) { |
| | | const t = String((b && b.errorDetail) || '') |
| | | const i = t.indexOf('【提醒 ') |
| | | if (i < 0) return '' |
| | | return t.slice(i).replace(/^【提醒\s*\d+\s*处】\s*/, '').trim() |
| | | }, |
| | | parseFailDetails(row) { |
| | | if (!row || !row.errorDetail) return [] |
| | |
| | | .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; } |
| | |
| | | .module-tabs-head { margin-bottom: 10px; } |
| | | .module-tab-pane { min-height: 120px; } |
| | | </style> |
| | | |
| | | <style> |
| | | /* 导入结果弹窗:el-dialog 默认 append-to-body,DOM 挂在 body 上,scoped 选择器匹配不到,必须写全局 */ |
| | | .import-result-dialog { border-radius: 10px; overflow: hidden; } |
| | | .import-result-dialog .el-dialog__header { cursor: move; user-select: none; -webkit-user-select: none; } |
| | | .import-result-dialog .el-dialog__headerbtn { cursor: pointer; } |
| | | .import-result-dialog .el-dialog__body { max-height: calc(100vh - 210px); overflow-y: auto; overscroll-behavior: contain; padding: 12px 20px; } |
| | | .import-result-dialog .el-dialog__footer { border-top: 1px solid #EBEEF5; padding: 10px 20px; } |
| | | .import-result-dialog .ird-body { line-height: 1.7; font-size: 13px; color: #303133; } |
| | | .import-result-dialog .ird-level { margin-bottom: 8px; font-weight: 600; } |
| | | .import-result-dialog .ird-success { color: #67C23A; } |
| | | .import-result-dialog .ird-warning { color: #E6A23C; } |
| | | .import-result-dialog .ird-error { color: #F56C6C; } |
| | | </style> |