From 31b792bb4abe27ae876952f412d4d9ef5b12193d Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 29 Aug 2022 10:47:31 +0800
Subject: [PATCH] 首页秧苗独立显示

---
 src/api/farmplant/farmplant.js |   11 +++++
 src/views/wel/index.vue        |   33 +++++++++++++++-
 src/views/wel/plant.vue        |   57 +++++++++++++++++++++++-----
 src/api/land/land.js           |   10 +++++
 4 files changed, 98 insertions(+), 13 deletions(-)

diff --git a/src/api/farmplant/farmplant.js b/src/api/farmplant/farmplant.js
index e46b041..ebd381c 100644
--- a/src/api/farmplant/farmplant.js
+++ b/src/api/farmplant/farmplant.js
@@ -22,6 +22,17 @@
         }
     })
 }
+export const getStrainCountYM = (current, size, params) => {
+    return request({
+        url: '/api/farmPlant/strainCountYM',
+        method: 'get',
+        params: {
+            ...params,
+            current,
+            size,
+        }
+    })
+}
 export const remove = (ids) => {
     return request({
         url: '/api/farmPlant/remove',
diff --git a/src/api/land/land.js b/src/api/land/land.js
index e5076fd..c316e40 100644
--- a/src/api/land/land.js
+++ b/src/api/land/land.js
@@ -20,6 +20,16 @@
   })
 }
 
+export const getLandListNoPage = (params) => {
+  return request({
+    url: '/api/land/land/getLandList',
+    method: 'get',
+    params: {
+      ...params,
+    }
+  })
+}
+
 export const getDetail = (id) => {
   return request({
     url: '/api/land/land/details',
diff --git a/src/views/wel/index.vue b/src/views/wel/index.vue
index cf012de..1a7e925 100644
--- a/src/views/wel/index.vue
+++ b/src/views/wel/index.vue
@@ -79,6 +79,24 @@
                             <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>
+                        </div>
+                    </div>
                 </div>
             </div>
             <div class="farm-bottom"></div>
@@ -184,7 +202,7 @@
 
 <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"
@@ -219,6 +237,7 @@
             total: 0,
             farmingCount: 0,
             farmPlanList: [],
+            farmPlanListYM:[],
             recoveryVisible: false,
             overVisible:false,
             landVisible: false,
@@ -356,6 +375,14 @@
                     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)
+                })
+            })
         },
         //采收
         recovery (data) {
@@ -402,10 +429,10 @@
             })
         },
         //种植
-        plant () {
+        plant (item) {
             this.plantVisible = true
             this.$nextTick(() => {
-                this.$refs.plant.init()
+                this.$refs.plant.init(item)
             })
         },
         //农事操作
diff --git a/src/views/wel/plant.vue b/src/views/wel/plant.vue
index 0c07615..4bee1b5 100644
--- a/src/views/wel/plant.vue
+++ b/src/views/wel/plant.vue
@@ -15,9 +15,9 @@
 <script>
 
 import { mapState } from "vuex";
-import { getLandList } from "@/api/land/land";
+import { getLandList,getLandListNoPage } from "@/api/land/land";
 import { getStrainList } from "@/api/farmplant/strain";
-import { save } from "@/api/farmplant/farmplant";
+import { save,getList } from "@/api/farmplant/farmplant";
 import { getFarmList } from "../../api/farm/farm";
 export default {
   data() {
@@ -30,7 +30,7 @@
         gutter: 30,
         column: [
           {
-            label: "品种",
+            label: "种类",
             prop: "strainId",
             labelWidth:110,
             type:"tree",
@@ -48,7 +48,7 @@
             ],
           },
           {
-            label: "品种描述",
+            label: "品种",
             prop: "varieties",
             labelWidth:110,
             // rules: [
@@ -170,7 +170,7 @@
               },
             ],
           },
-                    {
+          {
             label: "秧苗来源农场",
             prop: "farmId",
             type: "tree",
@@ -296,9 +296,8 @@
     }),
   },
   watch: {
-  "form.plantingWay": {
+    "form.plantingWay": {
       handler(val) {
-        console.log("plantingWay",val)
         var farmColumn = this.findObject(this.option.column,"farmId")
         var landColumn = this.findObject(this.option.column,"otherLandId")
         if(val != 0 ){
@@ -312,6 +311,19 @@
       },
       immediate: true,
     },
+    "$farmId":{
+      handler(val){
+        this.form.farmId = this.$farmId
+        //获取农地数据
+        getLandList(this.$farmId).then((res)=>{
+            if(res.data.code==200){
+              var landIdcolumn = that.findObject(that.option.column,"landId");
+              that.landList = res.data.data;
+              landIdcolumn.dicData = res.data.data;
+            }
+        })
+      }
+    }
   },
   methods: {
     //计算当前时间
@@ -330,7 +342,7 @@
         //秒 getSeconds():(0 ~ 59)
         var second = date.getSeconds();
         //赋值
-        this.form['time'] = year + '-'
+        this.form['transplanTime'] = year + '-'
                           + this.addZero(month) + '-'
                           + this.addZero(day) + ' '
                           + this.addZero(hour) + ':'
@@ -341,12 +353,37 @@
       return s < 10 ? ('0' + s) : s;
     },
     //初始化
-    init() {
+    init(item) {
+      var that = this;
+      console.log("item",item)
       this.form['operator'] = this.userInfo.user_id;
       //计算当前时间
       this.getNowTime();
+      var strainColumn = that.findObject(that.option.column,"strainId");
+      // var otherLandColumn = that.findObject(that.option.column,"otherLandId");
+      if(item.strainId){
+        that.form.strainId = item.strainId
+        strainColumn.disabled = true
+        var params = {}
+        params['tenantId'] = this.userInfo.tenant_id
+        params['farmId'] = this.$farmId
+        params['strainId'] = item.strainId
+        // params['plantingWay'] = "2"
+        getLandListNoPage(params).then((res)=>{
+          var landArr = []
+          res.data.data.records.forEach(e => {
+            landArr.push({
+              id:e.landId,
+              landName:e.landName
+            })
+          });
+          otherLandColumn.dicData = landArr
+        })
+      }else{
+        strainColumn.disabled = false
+        that.form.farmId = ""
+      }
       this.visible = true;
-      var that = this;
       //获取农地数据
       getLandList(this.$farmId).then((res)=>{
           if(res.data.code==200){

--
Gitblit v1.9.3