@ -1,7 +1,7 @@
< template >
<!-- 操作栏 -- >
< el-row justify = "end" >
< el-button type = "primary" @click ="handleAdd " >
< el-button type = "primary" @click ="openForm " >
< Icon class = "mr-5px" icon = "ep:plus" / >
新增
< / el-button >
@ -9,7 +9,7 @@
< Icon class = "mr-5px" icon = "ep:edit" / >
编辑
< / el-button >
< el-button @click ="handleRemov e" >
< el-button @click ="handleDelet e" >
< Icon class = "mr-5px" icon = "ep:delete" / >
移除
< / el-button >
@ -30,45 +30,32 @@
< el-table-column align = "center" label = "岗位" prop = "postNames" / >
< el-table-column align = "center" label = "权限级别" prop = "level" >
< template # default = "{ row }" >
< el -tag> { { getLevelName ( row . level ) } } < / el-tag >
< dict -tag :type = "DICT_TYPE.CRM_PERMISSION_LEVEL" :value = "row.level" / >
< / template >
< / el-table-column >
< el-table-column :formatter = "dateFormatter" align = "center" label = "加入时间" prop = "createTime" / >
< / el-table >
< CrmPermissionForm ref = "crmP ermissionFormRef" / >
< CrmPermissionForm ref = "p ermissionFormRef" @success ="getList" / >
< / template >
< script lang = "ts" setup >
/ / T O D O @ p u h u i 9 9 9 : 改 成 C r m P e r m i s s i o n L i s t
import { dateFormatter } from '@/utils/formatTime'
import { ElTable } from 'element-plus'
import * as PermissionApi from '@/api/crm/permission'
import { useUserStoreWithOut } from '@/store/modules/user'
import CrmPermissionForm from './CrmPermissionForm.vue'
import { CrmPermissionLevelEnum } from './index'
import { DICT _TYPE } from '@/utils/dict'
defineOptions ( { name : 'CrmTeam ' } )
defineOptions ( { name : 'CrmPermissionList ' } )
const message = useMessage ( ) / / 消 息
const props = defineProps < {
bizType : number
bizId : number
bizType : number / / 模 块 类 型
bizId : number / / 模 块 数 据 编 号
} > ( )
const loading = ref ( true ) / / 列 表 的 加 载 中
const list = ref < PermissionApi .PermissionVO [ ] > ( [
/ / T O D O 测 试 数 据
{
id : 1 , / / 数 据 权 限 编 号
userId : 1 , / / 用 户 编 号
bizType : 1 , / / C r m 类 型
bizId : 1 , / / C r m 类 型 数 据 编 号
level : 1 , / / 权 限 级 别
deptName : '研发部门' , / / 部 门 名 称
nickname : '芋道源码' , / / 用 户 昵 称
postNames : '全栈开发工程师' , / / 岗 位 名 称 数 组
createTime : new Date ( )
}
] ) / / 列 表 的 数 据
const list = ref < PermissionApi .PermissionVO [ ] > ( [ ] ) / / 列 表 的 数 据
/** 查询列表 */
const getList = async ( ) => {
@ -83,40 +70,28 @@ const getList = async () => {
loading . value = false
}
}
/ / T O D O @ p u h u i 9 9 9 : 字 典 格 式 化
/ * *
* 获得权限级别名称
* @ param level 权限级别
* /
const getLevelName = computed ( ( ) => ( level : number ) => {
switch ( level ) {
case CrmPermissionLevelEnum . OWNER :
return '负责人'
case CrmPermissionLevelEnum . READ :
return '只读'
case CrmPermissionLevelEnum . WRITE :
return '读写'
default :
break
}
} )
/ / T O D O @ p u h u i 9 9 9 : 空 行 稍 微 注 意 下 哈 ; 一 些 注 释 补 齐 下 ;
const multipleSelection = ref < PermissionApi .PermissionVO [ ] > ( [ ] )
const multipleSelection = ref < PermissionApi .PermissionVO [ ] > ( [ ] ) / / 选 择 的 团 队 成 员
const handleSelectionChange = ( val : PermissionApi . PermissionVO [ ] ) => {
multipleSelection . value = val
}
/ / T O D O @ p u h u i 9 9 9 : 一 些 变 量 命 名 , 看 看 有 没 可 能 跟 列 表 界 面 的 i n d e x . v u e 保 持 他 统 一 的 风 格 ;
const crmP ermissionFormRef = ref < InstanceType < typeof CrmPermissionForm > > ( )
const p ermissionFormRef = ref < InstanceType < typeof CrmPermissionForm > > ( ) / / 权 限 表 单 R e f
/ * *
* 编辑团队成员
* /
const handleEdit = ( ) => {
if ( multipleSelection . value ? . length === 0 ) {
message . warning ( '请先选择团队成员后操作!' )
return
}
const ids = multipleSelection . value ? . map ( ( item ) => item . id )
crmP ermissionFormRef. value ? . open ( 'update' , props . bizType , props . bizId , ids )
p ermissionFormRef. value ? . open ( 'update' , props . bizType , props . bizId , ids )
}
const handleRemove = async ( ) => {
/ * *
* 移除团队成员
* /
const handleDelete = async ( ) => {
if ( multipleSelection . value ? . length === 0 ) {
message . warning ( '请先选择团队成员后操作!' )
return
@ -129,11 +104,18 @@ const handleRemove = async () => {
ids
} )
}
const handleAdd = ( ) => {
crmPermissionFormRef . value ? . open ( 'create' , props . bizType , props . bizId )
/ * *
* 添加团队成员
* /
const openForm = ( ) => {
permissionFormRef . value ? . open ( 'create' , props . bizType , props . bizId )
}
const userStore = useUserStoreWithOut ( )
const userStore = useUserStoreWithOut ( ) / / 用 户 信 息 缓 存
/ * *
* 退出团队
* /
const handleQuit = async ( ) => {
const permission = list . value . find (
( item ) => item . userId === userStore . getUser . id && item . level === CrmPermissionLevelEnum . OWNER