liujt пре 2 недеља
родитељ
комит
c729e5d212
4 измењених фајлова са 30 додато и 16 уклоњено
  1. 5 4
      pages/home/home.vue
  2. 6 4
      pages/home/homeNew.vue
  3. 9 8
      pages/home/pages/manage/manage.vue
  4. 10 0
      utils/utils.js

+ 5 - 4
pages/home/home.vue

@@ -172,7 +172,8 @@
 	} from '@/api/wt/index.js'
 
 	import {
-		getDateNew
+		getDateNew,
+		yuanToWan
 	} from '@/utils/utils.js'
 	import {
 		postJ,
@@ -438,9 +439,9 @@
 				this.homeData.totalFinishedProducts = res1?.totalFinishedProducts ?? 0
 				this.homeData.totalRawMaterials = res1?.totalRawMaterials ?? 0
 				this.homeData.goodsCount = res2?.count ?? 0
-				this.homeData.yearAmount = (res3 / 10000).toFixed(2)
-				this.homeData.receivableAmount = res4 ?? 0
-				this.homeData.payableAmount = res5 ?? 0
+				this.homeData.yearAmount = yuanToWan(res3 ?? 0)
+				this.homeData.receivableAmount = yuanToWan(res4 ?? 0)
+				this.homeData.payableAmount = yuanToWan(res5 ?? 0)
 				this.homeData.yearProduceAmount = res6?.reduce((pre, cur) => {
 					return pre + cur?.formedNum
 				}, 0) ?? 0

+ 6 - 4
pages/home/homeNew.vue

@@ -103,7 +103,8 @@
 	import manage from './pages/manage/manage.vue'
 
 	import {
-		getDateNew
+		getDateNew,
+		yuanToWan
 	} from '@/utils/utils.js'
 	import {
 		postJ,
@@ -228,6 +229,7 @@
 
 
 		methods: {
+			
 			// 刷新 manage 子组件数据(供父组件 tab 切换时调用)
 			refreshManage() {
 				this.$refs.manageRef?.refreshData()
@@ -424,9 +426,9 @@
 				this.homeData.totalFinishedProducts = res1?.totalFinishedProducts ?? 0
 				this.homeData.totalRawMaterials = res1?.totalRawMaterials ?? 0
 				this.homeData.goodsCount = res2?.count ?? 0
-				this.homeData.yearAmount = (res3 / 10000).toFixed(2)
-				this.homeData.receivableAmount = res4 ?? 0
-				this.homeData.payableAmount = res5 ?? 0
+				this.homeData.yearAmount = yuanToWan(res3 ?? 0)
+				this.homeData.receivableAmount = yuanToWan(res4 ?? 0)
+				this.homeData.payableAmount = yuanToWan(res5 ?? 0)
 				this.homeData.yearProduceAmount = res6?.reduce((pre, cur) => {
 					return pre + cur?.formedNum
 				}, 0) ?? 0

+ 9 - 8
pages/home/pages/manage/manage.vue

@@ -203,6 +203,7 @@
 <script>
 import * as echarts from '@/uni_modules/lime-echart/static/echarts.min'
 import { getSaleOrderSummary, getSaleOrderTrendSummary, getPadStockStreamStatistics, getPdaFindMaterialTrend, getMonthOutput, getYearOutput, getTendencyChart, getPurchaseOrderSummary, getPurchaseOrderTrendSummary } from '@/api/home/index'
+import { yuanToWan } from '@/utils/utils.js'
 
 export default {
   data() {
@@ -307,9 +308,9 @@ export default {
       console.log('getPurchaseOrderSummary', res)
       // res: { yearlySummary: { quantity, amount }, monthlySummary: { quantity, amount } }
       this.purchase.yearCount = res?.yearlySummary?.quantity || 0
-      this.purchase.yearAmount = +(res?.yearlySummary?.amount / 10000).toFixed(2) || 0
+      this.purchase.yearAmount = yuanToWan(res?.yearlySummary?.amount)
       this.purchase.monthCount = res?.monthlySummary?.quantity || 0
-      this.purchase.monthAmount = +(res?.monthlySummary?.amount / 10000).toFixed(2) || 0
+      this.purchase.monthAmount = yuanToWan(res?.monthlySummary?.amount)
     },
     async getPurchaseOrderTrendSummary() {
       let res = await getPurchaseOrderTrendSummary({
@@ -330,8 +331,8 @@ export default {
         if (idx >= 0 && idx < 12) {
           quantityArr[idx] = item.quantity || 0
           lastQuantityArr[idx] = item.lastQuantity || 0
-          amountArr[idx] = +((item.amount || 0) / 10000).toFixed(2)
-          lastAmountArr[idx] = +((item.lastAmount || 0) / 10000).toFixed(2)
+          amountArr[idx] = yuanToWan(item.amount)
+          lastAmountArr[idx] = yuanToWan(item.lastAmount)
         }
       })
 
@@ -522,8 +523,8 @@ export default {
         if (idx >= 0 && idx < 12) {
           quantityArr[idx] = item.quantity || 0
           lastQuantityArr[idx] = item.lastQuantity || 0
-          amountArr[idx] = +((item.amount || 0) / 10000).toFixed(2)
-          lastAmountArr[idx] = +((item.lastAmount || 0) / 10000).toFixed(2)
+          amountArr[idx] = yuanToWan(item.amount)
+          lastAmountArr[idx] = yuanToWan(item.lastAmount)
         }
       })
 
@@ -551,9 +552,9 @@ export default {
       })
 
       this.marketing.yearOrderCount = res?.yearlySummary?.quantity || 0
-      this.marketing.yearOrderAmount = (res?.yearlySummary?.amount / 10000).toFixed(2) || 0
+      this.marketing.yearOrderAmount = yuanToWan(res?.yearlySummary?.amount)
       this.marketing.monthOrderCount = res?.monthlySummary?.quantity || 0
-      this.marketing.monthOrderAmount = (res?.monthlySummary?.amount / 10000).toFixed(2) || 0
+      this.marketing.monthOrderAmount = yuanToWan(res?.monthlySummary?.amount)
       console.log('getSaleOrderSummary', res)
     },
     toSaleOrderDetail(type) {

+ 10 - 0
utils/utils.js

@@ -290,4 +290,14 @@ export function uniqueByProperty(arr, property) {
 		}
 	});
 	return Array.from(map.values());
+}
+
+/**
+ * 元转万元,保留两位小数
+ * @param {number} yuan 元
+ * @returns {number} 万元
+ */
+export function yuanToWan(yuan) {
+	if (yuan === null || yuan === undefined || isNaN(yuan)) return 0
+	return +(yuan / 10000).toFixed(2)
 }