diff --git a/src/api/crm/permission/index.ts b/src/api/crm/permission/index.ts index f71e2bfc..c592bb23 100644 --- a/src/api/crm/permission/index.ts +++ b/src/api/crm/permission/index.ts @@ -1,14 +1,14 @@ import request from '@/config/axios' export interface PermissionVO { - id: number // 数据权限编号 - userId: number // 用户编号 - bizType: number // Crm 类型 - bizId: number // Crm 类型数据编号 - level: number // 权限级别 - deptName: string // 部门名称 - nickname: string // 用户昵称 - postNames: string // 岗位名称数组 + id?: number // 数据权限编号 + userId: number | undefined // 用户编号 + bizType: number | undefined // Crm 类型 + bizId: number | undefined // Crm 类型数据编号 + level: number | undefined // 权限级别 + deptName?: string // 部门名称 + nickname?: string // 用户昵称 + postNames?: string // 岗位名称数组 } // 查询团队成员列表 @@ -21,8 +21,8 @@ export const createPermission = async (data: PermissionVO) => { return await request.post({ url: `/crm/permission/add`, data }) } -// 修改团队成员 -export const updatePermission = async (data: PermissionVO) => { +// 修改团队成员权限级别 +export const updatePermission = async (data) => { return await request.put({ url: `/crm/permission/update`, data }) } @@ -30,3 +30,18 @@ export const updatePermission = async (data: PermissionVO) => { export const deletePermission = async (params) => { return await request.delete({ url: '/crm/permission/delete', params }) } + +// 退出团队 +export const quitTeam = async (id) => { + return await request.delete({ url: '/crm/permission/quit-team?id=' + id }) +} + +// 领取公海数据 +export const receive = async (data: { bizType: number; bizId: number }) => { + return await request.put({ url: `/crm/permission/receive`, data }) +} + +// 数据放入公海 +export const putPool = async (data: { bizType: number; bizId: number }) => { + return await request.put({ url: `/crm/permission/put-pool`, data }) +} diff --git a/src/views/crm/components/CrmPermissionForm.vue b/src/views/crm/components/CrmPermissionForm.vue index 1d217323..9754637b 100644 --- a/src/views/crm/components/CrmPermissionForm.vue +++ b/src/views/crm/components/CrmPermissionForm.vue @@ -1,5 +1,5 @@ diff --git a/src/views/crm/components/CrmTeamList.vue b/src/views/crm/components/CrmTeamList.vue index 824409b8..6a1c14bc 100644 --- a/src/views/crm/components/CrmTeamList.vue +++ b/src/views/crm/components/CrmTeamList.vue @@ -25,10 +25,10 @@ @selection-change="handleSelectionChange" > - - - - + + + + @@ -39,6 +39,7 @@ 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' defineOptions({ name: 'CrmTeam' }) const props = defineProps<{ @@ -65,14 +66,14 @@ const handleSelectionChange = (val: PermissionApi.PermissionVO[]) => { multipleSelection.value = val } const message = useMessage() -const crmPermissionFormRef = ref>(null) +const crmPermissionFormRef = ref>() const handleEdit = () => { if (multipleSelection.value?.length === 0) { message.warning('请先选择团队成员后操作!') return } const ids = multipleSelection.value?.map((item) => item.id) - crmPermissionFormRef.value?.open('update', props.bizType, props.bizId, ids[0]) + crmPermissionFormRef.value?.open('update', props.bizType, props.bizId, ids) } const handleRemove = async () => { if (multipleSelection.value?.length === 0) { @@ -81,13 +82,10 @@ const handleRemove = async () => { } await message.delConfirm() const ids = multipleSelection.value?.map((item) => item.id) - ids?.forEach((id) => { - // TODO 还不确定要不要搞个批量删除,还是一次只能删除一个,先用循环弄一下 - PermissionApi.deletePermission({ - bizType: props.bizType, - bizId: props.bizId, - id - }) + await PermissionApi.deletePermission({ + bizType: props.bizType, + bizId: props.bizId, + ids }) } const handleAdd = () => { @@ -95,14 +93,16 @@ const handleAdd = () => { } const userStore = useUserStoreWithOut() -const handleQuit = () => { +const handleQuit = async () => { const permission = list.value.find( - (item) => item.userId === userStore.getUser.id && item.level === 1 + (item) => item.userId === userStore.getUser.id && item.level === CrmPermissionLevelEnum.OWNER ) if (permission) { message.warning('负责人不能退出团队!') return } + const userPermission = list.value.find((item) => item.userId === userStore.getUser.id) + await PermissionApi.quitTeam(userPermission?.id) } watch( @@ -113,4 +113,3 @@ watch( { immediate: true, deep: true } ) - diff --git a/src/views/crm/components/index.ts b/src/views/crm/components/index.ts index b0bf3e42..c25feef3 100644 --- a/src/views/crm/components/index.ts +++ b/src/views/crm/components/index.ts @@ -8,4 +8,10 @@ enum CrmBizTypeEnum { CRM_CONTRACT = 6 // 合同 } -export { CrmTeam, CrmBizTypeEnum } +enum CrmPermissionLevelEnum { + OWNER = 1, // 负责人 + READ = 2, // 读 + WRITE = 3 // 写 +} + +export { CrmTeam, CrmBizTypeEnum, CrmPermissionLevelEnum }