Skip to content

Commit e951ed1

Browse files
committed
✨ ERP:完成 payment 付款单的逻辑 100%
1 parent 8a70b3f commit e951ed1

File tree

3 files changed

+234
-6
lines changed

3 files changed

+234
-6
lines changed

src/views/erp/finance/payment/components/FinancePaymentItemForm.vue

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
<el-input-number
3838
v-model="row.paymentPrice"
3939
controls-position="right"
40-
:min="0"
4140
:precision="2"
4241
class="!w-100%"
4342
/>
@@ -60,20 +59,28 @@
6059
</el-form>
6160
<el-row justify="center" class="mt-3" v-if="!disabled">
6261
<el-button @click="handleOpenPurchaseIn" round>+ 添加采购入库单</el-button>
63-
<el-button @click="handleAdd" round>+ 添加采购退货单</el-button>
62+
<el-button @click="handleOpenPurchaseReturn" round>+ 添加采购退货单</el-button>
6463
</el-row>
6564

65+
<!-- 可付款的【采购入库单】列表 -->
6666
<PurchaseInPaymentEnableList
6767
ref="purchaseInPaymentEnableListRef"
6868
@success="handleAddPurchaseIn"
6969
/>
70+
<!-- 可付款的【采购入库单】列表 -->
71+
<PurchaseReturnRefundEnableList
72+
ref="purchaseReturnRefundEnableListRef"
73+
@success="handleAddPurchaseReturn"
74+
/>
7075
</template>
7176
<script setup lang="ts">
7277
import { ProductVO } from '@/api/erp/product/product'
7378
import { erpPriceInputFormatter, getSumValue } from '@/utils'
7479
import PurchaseInPaymentEnableList from '@/views/erp/purchase/in/components/PurchaseInPaymentEnableList.vue'
80+
import PurchaseReturnRefundEnableList from '@/views/erp/purchase/return/components/PurchaseReturnRefundEnableList.vue'
7581
import { PurchaseInVO } from '@/api/erp/purchase/in'
7682
import { ErpBizType } from '@/utils/constants'
83+
import { PurchaseReturnVO } from '@/api/erp/purchase/return'
7784
7885
const props = defineProps<{
7986
items: undefined
@@ -115,7 +122,6 @@ const getSummaries = (param: SummaryMethodProps) => {
115122
sums[index] = ''
116123
}
117124
})
118-
119125
return sums
120126
}
121127
@@ -141,6 +147,28 @@ const handleAddPurchaseIn = (rows: PurchaseInVO[]) => {
141147
})
142148
}
143149
150+
/** 新增【采购退货】按钮操作 */
151+
const purchaseReturnRefundEnableListRef = ref()
152+
const handleOpenPurchaseReturn = () => {
153+
if (!props.supplierId) {
154+
message.error('请选择供应商')
155+
return
156+
}
157+
purchaseReturnRefundEnableListRef.value.open(props.supplierId)
158+
}
159+
const handleAddPurchaseReturn = (rows: PurchaseReturnVO[]) => {
160+
rows.forEach((row) => {
161+
formData.value.push({
162+
bizId: row.id,
163+
bizType: ErpBizType.PURCHASE_RETURN,
164+
bizNo: row.no,
165+
totalPrice: -row.totalPrice,
166+
paidPrice: -row.refundPrice,
167+
paymentPrice: -row.totalPrice + row.refundPrice
168+
})
169+
})
170+
}
171+
144172
/** 删除按钮操作 */
145173
const handleDelete = (index: number) => {
146174
formData.value.splice(index, 1)

src/views/erp/finance/payment/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ const handleDelete = async (ids: number[]) => {
334334
// 删除的二次确认
335335
await message.delConfirm()
336336
// 发起删除
337-
await FinancePaymentApi.deletePurchaseOrder(ids)
337+
await FinancePaymentApi.deleteFinancePayment(ids)
338338
message.success(t('common.delSuccess'))
339339
// 刷新列表
340340
await getList()
@@ -348,7 +348,7 @@ const handleUpdateStatus = async (id: number, status: number) => {
348348
// 审批的二次确认
349349
await message.confirm(`确定${status === 20 ? '审批' : '反审批'}该付款单吗?`)
350350
// 发起审批
351-
await FinancePaymentApi.updatePurchaseOrderStatus(id, status)
351+
await FinancePaymentApi.updateFinancePaymentStatus(id, status)
352352
message.success(`${status === 20 ? '审批' : '反审批'}成功`)
353353
// 刷新列表
354354
await getList()
@@ -362,7 +362,7 @@ const handleExport = async () => {
362362
await message.exportConfirm()
363363
// 发起导出
364364
exportLoading.value = true
365-
const data = await FinancePaymentApi.exportPurchaseOrder(queryParams)
365+
const data = await FinancePaymentApi.exportFinancePayment(queryParams)
366366
download.excel(data, '付款单.xls')
367367
} catch {
368368
} finally {
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
<!-- 可退款的采购退货单列表 -->
2+
<template>
3+
<Dialog
4+
title="选择采购退货(仅展示可退款)"
5+
v-model="dialogVisible"
6+
:appendToBody="true"
7+
:scroll="true"
8+
width="1080"
9+
>
10+
<ContentWrap>
11+
<!-- 搜索工作栏 -->
12+
<el-form
13+
class="-mb-15px"
14+
:model="queryParams"
15+
ref="queryFormRef"
16+
:inline="true"
17+
label-width="68px"
18+
>
19+
<el-form-item label="退货单号" prop="no">
20+
<el-input
21+
v-model="queryParams.no"
22+
placeholder="请输入退货单号"
23+
clearable
24+
@keyup.enter="handleQuery"
25+
class="!w-160px"
26+
/>
27+
</el-form-item>
28+
<el-form-item label="产品" prop="productId">
29+
<el-select
30+
v-model="queryParams.productId"
31+
clearable
32+
filterable
33+
placeholder="请选择产品"
34+
class="!w-160px"
35+
>
36+
<el-option
37+
v-for="item in productList"
38+
:key="item.id"
39+
:label="item.name"
40+
:value="item.id"
41+
/>
42+
</el-select>
43+
</el-form-item>
44+
<el-form-item label="退货时间" prop="orderTime">
45+
<el-date-picker
46+
v-model="queryParams.inTime"
47+
value-format="YYYY-MM-DD HH:mm:ss"
48+
type="daterange"
49+
start-placeholder="开始日期"
50+
end-placeholder="结束日期"
51+
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
52+
class="!w-160px"
53+
/>
54+
</el-form-item>
55+
<el-form-item>
56+
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
57+
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
58+
</el-form-item>
59+
</el-form>
60+
</ContentWrap>
61+
62+
<ContentWrap>
63+
<el-table
64+
v-loading="loading"
65+
:data="list"
66+
:show-overflow-tooltip="true"
67+
:stripe="true"
68+
@selection-change="handleSelectionChange"
69+
>
70+
<el-table-column width="30" label="选择" type="selection" />
71+
<el-table-column min-width="180" label="退货单号" align="center" prop="no" />
72+
<el-table-column label="供应商" align="center" prop="supplierName" />
73+
<el-table-column label="产品信息" align="center" prop="productNames" min-width="200" />
74+
<el-table-column
75+
label="退货时间"
76+
align="center"
77+
prop="returnTime"
78+
:formatter="dateFormatter2"
79+
width="120px"
80+
/>
81+
<el-table-column label="创建人" align="center" prop="creatorName" />
82+
<el-table-column
83+
label="应退金额"
84+
align="center"
85+
prop="totalPrice"
86+
:formatter="erpPriceTableColumnFormatter"
87+
/>
88+
<el-table-column
89+
label="已退金额"
90+
align="center"
91+
prop="refundPrice"
92+
:formatter="erpPriceTableColumnFormatter"
93+
/>
94+
<el-table-column label="未退金额" align="center">
95+
<template #default="scope">
96+
<span v-if="scope.row.refundPrice === scope.row.totalPrice">0</span>
97+
<el-tag type="danger" v-else>
98+
{{ erpPriceInputFormatter(scope.row.totalPrice - scope.row.refundPrice) }}
99+
</el-tag>
100+
</template>
101+
</el-table-column>
102+
</el-table>
103+
<!-- 分页 -->
104+
<Pagination
105+
v-model:limit="queryParams.pageSize"
106+
v-model:page="queryParams.pageNo"
107+
:total="total"
108+
@pagination="getList"
109+
/>
110+
</ContentWrap>
111+
<template #footer>
112+
<el-button :disabled="!selectionList.length" type="primary" @click="submitForm">
113+
确 定
114+
</el-button>
115+
<el-button @click="dialogVisible = false">取 消</el-button>
116+
</template>
117+
</Dialog>
118+
</template>
119+
<script lang="ts" setup>
120+
import { ElTable } from 'element-plus'
121+
import { dateFormatter2 } from '@/utils/formatTime'
122+
import { erpPriceInputFormatter, erpPriceTableColumnFormatter } from '@/utils'
123+
import { ProductApi, ProductVO } from '@/api/erp/product/product'
124+
import { PurchaseReturnApi, PurchaseReturnVO } from '@/api/erp/purchase/return'
125+
import { PurchaseInVO } from '@/api/erp/purchase/in'
126+
127+
defineOptions({ name: 'PurchaseInPaymentEnableList' })
128+
129+
const list = ref<PurchaseReturnVO[]>([]) // 列表的数据
130+
const total = ref(0) // 列表的总页数
131+
const loading = ref(false) // 列表的加载中
132+
const dialogVisible = ref(false) // 弹窗的是否展示
133+
const queryParams = reactive({
134+
pageNo: 1,
135+
pageSize: 10,
136+
no: undefined,
137+
productId: undefined,
138+
inTime: [],
139+
refundEnable: true,
140+
supplierId: undefined
141+
})
142+
const queryFormRef = ref() // 搜索的表单
143+
const productList = ref<ProductVO[]>([]) // 产品列表
144+
145+
/** 选中操作 */
146+
const selectionList = ref<PurchaseInVO[]>([])
147+
const handleSelectionChange = (rows: PurchaseInVO[]) => {
148+
selectionList.value = rows
149+
}
150+
151+
/** 打开弹窗 */
152+
const open = async (supplierId: number) => {
153+
dialogVisible.value = true
154+
await nextTick() // 等待,避免 queryFormRef 为空
155+
// 加载列表
156+
queryParams.supplierId = supplierId
157+
await resetQuery()
158+
// 加载产品列表
159+
productList.value = await ProductApi.getProductSimpleList()
160+
}
161+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
162+
163+
/** 提交选择 */
164+
const emits = defineEmits<{
165+
(e: 'success', value: PurchaseInVO[]): void
166+
}>()
167+
const submitForm = () => {
168+
try {
169+
emits('success', selectionList.value)
170+
} finally {
171+
// 关闭弹窗
172+
dialogVisible.value = false
173+
}
174+
}
175+
176+
/** 加载列表 */
177+
const getList = async () => {
178+
loading.value = true
179+
try {
180+
const data = await PurchaseReturnApi.getPurchaseReturnPage(queryParams)
181+
list.value = data.list
182+
total.value = data.total
183+
} finally {
184+
loading.value = false
185+
}
186+
}
187+
188+
/** 重置按钮操作 */
189+
const resetQuery = () => {
190+
queryFormRef.value.resetFields()
191+
handleQuery()
192+
}
193+
194+
/** 搜索按钮操作 */
195+
const handleQuery = () => {
196+
queryParams.pageNo = 1
197+
selectionList.value = []
198+
getList()
199+
}
200+
</script>

0 commit comments

Comments
 (0)