src/views/authority/apiscope.vue
@@ -1,8 +1,12 @@
<template>
  <basic-container
    :class="[$store.state.control.windowWidth >= 1024 ? 'oneRowSearch' : '']"
    :class="[
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      class="tablesss"
      :option="option"
      :table-loading="loading"
      :data="data"
@@ -92,14 +96,14 @@
  remove,
  update,
  getLazyMenuList,
  getMenu,
  getMenu
} from "@/api/system/menu";
import {
  addApiScope,
  removeApiScope,
  updateApiScope,
  getListApiScope,
  getMenuApiScope,
  getMenuApiScope
} from "@/api/system/scope";
import { mapGetters } from "vuex";
import iconList from "@/config/iconList";
@@ -116,7 +120,7 @@
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize,
        ...this.$store.state.control.changePageSize
      },
      drawerVisible: false,
      direction: "rtl",
@@ -151,9 +155,9 @@
              {
                required: true,
                message: "请输入菜单名称",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "路由地址",
@@ -162,9 +166,9 @@
              {
                required: true,
                message: "请输入路由地址",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "上级菜单",
@@ -173,15 +177,15 @@
            dicUrl: "/api/blade-system/menu/tree",
            hide: true,
            props: {
              label: "title",
              label: "title"
            },
            rules: [
              {
                required: false,
                message: "请选择上级菜单",
                trigger: "click",
              },
            ],
                trigger: "click"
              }
            ]
          },
          {
            label: "菜单图标",
@@ -194,9 +198,9 @@
              {
                required: true,
                message: "请输入菜单图标",
                trigger: "click",
              },
            ],
                trigger: "click"
              }
            ]
          },
          {
            label: "菜单编号",
@@ -206,9 +210,9 @@
              {
                required: true,
                message: "请输入菜单编号",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "菜单类型",
@@ -217,21 +221,21 @@
            dicData: [
              {
                label: "菜单",
                value: 1,
                value: 1
              },
              {
                label: "按钮",
                value: 2,
              },
                value: 2
              }
            ],
            hide: true,
            rules: [
              {
                required: true,
                message: "请选择菜单类型",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "菜单别名",
@@ -240,9 +244,9 @@
              {
                required: true,
                message: "请输入菜单别名",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "按钮功能",
@@ -251,25 +255,25 @@
            dicData: [
              {
                label: "工具栏",
                value: 0,
                value: 0
              },
              {
                label: "操作栏",
                value: 1,
                value: 1
              },
              {
                label: "工具操作栏",
                value: 2,
              },
                value: 2
              }
            ],
            hide: true,
            rules: [
              {
                required: true,
                message: "请选择按钮功能",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "菜单排序",
@@ -280,9 +284,9 @@
              {
                required: true,
                message: "请输入菜单排序",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "新窗口",
@@ -291,14 +295,14 @@
            dicData: [
              {
                label: "否",
                value: 0,
                value: 0
              },
              {
                label: "是",
                value: 1,
              },
                value: 1
              }
            ],
            hide: true,
            hide: true
          },
          {
            label: "菜单备注",
@@ -306,9 +310,9 @@
            type: "textarea",
            span: 24,
            minRows: 6,
            hide: true,
          },
        ],
            hide: true
          }
        ]
      },
      data: [],
      formScope: {},
@@ -316,7 +320,7 @@
      pageScope: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
        total: 0
      },
      optionScope: {
        tip: false,
@@ -339,9 +343,9 @@
              {
                required: true,
                message: "请输入数据权限名称",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "权限编号",
@@ -352,9 +356,9 @@
              {
                required: true,
                message: "请输入数据权限编号",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "权限路径",
@@ -364,9 +368,9 @@
              {
                required: true,
                message: "请输入数据权限编号",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "接口类型",
@@ -374,7 +378,7 @@
            dicUrl: "/api/blade-system/dict/dictionary?code=api_scope_type",
            props: {
              label: "dictValue",
              value: "dictKey",
              value: "dictKey"
            },
            dataType: "number",
            slot: true,
@@ -384,19 +388,19 @@
              {
                required: true,
                message: "请输入通知类型",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "备注",
            prop: "remark",
            span: 24,
            hide: true,
          },
        ],
            hide: true
          }
        ]
      },
      dataScope: [],
      dataScope: []
    };
  },
@@ -407,23 +411,26 @@
        addBtn: this.vaildData(this.permission.menu_add, false),
        viewBtn: this.vaildData(this.permission.menu_view, false),
        delBtn: this.vaildData(this.permission.menu_delete, false),
        editBtn: this.vaildData(this.permission.menu_edit, false),
        editBtn: this.vaildData(this.permission.menu_edit, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    scopeIds() {
      let ids = [];
      this.selectionListScope.forEach((ele) => {
      this.selectionListScope.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    }
  },
  mounted() {
    this.$store.commit("setWindowSizeHeightAdd");
  },
  methods: {
    // 菜单管理模块
@@ -433,11 +440,11 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -449,11 +456,11 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -463,7 +470,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
@@ -472,7 +479,7 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
        });
    },
@@ -503,7 +510,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
@@ -512,14 +519,14 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getMenu(this.form.id).then((res) => {
        getMenu(this.form.id).then(res => {
          this.form = res.data.data;
        });
      }
@@ -537,16 +544,17 @@
    onLoad(page, params = {}) {
      this.loading = true;
      getLazyMenuList(this.parentId, Object.assign(params, this.query)).then(
        (res) => {
        res => {
          this.data = res.data.data;
          this.loading = false;
          this.$store.commit("setWindowSizeHeightAdd");
          this.selectionClear();
        }
      );
    },
    treeLoad(tree, treeNode, resolve) {
      const parentId = tree.id;
      getLazyMenuList(parentId).then((res) => {
      getLazyMenuList(parentId).then(res => {
        resolve(res.data.data);
      });
    },
@@ -563,18 +571,18 @@
    rowSaveScope(row, done, loading) {
      row = {
        ...row,
        menuId: this.scopeMenuId,
        menuId: this.scopeMenuId
      };
      addApiScope(row).then(
        () => {
          this.onLoadScope(this.pageScope);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -583,18 +591,18 @@
    rowUpdateScope(row, index, done, loading) {
      row = {
        ...row,
        menuId: this.scopeMenuId,
        menuId: this.scopeMenuId
      };
      updateApiScope(row).then(
        () => {
          this.onLoadScope(this.pageScope);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -604,7 +612,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return removeApiScope(row.id);
@@ -613,7 +621,7 @@
          this.onLoadScope(this.pageScope);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
        });
    },
@@ -625,7 +633,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return removeApiScope(this.scopeIds);
@@ -634,14 +642,14 @@
          this.onLoadScope(this.pageScope);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          this.$refs.crudScope.toggleSelection();
        });
    },
    beforeOpenScope(done, type) {
      if (["edit", "view"].includes(type)) {
        getMenuApiScope(this.formScope.id).then((res) => {
        getMenuApiScope(this.formScope.id).then(res => {
          this.formScope = res.data.data;
        });
      }
@@ -667,20 +675,21 @@
      this.scopeLoading = true;
      const values = {
        ...params,
        menuId: this.scopeMenuId,
        menuId: this.scopeMenuId
      };
      getListApiScope(
        page.currentPage,
        page.pageSize,
        Object.assign(values, this.query)
      ).then((res) => {
      ).then(res => {
        const data = res.data.data;
        this.pageScope.total = data.total;
        this.dataScope = data.records;
        this.selectionListScope = [];
        this.$store.commit("setWindowSizeHeightAdd");
        this.scopeLoading = false;
      });
    },
  },
    }
  }
};
</script>