fix: 修复 CRM 的一些 bug

(cherry picked from commit d735f782fc)
This commit is contained in:
puhui999 2024-01-20 22:46:52 +08:00 committed by shizhong
parent c8e8ebf025
commit ba4a848fa8
4 changed files with 60 additions and 33 deletions

View File

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

View File

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

View File

@ -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) // 12
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 () => {
//

View File

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