1
1
<template >
2
- <CustomerDetailsHeader :customer =" customer" :loading =" loading" @refresh =" getCustomer(id)" />
2
+ <CustomerDetailsHeader :customer =" customer" :loading =" loading" >
3
+ <el-button @click =" close" >返回</el-button >
4
+ <!-- TODO puhui999: 按钮数据权限收尾统一完善,需要按权限分级和客户状态来动态显示匹配的按钮 -->
5
+ <el-button v-hasPermi =" ['crm:customer:update']" type =" primary" @click =" openForm" >
6
+ 编辑
7
+ </el-button >
8
+ <!-- TODO @puhui999:转移的操作接入 -->
9
+ <el-button type =" primary" @click =" transfer" >转移</el-button >
10
+ <!-- TODO @puhui999:修改成交状态的接入 -->
11
+ <el-button >更改成交状态</el-button >
12
+ <el-button v-if =" customer.lockStatus" @click =" handleUnlock" >解锁</el-button >
13
+ <el-button v-if =" !customer.lockStatus" @click =" handleLock" >锁定</el-button >
14
+ <el-button v-if =" !customer.ownerUserId" type =" primary" @click =" receive" >领取客户</el-button >
15
+ <el-button v-if =" customer.ownerUserId" type =" primary" @click =" putPool" >客户放入公海</el-button >
16
+ </CustomerDetailsHeader >
3
17
<el-col >
4
18
<el-tabs >
5
19
<el-tab-pane label =" 详细资料" >
11
25
<el-tab-pane label =" 联系人" lazy >
12
26
<ContactList :biz-id =" customer.id!" :biz-type =" BizTypeEnum.CRM_CUSTOMER" />
13
27
</el-tab-pane >
14
- <el-tab-pane label =" 团队成员" lazy >
28
+ <el-tab-pane label =" 团队成员" >
15
29
<PermissionList :biz-id =" customer.id!" :biz-type =" BizTypeEnum.CRM_CUSTOMER" />
16
30
</el-tab-pane >
17
31
<el-tab-pane label =" 商机" lazy >
27
41
<el-tab-pane label =" 回访" lazy >TODO 待开发</el-tab-pane >
28
42
</el-tabs >
29
43
</el-col >
44
+
45
+ <!-- 表单弹窗:添加/修改 -->
46
+ <CustomerForm ref =" formRef" @success =" getCustomer" />
30
47
</template >
31
48
<script lang="ts" setup>
32
49
import { useTagsViewStore } from ' @/store/modules/tagsView'
33
50
import * as CustomerApi from ' @/api/crm/customer'
51
+ import CustomerForm from ' @/views/crm/customer/CustomerForm.vue'
34
52
import CustomerDetailsInfo from ' ./CustomerDetailsInfo.vue' // 客户明细 - 详细信息
35
53
import CustomerDetailsHeader from ' ./CustomerDetailsHeader.vue' // 客户明细 - 头部
36
54
import ContactList from ' @/views/crm/contact/components/ContactList.vue' // 联系人列表
@@ -40,48 +58,86 @@ import ReceivableList from '@/views/crm/receivable/components/ReceivableList.vue
40
58
import ReceivablePlanList from ' @/views/crm/receivable/plan/components/ReceivablePlanList.vue' // 回款计划列表
41
59
import PermissionList from ' @/views/crm/permission/components/PermissionList.vue' // 团队成员列表(权限)
42
60
import { BizTypeEnum } from ' @/api/crm/permission'
43
- import { OperateLogV2VO } from ' @/api/system/operatelog'
61
+ import type { OperateLogV2VO } from ' @/api/system/operatelog'
44
62
45
63
defineOptions ({ name: ' CrmCustomerDetail' })
46
64
47
- const route = useRoute ()
48
- const id = Number (route .params .id ) // 客户编号
65
+ const customerId = ref (0 ) // 客户编号
49
66
const loading = ref (true ) // 加载中
67
+ const message = useMessage () // 消息弹窗
68
+ const { delView } = useTagsViewStore () // 视图操作
69
+ const { currentRoute, push } = useRouter () // 路由
50
70
/** 获取详情 */
51
71
const customer = ref <CustomerApi .CustomerVO >({} as CustomerApi .CustomerVO ) // 客户详情
52
- const getCustomer = async (id : number ) => {
72
+ const getCustomer = async () => {
53
73
loading .value = true
54
74
try {
55
- customer .value = await CustomerApi .getCustomer (id )
56
- await getOperateLog (id )
75
+ customer .value = await CustomerApi .getCustomer (customerId . value )
76
+ await getOperateLog ()
57
77
} finally {
58
78
loading .value = false
59
79
}
60
80
}
81
+ const formRef = ref <InstanceType <typeof CustomerForm >>() // 客户表单 Ref
82
+ // 编辑客户
83
+ const openForm = () => {
84
+ formRef .value ?.open (' update' , customerId .value )
85
+ }
86
+ // 客户转移
87
+ const transfer = () => {}
88
+ // 锁定客户
89
+ const handleLock = async () => {
90
+ await message .confirm (` 确定锁定客户【${customer .value .name }】 吗? ` )
91
+ await CustomerApi .lockCustomer (unref (customerId .value ), true )
92
+ message .success (` 锁定客户【${customer .value .name }】成功 ` )
93
+ await getCustomer ()
94
+ }
95
+ // 解锁客户
96
+ const handleUnlock = async () => {
97
+ await message .confirm (` 确定解锁客户【${customer .value .name }】 吗? ` )
98
+ await CustomerApi .lockCustomer (unref (customerId .value ), false )
99
+ message .success (` 解锁客户【${customer .value .name }】成功 ` )
100
+ await getCustomer ()
101
+ }
102
+ // 领取客户
103
+ const receive = async () => {
104
+ await message .confirm (` 确定领取客户【${customer .value .name }】 吗? ` )
105
+ await CustomerApi .receive ([unref (customerId .value )])
106
+ message .success (` 领取客户【${customer .value .name }】成功 ` )
107
+ await getCustomer ()
108
+ }
109
+ // 客户放入公海
110
+ const putPool = async () => {
111
+ await message .confirm (` 确定将客户【${customer .value .name }】放入公海吗? ` )
112
+ await CustomerApi .putPool (unref (customerId .value ))
113
+ message .success (` 客户【${customer .value .name }】放入公海成功 ` )
114
+ close ()
115
+ }
61
116
const logList = ref <OperateLogV2VO []>([]) // 操作日志列表
62
117
/**
63
118
* 获取操作日志
64
119
*/
65
- const getOperateLog = async (customerId : number ) => {
66
- if (! customerId ) {
120
+ const getOperateLog = async () => {
121
+ if (! customerId . value ) {
67
122
return
68
123
}
69
- const data = await CustomerApi .getOperateLogPage ({
70
- pageNo: 1 ,
71
- pageSize: 10 ,
72
- bizId: customerId
73
- })
124
+ const data = await CustomerApi .getOperateLogPage (customerId .value )
74
125
logList .value = data .list
75
126
}
127
+ const close = () => {
128
+ delView (unref (currentRoute ))
129
+ // TODO 先返回到客户列表
130
+ push ({ name: ' CrmCustomer' })
131
+ }
76
132
/** 初始化 */
77
- const { delView } = useTagsViewStore () // 视图操作
78
- const { currentRoute } = useRouter () // 路由
133
+ const { params } = useRoute ()
79
134
onMounted (() => {
80
- if (! id ) {
135
+ if (! params . id ) {
81
136
ElMessage .warning (' 参数错误,客户不能为空!' )
82
- delView ( unref ( currentRoute ) )
137
+ close ( )
83
138
return
84
139
}
85
- getCustomer (id )
140
+ customerId .value = params .id as unknown as number
141
+ getCustomer ()
86
142
})
87
143
</script >
0 commit comments