5
5
<Icon class =" mr-5px" icon =" system-uicons:contacts" />
6
6
创建联系人
7
7
</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 >
8
22
</el-row >
9
23
10
24
<!-- 列表 -->
11
25
<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" />
13
34
<el-table-column label =" 姓名" fixed =" left" align =" center" prop =" name" >
14
35
<template #default =" scope " >
15
36
<el-link type =" primary" :underline =" false" @click =" openDetail(scope.row.id)" >
37
58
38
59
<!-- 表单弹窗:添加 -->
39
60
<ContactForm ref =" formRef" @success =" getList" />
61
+ <!-- 关联商机选择弹框 -->
62
+ <ContactListModal
63
+ ref =" contactModalRef"
64
+ :customer-id =" props.customerId"
65
+ @success =" createContactBusinessList"
66
+ />
40
67
</template >
41
68
<script setup lang="ts">
42
69
import * as ContactApi from ' @/api/crm/contact'
43
70
import ContactForm from ' ./../ContactForm.vue'
44
71
import { DICT_TYPE } from ' @/utils/dict'
45
72
import { BizTypeEnum } from ' @/api/crm/permission'
73
+ import ContactListModal from ' ./ContactListModal.vue'
46
74
47
75
defineOptions ({ name: ' CrmContactList' })
48
76
const props = defineProps <{
@@ -58,8 +86,10 @@ const list = ref([]) // 列表的数据
58
86
const queryParams = reactive ({
59
87
pageNo: 1 ,
60
88
pageSize: 10 ,
61
- customerId: undefined as unknown // 允许 undefined + number
89
+ customerId: undefined as unknown , // 允许 undefined + number
90
+ businessId: undefined as unknown // 允许 undefined + number
62
91
})
92
+ const message = useMessage ()
63
93
64
94
/** 查询列表 */
65
95
const getList = async () => {
@@ -106,6 +136,41 @@ const openDetail = (id: number) => {
106
136
push ({ name: ' CrmContactDetail' , params: { id } })
107
137
}
108
138
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
+
109
174
/** 监听打开的 bizId + bizType,从而加载最新的列表 */
110
175
watch (
111
176
() => [props .bizId , props .bizType ],
0 commit comments