From f8a003267f1e24eb5ed5315ccd467fb3e34f3565 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Tue, 18 Oct 2022 08:55:31 +0800
Subject: [PATCH] 投入品单位处理
---
src/utils/public.js | 37 +++++++++++++++++++++++++++++++++++++
src/views/login/index.vue | 2 +-
src/views/manage/index.vue | 6 ++++--
3 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/src/utils/public.js b/src/utils/public.js
index 2be0eb7..d6be573 100644
--- a/src/utils/public.js
+++ b/src/utils/public.js
@@ -52,6 +52,43 @@
return obj;
};
+/**
+ * 转换为公斤
+ * @param num 总量
+ * @param specsValue1 单位
+ * @returns {number} 转换后的公斤数
+ */
+export const unitConversion = (num,specsValue1)=>{
+ var value = 0
+ //克
+ if (specsValue1 == 0) {
+ value = num * 0.001;
+ }
+ //斤
+ else if (specsValue1 == 1) {
+ value = num * 0.5;
+ }
+ //公斤
+ else if (specsValue1 == 2) {
+ value = num ;
+ }
+ //吨
+ else if (specsValue1 == 3) {
+ value = num * 1000;
+ }
+ //毫升
+ else if (specsValue1 == 4) {
+ //毫升换成升
+ var s = num * 0.001;
+ //升换成公斤
+ value = s;
+ }
+ //升
+ else if (specsValue1 == 5) {
+ value = num;
+ }
+ return value
+}
export default {
numUnitConversion
}
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 8900856..9f5fd09 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -77,7 +77,7 @@
},
created () {
//跳转到统一登录页
- // window.location.replace('http://dev.jxpskj.com:8020/ncny/login.html')
+ window.location.replace('http://dev.jxpskj.com:8020/ncny/login.html')
var that = this
this.newAxios = axios.create({
diff --git a/src/views/manage/index.vue b/src/views/manage/index.vue
index fca13c9..89877a5 100644
--- a/src/views/manage/index.vue
+++ b/src/views/manage/index.vue
@@ -618,7 +618,7 @@
farmSelectQuery,
} from "@/api/farm/farmingrecord"
-import publicjs, { deepClone } from '@/utils/public'
+import publicjs, { deepClone, unitConversion } from '@/utils/public'
import dateUtilsJs from '@/utils/dateUtils'
export default {
@@ -1053,8 +1053,10 @@
const chartDom = document.getElementById(dom)
const myChart = this.$echarts.init(chartDom)
myChart.clear()
-
var temp = deepClone(this.nztr)
+ temp.forEach(e=>{
+ e.cnum = unitConversion(e.cnum,e.specsValue1)
+ })
let idArr = [] //相同id放在同一数组中
let resultArr = [] //最终结果数组
for(let i = 0;i < temp.length; i++){
--
Gitblit v1.9.3