소스 검색

用户管理 空数据处理 金额保留两位小数

DESKTOP-2S67K1S\31396 2 년 전
부모
커밋
c38b4fc92a
1개의 변경된 파일56개의 추가작업 그리고 9개의 파일을 삭제
  1. 56 9
      src/views/user/list/index.vue

+ 56 - 9
src/views/user/list/index.vue

@@ -36,18 +36,28 @@
       <el-table-column label="注册来源" prop="registerChannel" align="center" :formatter="regFormatter" />
       <el-table-column label="注册系统" prop="mtype" align="center" :formatter="typeFormatter" />
       <el-table-column label="注册时间" prop="createTime" align="center" />
-      <el-table-column label="用户积分" prop="totalPoint" align="center" />
-      <el-table-column prop="balanceAndroid" align="center">
+      <el-table-column label="用户积分" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.totalPoint | empty(scope.row.totalPoint) }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column align="center">
         <template slot="header">
           <div>钱包余额</div>
           <div>(Android)</div>
         </template>
+        <template slot-scope="scope">
+          <span>{{ scope.row.balanceAndroid.toFixed(2) }}</span>
+        </template>
       </el-table-column>
-      <el-table-column prop="balanceIos" align="center">
+      <el-table-column align="center">
         <template slot="header">
           <div>钱包余额</div>
           <div>(iOS)</div>
         </template>
+        <template slot-scope="scope">
+          <span>{{ scope.row.balanceIos.toFixed(2) }}</span>
+        </template>
       </el-table-column>
       <el-table-column label="已绑设备" align="center" show-overflow-tooltip>
         <template slot-scope="scope">
@@ -59,11 +69,31 @@
           </span>
         </template>
       </el-table-column>
-      <el-table-column label="购买次数" prop="buyCount" align="center" />
-      <el-table-column label="累计消费 / 元" prop="buyAmount" align="center" />
-      <el-table-column label="上次消费" prop="lastBuyTime" align="center" />
-      <el-table-column label="累计充值 / 元" prop="rechargeAmount" align="center" />
-      <el-table-column label="上次充值" prop="lastRechargeTime" align="center" />
+      <el-table-column label="购买次数" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.buyCount | empty(scope.row.buyCount) }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="累计消费 / 元" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.buyAmount | emptyCount(scope.row.buyAmount) }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="上次消费" prop="lastBuyTime" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.lastBuyTime | emptyDate(scope.row.lastBuyTime) }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="累计充值 / 元" prop="rechargeAmount" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.rechargeAmount | emptyCount(scope.row.rechargeAmount) }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="上次充值" prop="lastRechargeTime" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.lastRechargeTime | emptyDate(scope.row.lastRechargeTime) }}</span>
+        </template>
+      </el-table-column>
     </el-table>
     <pagination v-show="total > 0" :total="total" :page.sync="form.pageNum" :limit.sync="form.pageSize"
       @pagination="getList" />
@@ -138,7 +168,6 @@ export default {
     getList() {
       this.loading = true
       list(this.form).then(res => {
-        console.log(res);
         if (res.code === 0) {
           this.tableData = res.data.records
           this.total = res.data.total
@@ -174,6 +203,24 @@ export default {
     typeFormatter(row) {
       return this.selectDictLabel(this.typeOptions, row.mtype)
     }
+  },
+
+  // 过滤器
+  filters: {
+    // 是否为空
+    empty(item) {
+      return !item ? 0 : item
+    },
+
+    // 金额是否为空
+    emptyCount(item) {
+      return !item ? '0.00' : Number(item).toFixed(2)
+    },
+
+    // 时间为空
+    emptyDate(item) {
+      return !item ? '-' : item
+    }
   }
 }
 </script>