wyh 9 місяців тому
батько
коміт
edae04feae

+ 35 - 20
src/components/module_interLock/UEquipmentTree/UEquipmentTree.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="equipment-tree-container">
     <div>
-      <a-button type="primary" icon="plus"  style="width:13%;"/>
+      <a-button type="primary" icon="plus"  style="width:13%;" @click="handleAdd"/>
       <a-input-search style="width:85%;margin-left:2%" placeholder="请输入" @change="onChange" />
     </div>
 
@@ -38,14 +38,19 @@
         <!-- :filter-tree-node="filterTreeNode" -->
       </a-tree>
     </div>
+
+    <!-- 新增修改弹框 -->
+    <base-InterLock-modal ref="modalForm" @ok="modalFormOk"></base-InterLock-modal>
   </div>
 </template>
 
 <script>
-  import { getAction } from '@api/manage'
+  import { getAction,deleteAction } from '@api/manage'
+  import BaseInterLockModal from '../../../views/module_interLock/baseInterLock/modules/BaseInterLockModal.vue'
   export default({
     name: 'UEquipmentTree',
     components: {
+      BaseInterLockModal
     },
     data () {
       return {
@@ -59,6 +64,9 @@
           children: 'children',
           title: 'interlockName',
         },
+        url: {
+          delete: "/base/interlockBase/delete",
+        },
       }
     },
     created() {
@@ -157,27 +165,34 @@
       selectNode(selectedKeys, e){
         this.$emit('select', selectedKeys, e)
       },
+      handleAdd: function () {
+        this.$refs.modalForm.add();
+        this.$refs.modalForm.title = "新增";
+        this.$refs.modalForm.disableSubmit = false;
+      },
       handleEdit: function (record) {
-        // this.$refs.modalForm.edit(record);
-        // this.$refs.modalForm.title = "编辑";
-        // this.$refs.modalForm.disableSubmit = false;
+        this.$refs.modalForm.edit(record);
+        this.$refs.modalForm.title = "编辑";
+        this.$refs.modalForm.disableSubmit = false;
       },
       handleDelete: function (id) {
-        // if(!this.url.delete){
-        //   this.$message.error("请设置url.delete属性!")
-        //   return
-        // }
-        // var that = this;
-        // deleteAction(that.url.delete, {id: id}).then((res) => {
-        //   if (res.success) {
-        //     //重新计算分页问题
-        //     that.reCalculatePage(1)
-        //     that.$message.success(res.message);
-        //     that.loadData();
-        //   } else {
-        //     that.$message.warning(res.message);
-        //   }
-        // });
+        if(!this.url.delete){
+          this.$message.error("请设置url.delete属性!")
+          return
+        }
+        var that = this;
+        deleteAction(that.url.delete, {id: id}).then((res) => {
+          if (res.success) {
+            that.getTpmTreeData();
+            that.$message.success(res.message);
+          } else {
+            that.$message.warning(res.message);
+          }
+        });
+      },
+      modalFormOk() {
+        // 新增/修改 成功时,重载列表
+        this.getTpmTreeData();
       },
     },
   })