Skip to content

Commit 174724d

Browse files
author
puhui999
committed
CRM:完善回款集成客户详情和合同详情
1 parent d9e1ffd commit 174724d

File tree

7 files changed

+223
-118
lines changed

7 files changed

+223
-118
lines changed

src/views/crm/contract/detail/index.vue

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,18 @@
1919
<el-tab-pane label="产品">
2020
<ContractProductList :contract="contract" />
2121
</el-tab-pane>
22-
<!-- TODO @puhui999:回款信息 -->
23-
<el-tab-pane label="回款"> 123 </el-tab-pane>
22+
<el-tab-pane label="回款">
23+
<ReceivablePlanList
24+
:contract-id="contract.id!"
25+
:customer-id="contract.customerId"
26+
@crate-receivable="crateReceivable"
27+
/>
28+
<ReceivableList
29+
ref="receivableListRef"
30+
:contract-id="contract.id!"
31+
:customer-id="contract.customerId"
32+
/>
33+
</el-tab-pane>
2434
<el-tab-pane label="团队成员">
2535
<PermissionList
2636
ref="permissionListRef"
@@ -53,6 +63,8 @@ import ContractForm from '@/views/crm/contract/ContractForm.vue'
5363
import CrmTransferForm from '@/views/crm/permission/components/TransferForm.vue'
5464
import PermissionList from '@/views/crm/permission/components/PermissionList.vue'
5565
import FollowUpList from '@/views/crm/followup/index.vue'
66+
import ReceivableList from '@/views/crm/receivable/components/ReceivableList.vue'
67+
import ReceivablePlanList from '@/views/crm/receivable/plan/components/ReceivablePlanList.vue'
5668
5769
defineOptions({ name: 'CrmContractDetail' })
5870
const props = defineProps<{ id?: number }>()
@@ -94,8 +106,14 @@ const getOperateLog = async (contractId: number) => {
94106
logList.value = data.list
95107
}
96108
109+
/** 从回款计划创建回款 */
110+
const receivableListRef = ref<InstanceType<typeof ReceivableList>>() // 回款列表 Ref
111+
const crateReceivable = (planData: any) => {
112+
receivableListRef.value?.crateReceivable(planData)
113+
}
114+
97115
/** 转移 */
98-
// TODO @puhui999:这个组件,要不传递业务类型,然后组件里判断 title 和 api 能调用哪个;整体治理掉;
116+
// TODO @puhui999:这个组件,要不传递业务类型,然后组件里判断 title 和 api 能调用哪个;整体治理掉;好呢
99117
const transferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // 合同转移表单 ref
100118
const transferContract = () => {
101119
transferFormRef.value?.open('合同转移', contract.value.id, ContractApi.transferContract)

src/views/crm/customer/detail/index.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
>
2727
锁定
2828
</el-button>
29-
<el-button v-if="!customer.ownerUserId" type="primary" @click="handleReceive"> 领取 </el-button>
29+
<el-button v-if="!customer.ownerUserId" type="primary" @click="handleReceive"> 领取</el-button>
3030
<el-button v-if="!customer.ownerUserId" type="primary" @click="handleDistributeForm">
3131
分配
3232
</el-button>
@@ -64,8 +64,8 @@
6464
<ContractList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
6565
</el-tab-pane>
6666
<el-tab-pane label="回款" lazy>
67-
<ReceivablePlanList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
68-
<ReceivableList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
67+
<ReceivablePlanList :customer-id="customer.id!" @crate-receivable="crateReceivable" />
68+
<ReceivableList ref="receivableListRef" :customer-id="customer.id!" />
6969
</el-tab-pane>
7070
<el-tab-pane label="操作日志">
7171
<OperateLogV2 :log-list="logList" />
@@ -197,6 +197,12 @@ const getOperateLog = async () => {
197197
logList.value = data.list
198198
}
199199
200+
/** 从回款计划创建回款 */
201+
const receivableListRef = ref<InstanceType<typeof ReceivableList>>() // 回款列表 Ref
202+
const crateReceivable = (planData: any) => {
203+
receivableListRef.value?.crateReceivable(planData)
204+
}
205+
200206
const close = () => {
201207
delView(unref(currentRoute))
202208
push({ name: 'CrmCustomer' })

src/views/crm/receivable/ReceivableForm.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,8 @@ const formRef = ref() // 表单 Ref
150150
const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
151151
const contractList = ref<ContractApi.ContractVO[]>([]) // 合同列表
152152
const receivablePlanList = ref<ReceivablePlanApi.ReceivablePlanVO[]>([]) // 回款计划列表
153-
154153
/** 打开弹窗 */
155-
const open = async (type: string, id?: number) => {
154+
const open = async (type: string, id?: number, planData?: ReceivablePlanApi.ReceivablePlanVO) => {
156155
dialogVisible.value = true
157156
dialogTitle.value = t('action.' + type)
158157
formType.value = type
@@ -174,6 +173,12 @@ const open = async (type: string, id?: number) => {
174173
if (formType.value === 'create') {
175174
formData.value.ownerUserId = useUserStore().getUser.id
176175
}
176+
// 从回款计划创建回款
177+
if (planData) {
178+
formData.value.customerId = planData.customerId
179+
formData.value.contractId = planData.contractId
180+
formData.value.planId = planData.id
181+
}
177182
}
178183
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
179184
@@ -249,9 +254,12 @@ watch(
249254
return
250255
}
251256
const receivablePlan = receivablePlanList.value.find((item) => item.id === newVal)
257+
if (!receivablePlan) {
258+
return
259+
}
252260
// 只有没有金额的时候才设置
253261
if (!formData.value.price || formData.value.price === 0) {
254-
formData.value.price = receivablePlan!.price
262+
formData.value.price = receivablePlan.price
255263
}
256264
}
257265
)

src/views/crm/receivable/components/ReceivableList.vue

Lines changed: 81 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,86 +9,95 @@
99

1010
<!-- 列表 -->
1111
<ContentWrap class="mt-10px">
12-
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
13-
<el-table-column label="回款编号" fixed="left" align="center" prop="no">
14-
<template #default="scope">
15-
<el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
16-
{{ scope.row.no }}
17-
</el-link>
18-
</template>
19-
</el-table-column>
20-
<el-table-column label="合同编号" align="center" prop="contractNo" />
12+
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
13+
<el-table-column align="center" label="回款编号" prop="no" />
14+
<el-table-column align="center" label="客户" prop="customerName" />
15+
<el-table-column align="center" label="合同" prop="contractName" />
2116
<el-table-column
22-
label="回款金额(元)"
17+
:formatter="dateFormatter2"
2318
align="center"
24-
prop="price"
25-
:formatter="fenToYuanFormat"
19+
label="回款日期"
20+
prop="returnTime"
21+
width="150px"
2622
/>
27-
<el-table-column label="负责人" align="center" prop="ownerUserName" />
28-
<el-table-column align="center" label="状态" prop="auditStatus">
23+
<el-table-column align="center" label="回款方式" prop="returnType" width="130px">
2924
<template #default="scope">
30-
<dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
25+
<dict-tag :type="DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE" :value="scope.row.returnType" />
26+
</template>
27+
</el-table-column>
28+
<el-table-column align="center" label="回款金额(元)" prop="price" />
29+
<el-table-column align="center" label="负责人" prop="ownerUserName" />
30+
<el-table-column align="center" label="备注" prop="remark" />
31+
<el-table-column align="center" fixed="right" label="操作" width="130px">
32+
<template #default="scope">
33+
<el-button
34+
v-hasPermi="['crm:receivable:update']"
35+
link
36+
type="primary"
37+
@click="openForm('update', scope.row.id)"
38+
>
39+
编辑
40+
</el-button>
41+
<el-button
42+
v-hasPermi="['crm:receivable:delete']"
43+
link
44+
type="danger"
45+
@click="handleDelete(scope.row.id)"
46+
>
47+
删除
48+
</el-button>
3149
</template>
3250
</el-table-column>
33-
<el-table-column
34-
label="回款日期"
35-
align="center"
36-
prop="returnTime"
37-
:formatter="dateFormatter"
38-
width="180px"
39-
/>
4051
</el-table>
4152
<!-- 分页 -->
4253
<Pagination
43-
:total="total"
44-
v-model:page="queryParams.pageNo"
4554
v-model:limit="queryParams.pageSize"
55+
v-model:page="queryParams.pageNo"
56+
:total="total"
4657
@pagination="getList"
4758
/>
4859
</ContentWrap>
4960

5061
<!-- 表单弹窗:添加 -->
5162
<ReceivableForm ref="formRef" @success="getList" />
5263
</template>
53-
<script setup lang="ts">
64+
<script lang="ts" setup>
65+
import * as ReceivablePlanApi from '@/api/crm/receivable/plan'
5466
import * as ReceivableApi from '@/api/crm/receivable'
5567
import ReceivableForm from './../ReceivableForm.vue'
56-
import { BizTypeEnum } from '@/api/crm/permission'
57-
import { dateFormatter } from '@/utils/formatTime'
58-
import { fenToYuanFormat } from '@/utils/formatter'
68+
import { dateFormatter2 } from '@/utils/formatTime'
5969
import { DICT_TYPE } from '@/utils/dict'
6070
6171
defineOptions({ name: 'CrmReceivableList' })
6272
const props = defineProps<{
63-
bizType: number // 业务类型
64-
bizId: number // 业务编号
73+
customerId?: number // 客户编号
74+
contractId?: number // 合同编号
6575
}>()
6676
77+
const message = useMessage() // 消息弹窗
78+
const { t } = useI18n() // 国际化
6779
const loading = ref(true) // 列表的加载中
6880
const total = ref(0) // 列表的总页数
6981
const list = ref([]) // 列表的数据
7082
const queryParams = reactive({
7183
pageNo: 1,
7284
pageSize: 10,
73-
customerId: undefined as unknown // 允许 undefined + number
85+
customerId: undefined as unknown, // 允许 undefined + number
86+
contractId: undefined as unknown // 允许 undefined + number
7487
})
7588
7689
/** 查询列表 */
7790
const getList = async () => {
7891
loading.value = true
7992
try {
80-
// 置空参数
81-
queryParams.customerId = undefined
82-
// 执行查询
83-
let data = { list: [], total: 0 }
84-
switch (props.bizType) {
85-
case BizTypeEnum.CRM_CUSTOMER:
86-
queryParams.customerId = props.bizId
87-
data = await ReceivableApi.getReceivablePageByCustomer(queryParams)
88-
break
89-
default:
90-
return
93+
if (props.customerId && !props.contractId) {
94+
queryParams.customerId = props.customerId
95+
} else if (props.customerId && props.contractId) {
96+
// 如果是合同的话客户编号也需要带上因为权限基于客户
97+
queryParams.customerId = props.customerId
98+
queryParams.contractId = props.contractId
9199
}
100+
const data = await ReceivableApi.getReceivablePageByCustomer(queryParams)
92101
list.value = data.list
93102
total.value = data.total
94103
} finally {
@@ -99,25 +108,45 @@ const getList = async () => {
99108
/** 搜索按钮操作 */
100109
const handleQuery = () => {
101110
queryParams.pageNo = 1
111+
// 置空参数
112+
queryParams.customerId = undefined
113+
queryParams.contractId = undefined
102114
getList()
103115
}
104116
105-
/** 添加 */
117+
/** 添加/修改操作 */
106118
const formRef = ref()
107-
const openForm = () => {
108-
formRef.value.open('create')
119+
const openForm = (type: string, id?: number) => {
120+
formRef.value.open(type, id)
109121
}
110122
111-
/** 打开合同详情 */
112-
const { push } = useRouter()
113-
const openDetail = (id: number) => {
114-
push({ name: 'CrmReceivableDetail', params: { id } })
123+
/** 删除按钮操作 */
124+
const handleDelete = async (id: number) => {
125+
try {
126+
// 删除的二次确认
127+
await message.delConfirm()
128+
// 发起删除
129+
await ReceivableApi.deleteReceivable(id)
130+
message.success(t('common.delSuccess'))
131+
// 刷新列表
132+
await getList()
133+
} catch {}
115134
}
116135
117-
/** 监听打开的 bizId + bizType,从而加载最新的列表 */
136+
/** 从回款计划创建回款 */
137+
const crateReceivable = (planData: any) => {
138+
const data = planData as unknown as ReceivablePlanApi.ReceivablePlanVO
139+
formRef.value.open('create', undefined, data)
140+
}
141+
defineExpose({ crateReceivable })
142+
/** 监听打开的 customerId + contractId,从而加载最新的列表 */
118143
watch(
119-
() => [props.bizId, props.bizType],
120-
() => {
144+
() => [props.customerId, props.contractId],
145+
(newVal) => {
146+
// 保证至少客户编号有值
147+
if (!newVal[0]) {
148+
return
149+
}
121150
handleQuery()
122151
},
123152
{ immediate: true, deep: true }

src/views/crm/receivable/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</template>
8484
</el-table-column>
8585
<el-table-column align="center" label="回款金额(元)" prop="price" />
86-
<el-table-column align="center" label="负责人" prop="ownerUserId" />
86+
<el-table-column align="center" label="负责人" prop="ownerUserName" />
8787
<el-table-column align="center" label="备注" prop="remark" />
8888
<el-table-column align="center" fixed="right" label="回款状态" prop="auditStatus" width="120">
8989
<template #default="scope">

0 commit comments

Comments
 (0)