fix: 角色管理调整

This commit is contained in:
lilinyuan
2024-04-01 14:27:52 +08:00
parent 8964cbe4bd
commit 1b10b9aa2b
3 changed files with 48 additions and 34 deletions

View File

@@ -14,6 +14,14 @@ export const getRoleOption = () => {
method: "get" method: "get"
}); });
}; };
export const getTemRoleOption = () => {
return request({
url: '/admin/role/option/template',
method: "get"
});
};
//查询角色信息 //查询角色信息
export const getRoleDetail = (roleId) => { export const getRoleDetail = (roleId) => {
return request({ return request({

View File

@@ -2,13 +2,17 @@
<div v-loading="loading"> <div v-loading="loading">
<baseTitle title="角色信息录入"></baseTitle> <baseTitle title="角色信息录入"></baseTitle>
<fvForm :schema="schame" @getInstance="getInstance" :rules="rules"></fvForm> <fvForm :schema="schame" @getInstance="getInstance" :rules="rules"></fvForm>
<baseTitle title="分配菜单"></baseTitle> <div class="assign-menu-title" >
<!-- <fvCheckbox :options="localData.checkOptions" v-model="localData.checkList" @change="checkBoxChange" /> --> <baseTitle title="分配菜单"></baseTitle>
<el-checkbox-group v-model="localData.checkList" @change="checkBoxChange"> <fvSelect
<el-checkbox :label="isExpand" value="1" /> :options="localData.tempRoleOpt"
<el-checkbox :label="isAllChose" value="2" /> v-model="localData.tempRoleSelect"
<el-checkbox label="父子联动" value="3" /> style="width: 200px;"
</el-checkbox-group> placeholder="请选择模版角色"
@change="roleTempChange"
/>
</div>
<fvCheckbox :options="localData.checkOptions" v-model="localData.checkList" @change="checkBoxChange" />
<el-input v-model="localData.filterText" placeholder="请输入关键词" style="width: 400px;" /> <el-input v-model="localData.filterText" placeholder="请输入关键词" style="width: 400px;" />
<div class="menu-assign"> <div class="menu-assign">
<el-tree <el-tree
@@ -35,7 +39,7 @@ import { useAuthStore } from '@/stores/userstore.js'
import fvRadio from '@/fvcomponents/fvRadio/index.vue' import fvRadio from '@/fvcomponents/fvRadio/index.vue'
import { ElLoading, ElNotification } from 'element-plus'; import { ElLoading, ElNotification } from 'element-plus';
import { getMenuList } from '@/api/system/menuman.js' import { getMenuList } from '@/api/system/menuman.js'
import { getRoleDetail, operate} from "@/api/role/role"; import { getRoleDetail, operate, getTemRoleOption } from "@/api/role/role";
const tagsViewStore = useTagsView() const tagsViewStore = useTagsView()
const authStore = useAuthStore() const authStore = useAuthStore()
@@ -70,7 +74,9 @@ const localData = reactive({
label: '父子联动', label: '父子联动',
value: '3' value: '3'
}, },
] ],
tempRoleOpt: [],
tempRoleSelect: ''
}) })
const schame = computed(()=>{ const schame = computed(()=>{
@@ -135,6 +141,8 @@ const getInstance = (e) => {
const init = async () => { const init = async () => {
form.value.setValues({state: '1', template: false}) form.value.setValues({state: '1', template: false})
const res = await getTemRoleOption()
localData.tempRoleOpt = res.data
const { data } = await getMenuList() const { data } = await getMenuList()
localData.menuData = data localData.menuData = data
} }
@@ -145,12 +153,25 @@ const getInfo = async () => {
data.menuIds.forEach(key=>{ data.menuIds.forEach(key=>{
menuTree.value.setChecked(key, true, false) menuTree.value.setChecked(key, true, false)
}) })
if(route.query.isAdd) { form.value.setValues(data)
}
const roleTempChange = async (val) => {
try {
loading.value = true
const { data } = await getRoleDetail(val.value)
data.menuIds.forEach(key=>{
menuTree.value.setChecked(key, true, false)
})
delete data.roleId delete data.roleId
delete data.roleName delete data.roleName
delete data.roleKey delete data.roleKey
form.value.setValues(data)
loading.value = false
} catch (error) {
loading.value = false
} }
form.value.setValues(data)
} }
const filterMenu = (value, data) => { const filterMenu = (value, data) => {
@@ -166,12 +187,8 @@ const checkChange = (data) => {
return [...checkedKeys, ...halfCheckedKeys] return [...checkedKeys, ...halfCheckedKeys]
} }
console.log(localData.checkList, 'localData.checkList');
const checkBoxChange = (val) => { const checkBoxChange = (val) => {
console.log(val, 'val');
console.log(val.includes('3'), 'val.includes');
localData.checkStrictly = val.includes('3') localData.checkStrictly = val.includes('3')
console.log(localData.checkStrictly, 'localData.checkStrictly');
let nodes = menuTree.value.store.nodesMap let nodes = menuTree.value.store.nodesMap
if (val.includes('1')) { if (val.includes('1')) {
for (const node in nodes) { for (const node in nodes) {
@@ -231,6 +248,14 @@ onMounted( async ()=>{
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.assign-menu-title {
display: flex;
justify-content: flex-start;
align-items: center;
>div:first-child {
margin-right: 15px;
}
}
.menu-assign { .menu-assign {
width: 400px; width: 400px;
max-height: 500px; max-height: 500px;

View File

@@ -132,15 +132,6 @@ const tableConfig = reactive({
fixed: 'right', fixed: 'right',
currentRender: ({row, index}) => { currentRender: ({row, index}) => {
let btn = [{label: '修改', auth: auths.edit, func: ()=>handleEdit(row) , type: 'primary'}] let btn = [{label: '修改', auth: auths.edit, func: ()=>handleEdit(row) , type: 'primary'}]
row.template ?
btn.push(
{
label: '使用模版',
auth: auths.edit,
func: ()=>handleUseTemp(row),
type: 'primary'
}
) :
btn.push( btn.push(
{ {
label: '分配用户', label: '分配用户',
@@ -222,16 +213,6 @@ const handleEdit = (row) => {
}) })
} }
const handleUseTemp = (row) => {
router.push({
path: '/system/roleadd',
query: {
id: row.roleId,
isAdd: 1
}
})
}
const handleAssign = (row) => { const handleAssign = (row) => {
} }