9
9
10
10
<!-- 列表 -->
11
11
<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" />
21
16
<el-table-column
22
- label = " 回款金额(元) "
17
+ :formatter = " dateFormatter2 "
23
18
align =" center"
24
- prop =" price"
25
- :formatter =" fenToYuanFormat"
19
+ label =" 回款日期"
20
+ prop =" returnTime"
21
+ width =" 150px"
26
22
/>
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" >
29
24
<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 >
31
49
</template >
32
50
</el-table-column >
33
- <el-table-column
34
- label =" 回款日期"
35
- align =" center"
36
- prop =" returnTime"
37
- :formatter =" dateFormatter"
38
- width =" 180px"
39
- />
40
51
</el-table >
41
52
<!-- 分页 -->
42
53
<Pagination
43
- :total =" total"
44
- v-model:page =" queryParams.pageNo"
45
54
v-model:limit =" queryParams.pageSize"
55
+ v-model:page =" queryParams.pageNo"
56
+ :total =" total"
46
57
@pagination =" getList"
47
58
/>
48
59
</ContentWrap >
49
60
50
61
<!-- 表单弹窗:添加 -->
51
62
<ReceivableForm ref =" formRef" @success =" getList" />
52
63
</template >
53
- <script setup lang="ts">
64
+ <script lang="ts" setup>
65
+ import * as ReceivablePlanApi from ' @/api/crm/receivable/plan'
54
66
import * as ReceivableApi from ' @/api/crm/receivable'
55
67
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'
59
69
import { DICT_TYPE } from ' @/utils/dict'
60
70
61
71
defineOptions ({ name: ' CrmReceivableList' })
62
72
const props = defineProps <{
63
- bizType : number // 业务类型
64
- bizId : number // 业务编号
73
+ customerId ? : number // 客户编号
74
+ contractId ? : number // 合同编号
65
75
}>()
66
76
77
+ const message = useMessage () // 消息弹窗
78
+ const { t } = useI18n () // 国际化
67
79
const loading = ref (true ) // 列表的加载中
68
80
const total = ref (0 ) // 列表的总页数
69
81
const list = ref ([]) // 列表的数据
70
82
const queryParams = reactive ({
71
83
pageNo: 1 ,
72
84
pageSize: 10 ,
73
- customerId: undefined as unknown // 允许 undefined + number
85
+ customerId: undefined as unknown , // 允许 undefined + number
86
+ contractId: undefined as unknown // 允许 undefined + number
74
87
})
75
88
76
89
/** 查询列表 */
77
90
const getList = async () => {
78
91
loading .value = true
79
92
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
91
99
}
100
+ const data = await ReceivableApi .getReceivablePageByCustomer (queryParams )
92
101
list .value = data .list
93
102
total .value = data .total
94
103
} finally {
@@ -99,25 +108,45 @@ const getList = async () => {
99
108
/** 搜索按钮操作 */
100
109
const handleQuery = () => {
101
110
queryParams .pageNo = 1
111
+ // 置空参数
112
+ queryParams .customerId = undefined
113
+ queryParams .contractId = undefined
102
114
getList ()
103
115
}
104
116
105
- /** 添加 */
117
+ /** 添加/修改操作 */
106
118
const formRef = ref ()
107
- const openForm = () => {
108
- formRef .value .open (' create ' )
119
+ const openForm = (type : string , id ? : number ) => {
120
+ formRef .value .open (type , id )
109
121
}
110
122
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 {}
115
134
}
116
135
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,从而加载最新的列表 */
118
143
watch (
119
- () => [props .bizId , props .bizType ],
120
- () => {
144
+ () => [props .customerId , props .contractId ],
145
+ (newVal ) => {
146
+ // 保证至少客户编号有值
147
+ if (! newVal [0 ]) {
148
+ return
149
+ }
121
150
handleQuery ()
122
151
},
123
152
{ immediate: true , deep: true }
0 commit comments