Browse Source

feat: format visit and deal rates as percentages in person cards

Yannay 5 days ago
parent
commit
fcb4ff5d77
1 changed files with 9 additions and 2 deletions
  1. 9 2
      pages/person/cards/index.vue

+ 9 - 2
pages/person/cards/index.vue

@@ -64,11 +64,11 @@
64 64
                         </view>
65 65
                         <view class="visit_item">
66 66
                             <text class="visit_label">上门率</text>
67
-                            <text class="visit_value">{{ cardData.visitRate }}</text>
67
+                            <text class="visit_value">{{ formatPercent(cardData.visitRate) }}</text>
68 68
                         </view>
69 69
                         <view class="visit_item">
70 70
                             <text class="visit_label">成交率</text>
71
-                            <text class="visit_value">{{ cardData.dealRate }}</text>
71
+                            <text class="visit_value">{{ formatPercent(cardData.dealRate) }}</text>
72 72
                         </view>
73 73
                         <view class="visit_item">
74 74
                             <text class="visit_label">投产比</text>
@@ -221,6 +221,13 @@ export default {
221 221
             if (Number.isNaN(num)) return '-';
222 222
             return num.toFixed(2);
223 223
         },
224
+        // 与 splitSummary 一致:上门率/成交率显示为 xx.xx%
225
+        formatPercent(val) {
226
+            if (val === null || val === undefined || val === '' || val === '-') return '-';
227
+            const num = Number(val);
228
+            if (Number.isNaN(num)) return '-';
229
+            return num.toFixed(2) + '%';
230
+        },
224 231
         getCardData() {
225 232
             const time = this.tabList[this.currentTab].value;
226 233
             uni.$u.api.getPersonCards({