瀏覽代碼

角色权限配置done

yujinwen 3 月之前
父節點
當前提交
13e9e13967

+ 15 - 0
src/api/system/common.js

@@ -12,5 +12,20 @@ export default{
 	// 手机号区号
 	mobileAreaCode:()=>{
 		return get('/eta_business/area_code/list',{})
+	},
+	/**
+	 * 获取系统角色
+	 * @param RoleLevel 部门管理菜单->添加用户->查询所有角色列表时,需传入RoleLevel:0
+	 */
+	getRoleList:params=>{
+		return get('/system/role/all',params)
+	},
+	// 获取角色对应的菜单数据
+	getRoleMenuList:params=>{
+		return get('/system/role/menu/list',params)
+	},
+	// 设置角色菜单权限
+	setRoleMenuData:params=>{
+		return post('/system/role/menu/add',params)
 	}
 }

+ 4 - 0
src/assets/svg/menu/menu09.svg

@@ -0,0 +1,4 @@
+<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M7.5 12.4997V13.7497H12.5V12.4997H7.5Z" fill="currentColor"/>
+<path d="M5.625 6.23828V7.49971H3.75C3.40482 7.49971 3.125 7.77953 3.125 8.12471V16.8747C3.125 17.2199 3.40482 17.4997 3.75 17.4997H16.25C16.5952 17.4997 16.875 17.2199 16.875 16.8747V8.12471C16.875 7.77953 16.5952 7.49971 16.25 7.49971H14.375V6.23828C14.375 3.82204 12.4162 1.86328 10 1.86328C7.58375 1.86328 5.625 3.82204 5.625 6.23828ZM13.125 7.49971H6.875V6.23828C6.875 4.51239 8.27411 3.11328 10 3.11328C11.7259 3.11328 13.125 4.51239 13.125 6.23828V7.49971ZM4.375 8.74971H15.625V16.2497H4.375V8.74971Z" fill="currentColor"/>
+</svg>

+ 1 - 0
src/layout/components/LeftWrap.vue

@@ -61,6 +61,7 @@ function getMenuIcon(item) {
     '培训管理':'menu/menu06',
     '个性化设置':'menu/menu07',
     '系统设置':'menu/menu08',
+    '权限配置':'menu/menu09'
   }
   return iconMap[item] || 'menu/setting'
 

+ 22 - 0
src/router/modules/system.js

@@ -0,0 +1,22 @@
+import LayoutIndex from "@/layout/Index.vue";
+
+export default[
+  {
+    path:'/system',
+    name:'SystemRole',
+    component:LayoutIndex,
+    meta:{
+      title:'权限配置'
+    },
+    children:[
+      {
+        path:'roleMenuAuth',
+        name:'SystemRoleMenuAuth',
+        component:()=>import('@/views/system/RoleMenuAuth.vue'),
+        meta:{
+          title:'权限配置'
+        },
+      },
+    ]
+  }
+]

+ 4 - 0
src/styles/common.scss

@@ -28,6 +28,10 @@ img {
     -ms-interpolation-mode: nearest-neighbor;
 }
 
+ul li{
+    list-style: none;
+}
+
 .flex{
     display: flex;
 }

+ 0 - 48
src/views/customer/components/SelectETACustomer.vue

@@ -1,48 +0,0 @@
-<script setup>
-
-const emits=defineEmits(['change'])
-
-const value = defineModel('value');
-const options = ref([]);
-const loading = ref(false);
-
-function remoteMethod (search) {
-
-    loading.value = true;
-    setTimeout(() => {
-      loading.value = false;
-      options.value = [
-        {
-          value: `腾讯_test1`,
-          label: `腾讯_test1`,
-        },
-        {
-          value: `腾讯_test2`,
-          label: `腾讯_test2`,
-        },
-        {
-          value: `腾讯_test3`,
-          label: `腾讯_test3`,
-        },
-      ];
-    }, 500);
-  
-};
-
-function handleChange(value,context){
-  emits('change',value,context)
-}
-
-</script>
-
-<template>
-  <t-select
-    v-model="value"
-    filterable
-    placeholder="输入社会信用码或客户名称"
-    :loading="loading"
-    :options="options"
-    @search="remoteMethod"
-    @change="handleChange"
-  />
-</template>

+ 2 - 2
src/views/customer/user/components/ActionStatisticForCustomer.vue

@@ -1,5 +1,4 @@
 <script setup>
-import SelectETACustomer from '../../components/SelectETACustomer.vue'
 import FavChartStatistic from './FavChartStatistic.vue'
 import { Calendar1Icon } from 'tdesign-icons-vue-next'
 
@@ -23,6 +22,7 @@ const timeType = [
 ]
 const timeTypeValue = ref('')
 const selectDate = ref([])
+const selectBusinessValue=ref('')
 
 const tableData = ref([])
 const columns = [
@@ -44,7 +44,7 @@ const showFavChart=ref(false)
 
 <template>
   <div class="flex top-filter">
-    <SelectETACustomer style="width: 240px; margin-right: 50px" />
+    <select-business placeholder="输入社会信用码或客户名称" filterable v-model="selectBusinessValue" style="width: 240px; margin-right: 50px" />
     <t-button
       :variant="timeTypeValue === item.value ? 'base' : 'outline'"
       v-for="item in timeType"

+ 111 - 0
src/views/system/RoleMenuAuth.vue

@@ -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>