From 2761abd2f50ae9f3838d0746b9817a30cb9fc13a Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期日, 20 九月 2026 14:47:08 +0800
Subject: [PATCH] fix(汇总表): 城市客运8月/累计同比取数修正(母版删AJ辅助列+按表头定位月份列)
---
traffic-audit-web/src/views/ReportExport.vue | 184 ++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 163 insertions(+), 21 deletions(-)
diff --git a/traffic-audit-web/src/views/ReportExport.vue b/traffic-audit-web/src/views/ReportExport.vue
index a3ad3c3..f78d81a 100644
--- a/traffic-audit-web/src/views/ReportExport.vue
+++ b/traffic-audit-web/src/views/ReportExport.vue
@@ -27,7 +27,7 @@
<!-- 绗簩琛岋細鎶ヨ〃绫诲瀷鍒囨崲锛堣揣杩� / 鏃呭 / 鎶曡祫 / 鑳借�� / 鍩庡競瀹㈣繍锛夛紱el-radio-group 鏇夸唬 el-tabs锛岃閬� el-tabs 甯冨眬鏃犻檺寰幆锛堜笌 /import 淇涓�鑷达級 -->
<el-radio-group v-model="activeKey" class="module-tabs">
- <el-radio-button v-for="m in modules" :key="m.key" :label="m.key">
+ <el-radio-button v-for="m in visibleModules" :key="m.key" :label="m.key">
{{ m.title }}<el-tag v-if="m.tag" size="mini" :type="m.tagType || 'info'" style="margin-left:6px">{{ m.tag }}</el-tag>
</el-radio-button>
</el-radio-group>
@@ -99,12 +99,14 @@
</div>
</el-alert>
</div>
- <el-dialog :title="'棰勮鏁版嵁 - ' + previewModule + '锛�' + previewPeriod + '锛�'" :visible.sync="previewVisible" width="760px">
+ <el-dialog :title="'棰勮鏁版嵁 - ' + previewModule + '锛�' + previewPeriod + '锛�'" :visible.sync="previewVisible" width="760px"
+ top="5vh" custom-class="pv-dialog" v-dialog-drag>
<div class="preview-body">
<div v-for="it in previewItems" :key="it.key" class="preview-item">
<div class="preview-head">
<span class="preview-name">{{ it.label }}</span>
- <span class="preview-rows">鍏� {{ it.rowCount || 0 }} 琛�</span>
+ <span class="preview-rows" v-if="it.key === 'summaryWorkbook'">鎸囨爣 {{ (it.summary || []).length }} 椤�</span>
+ <span class="preview-rows" v-else>鍏� {{ it.rowCount || 0 }} 琛屾槑缁�</span>
</div>
<div class="preview-coverage">
<span class="cov-label">鏈堝害瑕嗙洊锛�</span>
@@ -112,7 +114,25 @@
<span v-if="!it.ready" class="cov-bad" style="margin-left:10px">{{ it.note }}</span>
<span v-if="it.ready && it.audited === false" class="cov-bad" style="margin-left:10px">鏈鏍�</span>
</div>
- <table class="preview-summary" v-if="it.summary && it.summary.length">
+ <table class="preview-summary wb-table" v-if="it.key === 'summaryWorkbook' && it.summary && it.summary.length">
+ <thead>
+ <tr><th style="width:12%">鍒嗙被</th><th style="width:40%">鎸囨爣</th><th style="width:28%">鏁版嵁</th><th>鍚屾瘮</th></tr>
+ </thead>
+ <tbody>
+ <template v-for="(sec, si) in wbRows(it.summary)">
+ <tr v-for="(row, ri) in sec.rows" :key="si + '-' + ri">
+ <td v-if="ri === 0" :rowspan="sec.rows.length" class="wb-sec">{{ sec.name }}</td>
+ <td class="wb-label">{{ row.label }}</td>
+ <td class="wb-value">{{ row.value === null ? '鈥�' : fmtVal(row.value) }}</td>
+ <td class="wb-yoy" :class="{ 'yoy-empty': row.yoy === null }">{{ row.yoy === null ? '鈥�' : row.yoy }}</td>
+ </tr>
+ </template>
+ </tbody>
+ </table>
+ <div v-if="it.key === 'summaryWorkbook' && wbMissing(it.summary)" class="wb-note">
+ 閮ㄥ垎鎸囨爣缂哄皯涓婂勾鍚屾湡锛坽{ wbPrevYear() }}锛夊熀鏈熸暟鎹紝鍚屾瘮鏆傛湭璁$畻
+ </div>
+ <table class="preview-summary" v-if="it.key !== 'summaryWorkbook' && it.summary && it.summary.length">
<tbody>
<tr v-for="(s, i) in it.summary" :key="i">
<td>{{ s.label }}</td>
@@ -171,29 +191,33 @@
noteDraft: '',
modules: [
{
- key: 'freight', title: '璐ц繍鎶ヨ〃', items: [
+ key: 'summary', title: '姹囨�诲ぇ琛�', items: [
+ { key: 'summaryWorkbook', label: '閬撹矾杩愯緭閲忔眹鎬昏〃锛堟暣鏈級', fileName: '鐢熸垚_閬撹矾杩愯緭閲忔眹鎬昏〃.xlsx', status: null, statusNote: '' }
+ ], checked: []
+ },
+ {
+ key: 'freight', title: '璐ц繍鎶ヨ〃', hidden: true, items: [
{ key: 'cityDetail', label: '璐ц繍閲忓垎甯傚窞鏄庣粏', fileName: '鐢熸垚_璐ц繍閲忓垎甯傚窞鏄庣粏.xlsx', status: null, statusNote: '' },
{ key: 'freightRank', label: '璐ц繍閲忔帓鍚�', fileName: '鐢熸垚_璐ц繍閲忔帓鍚�.xlsx', status: null, statusNote: '' },
{ key: 'turnoverRank', label: '鍛ㄨ浆閲忔帓鍚�', fileName: '鐢熸垚_鍛ㄨ浆閲忔帓鍚�.xlsx', status: null, statusNote: '' }
], checked: []
},
{
- key: 'passenger', title: '鏃呭鎶ヨ〃', items: [
+ key: 'passenger', title: '鏃呭鎶ヨ〃', hidden: true, items: [
{ key: 'passengerCityDetail', label: '鍏矾鏃呭鍒嗗競宸�', fileName: '鐢熸垚_鍏矾鏃呭鍒嗗競宸�.xlsx', status: null, statusNote: '' },
{ key: 'passengerMidDetail', label: '涓彛寰勬槑缁�', fileName: '鐢熸垚_鍏矾鏃呭涓彛寰勬槑缁�.xlsx', status: null, statusNote: '' },
{ key: 'passengerMidRank', label: '涓彛寰勬帓鍚�', fileName: '鐢熸垚_鍏矾鏃呭涓彛寰勬帓鍚�.xlsx', status: null, statusNote: '' },
{ key: 'passengerMidAnalysis', label: '涓彛寰勫垎鏋�', fileName: '鐢熸垚_鍏矾鏃呭涓彛寰勫垎鏋�.xlsx', status: null, statusNote: '' }
], checked: []
}, {
- key: 'cityPassenger', title: '鍩庡競瀹㈣繍鎶ヨ〃', tag: '鍏氦/鍑虹/杞ㄩ亾杞浮/姹囨��', tagType: 'success', items: [
+ key: 'cityPassenger', title: '鍩庡競瀹㈣繍鎶ヨ〃', hidden: true, items: [
{ key: 'cityBusDetail', label: '鍩庡競鍏氦瀹㈣繍閲忓垎甯傚窞鏄庣粏', fileName: '鐢熸垚_鍩庡競鍏氦瀹㈣繍閲忓垎甯傚窞鏄庣粏.xlsx', status: null, statusNote: '' },
{ key: 'cityTaxiDetail', label: '宸℃父鍑虹瀹㈣繍閲忓垎甯傚窞鏄庣粏', fileName: '鐢熸垚_宸℃父鍑虹瀹㈣繍閲忓垎甯傚窞鏄庣粏.xlsx', status: null, statusNote: '' },
{ key: 'cityRailFerryDetail', label: '杞ㄩ亾杞浮瀹㈣繍閲忓垎甯傚窞鏄庣粏', fileName: '鐢熸垚_杞ㄩ亾杞浮瀹㈣繍閲忓垎甯傚窞鏄庣粏.xlsx', status: null, statusNote: '' },
{ key: 'cityPassengerCitySum', label: '鍩庡競瀹㈣繍瀹㈣繍閲忓垎甯傚窞绱', fileName: '鐢熸垚_鍩庡競瀹㈣繍瀹㈣繍閲忓垎甯傚窞绱.xlsx', status: null, statusNote: '' },
{ key: 'cityPassengerDetailSum', label: '鍩庡競瀹㈣繍鍚勫競宸炴槑缁嗚〃', fileName: '鐢熸垚_鍩庡競瀹㈣繍鍚勫競宸炴槑缁嗚〃.xlsx', status: null, statusNote: '' },
{ key: 'cityPassengerSummary', label: '鍩庡競瀹㈣繍姹囨��', fileName: '鐢熸垚_鍩庡競瀹㈣繍姹囨��.xlsx', status: null, statusNote: '' },
- { key: 'wycSplit', label: '缃戠害杞﹀杩愰噺鎷嗗垎琛�', fileName: '鐢熸垚_缃戠害杞﹀杩愰噺鎷嗗垎琛�.xlsx', status: null, statusNote: '' },
- { key: 'summaryWorkbook', label: '閬撹矾杩愯緭閲忔眹鎬昏〃锛堟暣鏈級', fileName: '鐢熸垚_閬撹矾杩愯緭閲忔眹鎬昏〃.xlsx', status: null, statusNote: '' }
+ { key: 'wycSplit', label: '缃戠害杞﹀杩愰噺鎷嗗垎琛�', fileName: '鐢熸垚_缃戠害杞﹀杩愰噺鎷嗗垎琛�.xlsx', status: null, statusNote: '' }
], checked: []
},
{
@@ -201,7 +225,9 @@
{ key: 'investPlan', label: '鍏ㄧ渷棰勫畨鎺掕鍒掕繘搴︽眹鎬�', fileName: '鐢熸垚_鍏ㄧ渷棰勫畨鎺掕鍒掕繘搴︽儏鍐垫眹鎬�.xls', status: null, statusNote: '' },
{ key: 'investFiveYearLogistics', label: '鍗佷簲浜旇鍒掔墿娴侀」鐩繘灞�', fileName: '鐢熸垚_鍗佷簲浜旇鍒掔墿娴侀」鐩繘灞曟儏鍐�.xls', status: null, statusNote: '' },
{ key: 'investBillion', label: '浜垮厓鎶曡祫椤圭洰', fileName: '鐢熸垚_婀栧寳鐪侊紙瀹㈣揣绔欏満锛変嚎鍏冩姇璧勯」鐩�.xls', status: null, statusNote: '' },
- { key: 'investCounty', label: '缁忔祹寮哄幙椤圭洰鎶曡祫缁熻', fileName: '鐢熸垚_缁忔祹寮哄幙浜ら�氱墿娴佸熀纭�璁炬柦鎶曡祫缁熻鎶ヨ〃.xls', status: null, statusNote: '' }
+ { key: 'investCounty', label: '缁忔祹寮哄幙椤圭洰鎶曡祫缁熻', fileName: '鐢熸垚_缁忔祹寮哄幙浜ら�氱墿娴佸熀纭�璁炬柦鎶曡祫缁熻鎶ヨ〃.xls', status: null, statusNote: '' },
+ { key: 'investPassengerDetail', label: '瀹㈣繍绔欐姇璧勬槑缁嗚〃', fileName: '鐢熸垚_X鏈堝杩愮珯鎶曡祫鏄庣粏琛�.xlsx', status: null, statusNote: '' },
+ { key: 'investLogisticsDetail', label: '鐗╂祦绔欏満鎶曡祫鏄庣粏', fileName: '鐢熸垚_X鏈堢墿娴佺珯鍦烘姇璧勬槑缁�.xls', status: null, statusNote: '' }
], checked: []
},
{
@@ -219,6 +245,9 @@
const s = sessionStorage.getItem('modules')
if (!s) return []
return s.split(',').filter(Boolean)
+ },
+ visibleModules() {
+ return this.modules.filter(m => !m.hidden)
},
curModule() {
return this.modules.find(m => m.key === this.activeKey) || this.modules[0]
@@ -238,7 +267,7 @@
// 鎶ヨ〃鏈熶笅鎷夊垎缁勶細骞存姤鎸夊勾浠斤紱鏈堟姤/瀛f姤鎸夊勾鍒嗙粍鍒� 1-12 鏈堬紙鑳借�楀彧鍒楀搴︽湯鏈堬級
periodGroups() {
const year = new Date().getFullYear()
- const years = [year - 1, year, year + 1]
+ const years = [year, year - 1, year + 1]
if (this.cycle === 'year') {
return [{ label: '閫夋嫨骞翠唤', options: years.map(y => ({ label: y + '骞�', value: String(y) })) }]
}
@@ -256,8 +285,8 @@
}
},
created() {
- const mine = this.myModules.filter(k => this.modules.some(m => m.key === k))
- this.activeKey = (mine.length ? mine : this.modules.map(m => m.key))[0]
+ const mine = this.myModules.filter(k => this.visibleModules.some(m => m.key === k))
+ this.activeKey = (mine.length ? mine : this.visibleModules.map(m => m.key))[0]
this.ensureCycle()
this.refreshAll()
}, methods: {
@@ -363,7 +392,7 @@
this.previewVisible = true
this.loading = ''
})
- .catch(err => this.failWith(err))
+ .catch(err => this.failWith(err, '棰勮'))
},
fmtVal(v) {
if (v === null || v === undefined || v === '') return '鈥�'
@@ -372,6 +401,65 @@
return v.toFixed(4).replace(/\.?0+$/, '')
}
return String(v)
+ },
+ wbRows(summary) {
+ const get = (key) => {
+ const hit = (summary || []).find(x => x.label === key)
+ return hit && hit.value !== null && hit.value !== undefined && hit.value !== '' ? hit.value : null
+ }
+ const pct = (key) => {
+ const v = get(key)
+ return v === null ? null : this.fmtVal(v) + '%'
+ }
+ const mk = (defs) => defs.map(d => ({
+ label: d[0],
+ value: get(d[1]),
+ yoy: d[2] ? pct(d[2]) : null
+ }))
+ return [
+ {
+ name: '閬撹矾璐ц繍',
+ rows: mk([
+ ['褰撴湀璐ц繍閲�(涓囧惃)', '鍏ㄧ渷璐ц繍閲徛峰綋鏈�', '鍏ㄧ渷璐ц繍閲徛峰綋鏈堝悓姣�'],
+ ['褰撴湀璐х墿鍛ㄨ浆閲�(涓囧惃鍏噷)', '鍏ㄧ渷璐х墿鍛ㄨ浆閲徛峰綋鏈�', '鍏ㄧ渷璐х墿鍛ㄨ浆閲徛峰綋鏈堝悓姣�'],
+ ['绱璐ц繍閲�(涓囧惃)', '鍏ㄧ渷璐ц繍閲徛风疮璁�', '鍏ㄧ渷璐ц繍閲徛风疮璁″悓姣�'],
+ ['绱璐х墿鍛ㄨ浆閲�(涓囧惃鍏噷)', '鍏ㄧ渷璐х墿鍛ㄨ浆閲徛风疮璁�', '鍏ㄧ渷璐х墿鍛ㄨ浆閲徛风疮璁″悓姣�']
+ ])
+ },
+ {
+ name: '鍩庡競瀹㈣繍',
+ rows: mk([
+ ['褰撴湀鍩庡競瀹㈣繍閲�', '鍩庡競瀹㈣繍閲徛峰綋鏈�', '鍩庡競瀹㈣繍閲徛峰綋鏈堝悓姣�'],
+ ['褰撴湀鍩庡競瀹㈣繍鍛ㄨ浆閲�', '鍩庡競瀹㈣繍鍛ㄨ浆閲徛峰綋鏈�', '鍩庡競瀹㈣繍鍛ㄨ浆閲徛峰綋鏈堝悓姣�'],
+ ['绱鍩庡競瀹㈣繍閲�', '鍩庡競瀹㈣繍閲徛风疮璁�', '鍩庡競瀹㈣繍閲徛风疮璁″悓姣�'],
+ ['绱鍩庡競瀹㈣繍鍛ㄨ浆閲�', '鍩庡競瀹㈣繍鍛ㄨ浆閲徛风疮璁�', '鍩庡競瀹㈣繍鍛ㄨ浆閲徛风疮璁″悓姣�']
+ ])
+ },
+ {
+ name: '涓彛寰�',
+ rows: mk([
+ ['褰撴湀涓彛寰勫杩愰噺', '涓彛寰勫杩愰噺路褰撴湀', '涓彛寰勫杩愰噺路褰撴湀鍚屾瘮'],
+ ['褰撴湀涓彛寰勫懆杞噺', '涓彛寰勫懆杞噺路褰撴湀', '涓彛寰勫懆杞噺路褰撴湀鍚屾瘮'],
+ ['绱涓彛寰勫杩愰噺', '涓彛寰勫杩愰噺路绱', '涓彛寰勫杩愰噺路绱鍚屾瘮'],
+ ['绱涓彛寰勫懆杞噺', '涓彛寰勫懆杞噺路绱', '涓彛寰勫懆杞噺路绱鍚屾瘮']
+ ])
+ }
+ ]
+ },
+ wbMissing(summary) {
+ let total = 0
+ let have = 0
+ ;(summary || []).forEach(x => {
+ if (String(x.label).indexOf('鍚屾瘮') >= 0) return
+ total++
+ if (x.value !== null && x.value !== undefined && x.value !== '') have++
+ })
+ return total > 0 && have < total
+ },
+ wbPrevYear() {
+ const m = /^(\d{4})-(\d{2})$/.exec(this.previewPeriod || '')
+ if (!m) return '涓婂勾鍚屾湡'
+ return (Number(m[1]) - 1) + '-' + m[2]
},
coverageText(it) {
const cov = it.monthCoverage || []
@@ -390,7 +478,7 @@
const doExport = () => {
if (items.length === 1) {
api.get('/report/export/' + items[0].key, { params, responseType: 'blob', timeout: 120000 })
- .then(res => { this.downloadBlob(res, items[0].fileName); this.$message.success('鎶ヨ〃瀵煎嚭鎴愬姛'); this.loading = '' })
+ .then(res => { this.downloadBlob(res, this.fileNameOf(items[0])); this.$message.success('鎶ヨ〃瀵煎嚭鎴愬姛'); this.loading = '' })
.catch(err => this.failWith(err))
return
}
@@ -421,13 +509,52 @@
})
.catch(() => doExport())
},
- failWith(err) {
+ // 棰勮/瀵煎嚭澶辫触缁熶竴鎻愮ず锛氬尯鍒嗏�滆繛涓嶄笂鏈嶅姟鍣ㄢ�濅笌鈥滃悗绔繑鍥炵殑閿欒鍘熷洜鈥濄��
+ // 瀵煎嚭鎺ュ彛鐢� responseType: 'blob'锛屾姤閿欐椂 data 涔熸槸 Blob锛屽繀椤诲厛璇绘枃鏈啀瑙f瀽锛�
+ // 鍚﹀垯鎷夸笉鍒板悗绔湡瀹炲師鍥狅紝鍙細鏄剧ず绗肩粺鐨勨�滆纭宸插鍏ュ搴旀暟鎹�濄��
+ failWith(err, action) {
if (err && err._toast) { this.loading = ''; return }
- let msg = ''
- const d = err && err.response && err.response.data
- if (d && typeof d === 'object' && d.message) msg = d.message
- this.$message.error('瀵煎嚭澶辫触锛�' + (msg || '璇风‘璁ゅ凡瀵煎叆瀵瑰簲鏁版嵁锛屾垨鏌ョ湅鍚庣鏃ュ織'))
- this.loading = ''
+ const act = action || '瀵煎嚭'
+ const finish = (reason) => {
+ this.$message.error(act + '澶辫触锛�' + reason)
+ this.loading = ''
+ }
+ if (!err || !err.response) {
+ if (err && err.code === 'ECONNABORTED') { finish('璇锋眰瓒呮椂锛岃绋嶅悗閲嶈瘯'); return }
+ finish('鏃犳硶杩炴帴鏈嶅姟鍣紝璇锋鏌ョ綉缁滆繛鎺ワ紝鎴栫‘璁ゅ悗绔湇鍔℃槸鍚﹀凡鍚姩')
+ return
+ }
+ const d = err.response.data
+ const fallback = '璇风‘璁ゅ凡瀵煎叆瀵瑰簲鏁版嵁锛屾垨鏌ョ湅鍚庣鏃ュ織'
+ if (d && typeof d.text === 'function') {
+ Promise.resolve(d.text()).then(txt => finish(this.errReason(txt) || fallback)).catch(() => finish(fallback))
+ return
+ }
+ finish(this.errReason(typeof d === 'string' ? d : (d && d.message)) || fallback)
+ },
+ // 鍚庣寮傚父鍝嶅簲鍙兘鏄� JSON/HTML/绾枃鏈紝灏介噺鎻愬彇鍑哄彲璇荤殑鍘熷洜
+ errReason(raw) {
+ if (!raw) return ''
+ let text = String(raw).trim()
+ if (text.charAt(0) === '{' || text.charAt(0) === '[') {
+ try {
+ const j = JSON.parse(text)
+ if (j && j.message) return j.message
+ } catch (e) { /* 闈� JSON锛屾寜绾枃鏈鐞� */ }
+ }
+ text = text.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim()
+ // 寮�鍙戜唬鐞�/缃戠粶灞傛姤閿欒浆鎴愪汉璇濓紝閬垮厤鐩存帴鎶� ECONNREFUSED 涔嬬被鎶涚粰鐢ㄦ埛
+ if (/ECONNREFUSED|ECONNRESET|Proxy error|socket hang up|Network Error|Failed to fetch/i.test(text)) {
+ return '鏃犳硶杩炴帴鏈嶅姟鍣紝璇锋鏌ョ綉缁滆繛鎺ワ紝鎴栫‘璁ゅ悗绔湇鍔℃槸鍚﹀凡鍚姩'
+ }
+ return text.length > 200 ? text.slice(0, 200) + '鈥�' : text
+ },
+ // 鏂囦欢鍚嶅崰浣嶇 X鏈� -> 褰撳墠鎶ヨ〃鏈熸湀浠斤紙濡傘�岀敓鎴恄X鏈堝杩愮珯鎶曡祫鏄庣粏琛�.xlsx銆�->銆岀敓鎴恄8鏈堝杩愮珯鎶曡祫鏄庣粏琛�.xlsx銆嶏級
+ fileNameOf(item) {
+ const name = (item && item.fileName) || ''
+ const mm = parseInt((this.period || '').split('-')[1], 10)
+ if (!mm) return name
+ return name.replace(/X鏈�/g, mm + '鏈�')
},
downloadBlob(res, fileName) {
const isZip = /\.zip$/.test(fileName)
@@ -487,4 +614,19 @@
@media (max-width: 900px) {
.panel-head { flex-direction: column; align-items: flex-start; }
}
+.wb-table th { background:#f5f7fa; }
+.wb-sec { background:#F7F9FC; font-weight:600; text-align:center; color:#303133; }
+.wb-label { color:#303133; }
+.wb-value { text-align:right; font-variant-numeric: tabular-nums; }
+.wb-yoy { text-align:right; color:#606266; }
+.wb-yoy.yoy-empty { color:#C0C4CC; }
+.wb-note { color:#E6A23C; font-size:12px; margin:2px 0 8px; }
+</style>
+
+<style>
+/* 棰勮鏁版嵁寮圭獥锛氬渾瑙� + 鍙�氳繃鏍囬鏍忔嫋鍔紙v-dialog-drag 鎸囦护锛夈��
+ 涓嶈兘鍐欒繘 scoped锛歟l-dialog 榛樿 append-to-body锛孌OM 鎸傚湪 body 涓婏紝scoped 閫夋嫨鍣ㄥ尮閰嶄笉鍒般�� */
+.pv-dialog { border-radius: 10px; overflow: hidden; }
+.pv-dialog .el-dialog__header { cursor: move; user-select: none; -webkit-user-select: none; }
+.pv-dialog .el-dialog__headerbtn { cursor: pointer; }
</style>
--
Gitblit v1.9.1