xsh 3 years ago
parent
commit
b855be84e9

+ 5 - 1
src/components/sideMenu.vue

@@ -6,7 +6,7 @@
       :unique-opened="true"
       @select="onSelect">
       <template v-for="item in menuItem">
-        <el-submenu v-show="navIndex === item.parentId" :key="item.id" :index="item.id">
+        <el-submenu v-show="selected === item.parentId" :key="item.id" :index="item.id">
           <template slot="title">
             <span>{{item.name}}</span>
           </template>
@@ -17,6 +17,7 @@
   </div>
 </template>
 <script>
+import {mapState} from 'vuex';
 export default {
   name: "sideMenu",
   props: ['navIndex', 'defaultUrl', 'menuItem'],
@@ -24,6 +25,9 @@ export default {
     return {
     }
   },
+  computed: {
+    ...mapState(['selected'])
+  },
   methods: {
     onSelect(index) {
       this.$router.push(index);

+ 5 - 1
src/store/index.js

@@ -5,9 +5,13 @@ Vue.use(Vuex)
 
 export default new Vuex.Store({
   state: {
-    baseUrl: 'http://122.112.224.199:9000'
+    baseUrl: 'http://122.112.224.199:9000',
+    selected: 1,
   },
   mutations: {
+    updateSelected(state, num) {
+      state.selected = num;
+    }
   },
   actions: {
   },

+ 9 - 4
src/views/MainLayout.vue

@@ -7,14 +7,14 @@
           <div class="menu-item">
             <div class="item_box" v-for="item in menuList" :key="item.id" @click="jump(item.id)">
               <img :src="item.img" alt="" style="height: 50px">
-              <div :class="['line', navIndex === item.id ? 'active' : '']">{{item.name}}</div>
+              <div :class="['line', selected === item.id ? 'active' : '']">{{item.name}}</div>
             </div>
           </div>
         </div>
       </el-header>
       <el-container style="height: calc(100vh - 170px); margin-top: 10px">
         <el-aside width="215px">
-          <sideMenu :navIndex="navIndex" :defaultUrl="defaultUrl" :menuItem="menuItem"></sideMenu>
+          <sideMenu :navIndex="selected" :defaultUrl="defaultUrl" :menuItem="menuItem"></sideMenu>
         </el-aside>
         <el-main>
           <div class="header_title">{{title}}</div>
@@ -29,6 +29,7 @@
 
 <script>
 import sideMenu from "../components/sideMenu";
+import {mapState, mapMutations} from 'vuex';
 export default {
   name: "MainLayout",
   components: {
@@ -101,19 +102,22 @@ export default {
           ]
         }
       ],
-      navIndex: 1,
       title: '',
       defaultUrl: '',
     }
   },
+  computed: {
+    ...mapState(['selected'])
+  },
   watch: {
     $route(newVal) {
       this.title = newVal.meta.title;
     }
   },
   methods: {
+    ...mapMutations(['updateSelected']),
     jump(id){
-      this.navIndex = id;
+      this.updateSelected(id);
       this.$router.push(this.menuItem[id - 1].children[0].url);
       this.defaultUrl = this.menuItem[id - 1].children[0].url;
     }
@@ -121,6 +125,7 @@ export default {
   mounted() {
     console.log(this.$route);
     this.title = this.$route.meta.title;
+    this.defaultUrl = this.$route.path;
     if(this.$route.meta.defaultUrl) {
       this.defaultUrl = this.$route.path;
       this.navIndex = this.$route.meta.id;

+ 18 - 1
src/views/collectData/collectData.vue

@@ -187,6 +187,7 @@ import lineChart from './charts/lineChart.vue'
 import hisChart from './charts/hisChart.vue'
 import areaZz from '../../components/areaZz.vue'
 import TableFooter from "../../components/TableFooter"
+import {mapState, mapMutations} from 'vuex';
 export default {
   name: "collectData",
   data () {
@@ -233,12 +234,19 @@ export default {
         bearPigMin: '', // 能繁母猪
         bearPigMax: ''
       },
-      tableData: [],
+      tableData: [
+        {
+          name: '测试牧场'
+        }
+      ],
       totalPages: 0,
       pageNum: 1,
       pageSize: 20
     }
   },
+  computed: {
+    ...mapState(['selected'])
+  },
   components: {
     lineChart,
     hisChart,
@@ -246,6 +254,7 @@ export default {
     TableFooter
   },
   methods: {
+    ...mapMutations(['updateSelected']),
     /* 年月日选择 */
     scopeDay (val) {
       this.daySelected = val
@@ -375,6 +384,14 @@ export default {
         }
       })
     },
+    // 跳转
+    onSelect() {
+      this.updateSelected(1);
+      this.$router.push({
+        path: '/',
+        query: {farmCode: 'N0003', type: 4}
+      })
+    }
   },
   mounted() {
     this.initEchart();

+ 13 - 4
src/views/pastureData/Home.vue

@@ -1,13 +1,13 @@
 <template>
   <div>
-    <!-- 省级  -->
-    <proinvce v-if="isProvince" @getCountyCode="getCountyCode"></proinvce>
     <!-- 市级   -->
-    <city v-if="!isProvince && type === 1" :cityCode="cityCode" @getCountyCode="getCountyCode"></city>
+    <city v-if="!isProvince && type === 1" :cityCode="cityCode" @goFarm="goFarm" @getCountyCode="getCountyCode"></city>
     <!-- 区级   -->
     <district v-if="!isProvince && type === 2" :distCode="distCode" @goFarm="goFarm"></district>
     <!-- 牧场级   -->
     <farm v-if="!isProvince && type === 4" :farmCode="farmCode"></farm>
+    <!-- 省级  -->
+    <proinvce v-if="isProvince" @getCountyCode="getCountyCode"></proinvce>
   </div>
 </template>
 
@@ -49,7 +49,6 @@ export default {
       this.type = data.type;
       this.typeList.push(this.type);
       this.isProvince = false;
-      console.log(data);
       if(data.type === 1) {
         this.cityCode = data.countyCode;
       } else if(data.type === 2){
@@ -62,6 +61,16 @@ export default {
       this.typeList.push(this.type);
       this.farmCode = data.farmCode;
     }
+  },
+  created() {
+    let farmCode = this.$route.query.farmCode;
+    let type = this.$route.query.type;
+    if(farmCode) {
+      this.farmCode = farmCode;
+      this.type = Number(type);
+      this.isProvince = false;
+      console.log(this.type);
+    }
   }
 }
 </script>

+ 12 - 8
src/views/pastureData/dataDetail.vue

@@ -11,7 +11,8 @@
         <div></div>
         <div></div>
         <div>首次上传时间(配标时间)</div>
-        <div>{{tableData.movePigPenData[2].moveDate}}</div>
+        <div v-if="tableData.movePigPenData">{{tableData.movePigPenData[2].moveDate}}</div>
+        <div v-else></div>
         <div>本次采集时间</div>
         <div>{{tableData.eartagdeta.time}}</div>
         <div>配标日龄</div>
@@ -27,23 +28,26 @@
         <div>耳标电量</div>
         <div>{{tableData.eartagdeta.bat}}%</div>
         <div>首次位置记录</div>
-        <div>
+        <div v-if="tableData.movePigPenData">
           <div style="line-height: 14px; font-size: 14px;">时间: {{tableData.movePigPenData[2].moveDate}}</div>
           <div style="line-height: 14px; font-size: 14px;">阶段:{{getStage(tableData.movePigPenData[2].stage)}}</div>
           <div style="line-height: 14px; font-size: 14px;">{{tableData.movePigPenData[2].penName}}{{tableData.movePigPenData[2].unitname}}</div>
         </div>
+        <div v-else></div>
         <div>上一次位置记录</div>
-        <div>
+        <div v-if="tableData.movePigPenData">
           <div style="line-height: 14px; font-size: 14px;">时间: {{tableData.movePigPenData[1].moveDate}}</div>
           <div style="line-height: 14px; font-size: 14px;">阶段:{{getStage(tableData.movePigPenData[1].stage)}}</div>
           <div style="line-height: 14px; font-size: 14px;">{{tableData.movePigPenData[1].penName}}{{tableData.movePigPenData[1].unitname}}</div>
         </div>
+        <div v-else></div>
         <div>当前位置位置</div>
-        <div>
+        <div v-if="tableData.movePigPenData">
           <div style="line-height: 14px; font-size: 14px;">时间: {{tableData.movePigPenData[0].moveDate}}</div>
           <div style="line-height: 14px; font-size: 14px;">阶段:{{getStage(tableData.movePigPenData[0].stage)}}</div>
           <div style="line-height: 14px; font-size: 14px;">位置:{{tableData.movePigPenData[0].penName}}{{tableData.movePigPenData[0].unitname}}</div>
         </div>
+        <div v-else></div>
         <div>信号强度</div>
         <div>-{{tableData.eartagdeta.rssi}}db(最后一次上传)</div>
       </div>
@@ -225,9 +229,9 @@ export default {
         endTime: this.value2[1]
       }
       this.$http({
-        url: this.$http.adornUrl('/manager/eartagdata/list_deatils'),
-        method: 'post',
-        data: this.$http.adornData(params)
+        url: this.$http.adornUrl('http://192.168.1.171:8210/manager/eartagdata/list_deatils'),
+        method: 'get',
+        params: this.$http.adornParams(params)
       })
           .then(res => {
             this.loading = false;
@@ -253,7 +257,7 @@ export default {
           })
     },
     jump() {
-      this.$router.replace('/');
+      this.$router.replace('/dayData');
     },
     onSelect() {
       // console.log(this.value2)

+ 0 - 1
src/views/pastureData/hand.vue

@@ -194,7 +194,6 @@ export default {
           let stock3 = arr5.reverse()
           this.mzclList = [time, stock1, stock2, stock3];
           this.mzxzList = [time, stockNew, offlineNo];
-          console.log(stockNew);
         } else {
           this.mzclList = [];
         }

+ 6 - 2
src/views/pastureData/homeComponent/city.vue

@@ -264,7 +264,11 @@ export default {
       this.countyCode = row.code;
       this.type = row.type;
       console.log(row);
-      this.$emit('getCountyCode', {countyCode: this.countyCode, type: this.type});
+      if(row.type === 4) {
+        this.$emit('goFarm', {farmCode: row.farmCode, type: 4});
+      } else {
+        this.$emit('getCountyCode', {countyCode: this.countyCode, type: this.type});
+      }
       // if (row.type === 1) {
       //   this.initCity();
       // } else if (row.type === 2) {
@@ -274,7 +278,7 @@ export default {
     // 统计
     initState() {
       this.$http({
-        url: this.$http.adornUrl('http://192.168.1.165:9000/manager/dailytabulatedata/countAllsow'),
+        url: this.$http.adornUrl('http://122.112.224.199:9000/manager/dailytabulatedata/countAllsow'),
         method: 'get',
         params: this.$http.adornParams({countyCode: this.cityCode})
       })

+ 1 - 1
src/views/pastureData/homeComponent/district.vue

@@ -249,7 +249,7 @@ export default {
     // 统计
     initState() {
       this.$http({
-        url: this.$http.adornUrl('http://192.168.1.165:9000/manager/dailytabulatedata/countAllsow'),
+        url: this.$http.adornUrl('http://122.112.224.199:9000/manager/dailytabulatedata/countAllsow'),
         method: 'get',
         params: this.$http.adornParams({countyCode: this.distCode})
       })

+ 8 - 2
src/views/pastureData/homeComponent/farm.vue

@@ -80,8 +80,10 @@
             height="700"
             style="width: 100%;">
           <el-table-column
-              prop="statisticDate"
               label="时间">
+            <template slot-scope="scope">
+              <span>{{scope.row.statisticDate.split(' ')[0]}}</span>
+            </template>
           </el-table-column>
           <el-table-column
               prop="stockTotal"
@@ -155,6 +157,7 @@
 
 <script>
 import TableFooter from "../../../components/TableFooter";
+import utils from '../../../utils/index';
 import {mapState} from "vuex";
 export default {
   name: "farm",
@@ -212,6 +215,9 @@ export default {
     ...mapState(['baseUrl'])
   },
   methods: {
+    getDate(val) {
+      return utils.timeDate(val);
+    },
     getCityCode(val) {
       let len = val.length;
       this.countyCode = val[len - 1];
@@ -292,7 +298,7 @@ export default {
     // 统计
     initState() {
       this.$http({
-        url: this.$http.adornUrl('http://192.168.1.165:9000/manager/dailytabulatedata/countAllsow'),
+        url: this.$http.adornUrl('http://122.112.224.199:9000/manager/dailytabulatedata/countAllsow'),
         method: 'get',
         params: this.$http.adornParams({farmCode: this.farmCode})
       })

+ 3 - 1
src/views/pastureData/homeComponent/proinvce.vue

@@ -209,10 +209,12 @@ export default {
     // 修改size
     sizeChange(val) {
       this.pageSize = val;
+      this.init();
     },
     // 修改页数
     pageChange(val) {
       this.pageNum = val;
+      this.init();
     },
     search() {
       this.init();
@@ -267,7 +269,7 @@ export default {
     // 统计
     initState() {
       this.$http({
-        url: this.$http.adornUrl('http://192.168.1.165:9000/manager/dailytabulatedata/countAllsow'),
+        url: this.$http.adornUrl('http://122.112.224.199:9000/manager/dailytabulatedata/countAllsow'),
         method: 'get',
         params: this.$http.adornParams({countyCode: this.countyCode})
       })