智慧农业大数据平台
guoshilong
2022-10-18 f8a003267f1e24eb5ed5315ccd467fb3e34f3565
投入品单位处理
3 files modified
45 ■■■■■ changed files
src/utils/public.js 37 ●●●●● patch | view | raw | blame | history
src/views/login/index.vue 2 ●●● patch | view | raw | blame | history
src/views/manage/index.vue 6 ●●●●● patch | view | raw | blame | history
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
}
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({
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++){