From 51b461fa17fb064b309c677019914d0cb89e1c54 Mon Sep 17 00:00:00 2001
From: xiebin <123456>
Date: Tue, 02 Aug 2022 10:53:09 +0800
Subject: [PATCH] 地块编辑优化

---
 src/views/land/cs.vue         |    7 ++
 src/views/land/LandDetail.vue |   68 ++++++++++++----------
 src/views/land/landUpdate.vue |   52 +++++++++++-----
 3 files changed, 80 insertions(+), 47 deletions(-)

diff --git a/src/views/land/LandDetail.vue b/src/views/land/LandDetail.vue
index eb7f709..6f2ad9a 100644
--- a/src/views/land/LandDetail.vue
+++ b/src/views/land/LandDetail.vue
@@ -2,7 +2,8 @@
     <div class="wraaper-box farming-detail-box">
         <div class="dd">
             <div class="da">
-                <div class="land-img" @click="mod(usePolygons)">
+<!--                <div class="land-img" @click="mod(usePolygons)">-->
+                <div class="land-img">
                     <img :src="url" class="landimg" />
                 </div>
                 <div class="cent">
@@ -43,21 +44,21 @@
             </div>
         </div>
 
-        <el-dialog
-            title="地块位置"
-            class="current-map-box"
-            :visible.sync="gradeBoxVisible1"
-            :modal="true"
-            :modal-append-to-body="true"
-            :append-to-body="true"
-            :close-on-click-modal="false"
-            :close-on-press-escape="false"
-            :before-close="dialogBeforeClose"
-        >
-            <getMapDataInThere ref="getMapData" id="getMapData" @setMapData="setMapData"></getMapDataInThere>
-            <el-button class="save" type="success" @click="upLand()">保存</el-button>
-        </el-dialog>
-        <landUpdate v-if="landVisible" ref="landUpdate" id="landUpdate" @refreshOnLoad="openLandUpdate"></landUpdate>
+<!--        <el-dialog-->
+<!--            title="地块位置"-->
+<!--            class="current-map-box"-->
+<!--            :visible.sync="gradeBoxVisible1"-->
+<!--            :modal="true"-->
+<!--            :modal-append-to-body="true"-->
+<!--            :append-to-body="true"-->
+<!--            :close-on-click-modal="false"-->
+<!--            :close-on-press-escape="false"-->
+<!--            :before-close="dialogBeforeClose"-->
+<!--        >-->
+<!--            <getMapDataInThere ref="getMapData" id="getMapData" @setMapData="setMapData"></getMapDataInThere>-->
+<!--            <el-button class="save" type="success" @click="upLand()">保存</el-button>-->
+<!--        </el-dialog>-->
+        <landUpdate v-if="landVisible" ref="landUpdate" id="landUpdate"></landUpdate>
     </div>
 </template>
 
@@ -125,19 +126,7 @@
         ...mapGetters(["userInfo", "permission", "polygons"]),
     },
     created () {
-        this.url = this.$route.query.url
-        this.landName = this.$route.query.landName
-        this.dic = this.$route.query.dic
-        this.landArea = this.$route.query.landArea
-        this.dica = this.$route.query.dica
-        this.deptname = this.$route.query.deptname
-        this.delId = this.$route.query.id
-        this.landUnit = this.$route.query.landUnit
-        // this.form = res.data.data;
-        this.usePolygons = this.$route.query.landRange
-            .split("POLYGON((")[1]
-            .split("))")[0]
-            .split(",")
+
     },
     methods: {
         //圈地
@@ -221,7 +210,26 @@
             // });
         }
     },
-    watch: {},
+    watch: {
+      '$route.query': {
+        immediate: true,
+        handler(newData, oldData) {
+          this.url = this.$route.query.url
+          this.landName = this.$route.query.landName
+          this.dic = this.$route.query.dic
+          this.landArea = this.$route.query.landArea
+          this.dica = this.$route.query.dica
+          this.deptname = this.$route.query.deptname
+          this.delId = this.$route.query.id
+          this.landUnit = this.$route.query.landUnit
+          // this.form = res.data.data;
+          this.usePolygons = this.$route.query.landRange
+            .split("POLYGON((")[1]
+            .split("))")[0]
+            .split(",")
+        }
+      }
+    },
 }
 </script>
 
diff --git a/src/views/land/cs.vue b/src/views/land/cs.vue
index 715c834..40ee59a 100644
--- a/src/views/land/cs.vue
+++ b/src/views/land/cs.vue
@@ -165,6 +165,13 @@
             this.onLoad(this.page)
         },
         landInfo (item) {
+          var arr = [];
+          this.$store.state.tags.tagList.forEach((item) => {
+            if (item.label != "地块详情") {
+              arr.push(item);
+            }
+          });
+          this.$store.state.tags.tagList = arr;
             this.$router.push({
                 path: `/LandDetail`,
                 query: item,
diff --git a/src/views/land/landUpdate.vue b/src/views/land/landUpdate.vue
index 5ca6701..b42f077 100644
--- a/src/views/land/landUpdate.vue
+++ b/src/views/land/landUpdate.vue
@@ -33,10 +33,12 @@
         return {
             title: "编辑地块",
             form: {},
+            isFarmNameCk:false,
             option: {
                 emptyBtn: false,
                 submitText: "保存",
                 gutter: 30,
+                farmName:'',
                 column: [
                     {
                         label: "地块名称",
@@ -57,6 +59,9 @@
                             value: "id"
                         },
                         slot: true,
+                        click:function (value){
+                            this.isFarmNameCk = true
+                        },
                         rules: [{
                             required: true,
                             message: "请选择所属农场",
@@ -113,11 +118,6 @@
     },
     methods: {
         initData (tenantId) {
-            // getDeptTree(tenantId).then(res => {        console.log(res)
-
-            //   const column = this.findObject(this.option.column, "deptId");
-            //   column.dicData = res.data.data;
-            // });
             const data = {
                 deptId: this.userInfo.dept_id
             }
@@ -132,19 +132,19 @@
             this.$store.commit('clear_polygon')
             //计算当前时间
             this.visible = true
-            console.log('land1111111111111:',this.$route.query)
             this.form.landName = this.$route.query.landName
             this.form.id = this.$route.query.id
             this.form.landArea = this.$route.query.landArea
             this.form.farmId = this.$route.query.farmId
+            this.form.$farmId = this.$route.query.deptname
             this.form.landUnit = this.$route.query.landUnit
             this.form.landType = this.$route.query.landType
             this.form.landRange = this.$route.query.landRange
 
 
-          this.form.landRange = this.form.landRange.replace(/POLYGON\(\(/g, '')
-          this.form.landRange = this.form.landRange.replace(/\)\)/g, '')
-          this.form.landRange = this.form.landRange.split(',')
+            this.form.landRange = this.form.landRange.replace(/POLYGON\(\(/g, '')
+            this.form.landRange = this.form.landRange.replace(/\)\)/g, '')
+            this.form.landRange = this.form.landRange.split(',')
 
         },
         // 表单提交
@@ -173,14 +173,32 @@
             }
 
             update(row).then(() => {
-                  that.$emit("refreshOnLoad")
-                  that.$refs.form.resetFields()
-                  that.visible = false
-                  this.$message({
-                      type: "success",
-                      message: "操作成功!"
-                  })
-                  done()
+                that.$emit("refreshOnLoad")
+                that.$refs.form.validate((vaild,done)=>{
+                    if (vaild) {
+                        that.visible = false
+                        this.$message({
+                          type: "success",
+                          message: "操作成功!"
+                        })
+                      done()
+                      this.form.landRange = this.$route.query.landRange
+                      this.form.dica = row.$landUnit
+                      this.form.dic = row.$landType
+                      this.form.deptname = row.$farmId
+
+                      var arr = [];
+                      this.$store.state.tags.tagList.forEach((item) => {
+                        if (item.label != "地块详情") {
+                          arr.push(item);
+                        }
+                      });
+                      this.$store.state.tags.tagList = arr;
+                      this.$router.replace({  path: `/LandDetail`, query: this.form  });
+                    }
+
+                })
+
               }, error => {
                   loading()
                   window.console.log(error)

--
Gitblit v1.9.3