From 336695c5449cbf5d526b89622c24c9c6b590baab Mon Sep 17 00:00:00 2001
From: zhizhijie <zhizhijie@users.noreply.gitee.com>
Date: 星期二, 22 九月 2026 11:03:01 +0800
Subject: [PATCH] docs: 数据查看口径筛选与表头单位功能测试报告 + 日结补充

---
 traffic-audit-web/src/views/DataView.vue |  107 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 89 insertions(+), 18 deletions(-)

diff --git a/traffic-audit-web/src/views/DataView.vue b/traffic-audit-web/src/views/DataView.vue
index 7b0d59e..cdf1f2f 100644
--- a/traffic-audit-web/src/views/DataView.vue
+++ b/traffic-audit-web/src/views/DataView.vue
@@ -21,14 +21,20 @@
           <el-date-picker v-model="period" type="month" placeholder="鎶ヨ〃鏈燂紙鍏ㄩ儴锛�" value-format="yyyy-MM" clearable style="width:150px" @change="doQuery"></el-date-picker>
           <span class="toolbar-sep"></span>
           <span class="toolbar-label">鏁版嵁绫诲瀷</span>
-          <el-radio-group v-model="activeModule" size="small" @change="onModuleChange">
-            <el-radio-button v-for="g in modules" :key="g.key" :label="g.key">{{ g.name }}</el-radio-button>
-          </el-radio-group>
-          <el-select v-model="type" size="small" style="width:250px" placeholder="閫夋嫨鏁版嵁绫诲瀷" @change="onTypeSelect">
-            <el-option-group :label="activeTypes.name">
-              <el-option v-for="t in activeTypes.types" :key="t.value" :label="t.label" :value="t.value"></el-option>
+          <el-select v-model="type" size="small" style="width:300px" placeholder="閫夋嫨鏁版嵁绫诲瀷" filterable
+                     popper-class="data-type-select" :title="currentTypeLabel" @change="onTypeSelect">
+            <el-option-group v-for="g in modules" :key="g.key" :label="g.name">
+              <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="hasPeriodType">
+            <span class="toolbar-label">鍙e緞</span>
+            <el-select v-model="periodType" size="small" style="width:110px" @change="doQuery">
+              <el-option label="鍏ㄩ儴" value=""></el-option>
+              <el-option label="褰撴湀" value="MONTH"></el-option>
+              <el-option label="绱" value="CUMULATIVE"></el-option>
+            </el-select>
+          </template>
           <el-input v-model="keyword" placeholder="浼佷笟/甯傚窞鍚嶇О" clearable style="width:180px" @keyup.enter.native="doQuery"></el-input>
           <el-button type="primary" size="small" @click="doQuery">鏌ヨ</el-button>
           <el-button size="small" icon="el-icon-full-screen" @click="toggleFullscreen">鍏ㄥ睆鏌ョ湅</el-button>
@@ -37,9 +43,9 @@
         <div class="table-wrap" ref="tableWrap">
           <div class="table-area">
             <el-table :data="records" border v-loading="loading" size="small" style="width:100%" height="100%">
-              <el-table-column v-for="c in visibleColumns" :key="c.prop" :prop="c.prop" :label="c.label" :min-width="c.width" show-overflow-tooltip>
+              <el-table-column v-for="c in renderColumns" :key="c.prop" :prop="c.prop" :label="c.label" :min-width="c.width" :fixed="c.fixed ? 'left' : false" show-overflow-tooltip>
                 <template slot-scope="scope">
-                  <span>{{ formatCell(scope.row[c.prop]) }}</span>
+                  <span>{{ formatCell(scope.row[c.prop], c.prop) }}</span>
                 </template>
               </el-table-column>
             </el-table>
@@ -101,6 +107,7 @@
       activeModule: 'freight',
       type: 'h2032',
       period: '',
+      periodType: '',
       keyword: '',
       page: 1,
       size: 50,
@@ -112,18 +119,47 @@
     }
   },
   computed: {
+    // 瑙勪笂瑙勪笅鎷嗗垎绛夎〃鏈�"鍙e緞"鍒楋紙褰撴湀/绱锛夛紝鎶婂畠鍋氭垚涓婃柟绛涢�夎�屼笉鏄〃鏍煎垪
+    hasPeriodType() {
+      return (this.columns || []).some(c => c.prop === 'periodType')
+    },
+    currentTypeLabel() {
+      for (const g of this.modules) {
+        const t = g.types.find(x => x.value === this.type)
+        if (t) return g.name + ' 路 ' + t.label
+      }
+      return this.type
+    },
     activeTypes() {
       const g = this.modules.find(x => x.key === this.activeModule) || this.modules[0]
       return g
     },
     visibleColumns() {
-      const hiddenProps = ['enterpriseCode', 'unifiedCreditCode', 'reportUnit']
-      const hiddenLabels = ['浼佷笟浠g爜', '缁熶竴绀句細淇$敤浠g爜', '濉姤鍗曚綅']
-      return (this.columns || []).filter(c =>
-        hiddenProps.indexOf(c.prop) < 0 && hiddenLabels.indexOf(c.label) < 0)
+      return (this.columns || []).filter(c => this.keepColumn(c))
+    },
+    // 宸︿晶鍐荤粨"杩欐槸璋佺殑鏁版嵁"鐨勫垪锛氬競宸�/鍦板尯 + 浼佷笟(椤圭洰)鍚嶇О/杞︾墝鍙凤紝鏈�澶� 3 鍒椼��
+    // 鎶ヨ〃鏈熶笌鎵�灞炲湴鍖轰笉鍙備笌鍐荤粨锛堟姤琛ㄦ湡鏄瓫閫夋潯浠讹紝鎵�灞炲湴鍖烘槸鍖哄垝浠g爜锛屽凡鐢卞競宸炲垪鏇夸唬锛夈��
+    renderColumns() {
+      const stickyProps = ['city', 'regionName', 'region', 'periodType', 'enterpriseName', 'projectName', 'plateNo']
+      const cols = this.visibleColumns
+      let count = 0
+      while (count < cols.length && count < 3 && stickyProps.indexOf(cols[count].prop) >= 0) {
+        count++
+      }
+      return cols.map((c, i) => Object.assign({}, c, { fixed: i < count }))
     }
   },
   methods: {
+    // 鏁版嵁鏌ョ湅缁熶竴鍒楄繃婊わ細鍐呴儴鏍囪瘑鍒椾笉灞曠ず锛涙姤琛ㄦ湡锛堢敱绛涢�夋潯浠朵綋鐜帮級涓庢墍灞炲湴鍖猴紙鍖哄垝浠g爜锛屽凡琚競宸炲垪鏇夸唬锛変笉灞曠ず
+    keepColumn(c) {
+      if (!c) return false
+      // 鍙e緞鍒椾笂绉讳负绛涢�夛紱鎷嗗垎琛ㄨ揣杩愰噺涓夊垪婧愭枃浠舵湭鎻愪緵锛堝叏绌猴級鏁呬笉灞曠ず
+      const hiddenProps = ['enterpriseCode', 'unifiedCreditCode', 'reportUnit', 'projectId', 'regionCode', 'reportPeriod',
+        'periodType', 'aboveScaleFreight', 'belowScaleFreight', 'totalFreight']
+      const hiddenLabels = ['浼佷笟浠g爜', '缁熶竴绀句細淇$敤浠g爜', '濉姤鍗曚綅', '椤圭洰ID', '鎵�灞炲湴鍖�', '鎶ヨ〃鏈�', '鍙e緞']
+      if (hiddenProps.indexOf(c.prop) >= 0 || hiddenLabels.indexOf(c.label) >= 0) return false
+      return true
+    },
     onModuleChange(key) {
       const g = this.modules.find(x => x.key === key)
       if (!g || !g.types.length) return
@@ -132,7 +168,12 @@
       }
       this.doQuery()
     },
-    onTypeSelect() { this.doQuery() },
+    onTypeSelect() {
+      const g = this.modules.find(x => x.types.some(t => t.value === this.type))
+      if (g) this.activeModule = g.key
+      this.periodType = ''
+      this.doQuery()
+    },
     doQuery() {
       this.page = 1
       this.records = []
@@ -146,13 +187,14 @@
           type: this.type,
           period: this.period || undefined,
           keyword: this.keyword || undefined,
+          periodType: this.periodType || undefined,
           page: this.page,
           size: this.size
         }
       }).then(res => {
         const d = res.data || {}
         this.records = d.records || []
-        this.columns = (d.columns || []).filter(c => ['enterpriseCode', 'unifiedCreditCode', 'reportUnit'].indexOf(c.prop) < 0 && ['浼佷笟浠g爜', '缁熶竴绀句細淇$敤浠g爜', '濉姤鍗曚綅'].indexOf(c.label) < 0)
+        this.columns = d.columns || []
         this.total = d.total || 0
         if (this.page > 1 && this.records.length === 0) {
           this.page = 1
@@ -188,6 +230,7 @@
           type: this.type,
           period: this.period || undefined,
           keyword: this.keyword || undefined,
+          periodType: this.periodType || undefined,
           page: nextPage,
           size: this.size
         }
@@ -201,7 +244,7 @@
         this.records = this.records.concat(addRows)
         this.page = nextPage
         if (d.total != null) this.total = d.total
-        if (d.columns && d.columns.length) this.columns = d.columns.filter(c => ['enterpriseCode', 'unifiedCreditCode', 'reportUnit'].indexOf(c.prop) < 0 && ['浼佷笟浠g爜', '缁熶竴绀句細淇$敤浠g爜', '濉姤鍗曚綅'].indexOf(c.label) < 0)
+        if (d.columns && d.columns.length) this.columns = d.columns
       }).catch(e => {
         if (e && e._toast) return
         this.$message.error('鍔犺浇鏇村澶辫触')
@@ -238,9 +281,21 @@
         document.exitFullscreen()
       }
     },
-    formatCell(v) {
+    // 鏄剧ず鏍煎紡鍖栵紙涓嶆敼鍔ㄥ簳灞傛暟鎹紝瀵煎嚭浠嶄负鍏ㄧ簿搴︼級锛�
+    //  - 姣旂巼绫诲垪锛堢幆姣�/鍚屾瘮/澧為��/鍗犳瘮锛夊簱鍐呮槸灏忔暟锛�0.045 = 4.5%锛夛紝鏄剧ず涓虹櫨鍒嗘瘮锛�
+    //  - 鎺掑悕绫诲垪鏄剧ず鏁存暟锛�
+    //  - 鍏朵綑鏁板�煎崈鍒嗕綅銆佷繚鐣欎袱浣嶅皬鏁帮紱鏁存暟鍘熸牱銆�
+    formatCell(v, prop) {
       if (v === null || v === undefined || v === '') return '-'
-      return v
+      const s = typeof v === 'string' ? v.trim() : v
+      if (typeof v !== 'number' && !/^-?\d+(\.\d+)?$/.test(String(s))) return v
+      const n = Number(s)
+      if (!isFinite(n)) return v
+      const key = String(prop || '').toLowerCase()
+      if (/rank/.test(key)) return Math.round(n).toLocaleString('zh-CN')
+      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 })
     }
   },
   mounted() {
@@ -281,4 +336,20 @@
 #app .table-area:fullscreen { padding:20px; background:#fff; overflow:auto; }
 #app .table-wrap:fullscreen { padding:20px; background:#fff; overflow:auto; display:flex; flex-direction:column; height:100vh; }
 #app .table-wrap:fullscreen .table-area { flex:1 1 auto; min-height:0; }
-</style>
\ No newline at end of file
+</style>
+<style>
+/* 鏁版嵁绫诲瀷涓嬫媺锛欵lement UI 榛樿鎶婂垎缁勬爣棰樺仛鎴� 12px 鐏拌壊灏忓瓧锛岀湅璧锋潵"姣旈�夐」鏇村皬鏇存贰"銆�
+   杩欓噷鎶婂畠鏀规垚鏄庣‘鐨勭粍鏍囬鏍峰紡锛堝姞娣便�佸姞绮椼�佺暐澶с�佸甫搴曡壊锛夛紝涓庨�夐」褰㈡垚鏈夋剰鐨勫眰绾с�� */
+.data-type-select .el-select-group__title {
+  font-size: 13px;
+  font-weight: 700;
+  color: #303133;
+  line-height: 28px;
+  background: #F5F7FA;
+  padding-left: 12px;
+  letter-spacing: .5px;
+}
+.data-type-select .el-select-group__title::after { display: none; }
+.data-type-select .el-select-group { padding-bottom: 6px; }
+.data-type-select .el-select-group .el-select-dropdown__item { padding-left: 20px; }
+</style>

--
Gitblit v1.9.1