소스 검색

自定义模型数据交互

lkk 10 달 전
부모
커밋
17e36c7734
2개의 변경된 파일100개의 추가작업 그리고 97개의 파일을 삭제
  1. 17 6
      src/views/farmlandProtection/components/fzjcyp.vue
  2. 83 91
      src/views/farmlandProtection/components/zdyModelPop.vue

+ 17 - 6
src/views/farmlandProtection/components/fzjcyp.vue

@@ -27,7 +27,7 @@
       <div class="treeDiv">
         <el-table :data="anaModels" style="width: 100%" :show-header="false">
           <el-table-column type="selection" width="33"> </el-table-column>
-          <el-table-column prop="name" show-overflow-tooltip>
+          <el-table-column prop="bsmmc" show-overflow-tooltip>
           </el-table-column>
           <el-table-column width="50">
             <template slot-scope="scope">
@@ -35,7 +35,7 @@
               <el-button
                 size="mini"
                 type="text"
-                @click="handleEdit(scope.$index, scope.row)"
+                @click="handleEdit(scope.row)"
                 >编辑</el-button
               >
             </template>
@@ -157,8 +157,19 @@ export default {
       this.$refs.zdyPop.dialogVisible = true;
     },
     handleEdit(item) {
-      console.log(item, "暂时使用");
-      this.zdyModel();
+      this.$refs.zdyPop.dialogVisible = true;
+      this.$refs.zdyPop.yzTableData = item.gdbhMxYz;
+      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();
+      
     },
     reset() {
       this.ruleForm = {
@@ -226,8 +237,8 @@ export default {
     },
   },
   mounted() {
-    // this.GetMxList();
-    this.testInit()
+    this.GetMxList();
+    // this.testInit()
   },
 };
 </script>

+ 83 - 91
src/views/farmlandProtection/components/zdyModelPop.vue

@@ -1,12 +1,22 @@
 <template>
   <div class="dialog">
-    <el-dialog title="自定义模型" :visible.sync="dialogVisible" width="40%" :before-close="close"
-      :modal-append-to-body="false" :close-on-click-modal="false">
+    <el-dialog
+      title="自定义模型"
+      :visible.sync="dialogVisible"
+      width="40%"
+      :before-close="close"
+      :modal-append-to-body="false"
+      :close-on-click-modal="false"
+    >
       <div class="modelTitle">
         <div class="siteCon">
           <span>分析模型名称:</span>
         </div>
-        <el-input v-model="fxmxmc" size="mini" placeholder="请输入项目名称"></el-input>
+        <el-input
+          v-model="fxmxmc"
+          size="mini"
+          placeholder="请输入项目名称"
+        ></el-input>
       </div>
       <el-row>
         <el-col :span="11">
@@ -14,60 +24,55 @@
           <el-scrollbar class="left-tree">
             <el-input placeholder="输入查询内容" v-model="filterText" clearable>
             </el-input>
-            <el-tree :data="options" :props="defaultProps" highlight-current show-checkbox node-key="id" ref="tree"
-              :default-checked-keys="defaultArr" :filter-node-method="filterNode"></el-tree>
+            <el-tree
+              :data="options"
+              :props="defaultProps"
+              highlight-current
+              show-checkbox
+              node-key="id"
+              ref="tree"
+              :default-checked-keys="defaultArr"
+              :filter-node-method="filterNode"
+            ></el-tree>
           </el-scrollbar>
         </el-col>
         <el-col :span="2">
           <div class="grid-content bg_purple">
-            <el-button icon="el-icon-d-arrow-right" @click="turnLeftToRight"></el-button>
-            <el-button icon="el-icon-d-arrow-left" @click="turnRightToLeft"></el-button>
+            <el-button
+              icon="el-icon-d-arrow-right"
+              @click="turnLeftToRight"
+            ></el-button>
+            <el-button
+              icon="el-icon-d-arrow-left"
+              @click="turnRightToLeft"
+            ></el-button>
           </div>
         </el-col>
         <el-col :span="11">
           <div class="yztitle">已选数据</div>
-          <el-table :data="dialogData" border class="right-table scroll-style" size="small" style="width: 100%"
-            @selection-change="handleSelectionChange">
+          <el-table
+            :data="dialogData"
+            border
+            class="right-table scroll-style"
+            size="small"
+            style="width: 100%"
+            @selection-change="handleSelectionChange"
+          >
             <el-table-column type="selection" width="55" align="center">
             </el-table-column>
-            <el-table-column prop="name" label="数据名称"> </el-table-column>
-            <!-- <el-table-column prop="conditionInfo" label="条件" width="150">
-              <template slot-scope="scope">
-                <el-select v-model="scope.row.conditionInfo.default" placeholder="请选择" class="input-style">
-                  <el-option v-for="item in scope.row.conditionInfo.items" :key="item.key" :label="item.name"
-                    :value="item.key">
-                  </el-option>
-                </el-select>
-              </template>
-            </el-table-column>
-            <el-table-column prop="defaultValue" label="约束值(m/°)" width="120">
-              <template slot-scope="scope">
-                <el-input
-                  Onkeyup="this.value=this.value.replace(/[^\d^\.]+/g,'').replace(/^0+(\d)/,'$1').replace(/^\./,'0.').match(/\d+.?\d{0,2}/);this.dispatchEvent(new Event('input'))"
-                  v-model.number="scope.row.conditionInfo.defaultValue" placeholder="距离" class="input-style font-14"
-                  :disabled="!scope.row.conditionInfo.hasValue" type="number"
-                  @input="testInput(scope.row.conditionInfo.defaultValue)"></el-input>
-              </template>
-            </el-table-column> -->
+            <el-table-column prop="bsmmc" label="数据名称"> </el-table-column>
           </el-table>
         </el-col>
       </el-row>
 
       <span slot="footer" class="dialog-footer">
-        <!-- <span class="clearBtn" @click="submit(true)">保存至模板</span> -->
         <el-button @click="reset">重置</el-button>
-        <el-button type="primary" @click="submit(false)">确 定</el-button>
+        <el-button type="primary" @click="submit">确 定</el-button>
       </span>
     </el-dialog>
   </div>
 </template>
-
 <script>
-// import {
-//   GetFactorList,
-//   AddTemplate,
-//   DelTemplate,
-// } from "../../../api/ghss/ghxz.js";
 import { GetFactorList } from "../../../api/ghss/gdbh.js";
 export default {
   components: {},
@@ -106,33 +111,18 @@ export default {
       if (!value) return true;
       return data.name.indexOf(value) !== -1;
     },
-    save(factors) {
-      AddTemplate({ landTypeCode: this.$parent.ydlxBSM, factors }).then(
-        (res) => {
-          if (res.success) {
-            this.$message.success(res.message);
-            this.$parent.GetTemplateFactorList(this.$parent.ydlxBSM);
-          }
-        }
-      );
-    },
     reset() {
-      // DelTemplate({ landTypeCode: this.$parent.ydlxBSM }).then((res) => {
-      //   if (res.success) {
-      //     this.$parent.GetTemplateFactorList(this.$parent.ydlxBSM);
-      //   }
-      // });
-
-      this.dialogData = [];//清空已选数据表单
-      this.filterText = "";//还原分析数据搜索框
-      this.fxmxmc = ''//清空分析模型名称输入框
-      this.getTreeList();//重新获取分析数据
+      this.dialogData = []; //清空已选数据表单
+      this.filterText = ""; //还原分析数据搜索框
+      this.fxmxmc = ""; //清空分析模型名称输入框
+      this.getTreeList(); //重新获取分析数据
     },
     testInput(val) {
       val = Number(val);
     },
     close() {
       this.dialogVisible = false;
+      this.reset();
     },
     GetFactorList() {
       GetFactorList().then((res) => {
@@ -166,12 +156,13 @@ export default {
     setTable(selectdata) {
       let tableList = [];
       selectdata.forEach((item) => {
-        let JSONItem = JSON.parse(item.conditionInfo);
+        console.log(item, "itemitemitem---");
+        // let JSONItem = JSON.parse(item.conditionInfo);
         tableList.push({
           id: item.id,
-          name: item.name,
+          bsmmc: item.name,
           bsm: item.bsm,
-          conditionInfo: JSONItem,
+          // conditionInfo: JSONItem,
         });
       });
       tableList.forEach((item) => {
@@ -213,7 +204,6 @@ export default {
         this.$message.warning("请勾选可选因子");
         return false;
       }
-      // this.dialogData = [];
       let list = this.$refs.tree.getCheckedNodes().filter((item) => {
         return item.children == undefined || item.children.length == 0;
       });
@@ -242,27 +232,35 @@ export default {
     handleSelectionChange(val) {
       this.selectdialogData = val;
     },
-    submit(issave) {
-      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("请将信息补充完整!");
-      }
+    submit() {
+      let saveData = {
+        bsm: new Date().getTime(),
+        bsmmc: this.fxmxmc,
+        gdbhMxYz: 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("请将信息补充完整!");
+      // }
     },
     setData(data) {
       data.filter((item) => {
@@ -289,13 +287,7 @@ export default {
         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.setData(this.dialogData);
       }
-      // if (this.defaultArr.length) {
       this.dialogData.forEach((item) => {
         this.resetTree(this.options, item);
       });
@@ -308,9 +300,9 @@ export default {
     filterText(val) {
       this.$refs.tree.filter(val);
     },
-    dialogVisible(oldVal, newVal) {
-      if (newVal) this.resetDialogData();
-    },
+    // dialogVisible(oldVal, newVal) {
+    //   if (newVal) this.resetDialogData();
+    // },
     yzTableData(oldVal, newVal) {
       let idArr = [];
       this.yzTableData.forEach((item) => {
@@ -364,7 +356,7 @@ export default {
     justify-content: center;
     height: 400px;
 
-    .el-button+.el-button {
+    .el-button + .el-button {
       margin-left: 0;
       margin-top: 20px;
     }