From 082613d446e29e4ec1c16bfaa52345106a498b23 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Tue, 08 Nov 2022 09:03:49 +0800
Subject: [PATCH] 农事操作隐藏后四个,地图模式2d改为3d

---
 src/views/wel/index.vue |  132 +++++++++++++++++++++++++++++--------------
 1 files changed, 89 insertions(+), 43 deletions(-)

diff --git a/src/views/wel/index.vue b/src/views/wel/index.vue
index f9d49b9..fac1af1 100644
--- a/src/views/wel/index.vue
+++ b/src/views/wel/index.vue
@@ -37,7 +37,7 @@
                         <div class="land-statis">
                             <div class="land-title">地块总面积</div>
                             <div class="land-num">
-                                <span>{{ landInfo.zarea }}</span>&nbsp;亩
+                                <span>{{  landInfo.zarea }}</span>&nbsp;亩
                             </div>
                         </div>
                         <div class="land-statis">
@@ -53,8 +53,8 @@
                             </div>
                         </div>
                     </div>
-                    <div class="map-view">
-                        <img src="../../../public/img/map.png" />
+                    <div class="map-view" @click="goToMapModel">
+                        <img src="../../../public/img/map.png"  />
                         <div class="title">农场地图→</div>
                     </div>
                 </div>
@@ -74,6 +74,24 @@
                         <div class="btn">
                             <el-button plain size="small" @click="recovery(item)">
                                 <span style="color: #5abf78">采收</span>
+                            </el-button>
+                            <!-- <el-button plain size="small" @click="over(item.id)">结束</el-button> -->
+                            <el-button plain size="small" @click="over(item)">结束</el-button>
+                        </div>
+                    </div>
+                    <!-- 秧苗 -->
+                    <div class="farm" v-for="(item, index) in farmPlanListYM" :key="index">
+                        <div class="farm-img" @click="recoveryDetail(item)">
+                            <img :src="item.url" class="img" />
+                        </div>
+                        <div class="cai">{{ item.strainName }}(秧苗)</div>
+                        <div class="area">
+                            种植面积:
+                            <span>{{ item.area }}</span>亩
+                        </div>
+                        <div class="btn">
+                            <el-button plain size="small" @click="plant(item)">
+                                <span style="color: #5abf78">移栽</span>
                             </el-button>
                             <!-- <el-button plain size="small" @click="over(item.id)">结束</el-button> -->
                             <el-button plain size="small" @click="over(item)">结束</el-button>
@@ -170,21 +188,21 @@
         <!-- 弹窗, 采收 -->
         <recovery v-if="recoveryVisible" ref="recovery" :farmDetail="farm"></recovery>
         <!-- 弹窗,结束种养-->
-        <over v-if="overVisible" ref="over"></over>
+        <over v-if="overVisible" ref="over" @refreshOnLoad="refreshAll"></over>
         <!-- 圈地 -->
-        <land v-if="landVisible" ref="land"></land>
+        <land v-if="landVisible" ref="land" @refreshOnLoad="refreshAll"></land>
         <!-- 种养品 -->
-        <plant v-if="plantVisible" ref="plant" @refreshOnLoad="onLoad"></plant>
+        <plant v-if="plantVisible" ref="plant" @refreshOnLoad="refreshAll"></plant>
         <!-- 农事操作 -->
-        <farming v-if="farmingVisible" ref="farming"></farming>
+        <farming v-if="farmingVisible" ref="farming" @refreshOnLoad="refreshAll"></farming>
         <!-- 农资入库 -->
-        <stock v-if="stockVisible" ref="stock"></stock>
+        <stock v-if="stockVisible" ref="stock" @refreshOnLoad="refreshAll"></stock>
     </div>
 </template>
 
 <script>
 import { mapGetters } from "vuex"
-import { getList, update,getStrainCount } from "@/api/farmplant/farmplant"
+import { getList, update,getStrainCount,getStrainCountYM } from "@/api/farmplant/farmplant"
 import { getFarmingCount, getFarmingStatis } from "@/api/farm/farmingrecord"
 import { selectCount } from "@/api/land/land"
 import { StockCount } from "@/api/stock/stock"
@@ -195,6 +213,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,
@@ -210,6 +229,7 @@
             farmingList: [],
             stockList: [],
             isFarmingDetail: false,
+            isStockDetail: false,
             landInfo: {},
             farm:{},
             farmList:[],
@@ -217,6 +237,7 @@
             total: 0,
             farmingCount: 0,
             farmPlanList: [],
+            farmPlanListYM:[],
             recoveryVisible: false,
             overVisible:false,
             landVisible: false,
@@ -233,6 +254,17 @@
         ...mapGetters(["userInfo","$farmId"]),
     },
   created () {
+
+        this.$EventBus.$on('getFarmObj', (farmObj)=>{
+            // this.$nextTick(() => {
+            //     this.$EventBus.$emit("setFarmId", farmObj.id);
+            // });
+            setTimeout(() => {
+                this.$EventBus.$emit("setFarmId", farmObj.id);
+            }, 100);
+        })
+
+
         //初始化农场信息
         // let farmId = this.userInfo.$farmId
         this.farm.id = this.$farmId
@@ -246,12 +278,15 @@
         //本年农事操作记录,分组
         this.getFarmingStatis()
         this.StockCount()
+
     },
   watch: {
     '$farmId':{
       handler (newName, oldName) {
         this.farm.id = newName
-          //农场概览 地块使用率
+
+        setTimeout(() => {
+        //农场概览 地块使用率
         this.getCountStatis ()
         //本年农事操作记录
         this.getFarmingCount()
@@ -260,6 +295,8 @@
         this.StockCount()
         //当前农场种养品种
         this.onLoad()
+        }, 100);
+
       }
     }
   },
@@ -272,6 +309,16 @@
           getFarmList(data).then(res => {
             this.farmList = this.farmList.concat(res.data.data)
           });
+        },
+        refreshAll(){
+            this.getCountStatis ()
+            //本年农事操作记录
+            this.getFarmingCount()
+            //本年农事操作记录,分组
+            this.getFarmingStatis()
+            this.StockCount()
+            //当前农场种养品种
+            this.onLoad()
         },
         //农场下拉框change事件
         farmChange(data) {
@@ -309,8 +356,12 @@
         StockCount () {
             var that = this
             StockCount(this.$farmId).then((res) => {
-                that.stockList = res.data.data
-                console.log(that.stockList)
+                that.stockList = res.data.data.filter((e)=>{
+                    return e.val != 0
+                })
+                that.stockList.forEach((e)=>{
+                    e.val = fixed.fixedNum(e.val)
+                })
             })
         },
         //地块使用率统计
@@ -319,6 +370,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) {
@@ -331,9 +384,20 @@
             }
             params['tenantId'] = this.userInfo.tenant_id
             params['farmId'] = this.farm.id
-            getStrainCount(1, 10, Object.assign(params)).then((res) => {
-                const data = res.data.data
-                this.farmPlanList = data.records
+            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)
+                })
+            })
+
+            getStrainCountYM(1, 100, Object.assign(params)).then((res) => {
+                const data = res.data.data.records
+                this.farmPlanListYM = data
+                this.farmPlanListYM.forEach((e)=>{
+                    e.area = fixed.fixedNum(e.area)
+                })
             })
         },
         //采收
@@ -350,30 +414,6 @@
                 this.$refs.over.initData(data,this.farm.id)
             })
         },
-        //结束种植
-        // over (id) {
-        //     var that = this
-        //     this.$confirm("确定结束当前种植的农产品?", {
-        //         confirmButtonText: "确定",
-        //         cancelButtonText: "取消",
-        //         type: "warning",
-        //     })
-        //         .then(() => {
-        //             const data = {
-        //                 id: id,
-        //                 status: 2,
-        //             }
-        //             return update(data)
-        //         })
-        //         .then(() => {
-        //             that.onLoad()
-        //             this.$message({
-        //                 type: "success",
-        //                 message: "操作成功!",
-        //             })
-        //         })
-        // },
-        //圈地
         land () {
             this.landVisible = true
             this.$nextTick(() => {
@@ -381,10 +421,10 @@
             })
         },
         //种植
-        plant () {
+        plant (item) {
             this.plantVisible = true
             this.$nextTick(() => {
-                this.$refs.plant.init()
+                this.$refs.plant.init(item)
             })
         },
         //农事操作
@@ -418,7 +458,6 @@
         },
         //本年农事操作明细--有参
         farmPlantDetails (item) {
-            console.log(item, 11111)
             const data = {
                 type: item.value,
                 activeName: "tab2",
@@ -464,6 +503,13 @@
                 query: data,
             })
         },
+        //进入地图模式
+        goToMapModel () {
+            this.$router.push({
+                path: `/mapPattern`,
+                // query: row,
+            })
+        }
     },
 };
 </script>
@@ -532,7 +578,7 @@
 
                     .land-statis {
                         width: 33%;
-                        margin: 3% 8%;
+                        margin: 3% 3%;
 
                         .land-num {
                             margin-top: 20px;

--
Gitblit v1.9.3