瀏覽代碼

temp save

liujq 4 年之前
父節點
當前提交
d95809d699
共有 2 個文件被更改,包括 31 次插入20 次删除
  1. 7 3
      src/views/base/components/popup/MenuEdit.vue
  2. 24 17
      src/views/base/menu.vue

+ 7 - 3
src/views/base/components/popup/MenuEdit.vue

@@ -4,7 +4,7 @@
   :show-close="false"
   :close-on-click-modal="false"
   :visible.sync="isShow"
-  :title="this.curObj && this.curObj.id ? '编辑菜单' : '添加菜单'"
+  :title="this.curType === 'edit' ? '编辑菜单' : '添加菜单'"
   :fullscreen="false"
   width="470px"
   custom-class="xl-dialog"
@@ -21,7 +21,8 @@
 export default {
   props: {
     isShow: Boolean,
-    curObj: Object
+    curObj: Object,
+    curType: String,
   },
   mixins,
   data() {
@@ -34,6 +35,8 @@ export default {
     isShow: function(val) {
       if (val) {
         let params = {...this.curObj}
+        if (this.curType === 'edit') params = {...this.curObj}
+        if (this.curType === 'add') params = {}
         this.formData = [
           {label: '菜单名称', key: 'name', rules: 1},
           {label: '类型', key: 'perm_type', type: 'select', options: this.$dictData.perm_type, rules: 1},
@@ -52,7 +55,8 @@ export default {
             const oldform = this.$refs.ruleForm.baseForm
             let params = {...oldform}
             let str = 'admpermissionsadd'
-            if(this.curObj && this.curObj.id) {
+            params.p_id = this.curObj.p_id
+            if(this.curType === 'edit') {
               params.dict_id = this.curObj.id
               str = 'admpermissionsedit'
             }

+ 24 - 17
src/views/base/menu.vue

@@ -58,35 +58,42 @@ export default {
       curData: [],
       isPopupShow: false,
       curObj: {},
+      curType: '',
     }
   },
   mounted () {
-    this.$api.base.admpermissionslist().then(res => {
-      this.curData = res || []
-      console.log(res)
-    })
+    this.getMenu()
   },
   methods: {
-    appendMenu (data) {},
+    getMenu () {
+      this.$api.base.admpermissionslist().then(res => {
+        this.curData = res || []
+      })
+    },
+    appendMenu (data) {
+      console.log(data)
+      this.openPopup(data, 'add')
+    },
     removeMenu (node, name) {
       console.log(node)
     },
-    delHandle (row) {
-      const msgHtml = `确定要删除此字典吗?`
-      this.$msg(msgHtml, 'confirm', ()=> {
-        this.$api.base.dicttypedel({
-          dict_id: row.id,
-        }).then(data => {
-          this.$msgs(`删除成功!`)
-          this.fetchData()
-        })
-      }, null, true)
-    },
+    // delHandle (row) {
+    //   const msgHtml = `确定要删除此字典吗?`
+    //   this.$msg(msgHtml, 'confirm', ()=> {
+    //     this.$api.base.dicttypedel({
+    //       dict_id: row.id,
+    //     }).then(data => {
+    //       this.$msgs(`删除成功!`)
+    //       this.fetchData()
+    //     })
+    //   }, null, true)
+    // },
     linkDtl (row) {
       this.$router.push(`/base/dictDtl?dict_type=${row.dict_type}&dict_name=${row.dict_name}&id=${row.id}`)
     },
-    openPopup (row) {
+    openPopup (row, type) {
       this.curObj = row
+      this.curType = type
       this.isPopupShow = true
     },
     closePopup (obj) {