Skip to content

Commit dcfe1ab

Browse files
committed
✨ CRM:增加商机关联联系人
1 parent 6caa94e commit dcfe1ab

File tree

2 files changed

+82
-2
lines changed

2 files changed

+82
-2
lines changed

src/api/crm/contact/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export interface ContactBusinessReqVO {
3737
businessIds: number[]
3838
}
3939

40+
export interface ContactBusiness2ReqVO {
41+
businessId: number
42+
contactIds: number[]
43+
}
44+
4045
// 查询 CRM 联系人列表
4146
export const getContactPage = async (params) => {
4247
return await request.get({ url: `/crm/contact/page`, params })
@@ -87,11 +92,21 @@ export const createContactBusinessList = async (data: ContactBusinessReqVO) => {
8792
return await request.post({ url: `/crm/contact/create-business-list`, data })
8893
}
8994

95+
// 批量新增联系人商机关联
96+
export const createContactBusinessList2 = async (data: ContactBusiness2ReqVO) => {
97+
return await request.post({ url: `/crm/contact/create-business-list2`, data })
98+
}
99+
90100
// 解除联系人商机关联
91101
export const deleteContactBusinessList = async (data: ContactBusinessReqVO) => {
92102
return await request.delete({ url: `/crm/contact/delete-business-list`, data })
93103
}
94104

105+
// 解除联系人商机关联
106+
export const deleteContactBusinessList2 = async (data: ContactBusiness2ReqVO) => {
107+
return await request.delete({ url: `/crm/contact/delete-business-list2`, data })
108+
}
109+
95110
// 联系人转移
96111
export const transferContact = async (data: TransferReqVO) => {
97112
return await request.put({ url: '/crm/contact/transfer', data })

src/views/crm/contact/components/ContactList.vue

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,32 @@
55
<Icon class="mr-5px" icon="system-uicons:contacts" />
66
创建联系人
77
</el-button>
8+
<el-button
9+
@click="openBusinessModal"
10+
v-hasPermi="['crm:contact:create-business']"
11+
v-if="queryParams.businessId"
12+
>
13+
<Icon class="mr-5px" icon="ep:circle-plus" />关联
14+
</el-button>
15+
<el-button
16+
@click="deleteContactBusinessList"
17+
v-hasPermi="['crm:contact:delete-business']"
18+
v-if="queryParams.businessId"
19+
>
20+
<Icon class="mr-5px" icon="ep:remove" />解除关联
21+
</el-button>
822
</el-row>
923

1024
<!-- 列表 -->
1125
<ContentWrap class="mt-10px">
12-
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
26+
<el-table
27+
ref="contactRef"
28+
v-loading="loading"
29+
:data="list"
30+
:stripe="true"
31+
:show-overflow-tooltip="true"
32+
>
33+
<el-table-column type="selection" width="55" v-if="queryParams.businessId" />
1334
<el-table-column label="姓名" fixed="left" align="center" prop="name">
1435
<template #default="scope">
1536
<el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
@@ -37,12 +58,19 @@
3758

3859
<!-- 表单弹窗:添加 -->
3960
<ContactForm ref="formRef" @success="getList" />
61+
<!-- 关联商机选择弹框 -->
62+
<ContactListModal
63+
ref="contactModalRef"
64+
:customer-id="props.customerId"
65+
@success="createContactBusinessList"
66+
/>
4067
</template>
4168
<script setup lang="ts">
4269
import * as ContactApi from '@/api/crm/contact'
4370
import ContactForm from './../ContactForm.vue'
4471
import { DICT_TYPE } from '@/utils/dict'
4572
import { BizTypeEnum } from '@/api/crm/permission'
73+
import ContactListModal from './ContactListModal.vue'
4674
4775
defineOptions({ name: 'CrmContactList' })
4876
const props = defineProps<{
@@ -58,8 +86,10 @@ const list = ref([]) // 列表的数据
5886
const queryParams = reactive({
5987
pageNo: 1,
6088
pageSize: 10,
61-
customerId: undefined as unknown // 允许 undefined + number
89+
customerId: undefined as unknown, // 允许 undefined + number
90+
businessId: undefined as unknown // 允许 undefined + number
6291
})
92+
const message = useMessage()
6393
6494
/** 查询列表 */
6595
const getList = async () => {
@@ -106,6 +136,41 @@ const openDetail = (id: number) => {
106136
push({ name: 'CrmContactDetail', params: { id } })
107137
}
108138
139+
/** 打开联系人与商机的关联弹窗 */
140+
const contactModalRef = ref()
141+
const openBusinessModal = () => {
142+
contactModalRef.value.open()
143+
}
144+
const createContactBusinessList = async (contactIds: number[]) => {
145+
const data = {
146+
businessId: props.bizId,
147+
contactIds: contactIds
148+
} as ContactApi.ContactBusiness2ReqVO
149+
contactRef.value.getSelectionRows().forEach((row: ContactApi.ContactVO) => {
150+
data.businessIds.push(row.id)
151+
})
152+
await ContactApi.createContactBusinessList2(data)
153+
// 刷新列表
154+
message.success('关联联系人成功')
155+
handleQuery()
156+
}
157+
158+
/** 解除联系人与商机的关联 */
159+
const contactRef = ref()
160+
const deleteContactBusinessList = async () => {
161+
const data = {
162+
businessId: props.bizId,
163+
contactIds: contactRef.value.getSelectionRows().map((row: ContactApi.ContactVO) => row.id)
164+
} as ContactApi.ContactBusiness2ReqVO
165+
if (data.contactIds.length === 0) {
166+
return message.error('未选择联系人')
167+
}
168+
await ContactApi.deleteContactBusinessList2(data)
169+
// 刷新列表
170+
message.success('取关联系人成功')
171+
handleQuery()
172+
}
173+
109174
/** 监听打开的 bizId + bizType,从而加载最新的列表 */
110175
watch(
111176
() => [props.bizId, props.bizType],

0 commit comments

Comments
 (0)