From 5b41c8896ef7850be2672e45b69bb58e149729ec Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期二, 01 十二月 2026 09:03:48 +0800
Subject: [PATCH] feat(货运统计): 完善台账核查与轨迹里程管理功能

---
 traffic-audit-web/src/views/DataView.vue |   97 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 95 insertions(+), 2 deletions(-)

diff --git a/traffic-audit-web/src/views/DataView.vue b/traffic-audit-web/src/views/DataView.vue
index 6eb9ba0..0d04f4c 100644
--- a/traffic-audit-web/src/views/DataView.vue
+++ b/traffic-audit-web/src/views/DataView.vue
@@ -10,6 +10,7 @@
           <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-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>
@@ -24,7 +25,9 @@
         <div class="toolbar">
           <template v-if="!isRollup">
             <span class="toolbar-label">鎶ヨ〃鏈�</span>
-            <el-date-picker v-model="period" type="month" placeholder="鎶ヨ〃鏈燂紙鍏ㄩ儴锛�" value-format="yyyy-MM" clearable style="width:150px" @change="doQuery"></el-date-picker>
+            <el-date-picker v-model="period" type="month" placeholder="鎶ヨ〃鏈燂紙鍏ㄩ儴锛�" value-format="yyyy-MM" clearable
+                            style="width:150px" :picker-options="periodPickerOptions" @change="doQuery"></el-date-picker>
+            <span v-if="periodHint" class="toolbar-hint">{{ periodHint }}</span>
           </template>
           <span class="toolbar-sep"></span>
           <span class="toolbar-label">鏁版嵁绫诲瀷</span>
@@ -34,6 +37,28 @@
               <el-option v-for="t in g.types" :key="t.value" :label="t.label" :value="t.value"></el-option>
             </el-option-group>
           </el-select>
+          <template v-if="!isRollup && type === 'trackMileage'">
+            <span class="toolbar-label">鏁版嵁鏉ユ簮</span>
+            <el-select v-model="dataSource" size="small" style="width:150px" @change="doQuery">
+              <el-option label="鍏ㄩ儴鏉ユ簮" value=""></el-option>
+              <el-option label="鐪侀噸杞藉钩鍙�" value="PROVINCIAL"></el-option>
+              <el-option label="甯傚窞绗笁鏂�" value="CITY_THIRD_PARTY"></el-option>
+            </el-select>
+            <span class="toolbar-label">甯傚窞</span>
+            <el-select v-model="cityName" size="small" style="width:130px" filterable clearable @change="doQuery">
+              <el-option label="鍏ㄩ儴甯傚窞" value=""></el-option>
+              <el-option v-for="city in cities" :key="city" :label="city" :value="city"></el-option>
+            </el-select>
+            <span class="toolbar-label">浼佷笟绫诲埆</span>
+            <el-select v-model="enterpriseCategory" size="small" style="width:140px" @change="doQuery">
+              <el-option label="鍏ㄩ儴" value=""></el-option>
+              <el-option label="瑙勪笂浼佷笟" value="ABOVE_SCALE"></el-option>
+              <el-option label="涓ゅ浼佷笟" value="PASSENGER"></el-option>
+              <el-option label="鏈叆瑙勪紒涓�" value="UNREGISTERED"></el-option>
+            </el-select>
+            <el-button type="success" size="small" icon="el-icon-download" :loading="exportingCityTrack"
+                       @click="exportTrackMileageCity">鐢熸垚鍒嗗競宸炶建杩�</el-button>
+          </template>
           <template v-if="canRollup">
             <span class="toolbar-label">瑙嗗浘</span>
             <el-radio-group v-model="viewMode" size="small" @change="onViewChange">
@@ -88,6 +113,7 @@
 <script>
 import AppHeader from '@/components/AppHeader.vue'
 import api from '@/api'
+import { granularityOfImportType, disabledDateFor, granularityHint, snapPeriod } from '@/utils/periodGranularity'
 export default {
   components: { AppHeader },
   name: 'DataView',
@@ -97,6 +123,7 @@
         {
           key: 'freight', name: '閬撹矾璐ц繍', types: [
             { value: 'h2032', label: '閬撹矾璐х墿杩愯緭鏈堝害鐢熶骇鎯呭喌' },
+            { value: 'h202', label: '鍏矾璐х墿钀ヨ繍杞﹁締鎷ユ湁鎯呭喌(H202)' },
             { value: 'transportAuth', label: '杩愭斂杞﹁締' },
             { value: 'trackMileage', label: '杞ㄨ抗閲岀▼' },
             { value: 'scaleSplit', label: '瑙勪笂瑙勪笅鎷嗗垎' },
@@ -137,6 +164,11 @@
       type: 'h2032',
       period: '',
       periodType: '',
+      dataSource: '',
+      cityName: '',
+      enterpriseCategory: '',
+      cities: ['姝︽眽甯�', '榛勭煶甯�', '鍗佸牥甯�', '瀹滄槍甯�', '瑗勯槼甯�', '閯傚窞甯�', '鑽嗛棬甯�', '瀛濇劅甯�', '鑽嗗窞甯�', '榛勫唸甯�',
+        '鍜稿畞甯�', '闅忓窞甯�', '鎭╂柦宸�', '浠欐甯�', '娼滄睙甯�', '澶╅棬甯�', '绁炲啘鏋舵灄鍖�'],
       viewMode: 'detail',
       rollupTypes: [],
       from: '',
@@ -150,10 +182,17 @@
       records: [],
       columns: [],
       loading: false,
-      loadingMore: false
+      loadingMore: false,
+      exportingCityTrack: false
     }
   },
   computed: {
+    periodGranularity() { return granularityOfImportType(this.type) },
+    periodPickerOptions() {
+      const d = disabledDateFor(this.periodGranularity)
+      return d ? { disabledDate: d } : {}
+    },
+    periodHint() { return granularityHint(this.periodGranularity) },
     canRollup() {
       return (this.rollupTypes || []).some(t => t.type === this.type)
     },
@@ -188,6 +227,17 @@
         count++
       }
       return cols.map((c, i) => Object.assign({}, c, { fixed: i < count }))
+    }
+  },
+  watch: {
+    // 閫夊埌鑳借�楋紙瀛f姤锛夋椂鎶婃姤琛ㄦ湡瀵归綈鍒板搴︽湯鏈�
+    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: {
@@ -264,10 +314,35 @@
         this.$message.success('姹囨�昏〃宸插鍑�')
       }).catch(() => this.$message.error('瀵煎嚭澶辫触'))
     },
+    exportTrackMileageCity() {
+      if (!this.period) { this.$message.warning('璇峰厛閫夋嫨鎶ヨ〃鏈�'); return }
+      this.exportingCityTrack = true
+      api.get('/data/trackMileageCityExport', {
+        params: { period: this.period },
+        responseType: 'blob',
+        timeout: 180000
+      }).then(res => {
+        const blob = res instanceof Blob ? res : new Blob([res], { type: 'application/zip' })
+        const url = window.URL.createObjectURL(blob)
+        const a = document.createElement('a')
+        const fileName = this.period.replace('-', '骞�') + '鏈堝垎甯傚窞杞ㄨ抗.zip'
+        a.href = url
+        a.download = fileName
+        document.body.appendChild(a)
+        a.click()
+        document.body.removeChild(a)
+        window.URL.revokeObjectURL(url)
+        this.$message.success('鍒嗗競宸炶建杩瑰凡鐢熸垚')
+      }).catch(() => this.$message.error('鐢熸垚鍒嗗競宸炶建杩瑰け璐�'))
+        .finally(() => { this.exportingCityTrack = false })
+    },
     onTypeSelect() {
       const g = this.modules.find(x => x.types.some(t => t.value === this.type))
       if (g) this.activeModule = g.key
       this.periodType = ''
+      this.enterpriseCategory = ''
+      this.dataSource = ''
+      this.cityName = ''
       this.viewMode = 'detail'
       this.summaryHint = ''
       this.doQuery()
@@ -286,6 +361,9 @@
           period: this.period || undefined,
           keyword: this.keyword || undefined,
           periodType: this.periodType || undefined,
+          enterpriseCategory: this.type === 'trackMileage' ? (this.enterpriseCategory || undefined) : undefined,
+          dataSource: this.type === 'trackMileage' ? (this.dataSource || undefined) : undefined,
+          cityName: this.type === 'trackMileage' ? (this.cityName || undefined) : undefined,
           page: this.page,
           size: this.size
         }
@@ -329,6 +407,9 @@
           period: this.period || undefined,
           keyword: this.keyword || undefined,
           periodType: this.periodType || undefined,
+          enterpriseCategory: this.type === 'trackMileage' ? (this.enterpriseCategory || undefined) : undefined,
+          dataSource: this.type === 'trackMileage' ? (this.dataSource || undefined) : undefined,
+          cityName: this.type === 'trackMileage' ? (this.cityName || undefined) : undefined,
           page: nextPage,
           size: this.size
         }
@@ -385,6 +466,7 @@
     //  - 鍏朵綑鏁板�煎崈鍒嗕綅銆佷繚鐣欎袱浣嶅皬鏁帮紱鏁存暟鍘熸牱銆�
     formatCell(v, prop) {
       if (v === null || v === undefined || v === '') return '-'
+      if (this.type === 'h202' && /Value$/.test(String(prop || ''))) return this.formatExactDecimal(v)
       const s = typeof v === 'string' ? v.trim() : v
       if (typeof v !== 'number' && !/^-?\d+(\.\d+)?$/.test(String(s))) return v
       const n = Number(s)
@@ -394,6 +476,17 @@
       if (/(rate|yoy|mom|growth|ratio|percent|share)/.test(key)) return (n * 100).toFixed(2) + '%'
       if (Number.isInteger(n)) return n.toLocaleString('zh-CN')
       return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
+    },
+    // H202 values arrive as exact decimal strings. Format without Number() to preserve source precision.
+    formatExactDecimal(v) {
+      const text = String(v === null || v === undefined ? '' : v).trim()
+      if (!/^-?\d+(?:\.\d+)?$/.test(text)) return v
+      const negative = text.charAt(0) === '-'
+      const unsigned = negative ? text.slice(1) : text
+      const parts = unsigned.split('.')
+      const integer = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
+      const fraction = (parts[1] || '').replace(/0+$/, '')
+      return (negative ? '-' : '') + integer + (fraction ? '.' + fraction : '')
     }
   },
   mounted() {

--
Gitblit v1.9.1