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"
});
};
export const getTemRoleOption = () => {
return request({
url: '/admin/role/option/template',
method: "get"
});
};
//查询角色信息
export const getRoleDetail = (roleId) => {
return request({

View File

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

View File

@@ -132,15 +132,6 @@ const tableConfig = reactive({
fixed: 'right',
currentRender: ({row, index}) => {
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(
{
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) => {
}