|
@@ -0,0 +1,111 @@
|
|
|
+<script setup>
|
|
|
+import {apiSystemCommon} from '@/api/system'
|
|
|
+
|
|
|
+// 获取角色对应的菜单数据
|
|
|
+const menuList=ref([])
|
|
|
+async function getMenuList(){
|
|
|
+ menuList.value=[]
|
|
|
+ const res=await apiSystemCommon.getRoleMenuList({
|
|
|
+ RoleId:roleId.value
|
|
|
+ })
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ menuList.value=res.Data.List||[]
|
|
|
+}
|
|
|
+
|
|
|
+const roleId=ref('')
|
|
|
+const roleOpts=ref([])
|
|
|
+async function getRoleOpts(){
|
|
|
+ const res=await apiSystemCommon.getRoleList({RoleLevel:0})
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ roleOpts.value=res.Data.List||[]
|
|
|
+ roleId.value=roleOpts.value[0]?.RoleId
|
|
|
+ getMenuList()
|
|
|
+}
|
|
|
+getRoleOpts()
|
|
|
+
|
|
|
+async function handleSave(){
|
|
|
+ let arr=[]
|
|
|
+ menuList.value.forEach(item => {
|
|
|
+ arr=[...arr,...item.CheckList]
|
|
|
+ });
|
|
|
+ const res=await apiSystemCommon.setRoleMenuData({
|
|
|
+ MenuIdStr:arr.join(','),
|
|
|
+ RoleId:roleId.value
|
|
|
+ })
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ MessagePlugin.success('保存成功')
|
|
|
+}
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="role-menu-auth-page">
|
|
|
+ <div class="bg-white flex top-wrap">
|
|
|
+ <span style="flex-shrink: 0;">角色</span>
|
|
|
+ <t-select placeholder="请选择角色" v-model="roleId" style="width:240px" @change="getMenuList">
|
|
|
+ <t-option
|
|
|
+ v-for="item in roleOpts"
|
|
|
+ :key="item.RoleId"
|
|
|
+ :label="item.RoleName"
|
|
|
+ :value="item.RoleId"
|
|
|
+ ></t-option>
|
|
|
+ </t-select>
|
|
|
+ </div>
|
|
|
+ <div class="bg-white main-wrap">
|
|
|
+ <div style="font-weight:600">ETACRM菜单权限</div>
|
|
|
+ <div class="list-wrap">
|
|
|
+ <t-checkbox-group v-model="item.CheckList" v-for="item in menuList" :key="item.MenuId" class="list-item">
|
|
|
+ <t-checkbox
|
|
|
+ :key="item.MenuId"
|
|
|
+ :check-all="true"
|
|
|
+ :checked="item.CheckList.length>0?true:false"
|
|
|
+ :indeterminate="item.CheckList.length>0&&item.CheckList.length<item.Child.length?true:false"
|
|
|
+ :label="item.Name"
|
|
|
+ class="check-all-box"
|
|
|
+ />
|
|
|
+ <t-checkbox
|
|
|
+ :key="child.MenuId"
|
|
|
+ :value="child.MenuId"
|
|
|
+ v-for="child in item.Child"
|
|
|
+ >{{child.Name}}</t-checkbox>
|
|
|
+ </t-checkbox-group>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="bg-white" style="text-align:center;padding-bottom:40px">
|
|
|
+ <t-button style="width:300px" @click="handleSave">确定</t-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.top-wrap {
|
|
|
+ padding: 20px;
|
|
|
+ align-items: center;
|
|
|
+ gap: 0 10px;
|
|
|
+}
|
|
|
+.main-wrap {
|
|
|
+ margin-top: 20px;
|
|
|
+ padding: 20px;
|
|
|
+ .list-wrap{
|
|
|
+ margin-top: 60px;
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ gap: 30px;
|
|
|
+ .list-item{
|
|
|
+ width: 200px;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ min-height: 200px;
|
|
|
+ border: 1px solid var(--border-color);
|
|
|
+ border-radius: 4px;
|
|
|
+ padding: 20px;
|
|
|
+ margin-bottom: 50px;
|
|
|
+ .check-all-box{
|
|
|
+ margin-top: -50px;
|
|
|
+ margin-left: -20px;
|
|
|
+ margin-bottom: 20px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|