Jelajahi Sumber

格式化金额

sqg 3 tahun lalu
induk
melakukan
99d31fc6d5

+ 17 - 2
front-vue/src/views/service/credit/addInformation.vue

@@ -119,7 +119,7 @@
                         <el-table-column label="应收企业"  align="center"  prop="receiveName"/>
                         <el-table-column label="应收企业"  align="center"  prop="payName"    />
                         <el-table-column label="预计还款期"  align="center"  prop="zbiPayDate" show-overflow-tooltip />
-                        <el-table-column label="金额"  align="center"  prop="zbiAmount" />
+                        <el-table-column label="金额" :formatter="moneyFormat"  align="center"  prop="zbiAmount" />
                         <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250">
                             <template slot-scope="scope">
                             <el-button
@@ -287,7 +287,7 @@
                 <el-table-column label="应收企业"  align="center"  prop="receiveName"/>
                 <el-table-column label="应收企业"  align="center"  prop="payName"    />
                 <el-table-column label="预计还款期"  align="center"  prop="zbiPayDate" show-overflow-tooltip />
-                <el-table-column label="金额"  align="center"  prop="zbiAmount" />
+                <el-table-column label="金额" :formatter="moneyFormat"  align="center"  prop="zbiAmount" />
             </el-table>
             <pagination
                 v-show="total > 0"
@@ -532,6 +532,21 @@ export default {
         })
     },
     methods: {
+        //列表格式化金额
+        moneyFormat(row, column, cellValue) {
+        if (cellValue == null || cellValue == undefined || cellValue == "") {
+            cellValue = "0.00";
+        }
+        cellValue += "";
+        if (!cellValue.includes(".")) {
+            cellValue += ".00";
+        }
+        return cellValue
+            .replace(/(\d)(?=(\d{3})+\.)/g, function($0, $1) {
+            return $1 + ",";
+            })
+            .replace(/\.$/, "");
+        },
         // 取消按钮
         cancel() {
             this.$store.dispatch("tagsView/delView", this.$route);

+ 16 - 2
front-vue/src/views/service/credit/creditApply.vue

@@ -26,7 +26,7 @@
                 <el-table-column label="应收企业" align="center" prop="receiveName" />
                 <el-table-column label="应付企业" align="center" prop="payName" />
                 <el-table-column label="预计还款期" align="center" prop="zbiPayDate" show-overflow-tooltip />
-                <el-table-column label="金额" align="center" prop="zbiAmount" />
+                <el-table-column label="金额" align="center" :formatter="moneyFormat" prop="zbiAmount" />
                 <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250">
                     <template slot-scope="scope">
                         <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.$index, ticketList)">删除</el-button>
@@ -237,7 +237,21 @@ export default {
 
     },
     methods: {
-
+        //列表格式化金额
+        moneyFormat(row, column, cellValue) {
+        if (cellValue == null || cellValue == undefined || cellValue == "") {
+            cellValue = "0.00";
+        }
+        cellValue += "";
+        if (!cellValue.includes(".")) {
+            cellValue += ".00";
+        }
+        return cellValue
+            .replace(/(\d)(?=(\d{3})+\.)/g, function($0, $1) {
+            return $1 + ",";
+            })
+            .replace(/\.$/, "");
+        },
         // 取消按钮
         cancel() {
             this.$store.dispatch("tagsView/delView", this.$route);

+ 17 - 2
front-vue/src/views/service/credit/creditDetail.vue

@@ -43,7 +43,7 @@
                 <td colspan="4">
                   人民币(大写):{{issuedAmount}}
                   <br />
-                  人民币(小写)¥{{form.zfiAmount}}
+                  人民币(小写)¥{{amtFormat(form.zfiAmount)}}
                 </td>
               </tr>
               <tr>
@@ -147,7 +147,7 @@
                 prop="zbiPayDate"
                 show-overflow-tooltip
               />
-              <el-table-column label="金额" align="center" prop="zbiAmount" />
+              <el-table-column label="金额" align="center" :formatter="moneyFormat" prop="zbiAmount" />
               <el-table-column
                 label="操作"
                 align="center"
@@ -463,6 +463,21 @@ export default {
       });
   },
   methods: {
+    //列表格式化金额
+    moneyFormat(row, column, cellValue) {
+    if (cellValue == null || cellValue == undefined || cellValue == "") {
+        cellValue = "0.00";
+    }
+    cellValue += "";
+    if (!cellValue.includes(".")) {
+        cellValue += ".00";
+    }
+    return cellValue
+        .replace(/(\d)(?=(\d{3})+\.)/g, function($0, $1) {
+        return $1 + ",";
+        })
+        .replace(/\.$/, "");
+    },
     // 取消按钮
     cancel() {
       this.$store.dispatch("tagsView/delView", this.$route);

+ 16 - 2
front-vue/src/views/service/credit/creditSeal.vue

@@ -70,7 +70,7 @@
                     <el-table-column label="应收企业"  align="center"  prop="receiveName"/>
                     <el-table-column label="应付企业"  align="center"  prop="payName"    />
                     <el-table-column label="预计还款期"  align="center"  prop="zbiPayDate" show-overflow-tooltip />
-                    <el-table-column label="金额"  align="center"  prop="zbiAmount" />
+                    <el-table-column label="金额" :formatter="moneyFormat"  align="center"  prop="zbiAmount" />
                 </el-table>
             </el-form-item>
             <el-row>
@@ -412,7 +412,21 @@ export default {
         })
     },
     methods: {
-
+        //列表格式化金额
+        moneyFormat(row, column, cellValue) {
+        if (cellValue == null || cellValue == undefined || cellValue == "") {
+            cellValue = "0.00";
+        }
+        cellValue += "";
+        if (!cellValue.includes(".")) {
+            cellValue += ".00";
+        }
+        return cellValue
+            .replace(/(\d)(?=(\d{3})+\.)/g, function($0, $1) {
+            return $1 + ",";
+            })
+            .replace(/\.$/, "");
+        },
         // 取消按钮
         cancel() {
             this.$store.dispatch("tagsView/delView", this.$route);

+ 17 - 3
front-vue/src/views/service/credit/financeOpen.vue

@@ -27,7 +27,7 @@
                         <el-table-column label="应收企业" align="center" prop="receiveName" />
                         <el-table-column label="应付企业" align="center" prop="payName" />
                         <el-table-column label="预计还款期" align="center" prop="zbiPayDate" width="100" show-overflow-tooltip />
-                        <el-table-column label="金额" align="center" prop="zbiAmount" width="120" />
+                        <el-table-column label="金额" align="center" :formatter="moneyFormat" prop="zbiAmount" width="120" />
                         <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250">
                             <template slot-scope="scope">
                                 <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.$index, ticketList)">删除</el-button>
@@ -125,7 +125,7 @@
             <el-table-column label="应收企业" align="center" prop="receiveName" />
             <el-table-column label="应付企业" align="center" prop="payName" />
             <el-table-column label="预计还款期" align="center" prop="zbiPayDate" show-overflow-tooltip />
-            <el-table-column label="金额" align="center" prop="zbiAmount" />
+            <el-table-column label="金额" :formatter="moneyFormat" align="center" prop="zbiAmount" />
         </el-table>
         <pagination v-show="total > 0" :total="total" :page.sync="queryParamsPay.pageNum" :limit.sync="queryParamsPay.pageSize" @pagination="getAccountsCollection" />
         <span slot="footer" class="dialog-footer">
@@ -338,7 +338,21 @@ export default {
 
     },
     methods: {
-
+        //列表格式化金额
+        moneyFormat(row, column, cellValue) {
+        if (cellValue == null || cellValue == undefined || cellValue == "") {
+            cellValue = "0.00";
+        }
+        cellValue += "";
+        if (!cellValue.includes(".")) {
+            cellValue += ".00";
+        }
+        return cellValue
+            .replace(/(\d)(?=(\d{3})+\.)/g, function($0, $1) {
+            return $1 + ",";
+            })
+            .replace(/\.$/, "");
+        },
         // 取消按钮
         cancel() {
             this.$store.dispatch("tagsView/delView", this.$route);

+ 16 - 2
front-vue/src/views/service/credit/goFinance.vue

@@ -144,7 +144,7 @@
             </tr> 
             <tr>
                 <td colspan="2">粮信金额</td>
-                <td colspan="4">人民币(大写):{{issuedAmount}}<br>人民币(小写)¥{{form.zfiAmount}}</td>
+                <td colspan="4">人民币(大写):{{issuedAmount}}<br>人民币(小写)¥{{amtFormat(form.zfiAmount)}}</td>
             </tr>
             <tr>
                 <td colspan="2">起止日期</td>
@@ -160,7 +160,7 @@
             <span class="label">金额大写:</span>
             <span class="value" style="margin-right: 40px;">{{ smallToBig(allAmount()) }}</span>
             <span class="label">消费金额:</span>
-            <span class="value">{{ allAmount() }} 元</span>
+            <span class="value">{{ amtFormat(allAmount()) }} 元</span>
           </el-row>
         </el-col>
       </el-row>
@@ -443,6 +443,20 @@ export default {
     this.getUserProfile();
   },
   methods: {
+    //格式化金额 
+    amtFormat(cellValue) {
+        if (cellValue == null || cellValue == undefined || cellValue == '') {
+            cellValue = '0.00'
+        }
+        cellValue += '';
+        if (!cellValue.includes('.')) {
+            cellValue += '.00';
+        }
+        console.log(cellValue);
+        return cellValue.replace(/(\d)(?=(\d{3})+\.)/g, function ($0, $1) {
+            return $1 + ',';
+        }).replace(/\.$/, '');
+    },
     /** 查询融信编号 */
     getFinanceInf(zfrFinanceId) {
       this.loading = true;

+ 17 - 2
front-vue/src/views/service/financeRecord/recordSeal.vue

@@ -72,7 +72,7 @@
             <span class="label">金额大写:</span>
             <span class="value" style="margin-right: 40px;">{{ smallToBig(allAmount()) }}</span>
             <span class="label">消费金额:</span>
-            <span class="value">{{ allAmount() }} 元</span>
+            <span class="value">{{ amtFormat(allAmount()) }} 元</span>
           </el-row>
         </el-col>
       </el-row>
@@ -87,7 +87,7 @@
       <el-table-column label="应收企业" align="center" prop="payee" />
       <el-table-column label="应付企业" align="center" prop="payer" />
       <el-table-column label="还款时间" align="center" prop="zbiPayDate" />
-      <el-table-column label="金额" align="center" prop="zbiAmount" />
+      <el-table-column label="金额" :formatter="moneyFormat" align="center" prop="zbiAmount" />
     </el-table>
     </el-row>
     <!-- 发票附件 -->
@@ -484,6 +484,21 @@ export default {
     });
   },
   methods: {
+    //列表格式化金额
+    moneyFormat(row, column, cellValue) {
+    if (cellValue == null || cellValue == undefined || cellValue == "") {
+        cellValue = "0.00";
+    }
+    cellValue += "";
+    if (!cellValue.includes(".")) {
+        cellValue += ".00";
+    }
+    return cellValue
+        .replace(/(\d)(?=(\d{3})+\.)/g, function($0, $1) {
+        return $1 + ",";
+        })
+        .replace(/\.$/, "");
+    },
     // 取消按钮
     cancel() {
       this.$store.dispatch("tagsView/delView", this.$route);