Quellcode durchsuchen

金额格式化

xiaohaizhao vor 3 Jahren
Ursprung
Commit
cf3fc2df9f

+ 8 - 3
packageA/contract/detail.js

@@ -1,4 +1,9 @@
-const _Http = getApp().globalData.http;
+const _Http = getApp().globalData.http,
+    currency = require("../../utils/currency"),
+    CNY = value => currency(value, {
+        symbol: "¥",
+        precision: 2
+    }).format();
 Page({
 Page({
     data: {
     data: {
         isLeader: false, //是否为负责人
         isLeader: false, //是否为负责人
@@ -258,7 +263,7 @@ Page({
             briefs.splice(6, 1)
             briefs.splice(6, 1)
             briefs.splice(7, 0, {
             briefs.splice(7, 0, {
                 label: "签约金额(元)",
                 label: "签约金额(元)",
-                value: data.signamount
+                value: CNY(data.signamount)
             })
             })
             list1.splice(3, 0, {
             list1.splice(3, 0, {
                 label: data.typemx == '直销' ? '客户' : "经销商",
                 label: data.typemx == '直销' ? '客户' : "经销商",
@@ -299,7 +304,7 @@ Page({
             })
             })
             list1.splice(12, 0, {
             list1.splice(12, 0, {
                 label: "签约金额",
                 label: "签约金额",
-                value: data.signamount
+                value: CNY(data.signamount)
             })
             })
             if (data.typemx == '直销') briefs[2].label = '客户';
             if (data.typemx == '直销') briefs[2].label = '客户';
         } else {
         } else {

+ 7 - 1
packageA/contract/modules/discount/product/index.js

@@ -1,5 +1,10 @@
 const _Http = getApp().globalData.http,
 const _Http = getApp().globalData.http,
-    file = require("../../../../../utils/matchingFeilType");
+    file = require("../../../../../utils/matchingFeilType"),
+    currency = require("../../../../../utils/currency"),
+    CNY = value => currency(value, {
+        symbol: "¥",
+        precision: 2
+    }).format();
 let queue = [],
 let queue = [],
     downCounter = null;
     downCounter = null;
 
 
@@ -46,6 +51,7 @@ Component({
                         let image = value.attinfos.find(v => v.fileType == "image");
                         let image = value.attinfos.find(v => v.fileType == "image");
                         value.cover = image ? image.cover : "";
                         value.cover = image ? image.cover : "";
                     }
                     }
+                    value.showMarketprice = CNY(value.marketprice)
                     value.className = value.itemclass.length == 0 ? "暂无类目" : value.itemclass.map(v => v.itemclassname);
                     value.className = value.itemclass.length == 0 ? "暂无类目" : value.itemclass.map(v => v.itemclassname);
                     value.brandName = value.brand.length == 0 ? "暂无品牌" : value.brand.map(v => v.brandname);
                     value.brandName = value.brand.length == 0 ? "暂无品牌" : value.brand.map(v => v.brandname);
                     value.discountrate = (value.discountrate * 100).toFixed(2);
                     value.discountrate = (value.discountrate * 100).toFixed(2);

+ 1 - 1
packageA/contract/modules/discount/product/list/index.wxml

@@ -23,7 +23,7 @@
                     <text class="line-1">型号:{{item.model||' --'}}</text>
                     <text class="line-1">型号:{{item.model||' --'}}</text>
                 </view>
                 </view>
                 <view class="subfield">
                 <view class="subfield">
-                    <text class="line-1" style="margin-right: 6rpx;">牌价:{{item.marketprice||' --'}}</text>
+                    <text class="line-1" style="margin-right: 6rpx;">牌价:{{item.showMarketprice||' --'}}</text>
                 </view>
                 </view>
             </view>
             </view>
             <view class="delete" wx:if="{{!disabled}}" data-item="{{item}}" catchtap="deleteProduct">
             <view class="delete" wx:if="{{!disabled}}" data-item="{{item}}" catchtap="deleteProduct">

+ 18 - 4
packageA/contract/modules/product/index.js

@@ -1,5 +1,10 @@
 const _Http = getApp().globalData.http,
 const _Http = getApp().globalData.http,
-    file = require("../../../../utils/matchingFeilType");
+    file = require("../../../../utils/matchingFeilType"),
+    currency = require("../../../../utils/currency"),
+    CNY = value => currency(value, {
+        symbol: "¥",
+        precision: 2
+    }).format();
 let queue = [],
 let queue = [],
     downCounter = null;
     downCounter = null;
 
 
@@ -46,6 +51,10 @@ Component({
                         let image = value.attinfos.find(v => v.fileType == "image");
                         let image = value.attinfos.find(v => v.fileType == "image");
                         value.cover = image ? image.cover : "";
                         value.cover = image ? image.cover : "";
                     }
                     }
+
+                    value.showMarketprice = CNY(value.marketprice)
+                    value.showAmount = CNY(value.amount)
+
                     value.className = value.itemclass.length == 0 ? "暂无类目" : value.itemclass.map(v => v.itemclassname);
                     value.className = value.itemclass.length == 0 ? "暂无类目" : value.itemclass.map(v => v.itemclassname);
                     value.brandName = value.brand.length == 0 ? "暂无品牌" : value.brand.map(v => v.brandname);
                     value.brandName = value.brand.length == 0 ? "暂无品牌" : value.brand.map(v => v.brandname);
                     value.discountrate = (value.discountrate * 100).toFixed(2);
                     value.discountrate = (value.discountrate * 100).toFixed(2);
@@ -222,12 +231,16 @@ Component({
                 }
                 }
                 items.forEach(v => {
                 items.forEach(v => {
                     v.discountrate = (v.discountrate * 100).toFixed(2);
                     v.discountrate = (v.discountrate * 100).toFixed(2);
+                    v.showAmount = CNY(v.showAmount)
                     let i = list.findIndex(value => v.sa_contract_itemsid == value.sa_contract_itemsid);
                     let i = list.findIndex(value => v.sa_contract_itemsid == value.sa_contract_itemsid);
                     if (i != -1) this.data.list[i] = {
                     if (i != -1) this.data.list[i] = {
                         ...list[i],
                         ...list[i],
                         ...v
                         ...v
                     }
                     }
                 });
                 });
+                this.setData({
+                    list
+                })
                 this.renewalAmount();
                 this.renewalAmount();
             })
             })
         },
         },
@@ -242,10 +255,11 @@ Component({
                 console.log("更新金额", res)
                 console.log("更新金额", res)
                 let page = getCurrentPages()[getCurrentPages().length - 1];
                 let page = getCurrentPages()[getCurrentPages().length - 1];
                 if (res.msg == '成功' && page.__route__ == 'packageA/contract/detail') {
                 if (res.msg == '成功' && page.__route__ == 'packageA/contract/detail') {
-                    console.log(page.data)
+                    let qy = page.data.briefs.findIndex(v => v.label == '签约金额(元)')
+                    let qy1 = page.data.list1.findIndex(v => v.label == '签约金额')
                     page.setData({
                     page.setData({
-                        "briefs[4].value": res.data.signamount,
-                        "list1[5].value": res.data.signamount,
+                        [`briefs[${qy}].value`]: CNY(res.data.signamount),
+                        [`list1[${qy1}].value`]: CNY(res.data.signamount),
                     })
                     })
                 }
                 }
             })
             })

+ 3 - 17
packageA/contract/modules/product/list/index.js

@@ -19,22 +19,6 @@ Component({
             switch (name) {
             switch (name) {
                 case "qty":
                 case "qty":
                     item.qty = detail;
                     item.qty = detail;
-                    /* if (detail < item.orderminqty) {
-                        item.qty = item.orderminqty == 0 ? 1 : item.orderminqty;
-                    } else {
-                        item.qty = detail
-                        if (item.orderaddqty != 0) {
-                            let remainder = (detail - item.orderminqty) % item.orderaddqty;
-                            if (remainder != 0) {
-                                wx.showToast({
-                                    title: '数量不符合条件,已自动调整',
-                                    icon: "none"
-                                })
-                                item.qty = detail - remainder + item.orderaddqty;
-                            }
-                        };
-                    } */
-                    //改变数量 现数量*现价
                     item.amount = (item.price * item.qty).toFixed(2);
                     item.amount = (item.price * item.qty).toFixed(2);
                     break;
                     break;
                 case "discountrate":
                 case "discountrate":
@@ -71,8 +55,10 @@ Component({
                 [`list[${index}]`]: item
                 [`list[${index}]`]: item
             })
             })
             let obj = {};
             let obj = {};
-            ["sa_contract_itemsid", "itemid", "price", "discountrate", "qty", "remarks"].forEach(v => obj[v] = item[v]);
+            ["sa_contract_itemsid", "itemid", "price", "discountrate", "qty", "remarks", 'marketprice'].forEach(v => obj[v] = item[v]);
             obj.discountrate = (obj.discountrate / 100).toFixed(4);
             obj.discountrate = (obj.discountrate / 100).toFixed(4);
+            obj.showAmount = item.amount;
+
             this.triggerEvent("changeQueue", obj)
             this.triggerEvent("changeQueue", obj)
         },
         },
         /* 计算百分比 */
         /* 计算百分比 */

+ 2 - 2
packageA/contract/modules/product/list/index.wxml

@@ -23,7 +23,7 @@
                     <text class="line-1">型号:{{item.model||' --'}}</text>
                     <text class="line-1">型号:{{item.model||' --'}}</text>
                 </view>
                 </view>
                 <view class="subfield">
                 <view class="subfield">
-                    <text class="line-1" style="margin-right: 6rpx;">牌价:{{item.marketprice||' --'}}</text>
+                    <text class="line-1" style="margin-right: 6rpx;">牌价:{{item.showMarketprice||' --'}}</text>
                 </view>
                 </view>
             </view>
             </view>
             <view class="delete" wx:if="{{!disabled}}" data-item="{{item}}" catchtap="deleteProduct">
             <view class="delete" wx:if="{{!disabled}}" data-item="{{item}}" catchtap="deleteProduct">
@@ -48,7 +48,7 @@
                 <input class="input" style="width: 180rpx;" type="digit" disabled="{{disabled}}" value="{{item.price}}" data-name="price" data-index="{{index}}" bindblur="onBlur" />
                 <input class="input" style="width: 180rpx;" type="digit" disabled="{{disabled}}" value="{{item.price}}" data-name="price" data-index="{{index}}" bindblur="onBlur" />
             </view>
             </view>
             <view class="money">
             <view class="money">
-                金额:<text>¥{{item.amount}}</text>
+                金额:<text>{{item.showAmount}}</text>
             </view>
             </view>
         </view>
         </view>
         <view class="row">
         <view class="row">

+ 1 - 1
project.private.config.json

@@ -32,5 +32,5 @@
             ]
             ]
         }
         }
     },
     },
-    "libVersion": "2.28.1"
+    "libVersion": "2.30.2"
 }
 }

+ 0 - 2
utils/Http.js

@@ -1,6 +1,4 @@
-// const baseUrl = "https://meida.cnyunl.com/yos/rest/index";
 // const baseUrl = "http://61.164.207.46:8000/yos/rest/index";
 // const baseUrl = "http://61.164.207.46:8000/yos/rest/index";
-// const baseUrl = "http://122.226.136.204:8082/yos/rest/index";
 const baseUrl = "https://oms.idcgroup.com.cn:8079/yos/rest/index";
 const baseUrl = "https://oms.idcgroup.com.cn:8079/yos/rest/index";
 
 
 let count = null;
 let count = null;