From ffcb8dcc05cf21b06bf34630706b458562c6dff0 Mon Sep 17 00:00:00 2001
From: xiebin <123456>
Date: Fri, 26 Aug 2022 10:02:22 +0800
Subject: [PATCH] 统计数量单位转化

---
 src/utils/public.js        |   12 ++++++
 src/views/manage/index.vue |   50 +++++++++++++++++-------
 2 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/src/utils/public.js b/src/utils/public.js
index e69de29..3c029a8 100644
--- a/src/utils/public.js
+++ b/src/utils/public.js
@@ -0,0 +1,12 @@
+/**
+ * 单位转换,如果大于10000 按1.0W显示
+ * @param num 需要转化的值
+ * @returns {*} 转化过的值
+ */
+function numUnitConversion (num) {
+    return (num > 9999) ? (num / 10000).toFixed(2) + 'w' : num.toFixed(0)
+}
+
+export default {
+    numUnitConversion
+}
diff --git a/src/views/manage/index.vue b/src/views/manage/index.vue
index bd10cd9..d9dde0a 100644
--- a/src/views/manage/index.vue
+++ b/src/views/manage/index.vue
@@ -618,6 +618,8 @@
     farmSelectQuery,
 } from "@/api/farm/farmingrecord"
 
+import publicjs from '@/utils/public'
+
 export default {
     data () {
         return {
@@ -1365,9 +1367,12 @@
             var that = this
             var farmId = that.farmValue
             selectXCount(farmId).then((res) => {
-                that.landsnum = res.data.data.snum.toFixed(0)
-                that.landwnum = res.data.data.wnum.toFixed(0)
-                that.znum = res.data.data.num.toFixed(0)
+                // that.landsnum = res.data.data.snum.toFixed(0)
+                // that.landwnum = res.data.data.wnum.toFixed(0)
+                // that.znum = res.data.data.num.toFixed(0)
+                that.landsnum = publicjs.numUnitConversion(res.data.data.snum)
+                that.landwnum = publicjs.numUnitConversion(res.data.data.wnum)
+                that.znum = publicjs.numUnitConversion(res.data.data.num)
             })
         },
         // 农资使用概况
@@ -1378,6 +1383,9 @@
                 that.jnStock = res.data.data.jn.toFixed(0)
                 that.qnStock = res.data.data.qn.toFixed(0)
                 that.byStock = res.data.data.by.toFixed(0)
+                // that.jnStock = publicjs.numUnitConversion(res.data.data.jn)
+                // that.qnStock = publicjs.numUnitConversion(res.data.data.qn)
+                // that.byStock = publicjs.numUnitConversion(res.data.data.by)
             })
         },
         // 大屏经营概况库存数量与年产量
@@ -1394,6 +1402,30 @@
                 this.yieldNCP = res.data.data.ncpNcl
                 this.yieldJG = res.data.data.jgNcl
                 this.yieldTj = res.data.data.ncpNcl + res.data.data.jgNcl
+
+                this.stockNCP = publicjs.numUnitConversion(this.stockNCP)
+                this.stockJG = publicjs.numUnitConversion(this.stockJG)
+                this.stockTj = publicjs.numUnitConversion(this.stockTj)
+
+                this.yieldNCP = publicjs.numUnitConversion(this.yieldNCP)
+                this.yieldJG = publicjs.numUnitConversion(this.yieldJG)
+                this.yieldTj = publicjs.numUnitConversion(this.yieldTj)
+            })
+        },
+        // 统计市场流通/去年流通量/本月流通量
+        selectMarketCirculate (year) {
+            var params = {}
+            params.codes = "000000"
+            params.farmId = this.farmValue
+            params.year = year
+            selectMarketCirculate(Object.assign(params)).then((res) => {
+                this.salaNumBN = res.data.data[0].num
+                this.salaNumQN = res.data.data[1].num
+                this.salaNumBY = res.data.data[2].num
+
+                this.salaNumBN = publicjs.numUnitConversion(this.salaNumBN)
+                this.salaNumQN = publicjs.numUnitConversion(this.salaNumQN)
+                this.salaNumBY = publicjs.numUnitConversion(this.salaNumBY)
             })
         },
         // 按月统计产量
@@ -1445,18 +1477,6 @@
                 if (this.trpOrNcp == "trp") {
                     this.initTrpBar("TrpEcharts")
                 }
-            })
-        },
-        // 统计市场流通/去年流通量/本月流通量
-        selectMarketCirculate (year) {
-            var params = {}
-            params.codes = "000000"
-            params.farmId = this.farmValue
-            params.year = year
-            selectMarketCirculate(Object.assign(params)).then((res) => {
-                this.salaNumBN = res.data.data[0].num
-                this.salaNumQN = res.data.data[1].num
-                this.salaNumBY = res.data.data[2].num
             })
         },
         // 统计任务总数

--
Gitblit v1.9.3