Sfoglia il codice sorgente

修改管理页管理模块代码

林倩 3 anni fa
parent
commit
237ec0fd53

+ 8 - 22
src/pages/admin-manage/add.vue

@@ -55,22 +55,12 @@ export default {
         this.handleDetail(row);
       }
     },
-    success(message = '操作成功!') {
-      const that = this;
-      that.$message.success(message);
-    },
-    fail(message = '操作失败', error) {
-      const that = this;
-      console.error('[Error]', error);
-      that.$message.error(message);
-    },
-    handleClose(bool) {
-      this.$emit('success', bool);
+    handleClose() {
+      this.$emit('close');
     },
     handlSave() {
       let ids = [];
       const selectionList = this.$refs.table.newChooseArr;
-      const that = this;
       let flag = false;
       let params = {
         userIds: ''
@@ -95,15 +85,15 @@ export default {
         if (!flag) {
           Api.addAdmin(params)
             .then((res) => {
-              that.success();
-              that.$emit('success', true);
+              this.$message.success('新增成功!');
+              this.$emit('success');
             })
             .catch(() => {
-              that.fail('新增失败');
+              this.$message.error('新增失败!');
             });
         }
       } else {
-        this.$message({ type: 'warning', message: '至少选择一条' });
+        this.$message({ type: 'warning', message: '至少选择一条' });
       }
     },
     handleDetail(row) {
@@ -120,19 +110,15 @@ export default {
           type: 'create'
         },
         on: {
-          success(bool = false) {
+          success() {
             layer.close(layer.dialogIndex);
-            if (bool) {
-              that.handleSearch();
-            }
+            that.handleSearch();
           },
           oneSaveOrg(boo) {
-            // that.orgSave = boo;
             row.orgSave = boo;
             that.$refs.table.toggleRowSelection(row, true);
           },
           oneSaveMenu(boo) {
-            // that.menuSave = boo;
             row.menuSave = boo;
             that.$refs.table.toggleRowSelection(row, true);
           }

+ 379 - 389
src/pages/admin-manage/noBindEditor.vue

@@ -1,417 +1,407 @@
 <template>
+  <div>
     <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
-        <el-tab-pane label="管理员管理范围" name="org" lazy>
-            <div style="text-align: right;">
-                <dg-button @click="handleSaveOrg">保存</dg-button>
-            </div>
-            <dg-tree
-                ref="tree"
-                show-checkbox
-                lazy
-                :load="loadNode"
-                node-key="id"
-                :props="defaultProps"
-                translate-data="translateData"
-                check-strictly
-                @check="checkClick"
-            />
-        </el-tab-pane>
-        <!--<el-tab-pane label="菜单管理范围" name="menu" lazy>-->
-        <!--<div style="text-align: right;">-->
-        <!--<dg-button @click="handleSaveMenu">保存</dg-button>-->
-        <!--</div>-->
-        <!--<dg-tree node-key="value" ref="menuTree" :data="allMenu" show-checkbox :props="menuProps"></dg-tree>-->
-        <!--</el-tab-pane>-->
+      <el-tab-pane label="管理员管理范围" name="org" lazy>
+        <dg-tree
+          ref="tree"
+          show-checkbox
+          lazy
+          :load="loadNode"
+          node-key="id"
+          :props="defaultProps"
+          translate-data="translateData"
+          check-strictly
+          @check="checkClick"
+        />
+      </el-tab-pane>
+      <!--<el-tab-pane label="菜单管理范围" name="menu" lazy>-->
+      <!--<div style="text-align: right;">-->
+      <!--<dg-button @click="handleSaveMenu">保存</dg-button>-->
+      <!--</div>-->
+      <!--<dg-tree node-key="value" ref="menuTree" :data="allMenu" show-checkbox :props="menuProps"></dg-tree>-->
+      <!--</el-tab-pane>-->
     </el-tabs>
+    <div v-footer>
+     <dg-button @click="handleCancel">取消</dg-button>
+    <dg-button type="primary" @click="handleSaveOrg">保存</dg-button>
+
+    </div>
+  </div>
 </template>
 
 <script>
-import * as commonApi from "@/api/common";
-import * as adminApi from "@/api/admin-manage";
-import { mapGetters } from "vuex";
+import * as commonApi from '@/api/common';
+import * as adminApi from '@/api/admin-manage';
+import { mapGetters } from 'vuex';
 export default {
-    name: "adminManageEditor",
-    props: {
-        id: String,
-        defaultProps: {
-            default() {
-                return {
-                    value: "id",
-                    label: "name",
-                    isLeaf(data) {
-                        return data.isParent !== true;
-                    }
-                };
-            }
-        },
-        menuProps: {
-            default() {
-                return {
-                    value: "value",
-                    label: "label",
-                    // isLeaf(data) {
-                    //     return data.isParent !== true;
-                    // },
-                    children: "children"
-                };
-            }
-        },
-        defaultExpandedKeys: {
-            type: Array,
-            default: () => []
-        },
-        defaultCheckedKeys: {
-            type: Array,
-            default: () => []
-        },
-        defaultHalfCheckedKeys: {
-            type: Array,
-            default: () => []
-        },
-        type: {
-            type: String,
-            default: ""
-        }
+  name: 'adminManageEditor',
+  props: {
+    id: String,
+    defaultProps: {
+      default() {
+        return {
+          value: 'id',
+          label: 'name',
+          isLeaf(data) {
+            return data.isParent !== true;
+          }
+        };
+      }
     },
-    data() {
-        const halfCheckKeys = [...this.defaultHalfCheckedKeys];
-        const checksKeys = [...this.defaultCheckedKeys];
+    menuProps: {
+      default() {
         return {
-            activeName: "org",
-            translateData: [],
-            halfCheckKeys,
-            checksKeys,
-            orgParams: {
-                id: "",
-                userId: "",
-                mtType: this.type == "create" ? "TEMP" : "APP"
-            },
-            menuParams: {
-                type: this.type == "create" ? "TEMP" : "",
-                userId: ""
-            },
-            allMenu: [],
-            tempNoChecks: [], //用户手动取消勾选
-            tempChecks: [], // 用户手动勾选
-            halfCheckList: [], //半选
-            parentStatus: null
+          value: 'value',
+          label: 'label',
+          // isLeaf(data) {
+          //     return data.isParent !== true;
+          // },
+          children: 'children'
         };
+      }
     },
-    methods: {
-        handleClick(tab) {
-            if (tab.name == "menu") {
-                this.getSelfMenu();
-            }
-        },
-        loadNode(node, resolve) {
-            const that = this;
-            this.orgParams.userId = this.id;
-            const params = {
-                ...this.orgParams,
-                id: node.key ? node.key : ""
-            };
-            that.getTree(params, resolve);
-        },
-        // 管理范围
-        getTree(params, resolve) {
-            const that = this;
-            let node, parentNode;
-
-            return adminApi
-                .orgRange(params)
-                .then(res => {
-                    // 渲染树节点
-                    resolve(res || []);
-                    if (res.length) {
-                        that.$nextTick(() => {
-                            res.forEach(item => {
-                                node = that.$refs.tree.getNode(item.id);
-                                parentNode = item.pid ? that.$refs.tree.getNode(item.pid) : null;
-                                // 父节点存在
-                                if (parentNode) {
-                                    // 父节点勾选
-                                    if (parentNode.checked) {
-                                        if (that.tempChecks.indexOf(item.pid) > -1) {
-                                            node.checked = true;
-                                            node.indeterminate = false;
-                                            that.tempChecks.push(item.id);
-                                        } else {
-                                            if (item.checked == "2") {
-                                                node.checked = true;
-                                                node.indeterminate = false;
-                                            } else if (item.checked == "0") {
-                                                node.checked = false;
-                                                node.indeterminate = false;
-                                            } else if (item.checked == "1") {
-                                                node.checked = false;
-                                                node.indeterminate = true;
-                                            }
-                                        }
-                                    } else if (!parentNode.checked) {
-                                        if (that.tempNoChecks.indexOf(item.pid) > -1) {
-                                            that.tempNoChecks.push(item.id);
-                                            node.checked = false;
-                                            node.indeterminate = false;
-                                        } else {
-                                            if (item.checked == "2") {
-                                                node.checked = true;
-                                                node.indeterminate = false;
-                                            } else if (item.checked == "0") {
-                                                node.checked = false;
-                                                node.indeterminate = false;
-                                            } else if (item.checked == "1") {
-                                                node.checked = false;
-                                                node.indeterminate = true;
-                                            }
-                                        }
-                                    }
-                                } else {
-                                    if (item.checked == "2") {
-                                        node.checked = true;
-                                        node.indeterminate = false;
-                                    } else if (item.checked == "0") {
-                                        node.checked = false;
-                                        node.indeterminate = false;
-                                    } else if (item.checked == "1") {
-                                        node.checked = false;
-                                        node.indeterminate = true;
-                                    }
-                                }
-                            });
-                        });
-                    }
-                })
-                .catch(error => {
-                    that.fail("获取管理范围失败!", error);
-                });
-        },
-        // 复选框被点击时
-        checkClick(data, node) {
-            // tempNoChecks -- 记录用户手动取消勾选  tempChecks--记录用户手动勾选
-            let currentNode = this.$refs.tree.getNode(data);
-            let parentNode = data.pid ? this.$refs.tree.getNode(data.pid) : null;
-            const that = this;
-            const setChecked = (node, isChecked) => {
-                let childs = node.childNodes;
-                if (childs && childs.length > 0) {
-                    childs.forEach(child => {
-                        child.checked = isChecked;
-                        child.indeterminate = false;
-                        setChecked(child, isChecked);
-                    });
-                }
+    defaultExpandedKeys: {
+      type: Array,
+      default: () => []
+    },
+    defaultCheckedKeys: {
+      type: Array,
+      default: () => []
+    },
+    defaultHalfCheckedKeys: {
+      type: Array,
+      default: () => []
+    },
+    type: {
+      type: String,
+      default: ''
+    }
+  },
+  data() {
+    const halfCheckKeys = [...this.defaultHalfCheckedKeys];
+    const checksKeys = [...this.defaultCheckedKeys];
+    return {
+      activeName: 'org',
+      translateData: [],
+      halfCheckKeys,
+      checksKeys,
+      orgParams: {
+        id: '',
+        userId: '',
+        mtType: this.type == 'create' ? 'TEMP' : 'APP'
+      },
+      menuParams: {
+        type: this.type == 'create' ? 'TEMP' : '',
+        userId: ''
+      },
+      allMenu: [],
+      tempNoChecks: [], //用户手动取消勾选
+      tempChecks: [], // 用户手动勾选
+      halfCheckList: [], //半选
+      parentStatus: null
+    };
+  },
+  methods: {
+    handleCancel() {
+      this.$emit('close');
+    },
+    handleClick(tab) {
+      if (tab.name == 'menu') {
+        this.getSelfMenu();
+      }
+    },
+    loadNode(node, resolve) {
+      const that = this;
+      this.orgParams.userId = this.id;
+      const params = {
+        ...this.orgParams,
+        id: node.key ? node.key : ''
+      };
+      that.getTree(params, resolve);
+    },
+    // 管理范围
+    getTree(params, resolve) {
+      const that = this;
+      let node, parentNode;
 
-                if (isChecked) {
-                    if (that.tempChecks.indexOf(data.id) == -1) {
-                        that.tempChecks.push(data.id);
+      return adminApi
+        .orgRange(params)
+        .then((res) => {
+          // 渲染树节点
+          resolve(res || []);
+          if (res.length) {
+            that.$nextTick(() => {
+              res.forEach((item) => {
+                node = that.$refs.tree.getNode(item.id);
+                parentNode = item.pid ? that.$refs.tree.getNode(item.pid) : null;
+                // 父节点存在
+                if (parentNode) {
+                  // 父节点勾选
+                  if (parentNode.checked) {
+                    if (that.tempChecks.indexOf(item.pid) > -1) {
+                      node.checked = true;
+                      node.indeterminate = false;
+                      that.tempChecks.push(item.id);
+                    } else {
+                      if (item.checked == '2') {
+                        node.checked = true;
+                        node.indeterminate = false;
+                      } else if (item.checked == '0') {
+                        node.checked = false;
+                        node.indeterminate = false;
+                      } else if (item.checked == '1') {
+                        node.checked = false;
+                        node.indeterminate = true;
+                      }
                     }
-                }
-                if (!isChecked) {
-                    if (that.tempNoChecks.indexOf(data.id) == -1) {
-                        that.tempNoChecks.push(data.id);
+                  } else if (!parentNode.checked) {
+                    if (that.tempNoChecks.indexOf(item.pid) > -1) {
+                      that.tempNoChecks.push(item.id);
+                      node.checked = false;
+                      node.indeterminate = false;
+                    } else {
+                      if (item.checked == '2') {
+                        node.checked = true;
+                        node.indeterminate = false;
+                      } else if (item.checked == '0') {
+                        node.checked = false;
+                        node.indeterminate = false;
+                      } else if (item.checked == '1') {
+                        node.checked = false;
+                        node.indeterminate = true;
+                      }
                     }
+                  }
+                } else {
+                  if (item.checked == '2') {
+                    node.checked = true;
+                    node.indeterminate = false;
+                  } else if (item.checked == '0') {
+                    node.checked = false;
+                    node.indeterminate = false;
+                  } else if (item.checked == '1') {
+                    node.checked = false;
+                    node.indeterminate = true;
+                  }
                 }
-            };
-
-            // 手动设置 全选和全不选
-            if (currentNode.checked) {
-                setChecked(currentNode, true);
-            } else {
-                setChecked(currentNode, false);
-                if (parentNode && parentNode.checked) {
-                    // 递归设置半选
-                    this.setHalfCheckedNodes(parentNode);
-                }
-            }
-        },
-
-        getCheckedKeys(leafOnly = false, includeHalfChecked = false) {
-            return this.$refs.tree.getCheckedKeys(leafOnly, includeHalfChecked);
-        },
-        getHalfCheckedKeys() {
-            return this.$refs.tree.getHalfCheckedKeys();
-        },
-        setCheckedNodes(keys, leafOnly = false) {
-            keys.forEach(item => {
-                this.$refs.tree.setChecked(item, true, leafOnly);
+              });
             });
-        },
-        // 递归获取顶级节点
-        getTopParentNode(key) {
-            const that = this;
-            let topParent = null;
-            const currentNode = this.$refs.tree.getNode(key);
-            topParent = currentNode.data.pid ? this.$refs.tree.getNode(currentNode.data.pid) : null;
-            if (currentNode && topParent) {
-                that.getTopParentNode(topParent);
-            }
-            return topParent || currentNode;
-        },
+          }
+        })
+    },
+    // 复选框被点击时
+    checkClick(data, node) {
+      // tempNoChecks -- 记录用户手动取消勾选  tempChecks--记录用户手动勾选
+      let currentNode = this.$refs.tree.getNode(data);
+      let parentNode = data.pid ? this.$refs.tree.getNode(data.pid) : null;
+      const that = this;
+      const setChecked = (node, isChecked) => {
+        let childs = node.childNodes;
+        if (childs && childs.length > 0) {
+          childs.forEach((child) => {
+            child.checked = isChecked;
+            child.indeterminate = false;
+            setChecked(child, isChecked);
+          });
+        }
 
-        // 递归设置半选
-        setHalfCheckedNodes(key) {
-            const that = this;
-            const node = this.$refs.tree.getNode(key);
-            const indeterminateFunc = node => {
-                if (node && node.parent && node.parent.checked) {
-                    node.parent.indeterminate = true;
-                    node.parent.checked = false;
-                    indeterminateFunc(node.parent);
-                }
-            };
-            if (node) {
-                node.indeterminate = true;
-                node.checked = false;
-                indeterminateFunc(node);
-            }
-        },
-        setHalfNoCheckedNodes(key) {
-            const that = this;
-            const node = this.$refs.tree.getNode(key);
-            const noindeterminateFunc = node => {
-                if (node && node.parent && !node.parent.checked) {
-                    node.parent.indeterminate = false;
-                    noindeterminateFunc(node.parent);
-                }
-            };
-            if (node) {
-                node.indeterminate = false;
-                // that.halfCheckKeys = that.halfCheckKeys.filter((item) => item != key);
-                noindeterminateFunc(node);
-            }
-        },
+        if (isChecked) {
+          if (that.tempChecks.indexOf(data.id) == -1) {
+            that.tempChecks.push(data.id);
+          }
+        }
+        if (!isChecked) {
+          if (that.tempNoChecks.indexOf(data.id) == -1) {
+            that.tempNoChecks.push(data.id);
+          }
+        }
+      };
 
-        getAllMenu() {
-            const that = this;
-            const { id } = this.user;
-            adminApi
-                .getAllMenu(id)
-                .then(res => {
-                    that.allMenu = res;
-                })
-                .catch(Error => {
-                    that.fail("获取全部菜单失败");
-                });
-        },
-        // 菜单范围
-        getSelfMenu() {
-            const that = this;
-            let params = {
-                ...this.menuParams,
-                userId: this.id
-            };
-            let node;
-            adminApi
-                .menuRange(params)
-                .then(res => {
-                    that.$nextTick(() => {
-                        res.forEach(key => {
-                            node = that.$refs.menuTree.getNode(key);
-                            if (node && node.isLeaf) {
-                                that.$refs.menuTree.setChecked(key, true);
-                            }
-                        });
-                    });
-                })
-                .catch(Error => {
-                    that.fail("获取菜单权限失败");
-                });
-        },
-        handleSaveOrg() {
-            // const { halfCheckKeys, checksKeys } = this;
-            const that = this;
-            const resultChecks = [];
-            const checks = this.getCheckedKeys(); //全勾选状态
-            const halfChecks = this.getHalfCheckedKeys(); //半勾选状态
-            let params = {};
-            let orgIds = "";
-            if (!checks.length && !halfChecks.length) {
-                that.$message("未勾选管理范围", "error");
-                return;
-            } else {
-                if (checks.length) {
-                    checks.forEach(item => {
-                        // debugger;
-                        let topParent = that.getTopParentNode(item);
-                        if (topParent.checked) {
-                            if (resultChecks.indexOf(topParent.data.id) === -1) {
-                                resultChecks.push(topParent.data.id);
-                            }
-                        } else {
-                            resultChecks.push(item);
-                        }
-                    });
-                    // console.log(resultChecks);
-                    resultChecks.forEach(aaa => {
-                        orgIds += aaa + ":2" + ",";
-                    });
-                }
-                if (halfChecks.length) {
-                    halfChecks.forEach(item => {
-                        orgIds += item + ":1" + ",";
-                    });
-                }
-                orgIds = orgIds.substr(0, orgIds.length - 1);
-            }
-            params["orgIds"] = orgIds;
-            params["type"] = this.type == "create" ? "TEMP" : "";
-            params["userId"] = this.id;
+      // 手动设置 全选和全不选
+      if (currentNode.checked) {
+        setChecked(currentNode, true);
+      } else {
+        setChecked(currentNode, false);
+        if (parentNode && parentNode.checked) {
+          // 递归设置半选
+          this.setHalfCheckedNodes(parentNode);
+        }
+      }
+    },
+
+    getCheckedKeys(leafOnly = false, includeHalfChecked = false) {
+      return this.$refs.tree.getCheckedKeys(leafOnly, includeHalfChecked);
+    },
+    getHalfCheckedKeys() {
+      return this.$refs.tree.getHalfCheckedKeys();
+    },
+    setCheckedNodes(keys, leafOnly = false) {
+      keys.forEach((item) => {
+        this.$refs.tree.setChecked(item, true, leafOnly);
+      });
+    },
+    // 递归获取顶级节点
+    getTopParentNode(key) {
+      const that = this;
+      let topParent = null;
+      const currentNode = this.$refs.tree.getNode(key);
+      topParent = currentNode.data.pid ? this.$refs.tree.getNode(currentNode.data.pid) : null;
+      if (currentNode && topParent) {
+        that.getTopParentNode(topParent);
+      }
+      return topParent || currentNode;
+    },
 
-            // 区别修改或新增
-            const apiName = this.type === "create" ? "saveOrgRange" : "saveAppRange";
+    // 递归设置半选
+    setHalfCheckedNodes(key) {
+      const that = this;
+      const node = this.$refs.tree.getNode(key);
+      const indeterminateFunc = (node) => {
+        if (node && node.parent && node.parent.checked) {
+          node.parent.indeterminate = true;
+          node.parent.checked = false;
+          indeterminateFunc(node.parent);
+        }
+      };
+      if (node) {
+        node.indeterminate = true;
+        node.checked = false;
+        indeterminateFunc(node);
+      }
+    },
+    setHalfNoCheckedNodes(key) {
+      const that = this;
+      const node = this.$refs.tree.getNode(key);
+      const noindeterminateFunc = (node) => {
+        if (node && node.parent && !node.parent.checked) {
+          node.parent.indeterminate = false;
+          noindeterminateFunc(node.parent);
+        }
+      };
+      if (node) {
+        node.indeterminate = false;
+        // that.halfCheckKeys = that.halfCheckKeys.filter((item) => item != key);
+        noindeterminateFunc(node);
+      }
+    },
 
-            adminApi[apiName](params)
-                .then(res => {
-                    that.success();
-                    // that.$emit("success", true); // 不必刷新表格
-                    that.$emit("oneSaveOrg", true);
-                })
-                .catch(error => {
-                    that.fail(error);
-                });
-        },
-        handleSaveMenu() {
-            const that = this;
-            const checks = this.$refs.menuTree.getCheckedKeys();
-            const halfChecks = this.$refs.menuTree.getHalfCheckedKeys();
-            let params = {};
-            if (!halfChecks.length && !checks.length) {
-                this.$message("未选择菜单范围", "warning");
-                return;
-            }
-            if (!halfChecks.length) {
-                params["menuIds"] = checks.toString();
+    getAllMenu() {
+      const that = this;
+      const { id } = this.user;
+      adminApi
+        .getAllMenu(id)
+        .then((res) => {
+          that.allMenu = res;
+        })
+    },
+    // 菜单范围
+    getSelfMenu() {
+      const that = this;
+      let params = {
+        ...this.menuParams,
+        userId: this.id
+      };
+      let node;
+      adminApi
+        .menuRange(params)
+        .then((res) => {
+          that.$nextTick(() => {
+            res.forEach((key) => {
+              node = that.$refs.menuTree.getNode(key);
+              if (node && node.isLeaf) {
+                that.$refs.menuTree.setChecked(key, true);
+              }
+            });
+          });
+        })
+    },
+    handleSaveOrg() {
+      // const { halfCheckKeys, checksKeys } = this;
+      const that = this;
+      const resultChecks = [];
+      const checks = this.getCheckedKeys(); //全勾选状态
+      const halfChecks = this.getHalfCheckedKeys(); //半勾选状态
+      let params = {};
+      let orgIds = '';
+      if (!checks.length && !halfChecks.length) {
+        that.$message('未勾选管理范围', 'error');
+        return;
+      } else {
+        if (checks.length) {
+          checks.forEach((item) => {
+            // debugger;
+            let topParent = that.getTopParentNode(item);
+            if (topParent.checked) {
+              if (resultChecks.indexOf(topParent.data.id) === -1) {
+                resultChecks.push(topParent.data.id);
+              }
             } else {
-                params["menuIds"] = halfChecks.toString() + "," + checks.toString();
+              resultChecks.push(item);
             }
-            params["type"] = this.type == "create" ? "TEMP" : "";
-            params["userId"] = this.id;
-            adminApi
-                .saveMenuRange(params)
-                .then(res => {
-                    that.success();
-                    // that.$emit("success");
-                    that.$emit("oneSaveMenu", true);
-                })
-                .catch(Error => {
-                    that.fail();
-                });
-        },
-        success(message = "操作成功!") {
-            const that = this;
-            that.$message.success(message);
-        },
-        fail(message = "操作失败", error) {
-            const that = this;
-            // console.error("[Error]", error);
-            that.$message.error(message);
+          });
+          // console.log(resultChecks);
+          resultChecks.forEach((aaa) => {
+            orgIds += aaa + ':2' + ',';
+          });
+        }
+        if (halfChecks.length) {
+          halfChecks.forEach((item) => {
+            orgIds += item + ':1' + ',';
+          });
         }
+        orgIds = orgIds.substr(0, orgIds.length - 1);
+      }
+      params['orgIds'] = orgIds;
+      params['type'] = this.type == 'create' ? 'TEMP' : '';
+      params['userId'] = this.id;
+
+      // 区别修改或新增
+      const apiName = this.type === 'create' ? 'saveOrgRange' : 'saveAppRange';
+
+      adminApi[apiName](params)
+        .then((res) => {
+          that.success();
+          // that.$emit("success", true); // 不必刷新表格
+          that.$emit('oneSaveOrg', true);
+        })
+    },
+    handleSaveMenu() {
+      const that = this;
+      const checks = this.$refs.menuTree.getCheckedKeys();
+      const halfChecks = this.$refs.menuTree.getHalfCheckedKeys();
+      let params = {};
+      if (!halfChecks.length && !checks.length) {
+        this.$message('未选择菜单范围', 'warning');
+        return;
+      }
+      if (!halfChecks.length) {
+        params['menuIds'] = checks.toString();
+      } else {
+        params['menuIds'] = halfChecks.toString() + ',' + checks.toString();
+      }
+      params['type'] = this.type == 'create' ? 'TEMP' : '';
+      params['userId'] = this.id;
+      adminApi
+        .saveMenuRange(params)
+        .then((res) => {
+          that.success();
+          // that.$emit("success");
+          that.$emit('oneSaveMenu', true);
+        })
     },
-    computed: {
-        ...mapGetters(["user"])
+    success(message = '操作成功!') {
+      const that = this;
+      that.$message.success(message);
     },
-    created() {
-        // this.getAllMenu();
+    fail(message = '操作失败', error) {
+      const that = this;
+      that.$message.error(message);
     }
+  },
+  computed: {
+    ...mapGetters(['user'])
+  },
+  created() {
+  }
 };
 </script>

+ 21 - 41
src/pages/admin-manage/tab-first.vue

@@ -31,7 +31,7 @@ import { downloadBlob } from '@/utils/download';
 import searchBar from '@/components/search-bar';
 import operateBar from '@/components/operate-bar';
 import { searchOpt } from '@/mixins/page-opt';
-import { conditionForm, tableHeader } from "./DataConfig"
+import { conditionForm, tableHeader } from './DataConfig';
 const area = ['950px', '660px'];
 export default {
   name: 'TabFirst',
@@ -43,19 +43,10 @@ export default {
       conditionForm,
       tableHeader,
       pageOptList: ['新增'],
-      tableOptList: ['修改', '用户信息', '撤销'],
+      tableOptList: ['修改', '用户信息', '撤销']
     };
   },
   methods: {
-    success(message = '操作成功!') {
-      const that = this;
-      that.$message.success(message);
-    },
-    fail(message = '操作失败', error) {
-      const that = this;
-      console.error('[Error]', error);
-      that.$message.error(message);
-    },
     receviceOpt(type, row) {
       if (type == '新增') {
         this.handleAddDialog();
@@ -79,11 +70,9 @@ export default {
           type: 'edit'
         },
         on: {
-          success(bool = false) {
+          success() {
             layer.close(layer.dialogIndex);
-            if (bool) {
-              that.handleSearch();
-            }
+            that.handleSearch();
           }
         }
       });
@@ -104,47 +93,38 @@ export default {
     },
     handleDelete({ id }) {
       const that = this;
-      that
-        .$confirm('是否确认撤销?', '确认信息', {
-          distinguishCancelAndClose: true,
-          confirmButtonText: '确定',
-          cancelButtonText: '取消'
-        })
-        .then(() => {
-          api
-            .del(id)
-            .then(() => {
-              that.handleSearch();
-              that.success('撤销成功!');
-            })
-            .catch((error) => {
-              that.fail('撤销失败!', error);
-            });
-        });
+      that.$confirm('是否确认撤销?', '确认信息').then(() => {
+        api
+          .del(id)
+          .then(() => {
+            that.handleSearch();
+            that.$message.success('撤销成功!');
+          })
+          .catch((error) => {
+            that.$message.error('撤销失败!');
+          });
+      });
     },
     // 新增
     handleAddDialog() {
       const that = this;
-      const orgId = this.$refs.searchBar.form.find(item => item.name == 'orgId').value;
+      const orgId = this.$refs.searchBar.form.find((item) => item.name == 'orgId').value;
       const layer = that.$dgLayer({
         title: '管理员添加',
         shade: [0.4, '#FFF'],
         content: Add,
-        props: { type: 'create', orgId},
+        props: { type: 'create', orgId },
         area,
         on: {
-          success(bool = false) {
+          success() {
             layer.close(layer.dialogIndex);
-            if (bool) {
-              that.handleSearch();
-            }
+            that.handleSearch();
           }
         }
       });
     },
     handleExport() {
-      const that = this;
-      let data = this.$refs.myTable.getReqSearchCondition();
+      let data = this.$refs.table.getReqSearchCondition();
       api
         .exports(data, {
           method: 'post',
@@ -155,7 +135,7 @@ export default {
         })
         .catch((error) => {
           console.error('[Error]', error);
-          that.fail('下载失败!', error);
+          this.$message.error('下载失败!');
         });
     },
     handleImport() {

+ 3 - 0
src/pages/common/new-table/index.vue

@@ -110,6 +110,9 @@ export default {
     handleSelectionChange(data) {
       this.$emit('handleSelectionChange', data);
     },
+     getReqSearchCondition() {
+      return this.$refs.baseTable.getReqSearchCondition();
+    },
 
     /**
      * 进入页面默认选中设置