zhangxiao
2024-08-30 c02bff2911f720d54388f4abb6456ec1777f8a96
src/views/authority/role/index.vue
@@ -87,6 +87,9 @@
        </template>
        <template #operations="{ record }">
          <a-space>
            <a-button type="outline" @click="operation(2, record)"
            >编辑</a-button
            >
            <a-button
              type="dashed"
              status="warning"
@@ -285,6 +288,8 @@
  import Authheader from '@/views/authority/components/authheader.vue';
  import router from "@/router";
  import { queryCanvasList } from "@/api/Agent";
  import { getUserInfo, getUserResources } from "@/utils/auth";
  import { forEach } from "lodash";
  let treeDataMenu = ref([]);
  let checkedKeysMenu = ref([]);
@@ -336,6 +341,7 @@
  let resourcevisible = ref(false);
  let selectRole = ref({});
  let u =JSON.parse(getUserInfo());
  const eachChildrenAdd=(node)=>{
    if (node.children?.length > 0) {
@@ -578,6 +584,14 @@
      editform.value.remark = "";
    }
    if (t == 2) {
      visible.value = true;
      formRef.value?.resetFields();
      save.value = '编辑';
      editform.value.roleId=record.roleId
      editform.value.roleName = record.roleName;
    }
    //删除
    if (t == 3) {
      await RoleDelete(record.roleId).then((res) => {
@@ -595,6 +609,7 @@
      checkStrictlyKnowledge.value = [];
      checkedKeysKnowledge.value = [];
      checkStrictlyDialog.value = [];
      checkStrictlyAgent.value = [];
      checkedKeysDialog.value = [];
      selectRole.value = record;
      if (record.resources) {
@@ -667,18 +682,45 @@
  };
  let userResources = JSON.parse(getUserResources());
  const isExist = (val): boolean => {
    let isok = false;
    userResources.forEach((r) => {
      if (val == r.menuId) {
        isok = true;
      }
    });
    return isok;
  };
  const removeChild = (nodes,newT) => {
    nodes.forEach((child) => {
      if (isExist(child.menuId)){
        newT.push(child);
        let nt = [];
        if (child.children?.length > 0) {
          removeChild(child.children, nt);
          child.children = nt;
        }
      }
    });
  };
  const MenuData = async (key) => {
    await ResourceList(key).then((res) => {
      let newTree = [];
      if (u.role != "admin") {
        removeChild(res.rows, newTree);
      }
      treeDataMenu.value = [...res.rows];
    });
  };
  KnowledgeList().then((res) => {
    knowledgeList.value = res.rows;
  KnowledgeList(u.role).then((res) => {
    knowledgeList.value = res.data;
  });
  DialogList().then((res) => {
    DialogsList.value = res.rows;
  DialogList(u.role).then((res) => {
    DialogsList.value = res.data;
  });
  queryCanvasList(null).then((canvas) => {
    AgentList= canvas.data