|
|
@@ -11,20 +11,6 @@
|
|
|
:maxable="true"
|
|
|
:resizable="true"
|
|
|
>
|
|
|
- <!-- 对账异常来源(10/11):没有产品清单/对账明细,收款界面参考【预收管理-确收】按行录入收款信息 -->
|
|
|
- <template v-if="isExceptionSource">
|
|
|
- <div style="margin: 10px 0; font-size: 14px; color: #606266;">
|
|
|
- <span>历史已收金额:{{ row.receivedTotalPrice || 0 }} 元</span>
|
|
|
- <span style="margin-left: 20px;">未收金额:{{ unreceivedAmount }} 元</span>
|
|
|
- </div>
|
|
|
- <collect-table-form
|
|
|
- ref="collectTableFormRef"
|
|
|
- :form.sync="collectForm"
|
|
|
- :total-price="selectedReceivableAmount"
|
|
|
- total-label="应收金额"
|
|
|
- ></collect-table-form>
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
<div style="margin: 10px 0; font-size: 14px; color: #606266;">
|
|
|
<span>应收金额:{{ selectedReceivableAmount }} 元</span>
|
|
|
<span style="margin-left: 20px;">本次收款金额:{{ receivedAmount }} 元</span>
|
|
|
@@ -123,7 +109,6 @@
|
|
|
</template>
|
|
|
</ele-pro-table>
|
|
|
</el-form>
|
|
|
- </template>
|
|
|
|
|
|
<div slot="footer">
|
|
|
<el-button type="primary" @click="save()">保存</el-button>
|
|
|
@@ -135,12 +120,11 @@
|
|
|
import { pricingWayList } from '@/enum/dict.js';
|
|
|
import { finReceivableSaveAPI, getProductListForReceiptAPI } from "@/api/financialManage/receivableManage";
|
|
|
import tabMixins from '@/mixins/tableColumnsMixin';
|
|
|
-import collectTableForm from '@/BIZComponents/collectTableForm/index.vue';
|
|
|
|
|
|
export default {
|
|
|
mixins: [tabMixins],
|
|
|
name: "collectionDialog",
|
|
|
- components: { collectTableForm },
|
|
|
+ components: {},
|
|
|
props: {
|
|
|
collectionDialogFlag: {
|
|
|
type: Boolean,
|
|
|
@@ -161,11 +145,6 @@ export default {
|
|
|
isView() {
|
|
|
return this.dialogType === 'view';
|
|
|
},
|
|
|
- // 来源类型为对账异常(10销售订单-对账异常 / 11采购订单-对账异常):
|
|
|
- // 该类应收由异常处置自动生成,产品清单与对账明细允许为空,收款界面参考预收管理-确收录入
|
|
|
- isExceptionSource() {
|
|
|
- return [10, 11].includes(Number(this.sourceTypeValue));
|
|
|
- },
|
|
|
// 应收金额 = 接口下发的 row.receivableTotalPrice
|
|
|
selectedReceivableAmount() {
|
|
|
return this.row.receivableTotalPrice || 0;
|
|
|
@@ -373,12 +352,6 @@ export default {
|
|
|
title: '',
|
|
|
loading: false,
|
|
|
info: {},
|
|
|
- // 来源类型(接口下发,兜底列表行):10/11 为对账异常来源
|
|
|
- sourceTypeValue: '',
|
|
|
- // 对账异常来源的收款记录表单(参考预收管理-确收)
|
|
|
- collectForm: {
|
|
|
- tableData: []
|
|
|
- },
|
|
|
form: {
|
|
|
id: '',
|
|
|
queryDimension: 1,
|
|
|
@@ -420,13 +393,6 @@ export default {
|
|
|
// 获取详情(收款专用接口:仅返回产品列表,不带表单主信息)
|
|
|
async getInfo(id) {
|
|
|
const data = await getProductListForReceiptAPI(id);
|
|
|
- // 来源类型:接口下发优先,兜底列表行数据
|
|
|
- this.sourceTypeValue =
|
|
|
- data?.sourceType != null
|
|
|
- ? data.sourceType
|
|
|
- : this.row.sourceType != null
|
|
|
- ? this.row.sourceType
|
|
|
- : '';
|
|
|
// 把接口返回的已收/未收金额回填到 row,供顶部汇总和表单展示
|
|
|
this.row = {
|
|
|
...this.row,
|
|
|
@@ -442,22 +408,6 @@ export default {
|
|
|
files: data?.files || [],
|
|
|
remark: data?.remark || ''
|
|
|
};
|
|
|
- // 对账异常来源:没有产品清单/对账明细,按预收确认方式录入收款记录
|
|
|
- if (this.isExceptionSource) {
|
|
|
- this.datasource = [];
|
|
|
- this.collectForm = {
|
|
|
- tableData: [
|
|
|
- {
|
|
|
- receivedDate: '',
|
|
|
- receivedTotalPrice: '',
|
|
|
- paymentType: '',
|
|
|
- files: [],
|
|
|
- remark: ''
|
|
|
- }
|
|
|
- ]
|
|
|
- };
|
|
|
- return;
|
|
|
- }
|
|
|
this.datasource = Array.isArray(data) ? data : data.productList || [];
|
|
|
// 明细为空(没有对账明细)时无法勾选收款行,直接拦掉
|
|
|
if (!this.datasource.length) {
|
|
|
@@ -570,10 +520,6 @@ export default {
|
|
|
},
|
|
|
|
|
|
async save() {
|
|
|
- // 对账异常来源:按【预收管理-确收】方式逐行保存收款记录(无产品明细)
|
|
|
- if (this.isExceptionSource) {
|
|
|
- return this.saveExceptionCollection();
|
|
|
- }
|
|
|
// 1. 校验收款信息表单
|
|
|
const formValid = await new Promise((resolve) => {
|
|
|
this.$refs.form.validate((valid) => resolve(valid));
|
|
|
@@ -622,61 +568,6 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- // 对账异常来源收款保存:参考【预收管理-确收】,按行录入收款时间/已收金额/支付类型/附件/备注
|
|
|
- async saveExceptionCollection() {
|
|
|
- const formRef = this.$refs.collectTableFormRef;
|
|
|
- if (!formRef) {
|
|
|
- return this.$message.warning('收款信息加载失败,请重新打开');
|
|
|
- }
|
|
|
- const valid = await formRef.validate().catch(() => false);
|
|
|
- if (!valid) return;
|
|
|
- const tableData = this.collectForm.tableData || [];
|
|
|
- if (!tableData.length) {
|
|
|
- return this.$message.warning('请至少添加一条收款记录');
|
|
|
- }
|
|
|
- // 本次收款金额合计不能大于历史未收金额(用「分」做整数比较,避开浮点精度)
|
|
|
- const totalAmount = tableData.reduce(
|
|
|
- (pre, item) => pre + (+item.receivedTotalPrice || 0),
|
|
|
- 0
|
|
|
- );
|
|
|
- const totalCents = Math.round(totalAmount * 100);
|
|
|
- const unreceiveCents = Math.round((+this.unreceivedAmount || 0) * 100);
|
|
|
- if (totalCents > unreceiveCents) {
|
|
|
- return this.$message.warning(
|
|
|
- `本次收款金额之和(${totalAmount.toFixed(2)} 元)不能大于未收金额(${
|
|
|
- this.unreceivedAmount
|
|
|
- } 元)`
|
|
|
- );
|
|
|
- }
|
|
|
- this.loading = true;
|
|
|
- try {
|
|
|
- // 逐条提交,避免并发重算应收已收/未收金额互相覆盖
|
|
|
- for (const item of tableData) {
|
|
|
- await finReceivableSaveAPI({
|
|
|
- receivableId: this.row.id,
|
|
|
- receivableCode: this.row.code,
|
|
|
- receivedDate: item.receivedDate,
|
|
|
- receivedTotalPrice: +item.receivedTotalPrice || 0,
|
|
|
- paymentType:
|
|
|
- item.paymentType === '' || item.paymentType == null
|
|
|
- ? null
|
|
|
- : Number(item.paymentType),
|
|
|
- files: item.files || [],
|
|
|
- remark: item.remark || '',
|
|
|
- // 对账异常来源应收没有产品清单
|
|
|
- productList: []
|
|
|
- });
|
|
|
- }
|
|
|
- this.$message.success('收款成功');
|
|
|
- this.cancel();
|
|
|
- this.done();
|
|
|
- } catch (error) {
|
|
|
- // 错误提示已由请求拦截器统一处理
|
|
|
- } finally {
|
|
|
- this.loading = false;
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
// 刷新主列表数据
|
|
|
done() {
|
|
|
this.$emit('reload');
|