From 9e55ae937f182660b9cadffc8607ed050ba88888 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Fri, 26 Aug 2022 11:07:24 +0800
Subject: [PATCH] 数字转换变更为js方法转换
---
src/views/wel/index.vue | 22 +++++++---
src/views/farmplant/process.vue | 8 +++-
src/views/land/cs.vue | 6 ++
src/views/farmplant/farmproductstock.vue | 6 ++
src/views/stock/stockmanage.vue | 9 +++-
src/util/mathHandler.js | 12 ++++++
src/views/stock/stockout.vue | 5 ++
7 files changed, 55 insertions(+), 13 deletions(-)
diff --git a/src/util/mathHandler.js b/src/util/mathHandler.js
new file mode 100644
index 0000000..ed733a9
--- /dev/null
+++ b/src/util/mathHandler.js
@@ -0,0 +1,12 @@
+/**
+ * 单位转换,如果大于10000 按1.0W显示
+ * @param num 需要转化的值
+ * @returns {*} 转化过的值
+ */
+function fixedNum (num) {
+ return (num > 9999) ? (num / 10000).toFixed(2) + '万' : num
+}
+
+export default {
+ fixedNum
+}
\ No newline at end of file
diff --git a/src/views/farmplant/farmproductstock.vue b/src/views/farmplant/farmproductstock.vue
index cb7ffa6..046a01f 100644
--- a/src/views/farmplant/farmproductstock.vue
+++ b/src/views/farmplant/farmproductstock.vue
@@ -40,7 +40,7 @@
<div class="cai">{{ item.strainName }}</div>
<div class="area">
库存量:
- <span>{{ item.weight>10000?(item.weight/10000).toFixed(2)+"万":item.weight }}</span>公斤
+ <span>{{ item.weight }}</span>公斤
</div>
<div class="btn">
<el-button
@@ -346,6 +346,7 @@
import { mapGetters } from "vuex"
import { regionData } from 'element-china-area-data'
import { click } from 'ol/events/condition'
+import fixed from "@/util/mathHandler"
export default {
data () {
@@ -1204,6 +1205,9 @@
this.data = data.records.filter((e)=>{
return e.weight !=0
})
+ this.data.forEach((e)=>{
+ e.weight = fixed.fixedNum(e.weight)
+ })
this.loading = false
// this.selectionClear()
})
diff --git a/src/views/farmplant/process.vue b/src/views/farmplant/process.vue
index 892c734..3b9e261 100644
--- a/src/views/farmplant/process.vue
+++ b/src/views/farmplant/process.vue
@@ -28,7 +28,7 @@
<div class="cai">{{ item.processName }}</div>
<div class="area">
库存量:
- <span>{{ item.productInventoryNum>10000?(item.productInventoryNum/10000).toFixed(2)+"万":item.productInventoryNum }}</span>公斤
+ <span>{{ item.productInventoryNum }}</span>公斤
</div>
<div class="area">
原材料:
@@ -265,6 +265,7 @@
} from "@/api/process/process"
import { mapGetters } from "vuex"
import { regionData } from 'element-china-area-data'
+import fixed from "@/util/mathHandler"
export default {
data () {
@@ -954,8 +955,11 @@
this.data = data.records.filter((e)=>{
return e.productInventoryNum != 0
})
+ this.data.forEach((e)=>{
+ e.productInventoryNum = fixed.fixedNum(e.productInventoryNum)
+ })
this.loading = false
- this.selectionClear()
+ // this.selectionClear()
})
},
},
diff --git a/src/views/land/cs.vue b/src/views/land/cs.vue
index 8027a65..abd1538 100644
--- a/src/views/land/cs.vue
+++ b/src/views/land/cs.vue
@@ -80,7 +80,7 @@
<div class="text">
<div class="land-name">{{ item.landName }}</div>
<div class="land-area">
- <div class="box">{{ item.landArea>10000?(item.landArea/10000).toFixed(2)+"万":item.landArea}} {{ item.dica }}</div>
+ <div class="box">{{ item.landArea}} {{ item.dica }}</div>
</div>
</div>
</div>
@@ -93,6 +93,7 @@
import { mapGetters } from "vuex"
import { getList } from "@/api/land/land"
import landAdd from "./landAdd"
+import fixed from "@/util/mathHandler"
export default {
components: {
landAdd,
@@ -201,6 +202,9 @@
const data = res.data.data
this.page.total = data.total
this.farmPlanList = data.records
+ this.farmPlanList.forEach((e)=>{
+ e.landArea = fixed.fixedNum(e.landArea)
+ })
})
},
//进入地图模式
diff --git a/src/views/stock/stockmanage.vue b/src/views/stock/stockmanage.vue
index 1e65c20..d71c359 100644
--- a/src/views/stock/stockmanage.vue
+++ b/src/views/stock/stockmanage.vue
@@ -76,8 +76,8 @@
</div>
<div class="right">
<div class="spec">
- <span class="num">{{ item.amount>10000?(item.amount/10000).toFixed(2)+"万":item.amount }}</span
- >{{ item.dic2 }}<span class="num1"> (共{{ item.cnum>10000?(item.cnum/10000).toFixed(2)+"万":item.cnum }}{{ item.dic1 }})</span>
+ <span class="num">{{ item.amount }}</span
+ >{{ item.dic2 }}<span class="num1"> (共{{ item.cnum }}{{ item.dic1 }})</span>
</div>
<div class="btn">
<div class="in" @click="modifiedGrades(item)">
@@ -182,6 +182,7 @@
import {getList, getDetail, add, update, remove} from "@/api/stock/stock";
import {add1} from "@/api/stockrecord/stockrecord";
import {mapGetters} from "vuex";
+import fixed from "@/util/mathHandler"
export default {
data() {
@@ -1023,6 +1024,10 @@
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
+ this.data.forEach((e)=>{
+ e.amount = fixed.fixedNum(e.amount)
+ e.cnum = fixed.fixedNum(e.cnum)
+ })
this.loading = false;
// this.selectionClear();
});
diff --git a/src/views/stock/stockout.vue b/src/views/stock/stockout.vue
index b87ed52..b784236 100644
--- a/src/views/stock/stockout.vue
+++ b/src/views/stock/stockout.vue
@@ -104,6 +104,7 @@
<script>
import {getList, getDetail, add, update, remove,Updateout} from "@/api/soldr/soldr";
import {mapGetters} from "vuex";
+import fixed from "@/util/mathHandler"
export default {
data() {
@@ -436,6 +437,10 @@
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
+ this.data.forEach((e)=>{
+ e.amount1 = fixed.fixedNum(e.cnum)
+ e.cnum = fixed.fixedNum(e.cnum)
+ })
this.loading = false;
// this.selectionClear();
});
diff --git a/src/views/wel/index.vue b/src/views/wel/index.vue
index c56ecd2..cf012de 100644
--- a/src/views/wel/index.vue
+++ b/src/views/wel/index.vue
@@ -37,13 +37,13 @@
<div class="land-statis">
<div class="land-title">地块总面积</div>
<div class="land-num">
- <span>{{ landInfo.zarea>10000?(landInfo.zarea/10000).toFixed(2)+"万":landInfo.zarea }}</span> 亩
+ <span>{{ landInfo.zarea }}</span> 亩
</div>
</div>
<div class="land-statis">
<div class="land-title">当前种养面积</div>
<div class="land-num">
- <span>{{ landInfo.sarea>10000?(landInfo.sarea/10000).toFixed(2)+"万":landInfo.sarea }}</span> 亩
+ <span>{{ landInfo.sarea }}</span> 亩
</div>
</div>
<div class="land-statis">
@@ -69,7 +69,7 @@
<div class="cai">{{ item.strainName }}</div>
<div class="area">
种植面积:
- <span>{{ item.area>10000?(item.area/10000).toFixed(2)+"万":item.area }}</span>亩
+ <span>{{ item.area }}</span>亩
</div>
<div class="btn">
<el-button plain size="small" @click="recovery(item)">
@@ -161,7 +161,7 @@
<div class="detail-title">{{ item.name}}</div>
<div class="detail-number">
剩余库存
- <span>{{ item.val>10000?(item.val/10000).toFixed(2)+"万":item.val}}</span>公斤
+ <span>{{ item.val}}</span>公斤
</div>
</div>
</div>
@@ -195,6 +195,7 @@
import plant from "./plant.vue"
import farming from "./farming.vue"
import stock from "./stock.vue"
+import fixed from "@/util/mathHandler"
export default {
components: {
recovery,
@@ -320,8 +321,11 @@
StockCount () {
var that = this
StockCount(this.$farmId).then((res) => {
- that.stockList = res.data.data.filter((e)=>{
+ that.stockList = res.data.data.filter((e)=>{
return e.val != 0
+ })
+ that.stockList.forEach((e)=>{
+ e.val = fixed.fixedNum(e.val)
})
})
},
@@ -331,6 +335,8 @@
selectCount(this.farm.id).then((res) => {
var data = res.data.data
that.landInfo = data
+ that.landInfo.zarea = fixed.fixedNum(that.landInfo.zarea)
+ that.landInfo.sarea = fixed.fixedNum(that.landInfo.sarea)
})
},
handleChange (val) {
@@ -343,9 +349,12 @@
}
params['tenantId'] = this.userInfo.tenant_id
params['farmId'] = this.farm.id
- getStrainCount(1, 10, Object.assign(params)).then((res) => {
+ getStrainCount(1, 100, Object.assign(params)).then((res) => {
const data = res.data.data.records
this.farmPlanList = data
+ this.farmPlanList.forEach((e)=>{
+ e.area = fixed.fixedNum(e.area)
+ })
})
},
//采收
@@ -430,7 +439,6 @@
},
//本年农事操作明细--有参
farmPlantDetails (item) {
- console.log(item, 11111)
const data = {
type: item.value,
activeName: "tab2",
--
Gitblit v1.9.3