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