Skip to content

Commit 25665f5

Browse files
committed
✨ CRM:完善回款在合同、客户的引入
1 parent c5e5228 commit 25665f5

File tree

7 files changed

+58
-28
lines changed

7 files changed

+58
-28
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<ReceivablePlanList
2424
:contract-id="contract.id!"
2525
:customer-id="contract.customerId"
26-
@crate-receivable="crateReceivable"
26+
@create-receivable="createReceivable"
2727
/>
2828
<ReceivableList
2929
ref="receivableListRef"
@@ -108,8 +108,8 @@ const getOperateLog = async (contractId: number) => {
108108
109109
/** 从回款计划创建回款 */
110110
const receivableListRef = ref<InstanceType<typeof ReceivableList>>() // 回款列表 Ref
111-
const crateReceivable = (planData: any) => {
112-
receivableListRef.value?.crateReceivable(planData)
111+
const createReceivable = (planData: any) => {
112+
receivableListRef.value?.createReceivable(planData)
113113
}
114114
115115
/** 转移 */

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<ContractList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
6565
</el-tab-pane>
6666
<el-tab-pane label="回款" lazy>
67-
<ReceivablePlanList :customer-id="customer.id!" @crate-receivable="crateReceivable" />
67+
<ReceivablePlanList :customer-id="customer.id!" @create-receivable="createReceivable" />
6868
<ReceivableList ref="receivableListRef" :customer-id="customer.id!" />
6969
</el-tab-pane>
7070
<el-tab-pane label="操作日志">
@@ -199,8 +199,8 @@ const getOperateLog = async () => {
199199
200200
/** 从回款计划创建回款 */
201201
const receivableListRef = ref<InstanceType<typeof ReceivableList>>() // 回款列表 Ref
202-
const crateReceivable = (planData: any) => {
203-
receivableListRef.value?.crateReceivable(planData)
202+
const createReceivable = (planData: any) => {
203+
receivableListRef.value?.createReceivable(planData)
204204
}
205205
206206
const close = () => {

src/views/crm/receivable/ReceivableForm.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,14 @@ const open = async (
201201
// 从回款计划创建回款
202202
if (receivablePlan) {
203203
formData.value.customerId = receivablePlan.customerId
204+
await handleCustomerChange(receivablePlan.customerId)
204205
formData.value.contractId = receivablePlan.contractId
205-
formData.value.planId = receivablePlan.id
206-
formData.value.price = receivablePlan.price
207-
formData.value.returnType = receivablePlan.returnType
206+
await handleContractChange(receivablePlan.contractId)
207+
if (receivablePlan.id) {
208+
formData.value.planId = receivablePlan.id
209+
formData.value.price = receivablePlan.price
210+
formData.value.returnType = receivablePlan.returnType
211+
}
208212
}
209213
}
210214
defineExpose({ open }) // 提供 open 方法,用于打开弹窗

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<!-- 操作栏 -->
33
<el-row justify="end">
4-
<el-button @click="openForm">
4+
<el-button @click="openForm('create')">
55
<Icon class="mr-5px" icon="icon-park:income-one" />
66
创建回款
77
</el-button>
@@ -12,7 +12,7 @@
1212
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
1313
<el-table-column align="center" label="回款编号" prop="no" />
1414
<el-table-column align="center" label="客户" prop="customerName" />
15-
<el-table-column align="center" label="合同" prop="contractName" />
15+
<el-table-column align="center" label="合同" prop="contract.no" />
1616
<el-table-column
1717
:formatter="dateFormatter2"
1818
align="center"
@@ -25,7 +25,12 @@
2525
<dict-tag :type="DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE" :value="scope.row.returnType" />
2626
</template>
2727
</el-table-column>
28-
<el-table-column align="center" label="回款金额(元)" prop="price" />
28+
<el-table-column
29+
align="center"
30+
label="回款金额(元)"
31+
prop="price"
32+
:formatter="erpPriceTableColumnFormatter"
33+
/>
2934
<el-table-column align="center" label="负责人" prop="ownerUserName" />
3035
<el-table-column align="center" label="备注" prop="remark" />
3136
<el-table-column align="center" fixed="right" label="操作" width="130px">
@@ -67,6 +72,7 @@ import * as ReceivableApi from '@/api/crm/receivable'
6772
import ReceivableForm from './../ReceivableForm.vue'
6873
import { dateFormatter2 } from '@/utils/formatTime'
6974
import { DICT_TYPE } from '@/utils/dict'
75+
import { erpPriceTableColumnFormatter } from '@/utils'
7076
7177
defineOptions({ name: 'CrmReceivableList' })
7278
const props = defineProps<{
@@ -117,7 +123,10 @@ const handleQuery = () => {
117123
/** 添加/修改操作 */
118124
const formRef = ref()
119125
const openForm = (type: string, id?: number) => {
120-
formRef.value.open(type, id)
126+
formRef.value.open(type, id, {
127+
customerId: props.customerId,
128+
contractId: props.contractId
129+
})
121130
}
122131
123132
/** 删除按钮操作 */
@@ -134,11 +143,12 @@ const handleDelete = async (id: number) => {
134143
}
135144
136145
/** 从回款计划创建回款 */
137-
const crateReceivable = (planData: any) => {
146+
const createReceivable = (planData: any) => {
138147
const data = planData as unknown as ReceivablePlanApi.ReceivablePlanVO
139148
formRef.value.open('create', undefined, data)
140149
}
141-
defineExpose({ crateReceivable })
150+
defineExpose({ createReceivable })
151+
142152
/** 监听打开的 customerId + contractId,从而加载最新的列表 */
143153
watch(
144154
() => [props.customerId, props.contractId],

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ const close = () => {
8787
/** 初始化 */
8888
const { params } = useRoute()
8989
onMounted(async () => {
90-
if (!params.id) {
90+
const id = props.id || route.params.id
91+
if (!id) {
9192
message.warning('参数错误,回款不能为空!')
9293
close()
9394
return
9495
}
95-
receivableId.value = params.id as unknown as number
96+
receivableId.value = id
9697
await getReceivable(receivableId.value)
9798
})
9899
</script>

src/views/crm/receivable/plan/ReceivablePlanForm.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ import * as CustomerApi from '@/api/crm/customer'
136136
import * as ContractApi from '@/api/crm/contract'
137137
import { useUserStore } from '@/store/modules/user'
138138
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
139+
import { aw } from '../../../../../dist-prod/assets/index-9eac537b'
139140
140141
const { t } = useI18n() // 国际化
141142
const message = useMessage() // 消息弹窗
@@ -157,7 +158,7 @@ const customerList = ref<CustomerApi.CustomerVO[]>([]) // 客户列表
157158
const contractList = ref<ContractApi.ContractVO[]>([]) // 合同列表
158159
159160
/** 打开弹窗 */
160-
const open = async (type: string, id?: number) => {
161+
const open = async (type: string, id?: number, customerId?: number, contractId?: number) => {
161162
dialogVisible.value = true
162163
dialogTitle.value = t('action.' + type)
163164
formType.value = type
@@ -179,6 +180,14 @@ const open = async (type: string, id?: number) => {
179180
if (formType.value === 'create') {
180181
formData.value.ownerUserId = useUserStore().getUser.id
181182
}
183+
// 设置 customerId 和 contractId 默认值
184+
if (customerId) {
185+
formData.value.customerId = customerId
186+
await handleCustomerChange(customerId)
187+
}
188+
if (contractId) {
189+
formData.value.contractId = contractId
190+
}
182191
}
183192
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
184193

src/views/crm/receivable/plan/components/ReceivablePlanList.vue

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<!-- 操作栏 -->
33
<el-row justify="end">
4-
<el-button @click="openForm">
4+
<el-button @click="openForm('create', undefined)">
55
<Icon class="mr-5px" icon="icon-park:income" />
66
创建回款计划
77
</el-button>
@@ -13,7 +13,13 @@
1313
<el-table-column align="center" label="客户名称" prop="customerName" width="150px" />
1414
<el-table-column align="center" label="合同编号" prop="contractNo" width="200px" />
1515
<el-table-column align="center" label="期数" prop="period" />
16-
<el-table-column align="center" label="计划回款(元)" prop="price" width="120" />
16+
<el-table-column
17+
align="center"
18+
label="计划回款(元)"
19+
prop="price"
20+
width="120"
21+
:formatter="erpPriceTableColumnFormatter"
22+
/>
1723
<el-table-column
1824
:formatter="dateFormatter2"
1925
align="center"
@@ -37,7 +43,8 @@
3743
v-hasPermi="['crm:receivable:create']"
3844
link
3945
type="primary"
40-
@click="crateReceivable(scope.row)"
46+
@click="createReceivable(scope.row)"
47+
:disabled="scope.row.receivableId"
4148
>
4249
创建回款
4350
</el-button>
@@ -75,8 +82,8 @@
7582
<script lang="ts" setup>
7683
import * as ReceivablePlanApi from '@/api/crm/receivable/plan'
7784
import ReceivableForm from './../ReceivablePlanForm.vue'
78-
import { DICT_TYPE } from '@/utils/dict'
7985
import { dateFormatter2 } from '@/utils/formatTime'
86+
import { erpPriceTableColumnFormatter } from '@/utils'
8087
8188
defineOptions({ name: 'CrmReceivablePlanList' })
8289
const props = defineProps<{
@@ -127,16 +134,15 @@ const handleQuery = () => {
127134
/** 添加/修改操作 */
128135
const formRef = ref()
129136
const openForm = (type: string, id?: number) => {
130-
formRef.value.open(type, id)
137+
formRef.value.open(type, id, props.customerId, props.contractId)
131138
}
132139
133-
// todo @puhui999:拼写错误
140+
/** 创建回款 */
134141
const emits = defineEmits<{
135-
(e: 'crateReceivable', v: ReceivablePlanApi.ReceivablePlanVO)
142+
(e: 'createReceivable', v: ReceivablePlanApi.ReceivablePlanVO)
136143
}>()
137-
/** 创建回款 */
138-
const crateReceivable = (row: ReceivablePlanApi.ReceivablePlanVO) => {
139-
emits('crateReceivable', row)
144+
const createReceivable = (row: ReceivablePlanApi.ReceivablePlanVO) => {
145+
emits('createReceivable', row)
140146
}
141147
142148
/** 删除按钮操作 */

0 commit comments

Comments
 (0)