xyc
2026-11-11 9483eb4f6d7a75261dbde71ace7878df2f7eda07
traffic-audit-web/src/views/DataView.vue
@@ -100,6 +100,7 @@
        {
          key: 'freight', name: '道路货运', types: [
            { value: 'h2032', label: '道路货物运输月度生产情况' },
            { value: 'h202', label: '公路货物营运车辆拥有情况(H202)' },
            { value: 'transportAuth', label: '运政车辆' },
            { value: 'trackMileage', label: '轨迹里程' },
            { value: 'scaleSplit', label: '规上规下拆分' },
@@ -405,6 +406,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)
@@ -414,6 +416,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() {