From 0a3994b8a4e5d89639a0348f28754fc595d4d0e9 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 17 Oct 2022 17:26:18 +0800
Subject: [PATCH] 相同投入品合并,优化显示

---
 src/utils/public.js        |   44 ++++++++++++++++++++++
 src/views/home/index.vue   |    6 +-
 src/views/login/index.vue  |    3 -
 src/views/manage/index.vue |   23 +++++++++--
 src/utils/dateUtils.js     |   10 ++++-
 5 files changed, 75 insertions(+), 11 deletions(-)

diff --git a/src/utils/dateUtils.js b/src/utils/dateUtils.js
index 44f67e2..66730b4 100644
--- a/src/utils/dateUtils.js
+++ b/src/utils/dateUtils.js
@@ -55,7 +55,13 @@
 function getSpecifyDayDate (day) {
     const timeCount = new Date().getTime() - day * 24 * 60 * 60 * 1000
     const date = new Date(timeCount)
-    return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} 00:00:00`
+    var month = ""
+    if (date.getMonth()+1<10){
+        month = "0"+(date.getMonth()+1)
+    }else {
+        month = date.getMonth() + 1
+    }
+    return `${date.getFullYear()}-${month}-${date.getDate()} 00:00:00`
 }
 
 /**
@@ -66,7 +72,7 @@
     const date = new Date()
     const year = date.getFullYear()
     const month = date.getMonth() + 1
-    const strDate = date.getDate() - 1
+    const strDate = date.getDate()
     return `${year}-${month}-${strDate} 23:59:59`
 }
 
diff --git a/src/utils/public.js b/src/utils/public.js
index dfd16a7..2be0eb7 100644
--- a/src/utils/public.js
+++ b/src/utils/public.js
@@ -7,6 +7,50 @@
     num = num-0
     return (num > 9999) ? (num / 10000).toFixed(2) + 'w' : num.toFixed(0)
 }
+export const getObjType = obj => {
+    var toString = Object.prototype.toString;
+    var map = {
+        '[object Boolean]': 'boolean',
+        '[object Number]': 'number',
+        '[object String]': 'string',
+        '[object Function]': 'function',
+        '[object Array]': 'array',
+        '[object Date]': 'date',
+        '[object RegExp]': 'regExp',
+        '[object Undefined]': 'undefined',
+        '[object Null]': 'null',
+        '[object Object]': 'object'
+    };
+    if (obj instanceof Element) {
+        return 'element';
+    }
+    return map[toString.call(obj)];
+};
+/**
+ * 对象深拷贝
+ */
+export const deepClone = data => {
+    var type = getObjType(data);
+    var obj;
+    if (type === 'array') {
+        obj = [];
+    } else if (type === 'object') {
+        obj = {};
+    } else {
+        //不再具有下一层次
+        return data;
+    }
+    if (type === 'array') {
+        for (var i = 0, len = data.length; i < len; i++) {
+            obj.push(deepClone(data[i]));
+        }
+    } else if (type === 'object') {
+        for (var key in data) {
+            obj[key] = deepClone(data[key]);
+        }
+    }
+    return obj;
+};
 
 export default {
     numUnitConversion
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index 44e037b..bfe662a 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -180,7 +180,7 @@
                             <div class="t-r"></div>
                             <div class="b-l"></div>
                             <div class="b-r"></div>
-                            <div class="title">全年销售总额(元)</div>
+                            <div class="title">全年销售总额(万元)</div>
                             <div class="price">
                                 <div v-for="(item,index) in salaNum" :key="index">
                                     <span>{{item}}</span>
@@ -1720,7 +1720,8 @@
             var params = {}
             params.farmId = this.farmId
             selctSaletZ(Object.assign(params)).then((res) => {
-                that.salaNum = res.data.data[0].num.toString().split('')
+                var num = res.data.data[0].num/10000
+                that.salaNum = num.toString().split('')
             })
         },
         getFarmingCount () {
@@ -1796,7 +1797,6 @@
         },
         setMarketChart (dom) {
             const chartDom = document.getElementById(dom)
-            console.log(chartDom, 456)
             const myChart = this.$echarts.init(chartDom)
             var marketData = this.marketDistrict
             var geoCoordMap = {}
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 5ded017..8900856 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({
@@ -114,7 +114,6 @@
                         if (res.data.access_token) {
                             this.$store.commit('setUser', res.data)
                             auth.setToken(res.data.access_token)
-                            console.log('23232323', res.data)
                             window.localStorage.setItem('userName', res.data.nick_name)//赋值
                             this.$router.push({ path: '/' })
                         } else {
diff --git a/src/views/manage/index.vue b/src/views/manage/index.vue
index ab9ab79..fca13c9 100644
--- a/src/views/manage/index.vue
+++ b/src/views/manage/index.vue
@@ -618,7 +618,7 @@
     farmSelectQuery,
 } from "@/api/farm/farmingrecord"
 
-import publicjs from '@/utils/public'
+import publicjs, { deepClone } from '@/utils/public'
 import dateUtilsJs from '@/utils/dateUtils'
 
 export default {
@@ -698,8 +698,8 @@
             inputNZ_nzname: "",
             inputTRP_nzname: "",
             inputNCP_nzname: "",
-            nsSelectTime: [dateUtilsJs.getSpecifyDayDate(30),dateUtilsJs.getToDay()],
-            nzSelectTime: [dateUtilsJs.getSpecifyDayDate(30),dateUtilsJs.getToDay()]
+            nsSelectTime: [dateUtilsJs.getSpecifyDayDate(30),dateUtilsJs.getDayLast()],
+            nzSelectTime: [dateUtilsJs.getSpecifyDayDate(30),dateUtilsJs.getDayLast()]
         }
     },
     created () {
@@ -1053,7 +1053,21 @@
             const chartDom = document.getElementById(dom)
             const myChart = this.$echarts.init(chartDom)
             myChart.clear()
-            var nztrData = this.nztr
+
+            var temp = deepClone(this.nztr)
+            let idArr = []  //相同id放在同一数组中
+            let resultArr = []  //最终结果数组
+            for(let i = 0;i < temp.length; i++){
+              let index = idArr.indexOf(temp[i].agrname)
+              if(index > -1){  //有相同id存在的话,获取index索引位置
+                resultArr[index].cnum += temp[i].cnum  //cnum
+              }else{
+                idArr.push(temp[i].agrname)
+                resultArr.push(temp[i])
+              }
+            }
+
+            var nztrData = resultArr
             var nztrX = []
             var nztrY = []
             for (let i = 0; i < nztrData.length; i++) {
@@ -1085,6 +1099,7 @@
                     axisLabel: {
                         color: "rgba(255,255,255,.4)",
                         rotate: 0,
+                        interval:0
                     },
                 },
                 yAxis: {

--
Gitblit v1.9.3