parent
c8e8ebf025
commit
ba4a848fa8
@ -2,14 +2,15 @@ import request from '@/config/axios'
|
|||||||
|
|
||||||
export interface PermissionVO {
|
export interface PermissionVO {
|
||||||
id?: number // 数据权限编号
|
id?: number // 数据权限编号
|
||||||
userId: number | undefined // 用户编号
|
userId: number // 用户编号
|
||||||
bizType: number | undefined // Crm 类型
|
bizType: number // Crm 类型
|
||||||
bizId: number | undefined // Crm 类型数据编号
|
bizId: number // Crm 类型数据编号
|
||||||
level: number | undefined // 权限级别
|
level: number // 权限级别
|
||||||
deptName?: string // 部门名称
|
deptName?: string // 部门名称
|
||||||
nickname?: string // 用户昵称
|
nickname?: string // 用户昵称
|
||||||
postNames?: string[] // 岗位名称数组
|
postNames?: string[] // 岗位名称数组
|
||||||
createTime?: Date
|
createTime?: Date
|
||||||
|
ids?: number[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,11 +51,11 @@ export const updatePermission = async (data) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除数据权限(删除团队成员)
|
// 删除数据权限(删除团队成员)
|
||||||
export const deletePermissionBatch = async (params) => {
|
export const deletePermissionBatch = async (val: number[]) => {
|
||||||
return await request.delete({ url: '/crm/permission/delete', params })
|
return await request.delete({ url: '/crm/permission/delete?ids=' + val.join(',') })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除自己的数据权限(退出团队)
|
// 删除自己的数据权限(退出团队)
|
||||||
export const deleteSelfPermission = async (id) => {
|
export const deleteSelfPermission = async (id: number) => {
|
||||||
return await request.delete({ url: '/crm/permission/quit-team?id=' + id })
|
return await request.delete({ url: '/crm/permission/delete-self?id=' + id })
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
:biz-id="customer.id!"
|
:biz-id="customer.id!"
|
||||||
:biz-type="BizTypeEnum.CRM_CUSTOMER"
|
:biz-type="BizTypeEnum.CRM_CUSTOMER"
|
||||||
:show-action="!permissionListRef?.isPool || false"
|
:show-action="!permissionListRef?.isPool || false"
|
||||||
|
@quit-team="close"
|
||||||
/>
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="商机" lazy>
|
<el-tab-pane label="商机" lazy>
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- TODO @puhui999:编辑时,level 没带过来 -->
|
|
||||||
<el-form-item label="权限级别" prop="level">
|
<el-form-item label="权限级别" prop="level">
|
||||||
<el-radio-group v-model="formData.level">
|
<el-radio-group v-model="formData.level">
|
||||||
<template
|
<template
|
||||||
@ -30,7 +29,13 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- TODO @puhui999:同时添加至 -->
|
<!-- TODO @puhui999:同时添加至,还没想好下次搞 -->
|
||||||
|
<el-form-item v-if="formType === 'create'" label="同时添加至" prop="toBizType">
|
||||||
|
<el-select v-model="formData.userId">
|
||||||
|
<el-option :value="1" label="联系人" />
|
||||||
|
<el-option :value="1" label="商机" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||||
@ -54,12 +59,7 @@ const dialogTitle = ref('') // 弹窗的标题
|
|||||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
const userOptions = ref<UserApi.UserVO[]>([]) // 用户列表
|
const userOptions = ref<UserApi.UserVO[]>([]) // 用户列表
|
||||||
const formData = ref<PermissionApi.PermissionVO & { ids?: number[] }>({
|
const formData = ref<PermissionApi.PermissionVO>({} as PermissionApi.PermissionVO)
|
||||||
userId: undefined, // 用户编号
|
|
||||||
bizType: undefined, // CRM 类型
|
|
||||||
bizId: undefined, // CRM 类型数据编号
|
|
||||||
level: undefined // 权限级别
|
|
||||||
})
|
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
userId: [{ required: true, message: '人员不能为空', trigger: 'blur' }],
|
userId: [{ required: true, message: '人员不能为空', trigger: 'blur' }],
|
||||||
level: [{ required: true, message: '权限级别不能为空', trigger: 'blur' }]
|
level: [{ required: true, message: '权限级别不能为空', trigger: 'blur' }]
|
||||||
@ -77,7 +77,23 @@ const open = async (type: 'create' | 'update', bizType: number, bizId: number, i
|
|||||||
formData.value.ids = ids
|
formData.value.ids = ids
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
/** 打开修改权限弹窗 */
|
||||||
|
const open0 = async (
|
||||||
|
type: 'create' | 'update',
|
||||||
|
bizType: number,
|
||||||
|
bizId: number,
|
||||||
|
id: number,
|
||||||
|
level: number
|
||||||
|
) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type) + '团队成员'
|
||||||
|
formType.value = type
|
||||||
|
resetForm(bizType, bizId)
|
||||||
|
// 修改时,设置数据
|
||||||
|
formData.value.level = level
|
||||||
|
formData.value.ids = [id]
|
||||||
|
}
|
||||||
|
defineExpose({ open, open0 }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
/** 提交表单 */
|
/** 提交表单 */
|
||||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
@ -108,12 +124,8 @@ const submitForm = async () => {
|
|||||||
/** 重置表单 */
|
/** 重置表单 */
|
||||||
const resetForm = (bizType: number, bizId: number) => {
|
const resetForm = (bizType: number, bizId: number) => {
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
formData.value = {
|
formData.value = {} as PermissionApi.PermissionVO
|
||||||
userId: undefined, // 用户编号
|
formData.value = { ...formData.value, bizType, bizId }
|
||||||
bizType, // Crm 类型
|
|
||||||
bizId, // Crm 类型数据编号
|
|
||||||
level: undefined // 权限级别
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 获得用户列表
|
// 获得用户列表
|
||||||
|
@ -105,8 +105,17 @@ const handleUpdate = () => {
|
|||||||
message.warning('请先选择团队成员后操作!')
|
message.warning('请先选择团队成员后操作!')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const ids = multipleSelection.value?.map((item) => item.id) as unknown as number[]
|
if (multipleSelection.value?.length > 1) {
|
||||||
formRef.value?.open('update', props.bizType, props.bizId!, ids)
|
message.warning('编辑团队成员时只能选择一个!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
formRef.value?.open0(
|
||||||
|
'update',
|
||||||
|
props.bizType,
|
||||||
|
props.bizId!,
|
||||||
|
multipleSelection.value[0].id!,
|
||||||
|
multipleSelection.value[0].level
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 移除团队成员 */
|
/** 移除团队成员 */
|
||||||
@ -116,12 +125,10 @@ const handleDelete = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
await message.delConfirm()
|
await message.delConfirm()
|
||||||
const ids = multipleSelection.value?.map((item) => item.id)
|
const ids = multipleSelection.value?.map((item) => item.id) as unknown as number[]
|
||||||
await PermissionApi.deletePermissionBatch({
|
await PermissionApi.deletePermissionBatch(ids)
|
||||||
bizType: props.bizType,
|
message.success('移除团队成员成功!')
|
||||||
bizId: props.bizId,
|
await getList()
|
||||||
ids
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 添加团队成员 */
|
/** 添加团队成员 */
|
||||||
@ -164,6 +171,9 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
defineExpose({ openForm, validateOwnerUser, validateWrite, isPool })
|
defineExpose({ openForm, validateOwnerUser, validateWrite, isPool })
|
||||||
|
const emits = defineEmits<{
|
||||||
|
(e: 'quitTeam'): void
|
||||||
|
}>()
|
||||||
/** 退出团队 */
|
/** 退出团队 */
|
||||||
const handleQuit = async () => {
|
const handleQuit = async () => {
|
||||||
const permission = list.value.find(
|
const permission = list.value.find(
|
||||||
@ -175,9 +185,12 @@ const handleQuit = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const userPermission = list.value.find((item) => item.userId === userStore.getUser.id)
|
const userPermission = list.value.find((item) => item.userId === userStore.getUser.id)
|
||||||
if (userPermission) {
|
if (!userPermission) {
|
||||||
await PermissionApi.deleteSelfPermission(userPermission.id!)
|
return
|
||||||
}
|
}
|
||||||
|
await PermissionApi.deleteSelfPermission(userPermission.id!)
|
||||||
|
message.success('退出团队成员成功!')
|
||||||
|
emits('quitTeam')
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
Loading…
Reference in New Issue
Block a user