feat(finance): 优化付款单新增功能及界面交互

- 移除预付单类型切换时的冗余处理逻辑
- 修复付款状态字典引用错误,统一使用 dict.type.payment_status
- 预付订单列表增加选择控制,限制只能选中一个订单
- 表格组件添加 ref 引用以便手动清除选中状态
- 新增预计付款时间必填校验规则
- 提交数据结构调整,明确区分应付单与预付单字段
- 增加含税总价大于0的前置校验
- 日志提示优化,增强用户操作引导信息
- 接口调用分离,针对不同付款类型调用对应后端接口
- 回执单组件默认值调整,避免空对象异常
dev_1.0.0
chenhao 2025-12-15 14:59:27 +08:00
parent a4a93ee484
commit 49cd27c221
5 changed files with 89 additions and 29 deletions

View File

@ -51,7 +51,7 @@ export function returnPayment(id) {
}
// 新增付款单
export function addPayment(data) {
export function addPaymentFromPayable(data) {
return request({
url: '/finance/payable/mergeAndInitiatePayment',
method: 'post',
@ -59,6 +59,14 @@ export function addPayment(data) {
needLoading: true
})
}
export function addPayment(data) {
return request({
url: '/finance/payment/add',
method: 'post',
data: data,
needLoading: true
})
}
// 申请付款
export function applyPaymentApi(data) {

View File

@ -33,7 +33,7 @@
<el-row>
<el-col :span="24">
<el-form-item label="是否预付" prop="paymentBillType">
<el-radio-group v-model="form.paymentBillType" @change="handleTypeChange">
<el-radio-group v-model="form.paymentBillType">
<el-radio label="PRE_PAYMENT"></el-radio>
<el-radio label="FROM_PAYABLE"></el-radio>
</el-radio-group>
@ -54,6 +54,7 @@
<div v-if="form.paymentBillType === 'FROM_PAYABLE'" class="table-container">
<h4>应付单列表</h4>
<el-table
ref="payableTable"
:data="payableList"
border
style="width: 100%"
@ -71,7 +72,7 @@
<el-table-column label="出入库单号" align="center" prop="inventoryCode" width="150"/>
<el-table-column label="付款状态" align="center" prop="paymentStatus" width="120">
<template slot-scope="scope">
<dict-tag :options="dicts.payment_status" :value="scope.row.paymentStatus"/>
<dict-tag :options="dict.type.payment_status" :value="scope.row.paymentStatus"/>
</template>
</el-table-column>
<el-table-column label="含税总价" align="center" prop="totalPriceWithTax" width="120"/>
@ -105,12 +106,15 @@
<div v-if="form.paymentBillType === 'PRE_PAYMENT'" class="table-container">
<h4>订单列表</h4>
<el-table
ref="orderTable"
:data="orderList"
border
style="width: 100%"
@selection-change="handleSelectionChange"
@select="handleSelect"
@select-all="handleSelectAll"
max-height="400"
row-key="orderNo"
row-key="id"
>
<el-table-column type="selection" width="55" reserve-selection></el-table-column>
<el-table-column prop="projectCode" label="项目编号"></el-table-column>
@ -138,11 +142,11 @@
</el-form>
<div slot="footer" class="dialog-footer">
<div v-if="form.paymentBillType === 'FROM_PAYABLE'" style="float: left; line-height: 36px;">
<span style="margin-right: 20px;">计划付款总金额: <el-tag type="success">{{
totalPlannedAmount.toFixed(2)
}}</el-tag></span>
</div>
<!-- <div v-if="form.paymentBillType === 'FROM_PAYABLE'" style="float: left; line-height: 36px;">-->
<!-- <span style="margin-right: 20px;">计划付款总金额: <el-tag type="success">{{-->
<!-- totalPlannedAmount.toFixed(2)-->
<!-- }}</el-tag></span>-->
<!-- </div>-->
<el-button @click="handleClose"> </el-button>
<el-button type="primary" @click="handleSubmit"> </el-button>
</div>
@ -202,6 +206,7 @@ export default {
},
rules: {
vendorCode: [{required: true, message: "制造商名称不能为空", trigger: "change"}],
estimatedPaymentTime: [{required: true, message: "预计付款时间不能为空", trigger: "change"}],
paymentBillType: [{required: true, message: "请选择是否预付", trigger: "change"}],
totalPriceWithTax: [{required: false, message: "预付金额不能为空", trigger: "blur"}]
},
@ -263,11 +268,6 @@ export default {
this.selectedRows = [];
this.loadTableData();
},
handleTypeChange() {
this.queryParams.pageNum = 1;
this.selectedRows = []; // Clear selection when switching type
this.loadTableData();
},
loadTableData() {
if (!this.form.vendorCode) return;
@ -277,7 +277,6 @@ export default {
const query = {
vendorCode: this.form.vendorCode,
orderStatus:'2',
pageNum: this.queryParams.pageNum,
pageSize: this.queryParams.pageSize
};
@ -305,11 +304,35 @@ export default {
this.total = res.total;
});
} else if (this.form.paymentBillType === 'PRE_PAYMENT') {
query.orderStatus = '2';
listOrders(query).then(res => {
this.orderList = res.rows || [];
this.total = res.total;
});
}
this.$nextTick(() => {
if (this.$refs.payableTable) {
this.$refs.payableTable.clearSelection()
}
if (this.$refs.orderTable) {
this.$refs.orderTable.clearSelection()
}
})
},
handleSelect(selection, row) {
if (this.form.paymentBillType === 'PRE_PAYMENT') {
this.$refs.orderTable.clearSelection();
const isSelected = selection.some(item => item.orderCode === row.orderCode);
if (isSelected) {
this.$refs.orderTable.toggleRowSelection(row, true);
}
}
},
handleSelectAll(selection) {
if (this.form.paymentBillType === 'PRE_PAYMENT') {
this.$refs.orderTable.clearSelection();
this.$modal.msgWarning("预付单只能选择一个订单");
}
},
handleSelectionChange(selection) {
this.selectedRows = selection;
@ -396,10 +419,26 @@ export default {
} else {
// Prepayment logic
console.log(this.selectedRows)
if (this.selectedRows.length > 1) {
this.$modal.msgWarning("只能选择一笔订单");
return;
}
if ((this.form.totalPriceWithTax ||0) <= 0) {
this.$message.warning("含税总价需要大于0");
return;
}
let order = this.selectedRows[0] ?? {};
const submitData = {
...this.form,
details: this.selectedRows
paymentBillType: 'PRE_PAYMENT',
orderCode: order.orderCode,
vendorCode: this.form.vendorCode,
projectCode:order.projectCode,
projectName:order.projectName,
paymentTime: this.form.estimatedPaymentTime,
totalPriceWithTax:this.form.totalPriceWithTax
};
console.log(submitData)
this.$emit("submit", submitData);
}
}

View File

@ -174,7 +174,7 @@ export default {
},
paymentData: {
type: Object,
default: () => null,
default: () => {},
},
dicts: {
type: Object,

View File

@ -256,7 +256,7 @@
</template>
<script>
import { listPayment, getPayment, returnPayment, addPayment, applyPaymentApi, applyRefund } from "@/api/finance/payment";
import { listPayment, getPayment, returnPayment, addPaymentFromPayable, applyPaymentApi, applyRefund,addPayment } from "@/api/finance/payment";
import { addDateRange } from "@/utils/ruoyi";
import DetailDrawer from "./components/DetailDrawer.vue";
import AddForm from "./components/AddForm.vue";
@ -306,7 +306,7 @@ export default {
addOpen: false,
//
receiptOpen: false,
currentRow: null,
currentRow: {},
//
applyPaymentOpen: false,
applyPaymentForm: {},
@ -373,14 +373,26 @@ export default {
},
/** 新增提交 */
handleAddSubmit(form) {
addPayment(form).then(response => {
this.$modal.msgSuccess("新增成功");
this.addOpen = false;
this.getList();
}).catch(error => {
console.error("新增付款单失败", error);
this.$modal.msgError("新增失败");
});
if (form.paymentBillType==='FROM_PAYABLE'){
addPaymentFromPayable(form).then(response => {
this.$modal.msgSuccess("新增成功");
this.addOpen = false;
this.getList();
}).catch(error => {
console.error("新增付款单失败", error);
this.$modal.msgError("新增失败");
});
}else{
addPayment(form).then(response => {
this.$modal.msgSuccess("新增成功");
this.addOpen = false;
this.getList();
}).catch(error => {
console.error("新增付款单失败", error);
this.$modal.msgError("新增失败");
});
}
},
/** 详情按钮操作 */
handleDetail(row) {

View File

@ -83,7 +83,7 @@ public class OmsPaymentBillController extends BaseController
}
/**
*
*
*/
@RequiresPermissions("finance:payment:add")
@Log(title = "采购付款单", businessType = BusinessType.INSERT)
@ -91,6 +91,7 @@ public class OmsPaymentBillController extends BaseController
@ResponseBody
public AjaxResult addSave(@RequestBody OmsPaymentBill omsPaymentBill)
{
omsPaymentBill.setPreResidueAmount(omsPaymentBill.getTotalPriceWithTax());
return toAjax(omsPaymentBillService.insertOmsPaymentBill(omsPaymentBill));
}