From 7d1e44c728a8e436fede1ceb8a62b5c4fb848b09 Mon Sep 17 00:00:00 2001 From: liudong <liudong> Date: 星期一, 19 八月 2024 17:32:43 +0800 Subject: [PATCH] agent会话名称修改 --- src/views/authority/role/index.vue | 123 +++++++++++++++++++++++++++++----------- 1 files changed, 88 insertions(+), 35 deletions(-) diff --git a/src/views/authority/role/index.vue b/src/views/authority/role/index.vue index baa7842..fd2223e 100644 --- a/src/views/authority/role/index.vue +++ b/src/views/authority/role/index.vue @@ -93,7 +93,7 @@ @click="operation(4, record)" >瑙掕壊鏉冮檺</a-button> <a-popconfirm - content="Are you sure you want to delete?" + content="璇风‘璁ゆ槸鍚﹀垹闄わ紵" type="success" @ok="operation(3, record)" > @@ -111,8 +111,8 @@ @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="澶囨敞"> @@ -142,14 +142,12 @@ v-model:expanded-keys="expandKdysMenu" :checkable="true" :data="treeDataMenu" - :show-line="showLineMenu" @check="onCheckMenu" :fieldNames="{ key: 'menuId', title: 'menuName', children: 'children', }" - :check-strictly="checkStrictlyMenu" > </a-tree> </a-tab-pane> @@ -193,8 +191,8 @@ </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" @@ -215,7 +213,7 @@ 'margin': '1px', }" class="card-demo" - title="鐢ㄦ埛鎵�鏈夋潈闄�" + title="瑙掕壊鎵�鏈夋潈闄�" hoverable > <a-space wrap> @@ -248,6 +246,13 @@ @close="handleDialogRemove(tag)" > {{ 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> @@ -330,18 +335,51 @@ let resourcevisible = ref(false); let selectRole = ref({}); + + 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) => { @@ -396,9 +434,7 @@ } }; - const handleRemove = (key) => { - checkStrictly.value = checkStrictly.value.filter((tag) => tag !== key); - }; + const handleMenuRemove = (key) => { checkStrictlyMenu.value = checkStrictlyMenu.value.filter( (tag) => tag !== key @@ -414,7 +450,7 @@ (tag) => tag !== key ); }; - + let formRef = ref(); const basePagination: Pagination = { current: 1, pageSize: 15, @@ -480,6 +516,7 @@ const editResourceHandleOk = async () => { let resources: Array = [], dialogs: Array = [], + agents: Array = [], Knowledges: Array = [], role: Role = { roleId: selectRole.value.roleId }; checkStrictlyMenu.value.forEach((val) => { @@ -497,32 +534,39 @@ }); 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) { @@ -580,6 +624,15 @@ 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); + }); + } } }; -- Gitblit v1.8.0