| | |
| | | </template> |
| | | <template #operations="{ record }"> |
| | | <a-space> |
| | | <a-button type="outline" @click="operation(2, record)" |
| | | >编辑</a-button |
| | | > |
| | | <a-button |
| | | type="dashed" |
| | | status="warning" |
| | | @click="operation(4, record)" |
| | | >角色权限</a-button> |
| | | <a-popconfirm |
| | | content="Are you sure you want to delete?" |
| | | content="请确认是否删除?" |
| | | type="success" |
| | | @ok="operation(3, record)" |
| | | > |
| | |
| | | @cancel="handleCancel(1)" |
| | | @ok="editHandleOk" |
| | | > |
| | | <a-form :model="editform"> |
| | | <a-form-item required field="roleName" label="角色名"> |
| | | <a-form ref="formRef" :model="editform"> |
| | | <a-form-item required field="roleName" label="角色名" :rules="[{required:true,message:'角色名必填'},{maxLength:50,message:'长度不超过50'}]"> |
| | | <a-input v-model="editform.roleName" /> |
| | | </a-form-item> |
| | | <a-form-item field="remark" label="备注"> |
| | |
| | | class="tree-demo" |
| | | v-model:checked-keys="checkedKeysMenu" |
| | | v-model:expanded-keys="expandKdysMenu" |
| | | :only-check-leaf=true |
| | | :checkable="true" |
| | | :data="treeDataMenu" |
| | | :show-line="showLineMenu" |
| | | @check="onCheckMenu" |
| | | :fieldNames="{ |
| | | key: 'menuId', |
| | | title: 'menuName', |
| | | children: 'children', |
| | | }" |
| | | :check-strictly="checkStrictlyMenu" |
| | | > |
| | | </a-tree> |
| | | </a-tab-pane> |
| | |
| | | </a-checkbox> |
| | | </a-checkbox-group> |
| | | <a-checkbox-group |
| | | v-model="checkedKeysDialog" |
| | | @change="onCheckDialog" |
| | | v-model="checkedKeysAgent" |
| | | @change="onCheckAgent" |
| | | > |
| | | <a-checkbox |
| | | v-for="(agent, index) of AgentList" |
| | |
| | | 'margin': '1px', |
| | | }" |
| | | class="card-demo" |
| | | title="用户所有权限" |
| | | title="角色所有权限" |
| | | hoverable |
| | | > |
| | | <a-space wrap> |
| | |
| | | > |
| | | {{ tag.dialogName }} |
| | | </a-tag> |
| | | <a-tag |
| | | v-for="(tag, index) of checkStrictlyAgent" |
| | | :key="tag.agentId" |
| | | @close="handleDialogRemove(tag)" |
| | | > |
| | | {{ tag.agentTitle }} |
| | | </a-tag> |
| | | </a-space> |
| | | </a-card> |
| | | </div> |
| | |
| | | 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([]); |
| | |
| | | let resourcevisible = ref(false); |
| | | let selectRole = ref({}); |
| | | |
| | | let u =JSON.parse(getUserInfo()); |
| | | |
| | | const eachChildrenAdd=(node)=>{ |
| | | if (node.children?.length > 0) { |
| | | node.children.forEach((child) => { |
| | | checkStrictlyMenu.value.push({ menuId: child.menuId, menuName: child.menuName }); |
| | | eachChildrenAdd(child); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | const findChild = (node, val): boolean => { |
| | | let isExist = false; |
| | | if (node.children?.length > 0) { |
| | | node.children.forEach((child) => { |
| | | if (val.menuId == child.menuId) { |
| | | isExist = isExist || true; |
| | | } else { |
| | | isExist = isExist || findChild(child, val); |
| | | } |
| | | }); |
| | | } |
| | | return isExist; |
| | | }; |
| | | |
| | | const onCheckMenu = (newCheckedKeys, event) => { |
| | | let o = { menuId: event.node.menuId, menuName: event.node.menuName }; |
| | | if (event.checked) { |
| | | checkStrictlyMenu.value.push(o); |
| | | eachChildrenAdd(event.node); |
| | | if (event.halfCheckedNodes?.length > 0) { |
| | | event.halfCheckedNodes.forEach((child) => { |
| | | let e = { menuId: child.menuId, menuName: child.menuName }; |
| | | if (checkStrictlyMenu.value.find((item) => item.menuId === e.menuId) == undefined) { |
| | | checkStrictlyMenu.value.push(e); |
| | | } |
| | | }); |
| | | } |
| | | } else { |
| | | let menus=[]; |
| | | checkStrictlyMenu.value.forEach((val, idx, array) => { |
| | | // val: 当前值 |
| | | if (val.menuId == event.node.menuId) { |
| | | checkStrictlyMenu.value.splice(idx, 1); |
| | | return true; |
| | | if (val.menuId != event.node.menuId && !findChild(event.node, val)) { |
| | | menus.push({ menuId: val.menuId, menuName: val.menuName }); |
| | | } |
| | | }); |
| | | checkStrictlyMenu.value = menus; |
| | | } |
| | | }; |
| | | const onCheckKnowledge = (newCheckedKeys, event) => { |
| | |
| | | } |
| | | }; |
| | | |
| | | const handleRemove = (key) => { |
| | | checkStrictly.value = checkStrictly.value.filter((tag) => tag !== key); |
| | | }; |
| | | |
| | | const handleMenuRemove = (key) => { |
| | | checkStrictlyMenu.value = checkStrictlyMenu.value.filter( |
| | | (tag) => tag !== key |
| | |
| | | (tag) => tag !== key |
| | | ); |
| | | }; |
| | | |
| | | let formRef = ref(); |
| | | const basePagination: Pagination = { |
| | | current: 1, |
| | | pageSize: 15, |
| | |
| | | const editResourceHandleOk = async () => { |
| | | let resources: Array = [], |
| | | dialogs: Array = [], |
| | | agents: Array = [], |
| | | Knowledges: Array = [], |
| | | role: Role = { roleId: selectRole.value.roleId }; |
| | | checkStrictlyMenu.value.forEach((val) => { |
| | |
| | | }); |
| | | role.dialogs = dialogs; |
| | | |
| | | checkStrictlyAgent.value.forEach((val) => { |
| | | agents.push(val.agentId); |
| | | }); |
| | | role.agents = agents; |
| | | |
| | | await RoleEdit(role).then((res) => { |
| | | fetchData(); |
| | | }); |
| | | }; |
| | | |
| | | const editHandleOk = async () => { |
| | | if(editform.value.roleName==""){ |
| | | Modal.warning({ |
| | | title: '警告', |
| | | content: '名称不能为空' |
| | | }); |
| | | return; |
| | | } |
| | | if (editform.value.roleId.length > 0) { |
| | | await RoleEdit({ |
| | | ...editform.value, |
| | | } as unknown as Role).then((res) => { |
| | | fetchData(); |
| | | }); |
| | | const cb = async (err) => { |
| | | if (err) { |
| | | visible.value = true; |
| | | } else { |
| | | await RoleAdd({ |
| | | ...editform.value, |
| | | } as unknown as Role).then((res) => { |
| | | fetchData(); |
| | | }); |
| | | if (editform.value.roleId.length > 0) { |
| | | await RoleEdit({ |
| | | ...editform.value, |
| | | } as unknown as Role).then((res) => { |
| | | fetchData(); |
| | | }); |
| | | } else { |
| | | await RoleAdd({ |
| | | ...editform.value, |
| | | } as unknown as Role).then((res) => { |
| | | fetchData(); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | }; |
| | | |
| | | const editHandleOk = () => { |
| | | formRef.value.validate(cb); |
| | | }; |
| | | const operation = async (t, record) => { |
| | | if (t == 0) { |
| | |
| | | editform.value.roleName = ""; |
| | | editform.value.roleKey = ""; |
| | | editform.value.remark = ""; |
| | | } |
| | | |
| | | if (t == 2) { |
| | | visible.value = true; |
| | | formRef.value?.resetFields(); |
| | | save.value = '编辑'; |
| | | editform.value.roleId=record.roleId |
| | | editform.value.roleName = record.roleName; |
| | | } |
| | | |
| | | //删除 |
| | |
| | | checkStrictlyKnowledge.value = []; |
| | | checkedKeysKnowledge.value = []; |
| | | checkStrictlyDialog.value = []; |
| | | checkStrictlyAgent.value = []; |
| | | checkedKeysDialog.value = []; |
| | | selectRole.value = record; |
| | | if (record.resources) { |
| | |
| | | dialogName: val.name, |
| | | }); |
| | | checkedKeysDialog.value.push(val.id); |
| | | }); |
| | | } |
| | | if (record.agents) { |
| | | record.agents.forEach((val) => { |
| | | checkStrictlyAgent.value.push({ |
| | | agentId: val.id, |
| | | agentTitle: val.title, |
| | | }); |
| | | checkedKeysAgent.value.push(val.id); |
| | | }); |
| | | } |
| | | } |
| | |
| | | }; |
| | | |
| | | |
| | | 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 |