fix: 修复 CRM 的一些 bug

This commit is contained in:
puhui999 2024-01-20 22:46:52 +08:00
parent 9628517b8b
commit d735f782fc
4 changed files with 60 additions and 33 deletions

View File

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

View File

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

View File

@ -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) // 12 const formLoading = ref(false) // 12
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 () => {
// //

View File

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