Browse Source

Merge branch 'master' of http://114.244.114.158:8802/siwei/real3d-portalsite

maxiaoxiao 10 months ago
parent
commit
39c59391c7

+ 14 - 34
src/views/farmlandProtection/components/fzjcyp.vue

@@ -32,10 +32,7 @@
           <el-table-column width="50">
             <template slot-scope="scope">
               <!-- <span>编辑</span> -->
-              <el-button
-                size="mini"
-                type="text"
-                @click="handleEdit(scope.row)"
+              <el-button size="mini" type="text" @click="handleEdit(scope.row)"
                 >编辑</el-button
               >
             </template>
@@ -47,7 +44,7 @@
       <span class="clearBtn" @click="reset">取消</span>
       <span class="sureBtn" @click="submitData">确定</span>
     </div>
-    <zdyModelPop :tableData="anaModels" ref="zdyPop"></zdyModelPop>
+    <zdyModelPop :tableData="templateYZ" :editData="editData" ref="zdyPop"></zdyModelPop>
   </div>
 </template>
 
@@ -81,24 +78,9 @@ export default {
       },
       //分析模型列表
       anaModels: [
-        {
-          id: 1,
-          name: "耕地监测分析模型",
-        },
-        {
-          id: 2,
-          name: "基本农田保护模型",
-        },
-        {
-          id: 3,
-          name: "生态保护分析模型",
-        },
-        {
-          id: 4,
-          name: "矿产监测分析模型",
-        },
       ],
       templateYZ: [], //用地性质模版因子
+      editData:{},//编辑的对象
     };
   },
   methods: {
@@ -130,8 +112,6 @@ export default {
         },
       ];
       this.templateYZ.forEach((item) => {
-        // let JSONItem = JSON.parse(item.conditionInfo);
-        // item.conditionInfo = JSONItem;
         item.children = [];
       });
       this.anaModels = this.templateYZ;
@@ -155,21 +135,21 @@ export default {
     //自定义模型按钮
     zdyModel() {
       this.$refs.zdyPop.dialogVisible = true;
+      this.editData={}
+      this.$refs.zdyPop.reset()
+      this.$refs.zdyPop.yzTableData = [];
     },
     handleEdit(item) {
+      this.editData = item
       this.$refs.zdyPop.dialogVisible = true;
-      this.$refs.zdyPop.yzTableData = item.gdbhMxYz;
+      this.templateYZ = item.gdbhMxYzRet;
+      this.templateYZ.forEach((item) => {
+        item.children = [];
+      });
+      this.$refs.zdyPop.yzTableData = this.templateYZ;
       this.$refs.zdyPop.fxmxmc = item.bsmmc;
-      // console.log(item, "暂时使用");
-      // item.gdbhMxYz.forEach((item) => {
-      //   // let JSONItem = JSON.parse(item.conditionInfo);
-      //   // item.conditionInfo = JSONItem;
-      //   item.children = [];
-      // });
-      // this.anaModels = item.gdbhMxYz;
-      // this.$refs.zdyPop.yzTableData = item.gdbhMxYz;
-      // // this.zdyModel();
-      
+
+      // this.zdyModel();
     },
     reset() {
       this.ruleForm = {

+ 32 - 31
src/views/farmlandProtection/components/zdyModelPop.vue

@@ -51,6 +51,7 @@
         <el-col :span="11">
           <div class="yztitle">已选数据</div>
           <el-table
+            ref="multipleTable"
             :data="dialogData"
             border
             class="right-table scroll-style"
@@ -60,7 +61,7 @@
           >
             <el-table-column type="selection" width="55" align="center">
             </el-table-column>
-            <el-table-column prop="bsmmc" label="数据名称"> </el-table-column>
+            <el-table-column prop="name" label="数据名称"> </el-table-column>
           </el-table>
         </el-col>
       </el-row>
@@ -80,6 +81,10 @@ export default {
     tableData: {
       type: Array,
     },
+    editData: {
+      //editData用来存储编辑的数据,用bsm判断是否为编辑,全部存储是为了防止以后新增需求
+      type: Object,
+    },
   },
 
   data() {
@@ -112,10 +117,14 @@ export default {
       return data.name.indexOf(value) !== -1;
     },
     reset() {
-      this.dialogData = []; //清空已选数据表单
+      console.log(898888);
+      this.$parent.templateYZ = [];
       this.filterText = ""; //还原分析数据搜索框
       this.fxmxmc = ""; //清空分析模型名称输入框
-      this.getTreeList(); //重新获取分析数据
+      this.yzTableData = [];
+      this.GetFactorList(); //重新获取分析数据
+      this.dialogData = []; //清空已选数据表单
+      console.log(this.dialogData, "到货时间肯定会撒");
     },
     testInput(val) {
       val = Number(val);
@@ -156,11 +165,9 @@ export default {
     setTable(selectdata) {
       let tableList = [];
       selectdata.forEach((item) => {
-        console.log(item, "itemitemitem---");
-        // let JSONItem = JSON.parse(item.conditionInfo);
         tableList.push({
           id: item.id,
-          bsmmc: item.name,
+          name: item.name,
           bsm: item.bsm,
           // conditionInfo: JSONItem,
         });
@@ -236,31 +243,21 @@ export default {
       let saveData = {
         bsm: new Date().getTime(),
         bsmmc: this.fxmxmc,
-        gdbhMxYz: this.dialogData,
+        gdbhMxYzRet: this.dialogData,
       };
-      console.log(saveData, ":this.dialogData");
-      this.$parent.anaModels.push(saveData);
-      this.dialogVisible = false;
-      // var sign = true;
-      // let saveData = [];
-      // this.dialogData.forEach((item) => {
-      //   item.type && item.value == "" && (sign = false);
-      //   issave &&
-      //     saveData.push({
-      //       ...item,
-      //       conditionInfo: JSON.stringify(item.conditionInfo),
-      //     });
-      // });
-      // if (sign) {
-      //   if (issave) {
-      //     this.save(saveData);
-      //   } else {
-      //     this.$parent.tableData = this.dialogData;
-      //     this.dialogVisible = false;
-      //   }
-      // } else {
-      //   this.$message.warning("请将信息补充完整!");
-      // }
+      if (this.editData.bsm) {
+        //判断是否为编辑状态
+        this.$parent.anaModels.forEach((item) => {
+          if (item.bsm == this.editData.bsm) {
+            this.$parent.anaModels[item] = saveData; //替换数据
+          }
+        });
+        this.dialogVisible = false;
+      } else {
+        this.$parent.anaModels.push(saveData);
+        this.dialogVisible = false;
+      }
+      this.$refs.multipleTable.clearSelection();//清空勾选
     },
     setData(data) {
       data.filter((item) => {
@@ -282,11 +279,15 @@ export default {
         : (this.options[1].disabled = false);
     },
     resetDialogData() {
-      if (this.tableData.length == []) {
+      if (!this.tableData.length) {
         // 重置时,树的数据恢复
         this.dialogData = [];
         this.options = JSON.parse(JSON.stringify(this.optionsTemp));
         this.selectdialogData = [];
+      } else {
+        // 选择模板时,生成新的树
+        this.dialogData = JSON.parse(JSON.stringify(this.tableData));
+        this.options = JSON.parse(JSON.stringify(this.optionsTemp));
       }
       this.dialogData.forEach((item) => {
         this.resetTree(this.options, item);