فهرست منبع

行情类型转换为对应的中文名称

刘浩男 1 سال پیش
والد
کامیت
f35c87708b
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 8 1
      pages/quotations/quotations.vue

+ 8 - 1
pages/quotations/quotations.vue

@@ -27,7 +27,7 @@
           <uni-td align="center">{{ item.productName }}
           </uni-td>
           <uni-td align="center">
-            <view class="name">{{ item.type }}</view>
+            <view class="name">{{ item.type}}</view>
           </uni-td>
           <uni-td align="center">{{ item.price }}
           </uni-td>
@@ -132,9 +132,16 @@ export default {
       uni.stopPullDownRefresh();
     },
     dataFormat(rows) {
+      // 创建一个映射对象,键是id,值是productName
+      const idToProductName = this.categories.reduce((acc, cur) => {
+        acc[cur.id] = cur.productName;
+        return acc;
+      }, {});
       return rows.map(item => {
         let date = new Date(item.createTime);
         item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
+        // 使用映射对象将type的值从id转换为productName
+        item.type = idToProductName[item.type] || item.type;
         return item;
       });
     },