瀏覽代碼

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

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