| | |
| | | </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-button> |
| | | <a-button |
| | | type="dashed" |
| | | status="success" |
| | | @click="operation(5, record)" |
| | | >部门配置</a-button> |
| | | <a-popconfirm |
| | | content="请确认是否删除?" |
| | | type="success" |
| | |
| | | > |
| | | <a-button type="outline" status="danger">删除</a-button> |
| | | </a-popconfirm> |
| | | |
| | | |
| | | </a-space> |
| | | </template> |
| | | </a-table> |
| | |
| | | <icon-calendar /> |
| | | 菜单 |
| | | </template> |
| | | <div class="cdtree"> |
| | | <a-tree |
| | | class="tree-demo" |
| | | v-model:checked-keys="checkedKeysMenu" |
| | |
| | | }" |
| | | > |
| | | </a-tree> |
| | | </div> |
| | | </a-tab-pane> |
| | | <a-tab-pane key="2"> |
| | | <template #title> |
| | |
| | | </a-checkbox> |
| | | </a-checkbox-group> |
| | | </a-tab-pane> |
| | | <a-tab-pane key="4"> |
| | | <template #title> |
| | | <icon-user /> |
| | | 模型 |
| | | </template> |
| | | <a-checkbox-group |
| | | v-model="checkedKeysModel" |
| | | @change="onCheckModel" |
| | | > |
| | | <a-checkbox |
| | | v-for="(model, index) of ModelList" |
| | | :value="model.id" |
| | | @change="onCheckModel" |
| | | style="width:100%"> |
| | | {{ model.llm_factory+" "+model.llm_name+" "+model.model_type }} |
| | | </a-checkbox> |
| | | </a-checkbox-group> |
| | | </a-tab-pane> |
| | | </a-tabs> |
| | | <a-card |
| | | :style="{ |
| | |
| | | {{ tag.agentTitle }} |
| | | </a-tag> |
| | | </a-space> |
| | | <a-divider /> |
| | | <a-space wrap> |
| | | 模型: |
| | | <a-tag |
| | | v-for="(tag, index) of checkStrictlyModel" |
| | | :key="tag.modelId" |
| | | > |
| | | {{ tag.modelTitle }} |
| | | </a-tag> |
| | | </a-space> |
| | | </a-card> |
| | | </div> |
| | | </a-modal> |
| | | <a-modal |
| | | width="50%" |
| | | v-model:visible="deptvisible" |
| | | title="部门配置" |
| | | @cancel="handleCancel(3)" |
| | | @ok="editDeptHandleOk" |
| | | > |
| | | <div :style="{ display: 'flex' }"> |
| | | <a-card |
| | | :style="{ 'width': '460px', 'height': '500px', 'overflow-y': 'auto' }" |
| | | title="部门配置" |
| | | hoverable |
| | | > |
| | | <a-tree |
| | | class="tree-demo" |
| | | v-model:checked-keys="checkedKeys" |
| | | v-model:expanded-keys="expandKdys" |
| | | :checkable="true" |
| | | :data="treeData" |
| | | :show-line="showLine" |
| | | @check="onCheck" |
| | | :fieldNames="{ |
| | | key: 'deptId', |
| | | title: 'deptName', |
| | | children: 'children', |
| | | }" |
| | | > |
| | | </a-tree> |
| | | </a-card> |
| | | <a-card class="card-demo" title="角色所属部门" hoverable> |
| | | <a-space wrap> |
| | | <a-tag |
| | | v-for="(tag, index) of checkStrictly" |
| | | :key="tag.deptId" |
| | | > |
| | | {{ tag.deptName }} |
| | | </a-tag> |
| | | </a-space> |
| | | </a-card> |
| | | </div> |
| | | </a-modal> |
| | |
| | | import { Modal } from '@arco-design/web-vue'; |
| | | import Authheader from '@/views/authority/components/authheader.vue'; |
| | | import router from "@/router"; |
| | | import { queryCanvasList } from "@/api/Agent"; |
| | | import { getUserResources } from "@/utils/auth"; |
| | | import { queryCanvasList, queryModelList } from "@/api/Agent"; |
| | | import { getUserInfo, getUserResources } from "@/utils/auth"; |
| | | import { forEach } from "lodash"; |
| | | |
| | | let treeData = ref([]); |
| | | let checkedKeys = ref([]); |
| | | let expandKdys = ref([]); |
| | | let checkStrictly = ref([]); |
| | | |
| | | let treeDataMenu = ref([]); |
| | | let checkedKeysMenu = ref([]); |
| | |
| | | |
| | | let checkedKeysAgent = ref([]); |
| | | let checkStrictlyAgent = ref([]); |
| | | let checkStrictlyModel = ref([]); |
| | | let checkedKeysModel = ref([]); |
| | | |
| | | |
| | | let knowledgeList = ref([]); |
| | | let DialogsList = ref([]); |
| | | let AgentList = ref([]); |
| | | let ModelList = ref([]); |
| | | |
| | | |
| | | let menuTips = ref(['权限管理', '角色']); |
| | | type SizeProps = 'mini' | 'small' | 'medium' | 'large'; |
| | |
| | | |
| | | let size = ref<SizeProps>('medium'); |
| | | let visible = ref(false); |
| | | let deptvisible = ref(false); |
| | | let resourcevisible = ref(false); |
| | | let selectRole = ref({}); |
| | | |
| | | let u =JSON.parse(getUserInfo()); |
| | | |
| | | |
| | | const editDeptHandleOk = async () => { |
| | | let depts: Array = [], |
| | | role: Role = { roleId: selectRole.value.roleId }; |
| | | checkStrictly.value.forEach((val) => { |
| | | depts.push(val.deptId); |
| | | }); |
| | | role.dept = depts; |
| | | await RoleEdit(role).then((res) => { |
| | | fetchData(); |
| | | }); |
| | | }; |
| | | |
| | | const onCheck = (newCheckedKeys, event) => { |
| | | if (event.checked) { |
| | | if (event.node.children.length > 0) { |
| | | event.checkedNodes.forEach((node) => { |
| | | let o = { deptId: node.deptId, deptName: node.deptName,parentId: node.parentId }; |
| | | checkStrictly.value.push(o); |
| | | }); |
| | | } else { |
| | | let o = { deptId: event.node.deptId, deptName: event.node.deptName,parentId: event.node.parentId }; |
| | | checkStrictly.value.push(o); |
| | | } |
| | | } else { |
| | | let depts = []; |
| | | let isParent = false; |
| | | let parentNode; |
| | | checkStrictly.value.forEach((val, idx, array) => { |
| | | if (val.deptId == event.node.parentId) { |
| | | parentNode = { deptId: val.deptId, deptName: val.deptName, parentId: val.parentId }; |
| | | } else { |
| | | if (val.deptId != event.node.deptId && !findDeptChild(event.node, val)) { |
| | | depts.push({ deptId: val.deptId, deptName: val.deptName, parentId: val.parentId }); |
| | | if (val.parentId == event.node.parentId && val.parentId.length>0) { |
| | | isParent = true; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | if (isParent && parentNode) { |
| | | depts.push(parentNode); |
| | | } |
| | | checkStrictly.value = depts; |
| | | } |
| | | }; |
| | | |
| | | const findDeptChild = (node, val): boolean => { |
| | | let isExist = false; |
| | | if (node.children?.length > 0) { |
| | | node.children.forEach((child) => { |
| | | if (val.deptId == child.deptId) { |
| | | isExist = isExist || true; |
| | | } else { |
| | | isExist = isExist || findDeptChild(child, val); |
| | | } |
| | | }); |
| | | } |
| | | return isExist; |
| | | }; |
| | | |
| | | const OrganizationData = async (key) => { |
| | | await OrganizationList(key).then((res) => { |
| | | treeData.value = [...res.rows]; |
| | | }); |
| | | }; |
| | | |
| | | const eachChildrenAdd=(node)=>{ |
| | | if (node.children?.length > 0) { |
| | |
| | | }); |
| | | } |
| | | }; |
| | | const onCheckModel = (newCheckedKeys, event) => { |
| | | let o = { |
| | | modelId: event.target.value, |
| | | modelTitle: event.target.labels[0].innerText, |
| | | }; |
| | | if (event.target.checked) { |
| | | checkStrictlyModel.value.push(o); |
| | | } else { |
| | | checkStrictlyModel.value.forEach((val, idx, array) => { |
| | | // val: 当前值 |
| | | if (val.modelId == event.target.value) { |
| | | checkStrictlyModel.value.splice(idx, 1); |
| | | return true; |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | const onCheckDialog = (newCheckedKeys, event) => { |
| | | let o = { |
| | | dialogId: event.target.value, |
| | |
| | | if (type == 2) { |
| | | resourcevisible.value = false; |
| | | } |
| | | if (type == 3) { |
| | | deptvisible.value = false; |
| | | } |
| | | }; |
| | | |
| | | |
| | |
| | | dialogs: Array = [], |
| | | agents: Array = [], |
| | | Knowledges: Array = [], |
| | | llms: Array = [], |
| | | role: Role = { roleId: selectRole.value.roleId }; |
| | | checkStrictlyMenu.value.forEach((val) => { |
| | | resources.push(val.menuId); |
| | |
| | | agents.push(val.agentId); |
| | | }); |
| | | role.agents = agents; |
| | | |
| | | checkStrictlyModel.value.forEach((val) => { |
| | | llms.push(val.modelId); |
| | | }); |
| | | role.llms = llms; |
| | | |
| | | await RoleEdit(role).then((res) => { |
| | | fetchData(); |
| | |
| | | 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) => { |
| | |
| | | checkStrictlyKnowledge.value = []; |
| | | checkedKeysKnowledge.value = []; |
| | | checkStrictlyDialog.value = []; |
| | | checkStrictlyAgent.value = []; |
| | | checkStrictlyModel.value = []; |
| | | checkedKeysDialog.value = []; |
| | | selectRole.value = record; |
| | | if (record.resources) { |
| | |
| | | agentTitle: val.title, |
| | | }); |
| | | checkedKeysAgent.value.push(val.id); |
| | | }); |
| | | } |
| | | if (record.llms) { |
| | | record.llms.forEach((val) => { |
| | | checkStrictlyModel.value.push({ |
| | | modelId: val.id, |
| | | modelTitle: val.llm_name, |
| | | }); |
| | | checkedKeysModel.value.push(val.id); |
| | | }); |
| | | } |
| | | |
| | | } |
| | | //部门配置 |
| | | if (t == 5) { |
| | | deptvisible.value = true; |
| | | checkedKeys.value = []; |
| | | expandKdys.value = []; |
| | | checkStrictly.value = []; |
| | | selectRole.value = record; |
| | | expandKdys.value.push('0'); |
| | | if (record?.dept) { |
| | | record.dept.forEach((val) => { |
| | | checkStrictly.value.push({ |
| | | deptId: val.deptId, |
| | | deptName: val.deptName, |
| | | }); |
| | | checkedKeys.value.push(val.deptId); |
| | | expandKdys.value.push(val.deptId); |
| | | }); |
| | | } |
| | | } |
| | |
| | | |
| | | const MenuData = async (key) => { |
| | | await ResourceList(key).then((res) => { |
| | | let newTree=[] |
| | | removeChild(res.rows,newTree) |
| | | let newTree = []; |
| | | if (u.role != "admin") { |
| | | removeChild(res.rows, newTree); |
| | | } |
| | | treeDataMenu.value = [...res.rows]; |
| | | }); |
| | | }; |
| | | |
| | | KnowledgeList().then((res) => { |
| | | KnowledgeList(u.role).then((res) => { |
| | | knowledgeList.value = res.data; |
| | | }); |
| | | |
| | | DialogList().then((res) => { |
| | | DialogList(u.role).then((res) => { |
| | | DialogsList.value = res.data; |
| | | }); |
| | | queryCanvasList(null).then((canvas) => { |
| | | AgentList= canvas.data |
| | | }); |
| | | queryModelList().then((models) => { |
| | | ModelList = models.data; |
| | | }); |
| | | |
| | | fetchData(); |
| | | MenuData(); |
| | | OrganizationData(""); |
| | | |
| | | const reset = () => { |
| | | formModel.value = generateFormModel(); |
| | |
| | | } |
| | | } |
| | | </style> |
| | | <style> |
| | | .cdtree { |
| | | .arco-tree-node-is-leaf { |
| | | display: inline-flex; |
| | | } |
| | | } |
| | | </style> |