From ec37ed0f518eb5f225e028e7ef60008e29bc4b01 Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期三, 28 十月 2026 12:16:42 +0800
Subject: [PATCH] feat(企业台账抽查): 完成2026年9月台账核查、轨迹落库及结果报告
---
traffic-audit-web/src/views/DataImport.vue | 135 +++++++++++++++++++++++++++++++++++++++++---
1 files changed, 124 insertions(+), 11 deletions(-)
diff --git a/traffic-audit-web/src/views/DataImport.vue b/traffic-audit-web/src/views/DataImport.vue
index deb64c6..8585aba 100644
--- a/traffic-audit-web/src/views/DataImport.vue
+++ b/traffic-audit-web/src/views/DataImport.vue
@@ -10,9 +10,14 @@
<el-menu-item index="/explain">浼佷笟瑙i噴</el-menu-item>
<el-menu-item index="/audit">瀹℃牳缁撴灉</el-menu-item>
<el-menu-item index="/report">鎶ヨ〃鐢熸垚</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">
@@ -21,7 +26,8 @@
<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>
@@ -76,6 +82,7 @@
瀵煎叆缁撴灉锛坽{ 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">
@@ -93,6 +100,24 @@
</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 }">
@@ -152,7 +177,8 @@
</el-dialog>
<!-- 瀵煎叆缁撴灉寮圭獥锛氬彲鎷栧姩銆佸唴瀹瑰尯婊氬姩銆佸簳閮ㄦ寜閽浐瀹氬彲瑙侊紙鍘� $alert 鍐呭闀挎椂搴曢儴鎸夐挳浼氳鎸ゅ嚭灞忓箷锛� -->
<el-dialog :title="resultDialog.title" :visible.sync="resultDialog.visible" width="860px" top="5vh"
- append-to-body :close-on-click-modal="false" custom-class="import-result-dialog" v-dialog-drag>
+ 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>
@@ -170,6 +196,7 @@
<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: '瑙勪笂瑙勪笅鎷嗗垎',
freightTurnover: '璐ц繍閲忓懆杞噺', passengerMonthly: 'H203-1鏃呭鏈堟姤', passengerIndividual: '涓綋瀹㈣繍閲�/鍛ㄨ浆閲�',
@@ -278,15 +305,41 @@
}
},
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) },
+ // 鍚彁閱掔殑鎵规锛歟rrorDetail 閲屾湁銆屻�愭彁閱� 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 }))
}
@@ -342,6 +395,17 @@
investmentSystem: '鎶曡祫/妯℃澘_鏌ヨ缁撴灉(鎶曡祫绯荤粺-瀹㈣繍+鐗╂祦 2026.7).xls'
}
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: {
@@ -545,16 +609,42 @@
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 {
+ if (row.status !== 'success') {
this.showResultDialog({
title: '鏁版嵁瀵煎叆澶辫触',
- html: (msg || '鏁版嵁瀵煎叆澶辫触锛岃瑙佷笅鏂瑰け璐ヨ褰�').replace(/\n/g, '<br>'),
+ 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() }
@@ -567,7 +657,17 @@
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锛�
+ // 鍚庣瑙f瀽/鏍¢獙寮傚父鏃惰繑鍥� 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(() => {})
},
@@ -718,6 +818,19 @@
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 []
const lines = String(row.errorDetail).split(/\r?\n/)
--
Gitblit v1.9.1