From 841847dbbab3c6fd532dcb747ca290ba6a9e12d0 Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期三, 11 十一月 2026 20:07:50 +0800
Subject: [PATCH] feat(企业台账): 完善抽查报告和车辆核查工具
---
traffic-audit-web/src/views/DataImport.vue | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 165 insertions(+), 15 deletions(-)
diff --git a/traffic-audit-web/src/views/DataImport.vue b/traffic-audit-web/src/views/DataImport.vue
index 82abc05..b6a2ba8 100644
--- a/traffic-audit-web/src/views/DataImport.vue
+++ b/traffic-audit-web/src/views/DataImport.vue
@@ -26,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>
@@ -48,7 +49,7 @@
<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>
</div>
<div v-if="isCityDirType(moduleSel[g.key])" class="module-file">
@@ -58,11 +59,17 @@
</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="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>
</div>
@@ -81,6 +88,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">
@@ -98,6 +106,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 }">
@@ -157,7 +183,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>
@@ -175,8 +202,9 @@
<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: '鎶曡祫绯荤粺瀵煎嚭',
@@ -190,7 +218,7 @@
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',
SCALE_SPLIT: 'scaleSplit', FREIGHT_TURNOVER: 'freightTurnover',
H2031: 'passengerMonthly', PASSENGER_AUTH: 'passengerAuth', PASSENGER_INDIVIDUAL: 'passengerIndividual',
H204: 'energyMonthly', ENERGY_AUTH: 'energyAuth',
@@ -198,6 +226,7 @@
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',
@@ -226,6 +255,7 @@
{
key: 'freight', name: '閬撹矾璐ц繍', types: [
{ value: 'h2032', label: '閬撹矾璐х墿杩愯緭鏈堝害鐢熶骇鎯呭喌' },
+ { value: 'h202', label: '鍏矾璐х墿钀ヨ繍杞﹁締鎷ユ湁鎯呭喌(H202)' },
{ value: 'transportAuth', label: '杩愭斂杞﹁締' },
{ value: 'trackMileage', label: '杞ㄨ抗閲岀▼' },
{ value: 'scaleSplit', label: '瑙勪笂瑙勪笅鎷嗗垎' },
@@ -283,15 +313,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 }))
}
@@ -301,13 +357,14 @@
templateName() {
const map = {
h2032: '妯℃澘_浜や紒缁烪203-2琛╛閬撹矾璐х墿杩愯緭鏈堝害鐢熶骇鎯呭喌.xlsx',
+ h202: 'RP_JTB_FreightVehicle_鍏ㄧ渷.xlsx锛堝鍏ュ墠灏嗘枃浠跺悕鈥滃叏鐪佲�濆拰琛ㄥ唴 L3 鎶ヨ〃鏃ユ湡鏀逛负瀹為檯鍦板尯銆佹姤琛ㄦ湡鏈棩鏈燂級',
transportAuth: '妯℃澘_杩愭斂杞﹁締.xlsx',
trackMileage: '妯℃澘_杞ㄨ抗閲岀▼.xlsx',
scaleSplit: '妯℃澘_瑙勪笂瑙勪笅鎷嗗垎杩愯緭閲�.xlsx',
freightTurnover: '妯℃澘_璐ц繍閲忓懆杞噺.xlsx',
passengerMonthly: '鍏矾鏃呭杩愯緭鏈堝害鐢熶骇鎯呭喌.xlsx锛堝惈杩愭斂杞﹁締鏁皊heet锛�',
passengerAuth: '妯℃澘_鍏矾鏃呭杩愭斂杞﹁締鏁�.xls锛堟敮鎸� 浼佷笟浠g爜/浼佷笟鍚嶇О/杞﹁締鏁�/杞藉浣嶆暟 涓� 杩愭斂搴撳鍑� OWNERNAME/鎬昏溅杈嗘暟/瀹綅鏁帮級',
- passengerIndividual: '涓綋瀹㈣繍閲忔眹鎬�.xlsx锛堝垪锛氭墍灞炲湴鍖�/浼佷笟浠g爜/浼佷笟鍚嶇О/涓綋瀹㈣繍閲�/涓綋鏃呭鍛ㄨ浆閲忥級',
+ passengerIndividual: '妯℃澘_涓綋瀹㈣繍锛�2026.7锛�.xlsx锛堟爣棰樻湀浠介渶涓庢姤琛ㄦ湡涓�鑷达紱鍒楋細甯傚窞/涓綋杞﹁締鏁�/涓綋瀹㈣繍閲�/涓綋鏃呭鍛ㄨ浆閲忥級',
energyMonthly: '閬撹矾璐ц繍杞﹁締鑳芥簮娑堣�楁儏鍐碉紙2026骞达級.xlsx锛堣兘鑰楁槑缁�+杩愭斂杞﹁締淇℃伅涓heet锛�',
energyAuth: '妯℃澘_鑳借�楄溅杈嗚繍鏀夸俊鎭�.xlsx锛堝垪锛氳溅鐗屽彿/杞﹁締绫诲瀷/鐕冩枡绫诲瀷/鏍囪鍚ㄤ綅/鍑嗙壍寮曡川閲忥級',
investment: '7鏈堝杩愮珯鎶曡祫鏄庣粏琛紙甯傚窞姹囨�诲ぇ琛紝缁欓瀵硷級.xlsx',
@@ -327,13 +384,14 @@
templateUrl() {
const map = {
h2032: '璐ц繍/妯℃澘_浜や紒缁烪203-2琛╛閬撹矾璐х墿杩愯緭鏈堝害鐢熶骇鎯呭喌.xlsx',
+ h202: '璐ц繍/RP_JTB_FreightVehicle_鍏ㄧ渷.xlsx',
transportAuth: '璐ц繍/妯℃澘_杩愭斂杞﹁締.xlsx',
trackMileage: '璐ц繍/妯℃澘_杞ㄨ抗閲岀▼.xlsx',
scaleSplit: '璐ц繍/妯℃澘_瑙勪笂瑙勪笅鎷嗗垎杩愯緭閲�.xlsx',
freightTurnover: '璐ц繍/妯℃澘_璐ц繍閲忓懆杞噺.xlsx',
passengerMonthly: '鍏矾鏃呭/妯℃澘_浜や紒缁烪203-1琛╛鍏矾鏃呭杩愯緭鏈堝害鐢熶骇鎯呭喌.xlsx',
passengerAuth: '鍏矾鏃呭/妯℃澘_鍏矾鏃呭杩愭斂杞﹁締鏁�.xls',
- passengerIndividual: '鍏矾鏃呭/涓綋瀹㈣繍閲忔眹鎬�.xlsx',
+ passengerIndividual: '鍏矾鏃呭/妯℃澘_涓綋瀹㈣繍锛�2026.7锛�.xlsx',
energyMonthly: '鑳借��/妯℃澘_閬撹矾璐ц繍杞﹁締鑳芥簮娑堣�楁儏鍐碉紙2026锛�.xlsx',
energyAuth: '鑳借��/妯℃澘_鑳借�楄溅杈嗚繍鏀夸俊鎭�.xlsx',
cityBus: '鍩庡競瀹㈣繍/鐢熸垚_鍩庡競鍏氦瀹㈣繍閲忓垎甯傚窞鏄庣粏.xlsx',
@@ -347,6 +405,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: {
@@ -378,6 +447,7 @@
endpoint(t) {
const map = {
h2032: '/import/h2032',
+ h202: '/import/h202',
transportAuth: '/import/transportAuth',
trackMileage: '/import/trackMileage',
scaleSplit: '/import/scaleSplit',
@@ -398,6 +468,37 @@
wycOrderReport: '/import/wycOrderReport'
}
return map[t] || ''
+ },
+ pickH202Folder(key) {
+ if (this.importing) { this.$message.warning('姝e湪瀵煎叆涓紝璇风◢鍊欏啀閫夋嫨鏂囦欢澶�'); 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('姝e湪瀵煎叆涓紝璇风◢鍊欏啀閫夋嫨鏂囦欢澶�'); 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]
@@ -550,16 +651,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() }
@@ -572,7 +699,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(() => {})
},
@@ -723,6 +860,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