CRM:完善数据权限,实现数据权限同时添加、同时转移

This commit is contained in:
puhui999 2024-03-03 20:11:52 +08:00
parent 3660cd26ae
commit 13e925e29f
15 changed files with 159 additions and 111 deletions

View File

@ -1,5 +1,5 @@
import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/customer'
import { TransferReqVO } from '@/api/crm/permission'
export interface BusinessVO {
id: number

View File

@ -1,5 +1,5 @@
import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/customer'
import { TransferReqVO } from '@/api/crm/permission'
export interface ClueVO {
id: number // 编号

View File

@ -1,5 +1,5 @@
import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/customer'
import { TransferReqVO } from '@/api/crm/permission'
export interface ContactVO {
id: number // 编号

View File

@ -1,5 +1,5 @@
import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/customer'
import { TransferReqVO } from '@/api/crm/permission'
export interface ContractVO {
id: number

View File

@ -1,4 +1,5 @@
import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/permission'
export interface CustomerVO {
id: number // 编号
@ -102,12 +103,6 @@ export const getCustomerSimpleList = async () => {
// ======================= 业务操作 =======================
export interface TransferReqVO {
id: number | undefined // 客户编号
newOwnerUserId: number | undefined // 新负责人的用户编号
oldOwnerPermissionLevel: number | undefined // 老负责人加入团队后的权限级别
}
// 客户转移
export const transferCustomer = async (data: TransferReqVO) => {
return await request.put({ url: '/crm/customer/transfer', data })

View File

@ -6,6 +6,7 @@ export interface PermissionVO {
bizType: number // Crm 类型
bizId: number // Crm 类型数据编号
level: number // 权限级别
toBizTypes?: number[] // 同时添加至
deptName?: string // 部门名称
nickname?: string // 用户昵称
postNames?: string[] // 岗位名称数组
@ -13,6 +14,13 @@ export interface PermissionVO {
ids?: number[]
}
export interface TransferReqVO {
bizId: number // 模块编号
newOwnerUserId: number // 新负责人的用户编号
oldOwnerPermissionLevel: number // 老负责人加入团队后的权限级别
toBizTypes?: number[] // 转移客户时,需要额外有【联系人】【商机】【合同】的 checkbox 选择
}
/**
* CRM
*

View File

@ -4,8 +4,8 @@
编辑
</el-button>
<el-button
:disabled="business.endStatus"
v-if="permissionListRef?.validateWrite"
:disabled="business.endStatus"
type="success"
@click="openStatusForm()"
>
@ -53,13 +53,12 @@
</el-col>
<!-- 表单弹窗添加/修改 -->
<BusinessForm ref="formRef" @success="getBusiness(business.id)" />
<BusinessUpdateStatusForm ref="statusFormRef" @success="getBusiness(business.id)" />
<CrmTransferForm ref="transferFormRef" @success="close" />
<BusinessForm ref="formRef" @success="getBusiness" />
<BusinessUpdateStatusForm ref="statusFormRef" @success="getBusiness" />
<CrmTransferForm ref="transferFormRef" :biz-type="BizTypeEnum.CRM_BUSINESS" @success="close" />
</template>
<script lang="ts" setup>
import { useTagsViewStore } from '@/store/modules/tagsView'
import * as ContactApi from '@/api/crm/contact'
import * as BusinessApi from '@/api/crm/business'
import BusinessDetailsHeader from './BusinessDetailsHeader.vue'
import BusinessDetailsInfo from './BusinessDetailsInfo.vue'
@ -73,6 +72,7 @@ import FollowUpList from '@/views/crm/followup/index.vue'
import ContactList from '@/views/crm/contact/components/ContactList.vue'
import BusinessUpdateStatusForm from '@/views/crm/business/BusinessUpdateStatusForm.vue'
import ContractList from '@/views/crm/contract/components/ContractList.vue'
import BusinessProductList from '@/views/crm/business/detail/BusinessProductList.vue'
defineOptions({ name: 'CrmBusinessDetail' })
@ -80,15 +80,15 @@ const message = useMessage()
const businessId = ref(0) // 线
const loading = ref(true) //
const business = ref<ContactApi.ContactVO>({} as ContactApi.ContactVO) //
const business = ref<BusinessApi.BusinessVO>({} as BusinessApi.BusinessVO) //
const permissionListRef = ref<InstanceType<typeof PermissionList>>() // Ref
/** 获取详情 */
const getBusiness = async (id: number) => {
const getBusiness = async () => {
loading.value = true
try {
business.value = await BusinessApi.getBusiness(id)
await getOperateLog(id)
business.value = await BusinessApi.getBusiness(businessId.value)
await getOperateLog(businessId.value)
} finally {
loading.value = false
}
@ -109,7 +109,7 @@ const openStatusForm = () => {
/** 联系人转移 */
const transferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // ref
const transfer = () => {
transferFormRef.value?.open('商机转移', business.value.id, BusinessApi.transferBusiness)
transferFormRef.value?.open(business.value.id)
}
/** 获取操作日志 */
@ -141,6 +141,6 @@ onMounted(async () => {
return
}
businessId.value = params.id as unknown as number
await getBusiness(businessId.value)
await getBusiness()
})
</script>

View File

@ -18,7 +18,7 @@
>
转化为客户
</el-button>
<el-button v-else type="success" disabled>已转化客户</el-button>
<el-button v-else disabled type="success">已转化客户</el-button>
</ClueDetailsHeader>
<el-col>
<el-tabs>
@ -45,7 +45,7 @@
<!-- 表单弹窗添加/修改 -->
<ClueForm ref="formRef" @success="getClue" />
<CrmTransferForm ref="transferFormRef" @success="close" />
<CrmTransferForm ref="transferFormRef" :biz-type="BizTypeEnum.CRM_CLUE" @success="close" />
</template>
<script lang="ts" setup>
import { useTagsViewStore } from '@/store/modules/tagsView'
@ -91,7 +91,7 @@ const openForm = () => {
/** 线索转移 */
const transferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // 线 ref
const transfer = () => {
transferFormRef.value?.open('线索转移', clueId.value, ClueApi.transferClue)
transferFormRef.value?.open(clueId.value)
}
/** 转化为客户 */

View File

@ -6,18 +6,20 @@
创建联系人
</el-button>
<el-button
@click="openBusinessModal"
v-hasPermi="['crm:contact:create-business']"
v-if="queryParams.businessId"
v-hasPermi="['crm:contact:create-business']"
@click="openBusinessModal"
>
<Icon class="mr-5px" icon="ep:circle-plus" />关联
<Icon class="mr-5px" icon="ep:circle-plus" />
关联
</el-button>
<el-button
@click="deleteContactBusinessList"
v-hasPermi="['crm:contact:delete-business']"
v-if="queryParams.businessId"
v-hasPermi="['crm:contact:delete-business']"
@click="deleteContactBusinessList"
>
<Icon class="mr-5px" icon="ep:remove" />解除关联
<Icon class="mr-5px" icon="ep:remove" />
解除关联
</el-button>
</el-row>
@ -27,21 +29,21 @@
ref="contactRef"
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
:stripe="true"
>
<el-table-column type="selection" width="55" v-if="queryParams.businessId" />
<el-table-column label="姓名" fixed="left" align="center" prop="name">
<el-table-column v-if="queryParams.businessId" type="selection" width="55" />
<el-table-column align="center" fixed="left" label="姓名" prop="name">
<template #default="scope">
<el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column label="手机号" align="center" prop="mobile" />
<el-table-column label="职位" align="center" prop="post" />
<el-table-column label="直属上级" align="center" prop="parentName" />
<el-table-column label="是否关键决策人" align="center" prop="master" min-width="100">
<el-table-column align="center" label="手机号" prop="mobile" />
<el-table-column align="center" label="职位" prop="post" />
<el-table-column align="center" label="直属上级" prop="parentName" />
<el-table-column align="center" label="是否关键决策人" min-width="100" prop="master">
<template #default="scope">
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.master" />
</template>
@ -49,9 +51,9 @@
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
@ -60,12 +62,13 @@
<ContactForm ref="formRef" @success="getList" />
<!-- 关联商机选择弹框 -->
<ContactListModal
v-if="customerId"
ref="contactModalRef"
:customer-id="props.customerId"
:customer-id="customerId"
@success="createContactBusinessList"
/>
</template>
<script setup lang="ts">
<script lang="ts" setup>
import * as ContactApi from '@/api/crm/contact'
import ContactForm from './../ContactForm.vue'
import { DICT_TYPE } from '@/utils/dict'
@ -76,8 +79,8 @@ defineOptions({ name: 'CrmContactList' })
const props = defineProps<{
bizType: number //
bizId: number //
customerId: number //
businessId: number //
customerId?: number //
businessId?: number //
}>()
const loading = ref(true) //
@ -147,7 +150,7 @@ const createContactBusinessList = async (contactIds: number[]) => {
contactIds: contactIds
} as ContactApi.ContactBusiness2ReqVO
contactRef.value.getSelectionRows().forEach((row: ContactApi.ContactVO) => {
data.businessIds.push(row.id)
data.contactIds.push(row.id)
})
await ContactApi.createContactBusinessList2(data)
//

View File

@ -1,28 +1,35 @@
<template>
<Dialog title="关联联系人" v-model="dialogVisible">
<Dialog v-model="dialogVisible" title="关联联系人">
<!-- 搜索工作栏 -->
<ContentWrap>
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="90px"
>
<el-form-item label="联系人名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入联系人名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
clearable
placeholder="请输入联系人名称"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button type="primary" @click="openForm()" v-hasPermi="['crm:business:create']">
<Icon icon="ep:plus" class="mr-5px" /> 新增
<el-button @click="handleQuery">
<Icon class="mr-5px" icon="ep:search" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button v-hasPermi="['crm:business:create']" type="primary" @click="openForm()">
<Icon class="mr-5px" icon="ep:plus" />
新增
</el-button>
</el-form-item>
</el-form>
@ -31,24 +38,24 @@
<!-- 列表 -->
<ContentWrap class="mt-10px">
<el-table
v-loading="loading"
ref="contactRef"
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
:stripe="true"
>
<el-table-column type="selection" width="55" />
<el-table-column label="姓名" fixed="left" align="center" prop="name">
<el-table-column align="center" fixed="left" label="姓名" prop="name">
<template #default="scope">
<el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column label="手机号" align="center" prop="mobile" />
<el-table-column label="职位" align="center" prop="post" />
<el-table-column label="直属上级" align="center" prop="parentName" />
<el-table-column label="是否关键决策人" align="center" prop="master" min-width="100">
<el-table-column align="center" label="手机号" prop="mobile" />
<el-table-column align="center" label="职位" prop="post" />
<el-table-column align="center" label="直属上级" prop="parentName" />
<el-table-column align="center" label="是否关键决策人" min-width="100" prop="master">
<template #default="scope">
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.master" />
</template>
@ -56,14 +63,14 @@
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
@ -71,10 +78,9 @@
<ContactForm ref="formRef" @success="getList" />
</Dialog>
</template>
<script setup lang="ts">
<script lang="ts" setup>
import * as ContactApi from '@/api/crm/contact'
import ContactForm from '../ContactForm.vue'
import { erpPriceTableColumnFormatter } from '@/utils'
import { DICT_TYPE } from '@/utils/dict'
const message = useMessage() //

View File

@ -31,15 +31,15 @@
<BusinessList
:biz-id="contact.id!"
:biz-type="BizTypeEnum.CRM_CONTACT"
:customer-id="contact.customerId"
:contact-id="contact.id"
:customer-id="contact.customerId"
/>
</el-tab-pane>
</el-tabs>
</el-col>
<!-- 表单弹窗添加/修改 -->
<ContactForm ref="formRef" @success="getContact(contact.id)" />
<CrmTransferForm ref="transferFormRef" @success="close" />
<ContactForm ref="formRef" @success="getContact" />
<CrmTransferForm ref="transferFormRef" :biz-type="BizTypeEnum.CRM_CONTACT" @success="close" />
</template>
<script lang="ts" setup>
import { useTagsViewStore } from '@/store/modules/tagsView'
@ -65,11 +65,11 @@ const contact = ref<ContactApi.ContactVO>({} as ContactApi.ContactVO) // 联系
const permissionListRef = ref<InstanceType<typeof PermissionList>>() // Ref
/** 获取详情 */
const getContact = async (id: number) => {
const getContact = async () => {
loading.value = true
try {
contact.value = await ContactApi.getContact(id)
await getOperateLog(id)
contact.value = await ContactApi.getContact(contactId.value)
await getOperateLog(contactId.value)
} finally {
loading.value = false
}
@ -84,7 +84,7 @@ const openForm = (type: string, id?: number) => {
/** 联系人转移 */
const transferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // ref
const transfer = () => {
transferFormRef.value?.open('联系人转移', contact.value.id, ContactApi.transferContact)
transferFormRef.value?.open(contact.value.id)
}
/** 获取操作日志 */
@ -116,6 +116,6 @@ onMounted(async () => {
return
}
contactId.value = params.id as unknown as number
await getContact(contactId.value)
await getContact()
})
</script>

View File

@ -48,7 +48,7 @@
<!-- 表单弹窗添加/修改 -->
<ContractForm ref="formRef" @success="getContractData" />
<CrmTransferForm ref="transferFormRef" @success="close" />
<CrmTransferForm ref="transferFormRef" :biz-type="BizTypeEnum.CRM_CONTRACT" @success="close" />
</template>
<script lang="ts" setup>
import { useTagsViewStore } from '@/store/modules/tagsView'
@ -113,10 +113,9 @@ const createReceivable = (planData: any) => {
}
/** 转移 */
// TODO @puhui999 title api
const transferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // ref
const transferContract = () => {
transferFormRef.value?.open('合同转移', contract.value.id, ContractApi.transferContract)
transferFormRef.value?.open(contract.value.id)
}
/** 关闭 */

View File

@ -76,7 +76,7 @@
<!-- 表单弹窗添加/修改 -->
<CustomerForm ref="formRef" @success="getCustomer" />
<CustomerDistributeForm ref="distributeForm" @success="getCustomer" />
<CrmTransferForm ref="transferFormRef" @success="getCustomer" />
<CrmTransferForm ref="transferFormRef" :biz-type="BizTypeEnum.CRM_CUSTOMER" @success="close" />
</template>
<script lang="ts" setup>
import { useTagsViewStore } from '@/store/modules/tagsView'
@ -142,7 +142,7 @@ const handleUpdateDealStatus = async () => {
/** 客户转移 */
const transferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // ref
const transfer = () => {
transferFormRef.value?.open('客户转移', customerId.value, CustomerApi.transferCustomer)
transferFormRef.value?.open(customerId.value)
}
/** 锁定客户 */

View File

@ -29,12 +29,15 @@
</template>
</el-radio-group>
</el-form-item>
<!-- TODO @puhui999同时添加至,还没想好下次搞 -->
<el-form-item v-if="false && 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
v-if="formType === 'create' && formData.bizType === BizTypeEnum.CRM_CUSTOMER"
label="同时添加至"
>
<el-checkbox-group v-model="formData.toBizTypes">
<el-checkbox :label="BizTypeEnum.CRM_CONTACT">联系人</el-checkbox>
<el-checkbox :label="BizTypeEnum.CRM_BUSINESS">商机</el-checkbox>
<el-checkbox :label="BizTypeEnum.CRM_CONTRACT">合同</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<template #footer>
@ -46,7 +49,7 @@
<script lang="ts" setup>
import * as UserApi from '@/api/system/user'
import * as PermissionApi from '@/api/crm/permission'
import { PermissionLevelEnum } from '@/api/crm/permission'
import { BizTypeEnum, PermissionLevelEnum } from '@/api/crm/permission'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
defineOptions({ name: 'CrmPermissionForm' })

View File

@ -19,10 +19,7 @@
</el-select>
</el-form-item>
<el-form-item label="老负责人">
<el-radio-group
v-model="oldOwnerHandler"
@change="formData.oldOwnerPermissionLevel = undefined"
>
<el-radio-group v-model="oldOwnerHandler" @change="formData.oldOwnerPermissionLevel">
<el-radio :label="false" size="large">移除</el-radio>
<el-radio :label="true" size="large">加入团队</el-radio>
</el-radio-group>
@ -39,8 +36,14 @@
</template>
</el-radio-group>
</el-form-item>
<el-form-item v-if="bizType === BizTypeEnum.CRM_CUSTOMER" label="同时转移">
<el-checkbox-group v-model="formData.toBizTypes">
<el-checkbox :label="BizTypeEnum.CRM_CONTACT">联系人</el-checkbox>
<el-checkbox :label="BizTypeEnum.CRM_BUSINESS">商机</el-checkbox>
<el-checkbox :label="BizTypeEnum.CRM_CONTRACT">合同</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<!-- TODO @puhui999 转移客户时需要额外有联系人商机合同 checkbox 选择 -->
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
@ -49,23 +52,27 @@
</template>
<script lang="ts" setup>
import * as UserApi from '@/api/system/user'
import type { TransferReqVO } from '@/api/crm/customer'
import * as BusinessApi from '@/api/crm/business'
import * as ClueApi from '@/api/crm/clue'
import * as ContactApi from '@/api/crm/contact'
import * as CustomerApi from '@/api/crm/customer'
import * as ContractApi from '@/api/crm/contract'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { PermissionLevelEnum } from '@/api/crm/permission'
import { BizTypeEnum, PermissionLevelEnum, TransferReqVO } from '@/api/crm/permission'
defineOptions({ name: 'CrmTransferForm' })
const props = defineProps<{
bizType: number
}>()
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const userOptions = ref<UserApi.UserVO[]>([]) //
const oldOwnerHandler = ref(false) //
const formData = ref<TransferReqVO>({
id: undefined, //
newOwnerUserId: undefined, //
oldOwnerPermissionLevel: undefined //
})
const formData = ref<TransferReqVO>({} as TransferReqVO)
const formRules = reactive({
newOwnerUserId: [{ required: true, message: '新负责人不能为空', trigger: 'blur' }],
oldOwnerPermissionLevel: [
@ -73,15 +80,13 @@ const formRules = reactive({
]
})
const formRef = ref() // Ref
const transferFuncRef = ref<Function>(() => {}) //
/** 打开弹窗 */
const open = async (title: string, bizId: number, transferFunc: Function) => {
const open = async (bizId: number) => {
dialogVisible.value = true
dialogTitle.value = title
transferFuncRef.value = transferFunc
dialogTitle.value = getDialogTitle()
resetForm()
formData.value.id = bizId
formData.value.bizId = bizId
}
defineExpose({ open }) // open
@ -96,7 +101,7 @@ const submitForm = async () => {
formLoading.value = true
try {
const data = formData.value
await transferFuncRef.value(unref(data))
await transfer(unref(data))
message.success(dialogTitle.value + '成功')
dialogVisible.value = false
//
@ -105,15 +110,44 @@ const submitForm = async () => {
formLoading.value = false
}
}
const transfer = async (data: TransferReqVO) => {
switch (props.bizType) {
case BizTypeEnum.CRM_CLUE:
return await ClueApi.transferClue(data)
case BizTypeEnum.CRM_CUSTOMER:
return await CustomerApi.transferCustomer(data)
case BizTypeEnum.CRM_CONTACT:
return await ContactApi.transferContact(data)
case BizTypeEnum.CRM_BUSINESS:
return await BusinessApi.transferBusiness(data)
case BizTypeEnum.CRM_CONTRACT:
return await ContractApi.transferContract(data)
default:
message.error('【转移失败】没有转移接口')
throw new Error('【转移失败】没有转移接口')
}
}
const getDialogTitle = () => {
switch (props.bizType) {
case BizTypeEnum.CRM_CLUE:
return '线索转移'
case BizTypeEnum.CRM_CUSTOMER:
return '客户转移'
case BizTypeEnum.CRM_CONTACT:
return '联系人转移'
case BizTypeEnum.CRM_BUSINESS:
return '商机转移'
case BizTypeEnum.CRM_CONTRACT:
return '合同转移'
default:
return '转移'
}
}
/** 重置表单 */
const resetForm = () => {
formRef.value?.resetFields()
formData.value = {
id: undefined, //
newOwnerUserId: undefined, //
oldOwnerPermissionLevel: undefined //
}
formData.value = {} as TransferReqVO
}
onMounted(async () => {
//