9/10
This commit is contained in:
@@ -11,17 +11,23 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="楼栋" prop="buildingId">
|
||||
<el-select v-model="queryParams.buildingId" placeholder="请选择楼栋" @change="handleChangeBuilding">
|
||||
<el-select
|
||||
v-model="queryParams.buildingId"
|
||||
clearable
|
||||
placeholder="请选择楼栋"
|
||||
@change="handleChangeBuilding"
|
||||
@clear="handleClearBuildingId"
|
||||
>
|
||||
<el-option v-for="(item, index) in buildingList" :key="index" :label="item.buildingName" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="单元" prop="unitNoId">
|
||||
<el-select v-model="queryParams.unitNoId" placeholder="请选择单元" @change="handleChangeUnit">
|
||||
<el-select v-model="queryParams.unitNoId" clearable placeholder="请选择单元" @change="handleChangeUnit" @clear="handleClearUnit">
|
||||
<el-option v-for="(item, index) in unitList" :key="index" :label="item.unitNoName" :value="item.unitNoId"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="房号" prop="houseId" @change="handleChangeHouseNo">
|
||||
<el-select v-model="queryParams.houseId" placeholder="请选择房号">
|
||||
<el-form-item label="房号" prop="houseId">
|
||||
<el-select v-model="queryParams.houseId" clearable placeholder="请选择房号" @clear="handleClear('houseId')">
|
||||
<el-option-group v-for="group in houseList" :key="group.floorNo" :label="String(group.floorNo) + ' 楼'">
|
||||
<el-option v-for="item in group.houses" :key="item.houseId" :label="item.houseNo" :value="item.houseId" />
|
||||
</el-option-group>
|
||||
@@ -30,7 +36,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<el-form-item label="收费项目" prop="itemId">
|
||||
<el-select v-model="queryParams.chargeItemId" multiple placeholder="请选择收费项目">
|
||||
<el-select v-model="queryParams.chargeItemId" clearable multiple placeholder="请选择收费项目" @clear="handleClear('chargeItemId')">
|
||||
<el-option
|
||||
v-for="(item, index) in chargeItems"
|
||||
:key="index"
|
||||
@@ -43,6 +49,7 @@
|
||||
<el-form-item label="缴费周期">
|
||||
<el-date-picker
|
||||
v-model="queryParams.startDate"
|
||||
clearable
|
||||
format="YYYY-MM-DD"
|
||||
placeholder="请选择开始缴费日期"
|
||||
type="date"
|
||||
@@ -60,31 +67,39 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋分类" prop="houseUseTypeId">
|
||||
<el-select v-model="queryParams.houseUseTypeId">
|
||||
<el-select v-model="queryParams.houseUseTypeId" clearable @clear="handleClear('houseUseTypeId')">
|
||||
<el-option v-for="item in houseUseTypeList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="缴费时间">
|
||||
<el-date-picker
|
||||
v-model="queryParams.payTimeBegin"
|
||||
clearable
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择开始缴费时间"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
@clear="handleClearPayTime('payTimeBegin')"
|
||||
@clear="handleClear('payTimeBegin')"
|
||||
/>
|
||||
<el-date-picker
|
||||
v-model="queryParams.payTimeEnd"
|
||||
clearable
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择结束缴费时间"
|
||||
style="margin-left: 10px"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
@clear="handleClearPayTime('payTimeEnd')"
|
||||
@clear="handleClear('payTimeEnd')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="业主姓名" prop="residentName">
|
||||
<el-input v-model.trim="queryParams.residentName" maxlength="30" placeholder="请选择业主姓名"></el-input>
|
||||
<el-input
|
||||
v-model.trim="queryParams.residentName"
|
||||
clearable
|
||||
maxlength="30"
|
||||
placeholder="请选择业主姓名"
|
||||
@clear="handleClear('residentName')"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div style="text-align: right">
|
||||
@@ -154,13 +169,13 @@
|
||||
<el-table-column align="center" label="应收金额" prop="amount" width="100" />
|
||||
<el-table-column align="center" label="缴费状态" prop="payStatus" width="100">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.payStatus === '0'">未缴纳</span>
|
||||
<span v-else-if="scope.row.payStatus === '1'">已缴纳</span>
|
||||
<span v-else-if="scope.row.payStatus === '2'">缴纳失败</span>
|
||||
<span v-else-if="scope.row.payStatus === '3'">部分缴纳</span>
|
||||
<span v-if="scope.row.payStatus === PayStatus.PENDING">未缴纳</span>
|
||||
<span v-else-if="scope.row.payStatus === PayStatus.PAID">已缴纳</span>
|
||||
<span v-else-if="scope.row.payStatus === PayStatus.FAILED">缴纳失败</span>
|
||||
<span v-else-if="scope.row.payStatus === PayStatus.PARTIAL">部分缴纳</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="应缴金额" prop="amount" width="100" />
|
||||
<el-table-column align="center" label="应缴金额" prop="needPayAmount" width="100" />
|
||||
<el-table-column align="center" label="优惠金额" prop="singleDiscountAmount" width="100" />
|
||||
<el-table-column align="center" label="实缴金额" prop="actualAccount" width="100" />
|
||||
<el-table-column align="center" label="缴费人" prop="residentName" width="120" />
|
||||
@@ -168,8 +183,8 @@
|
||||
<el-table-column align="center" label="备注" prop="remark" show-overflow-tooltip />
|
||||
<el-table-column align="center" class-name="small-padding fixed-width" label="操作" width="150">
|
||||
<template #default="scope">
|
||||
<el-button v-if="scope.row.payStatus !== '1'" link type="primary" @click="handleIncome(scope.row)">收款</el-button>
|
||||
<el-button v-if="scope.row.payStatus === '1'" link type="success" @click="printPIaoJuByOnly(scope.row)">打印票据</el-button>
|
||||
<el-button v-if="scope.row.payStatus !== PayStatus.PAID" link type="primary" @click="handleIncome(scope.row)">收款</el-button>
|
||||
<el-button v-if="scope.row.payStatus === PayStatus.PAID" link type="success" @click="printPIaoJuByOnly(scope.row)">打印票据</el-button>
|
||||
<el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -177,12 +192,10 @@
|
||||
<div class="footerBox">
|
||||
<div class="totalBox">
|
||||
<span>合计:</span>
|
||||
<span style="padding: 0 10px">应收:{{ totalAll.totalAccount }}元</span>
|
||||
<span style="padding: 0 10px">实收:{{ totalAll.TotalPaymentAmount }}元</span>
|
||||
<span style="padding: 0 10px">优惠:{{ totalAll.totalDiscountAmount }}元</span>
|
||||
<span style="padding: 0 10px">未收:{{ totalAll.TotalUnPaymentAmount }}元</span>
|
||||
<span>应收:{{ totalAll.totalAccount }}元(原金额:{{ totalAll.originalAmount }}元, 优惠:{{ totalAll.totalDiscountAmount }}元)</span>
|
||||
<span style="padding: 0 5px">已收:{{ totalAll.TotalPaymentAmount }}元</span>
|
||||
<span style="padding: 0 5px">未收:{{ totalAll.TotalUnPaymentAmount }}元</span>
|
||||
</div>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@@ -214,7 +227,7 @@
|
||||
<div style="text-decoration: underline; padding-right: 5px; text-align: center">
|
||||
{{ item.detailsName }} (应缴:¥{{ item.needPayAmount }})
|
||||
</div>
|
||||
<el-tooltip v-if="item.payStatus === '3'" class="box-item" effect="light" placement="top">
|
||||
<el-tooltip v-if="item.payStatus === PayStatus.PENDING" class="box-item" effect="light" placement="top">
|
||||
<el-icon color="#909399"><QuestionFilled /></el-icon>
|
||||
<template #content>
|
||||
<div style="line-height: 1.8; font-size: 13px; width: 180px">
|
||||
@@ -241,7 +254,7 @@
|
||||
</template>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<span v-if="item.payStatus === '1'">(已缴费,不计入金额)</span>
|
||||
<span v-if="item.payStatus === PayStatus.PAID">(已缴费,不计入金额)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -288,7 +301,7 @@
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="inComeFrom.payStatus !== '0'" label="优惠方式" prop="discountMethod">
|
||||
<el-form-item v-if="inComeFrom.payStatus !== PayStatus.PENDING" label="优惠方式" prop="discountMethod">
|
||||
<el-select v-model="inComeFrom.discountMethod" placeholder="请选择" style="width: 400px" @change="handleChangeDisCountMethod">
|
||||
<el-option :value="0" label="不优惠"></el-option>
|
||||
<el-option :value="2" label="金额"></el-option>
|
||||
@@ -325,7 +338,7 @@
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item v-if="inComeFrom.payStatus !== '0'" label="支付方式" prop="payType">
|
||||
<el-form-item v-if="inComeFrom.payStatus !== PayStatus.PENDING" label="支付方式" prop="payType">
|
||||
<div class="flex-1">
|
||||
<div v-for="(item, index) in payList" :key="index" class="flex flex-items-center">
|
||||
<div class="flex-1 flex">
|
||||
@@ -452,7 +465,7 @@ import { getCommunitylistAPI } from '@/api/system/community';
|
||||
import { billDelete, billEdit, billlistType, billPrint, BillPrintType, billQuery, getAllAccount } from '@/api/system/SdbCashier';
|
||||
import { listChargeItem } from '@/api/system/SdbChargeItem';
|
||||
import { ref } from 'vue';
|
||||
import { add, div, eq, eqMoney, gtMoney, ltMoney, minMoney, moneyAdd, mul, sub, sum, toBig } from '@/utils/money';
|
||||
import { add, div, eq, eqMoney, gtMoney, minMoney, moneyAdd, mul, sub, sum, toBig } from '@/utils/money';
|
||||
import { BuildingUnitlist, BuildingVo, FloorsType } from '@/api/system/house/type';
|
||||
import { ChargeItemVO } from '@/api/system/SdbChargeItem/type';
|
||||
import { communitylist_rows_type } from '@/api/system/community/type';
|
||||
@@ -464,6 +477,18 @@ import { useUserStore } from '@/store/modules/user';
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { com_pay_method, com_charge_item_unit } = toRefs<any>(proxy?.useDict('com_pay_method', 'com_charge_item_unit'));
|
||||
|
||||
/** 支付状态 */
|
||||
const PayStatus = {
|
||||
/** 待缴纳 */
|
||||
PENDING: '0',
|
||||
/** 已缴纳 */
|
||||
PAID: '1',
|
||||
/** 缴纳失败 */
|
||||
FAILED: '2',
|
||||
/** 部分缴纳 */
|
||||
PARTIAL: '3'
|
||||
} as const;
|
||||
|
||||
const userStore = useUserStore();
|
||||
const loading = ref(false);
|
||||
const ids = ref<Array<billlistType>>([]);
|
||||
@@ -476,15 +501,15 @@ const tabs = [
|
||||
type: '全部'
|
||||
},
|
||||
{
|
||||
value: 0,
|
||||
value: PayStatus.PENDING,
|
||||
type: '待缴纳'
|
||||
},
|
||||
{
|
||||
value: 1,
|
||||
value: PayStatus.PAID,
|
||||
type: '已缴纳'
|
||||
},
|
||||
{
|
||||
value: 3,
|
||||
value: PayStatus.PARTIAL,
|
||||
type: '部分缴纳'
|
||||
}
|
||||
];
|
||||
@@ -520,6 +545,8 @@ const queryParams = ref({
|
||||
// 结束时间
|
||||
endDate: undefined
|
||||
});
|
||||
// ts工具 排除参数
|
||||
type ExcludeType = keyof Omit<typeof queryParams.value, 'villageId' | 'pageSize' | 'pageNum'>;
|
||||
|
||||
const villageList = ref<communitylist_rows_type[]>([]); // 小区列表
|
||||
const buildingList = ref<BuildingVo[]>([]); // 楼栋列表
|
||||
@@ -538,7 +565,7 @@ function getHouseTypeList() {
|
||||
});
|
||||
}
|
||||
// 切换 账单类型
|
||||
function changeTabs(value: number) {
|
||||
function changeTabs(value: string) {
|
||||
activeTabs.value = value;
|
||||
queryParams.value.payStatus = value;
|
||||
getList();
|
||||
@@ -575,12 +602,17 @@ function handleChangeBuilding(val: string): void {
|
||||
queryParams.value.unitNoId = undefined;
|
||||
queryParams.value.houseId = undefined;
|
||||
unitList.value = [];
|
||||
getHouselistAPI(val).then((res) => {
|
||||
unitList.value = res.data.units;
|
||||
});
|
||||
if (val !== undefined) {
|
||||
getHouselistAPI(val).then((res) => {
|
||||
unitList.value = res.data.units;
|
||||
});
|
||||
}
|
||||
}
|
||||
// 选择 单元
|
||||
function handleChangeUnit(val: string) {
|
||||
if (val === undefined) {
|
||||
return;
|
||||
}
|
||||
const find = unitList.value.find((item) => item.unitNoId === val);
|
||||
queryParams.value.houseId = undefined;
|
||||
houseList.value = [];
|
||||
@@ -588,13 +620,7 @@ function handleChangeUnit(val: string) {
|
||||
houseList.value = find.floors;
|
||||
}
|
||||
}
|
||||
// 选择房屋
|
||||
function handleChangeHouseNo() {}
|
||||
|
||||
// 清空缴费时间
|
||||
function handleClearPayTime(type: 'payTimeBegin' | 'payTimeEnd') {
|
||||
queryParams.value[type] = undefined;
|
||||
}
|
||||
// 清空缴费周期
|
||||
function handleClearChargePeriod(type: 'start' | 'end' = 'start') {
|
||||
if (type === 'start') {
|
||||
@@ -622,7 +648,8 @@ function getAllBillAmount() {
|
||||
totalAll.value = {
|
||||
totalDiscountAmount: res.data.discountAmount, // 总优惠金额
|
||||
TotalPaymentAmount: res.data.receivedAmount, // 总实收金额
|
||||
totalAccount: res.data.receivableAmount, // 总金额
|
||||
totalAccount: res.data.receivableAmount, // 总 应收金额
|
||||
originalAmount: res.data.originalAmount, // 原始金额之和(应收+优惠)
|
||||
TotalUnPaymentAmount: res.data.unpaidAmount // 未收金额
|
||||
};
|
||||
});
|
||||
@@ -634,30 +661,51 @@ const handleQuery = () => {
|
||||
getList();
|
||||
};
|
||||
|
||||
// 优化后
|
||||
const defaultQueryParams = () => ({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
payStatus: null as number | null,
|
||||
villageId: villageId as string | undefined,
|
||||
buildingId: undefined,
|
||||
unitNoId: undefined,
|
||||
houseId: undefined,
|
||||
houseUseTypeId: undefined,
|
||||
payTime: undefined,
|
||||
residentName: undefined,
|
||||
chargeItemId: undefined,
|
||||
period: undefined,
|
||||
payTimeBegin: undefined,
|
||||
payTimeEnd: undefined,
|
||||
startDate: undefined,
|
||||
endDate: undefined
|
||||
});
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
queryParams.value = {
|
||||
startDate: undefined,
|
||||
payTime: undefined,
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
payStatus: queryParams.value.payStatus,
|
||||
villageId: undefined,
|
||||
buildingId: undefined,
|
||||
unitNoId: undefined,
|
||||
houseId: undefined,
|
||||
chargeItemId: undefined,
|
||||
period: undefined,
|
||||
houseUseTypeId: undefined,
|
||||
residentName: undefined,
|
||||
payTimeBegin: undefined,
|
||||
payTimeEnd: undefined,
|
||||
endDate: undefined
|
||||
...defaultQueryParams(),
|
||||
payStatus: queryParams.value.payStatus // 保留当前 tab
|
||||
};
|
||||
queryParams.value.villageId = villageId;
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
// 清空楼栋
|
||||
function handleClearBuildingId() {
|
||||
queryParams.value.buildingId = undefined;
|
||||
queryParams.value.unitNoId = undefined;
|
||||
queryParams.value.houseId = undefined;
|
||||
}
|
||||
// 清空单元
|
||||
function handleClearUnit() {
|
||||
queryParams.value.unitNoId = undefined;
|
||||
queryParams.value.houseId = undefined;
|
||||
}
|
||||
// 清空其他参数
|
||||
function handleClear(type: ExcludeType) {
|
||||
queryParams.value[type] = undefined;
|
||||
}
|
||||
|
||||
// 控制收费 按钮 不能有已缴纳的(后端会校验)
|
||||
const single = ref(true);
|
||||
// 控制打印票据的 按钮 不能有收费的
|
||||
@@ -666,9 +714,9 @@ const printSingle = ref(true);
|
||||
const handleSelectionChange = (selection: billlistType[]) => {
|
||||
ids.value = selection.map((item) => item);
|
||||
// 不能全部都是已缴纳的 0待缴纳 1已缴纳 2缴纳失败 3混合缴纳
|
||||
single.value = ids.value.every((item) => item.payStatus === '0' || item.payStatus === '3');
|
||||
single.value = ids.value.every((item) => item.payStatus === PayStatus.PENDING || item.payStatus === PayStatus.PARTIAL);
|
||||
// 必须都要缴费后打印
|
||||
printSingle.value = ids.value.every((item) => item.payStatus === '1');
|
||||
printSingle.value = ids.value.every((item) => item.payStatus === PayStatus.PAID);
|
||||
};
|
||||
const buttonLoading = ref(false);
|
||||
// 是否多选
|
||||
@@ -760,7 +808,7 @@ function handleChangeDiscountMoney(val: string) {
|
||||
if (isMore) {
|
||||
// 过滤:只保留未支付账单,已支付直接丢弃
|
||||
const unPaidList = ids.value.filter((item) => {
|
||||
return item.payStatus !== '1';
|
||||
return item.payStatus !== PayStatus.PAID;
|
||||
});
|
||||
|
||||
// 计算优惠总额
|
||||
@@ -819,7 +867,7 @@ function handleChangeDiscountRate(val: string) {
|
||||
// 批量多选模式
|
||||
if (isMore) {
|
||||
const unPaidList = ids.value.filter((item) => {
|
||||
return item.payStatus !== '1';
|
||||
return item.payStatus !== PayStatus.PAID;
|
||||
});
|
||||
// 总价格
|
||||
const sourceTotal = sum(unPaidList.map((item) => item.needPayAmount ?? 0));
|
||||
@@ -864,7 +912,7 @@ function handleIncome(row: billlistType | false) {
|
||||
ids.value.forEach((item) => {
|
||||
set.add(item.residentId);
|
||||
});
|
||||
if (ids.value.some((item) => item.payStatus === '1')) {
|
||||
if (ids.value.some((item) => item.payStatus === PayStatus.PAID)) {
|
||||
return ElMessage.warning('存在已支付账单,请重新选择');
|
||||
}
|
||||
if (set.size > 1) {
|
||||
@@ -875,7 +923,7 @@ function handleIncome(row: billlistType | false) {
|
||||
inComeFrom.value.residentName = ids.value[0].residentName;
|
||||
ids.value.forEach((item) => {
|
||||
inComeFrom.value.billResidentId.push(item);
|
||||
if (item.payStatus === '0' || item.payStatus === '3') {
|
||||
if (item.payStatus === PayStatus.PENDING || item.payStatus === PayStatus.PARTIAL) {
|
||||
inComeFrom.value.allCost = moneyAdd(inComeFrom.value.allCost || 0, item.needPayAmount);
|
||||
}
|
||||
});
|
||||
@@ -899,17 +947,17 @@ const submitForm = () => {
|
||||
}
|
||||
buttonLoading.value = true;
|
||||
// 部分缴纳时 判断 支付金额 和 预计支付金额 是否相等 ,相等 则 可选择 部分缴纳 方式
|
||||
if (inComeFrom.value.payStatus === '3') {
|
||||
if (inComeFrom.value.payStatus === PayStatus.PARTIAL) {
|
||||
if (eqMoney(totalPayAmount.value, payListAllAmount.value)) {
|
||||
buttonLoading.value = false;
|
||||
return ElMessage.warning('实缴金额等于应收金额时,请选择 【已缴纳】 状态');
|
||||
}
|
||||
}
|
||||
// 已缴纳时 判断 支付金额 和 预计支付金额 是否相等
|
||||
if (inComeFrom.value.payStatus === '1') {
|
||||
if (inComeFrom.value.payStatus === PayStatus.PAID) {
|
||||
if (!eqMoney(totalPayAmount.value, payListAllAmount.value)) {
|
||||
buttonLoading.value = false;
|
||||
return ElMessage.warning('支付金额不足,请选择 【部分缴纳】 状态');
|
||||
return ElMessage.warning('支付金额不足,可以选择 【部分缴纳】 状态');
|
||||
}
|
||||
}
|
||||
const obj = {
|
||||
@@ -1097,22 +1145,14 @@ function conFimPrint() {
|
||||
|
||||
// 删除
|
||||
async function handleDelete(row: billlistType | false) {
|
||||
if (row) {
|
||||
await proxy?.$modal.confirm('该信息删除后无法恢复,确定要删除吗?');
|
||||
billDelete(row.detailsId).then(() => {
|
||||
ElMessage.success('删除成功');
|
||||
getList();
|
||||
});
|
||||
} else {
|
||||
if (ids.value.length <= 0) {
|
||||
return ElMessage.warning('请选择账单!');
|
||||
}
|
||||
await proxy?.$modal.confirm('该信息删除后无法恢复,确定要删除吗?');
|
||||
billDelete(ids.value.map((item) => item.detailsId)).then(() => {
|
||||
ElMessage.success('删除成功');
|
||||
getList();
|
||||
});
|
||||
const targetIds = row ? [row.detailsId] : ids.value.map((item) => item.detailsId);
|
||||
if (targetIds.length === 0) {
|
||||
return ElMessage.warning('请选择账单!');
|
||||
}
|
||||
await proxy?.$modal.confirm('该信息删除后无法恢复,确定要删除吗?');
|
||||
await billDelete(targetIds);
|
||||
ElMessage.success('删除成功');
|
||||
getList();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -1129,8 +1169,9 @@ onMounted(() => {
|
||||
// 总 表单
|
||||
const totalAll = ref({
|
||||
totalDiscountAmount: '0', // 总优惠金额
|
||||
TotalPaymentAmount: '0', // 总实收金额
|
||||
totalAccount: '0', // 总金额
|
||||
TotalPaymentAmount: '0', // 总已收金额
|
||||
totalAccount: '0', // 总 应收金额
|
||||
originalAmount: '0', // 原始金额之和(应收+优惠)
|
||||
TotalUnPaymentAmount: '0' // 未收金额
|
||||
});
|
||||
|
||||
@@ -1138,7 +1179,7 @@ function handleChangePayTypeId(val: string, index: number) {
|
||||
// 【可选兜底校验】防止异常数据出现重复
|
||||
const repeatCount = usedPayValues.value.filter((v) => v === val).length;
|
||||
if (repeatCount > 1) {
|
||||
payList.value[index].payType = null;
|
||||
payList.value[index].payType = '';
|
||||
}
|
||||
}
|
||||
const usedPayValues = computed(() => {
|
||||
@@ -1150,15 +1191,20 @@ const isOptionDisabled = (optVal: string, currentVal: any) => {
|
||||
return usedPayValues.value.includes(optVal);
|
||||
};
|
||||
|
||||
/** 支付列表项类型 */
|
||||
interface PayListItem {
|
||||
payType: string;
|
||||
payAmount: number | null;
|
||||
}
|
||||
// 混合支付 列表
|
||||
const payList = ref([
|
||||
const payList = ref<PayListItem[]>([
|
||||
{
|
||||
payType: '',
|
||||
payAmount: null
|
||||
}
|
||||
]);
|
||||
// 混合支付 总金额
|
||||
const payListAllAmount = computed(() => {
|
||||
const payListAllAmount = computed<number>(() => {
|
||||
return sum(payList.value.map((item) => item.payAmount ?? 0));
|
||||
});
|
||||
// 添加支付方式
|
||||
@@ -1172,27 +1218,32 @@ function addPayList() {
|
||||
function removePayList(index: number) {
|
||||
payList.value.splice(index, 1);
|
||||
}
|
||||
// 数据框改变时 检测数据是否大于 总金额
|
||||
// 数据框改变时 检测数据是否大于 总金额, 如果大于则自动回填剩余金额
|
||||
function handleChangePay(val: string, index: number = -1) {
|
||||
if (!checkMoney(val)) {
|
||||
ElMessage.warning('金额格式错误');
|
||||
payList.value[index].payAmount = null;
|
||||
return;
|
||||
}
|
||||
// 如果 当前行输入的金额 大于 总实缴金额
|
||||
// 则在当前行,自动回填正确剩余金额
|
||||
if (gtMoney(payListAllAmount.value, totalPayAmount.value)) {
|
||||
ElMessage.warning('输入金额 总和 不能大于 总实缴金额');
|
||||
if (index > -1) {
|
||||
payList.value[index].payAmount = 0;
|
||||
// 自动回填
|
||||
payList.value[index].payAmount = sub(totalPayAmount.value, payListAllAmount.value);
|
||||
}
|
||||
}
|
||||
// 已缴纳状态时,输入金额 总和 不能小于 总实缴金额
|
||||
if (inComeFrom.value.payStatus === '1') {
|
||||
if (ltMoney(payListAllAmount.value, totalPayAmount.value)) {
|
||||
ElMessage.warning('输入金额 总和 不能小于 总实缴金额');
|
||||
// BUG: payAmount=0,让 payListAllAmount’s computed 只算其他行,然后 补 回来
|
||||
// payList.value[index].payAmount = 0;
|
||||
// payList.value[index].payAmount = sub(totalPayAmount.value, payListAllAmount.value);
|
||||
// 总实缴 - (全部总和 - 当前行刚输入的值) = 总实缴 - 其他行总和 = 当前行剩余应缴金额
|
||||
payList.value[index].payAmount = sub(totalPayAmount.value, sub(payListAllAmount.value, val));
|
||||
}
|
||||
}
|
||||
// // 已缴纳状态时,输入金额 总和 不能小于 总实缴金额
|
||||
// if (inComeFrom.value.payStatus === PayStatus.PAID) {
|
||||
// if (ltMoney(payListAllAmount.value, totalPayAmount.value)) {
|
||||
// ElMessage.warning('输入金额 总和 不能小于 总实缴金额');
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
function handlePayListIsEmpty() {
|
||||
@@ -1201,13 +1252,7 @@ function handlePayListIsEmpty() {
|
||||
return false;
|
||||
}
|
||||
const invalidIndex = payList.value.findIndex(
|
||||
(item) =>
|
||||
item.payType === null ||
|
||||
item.payType === undefined ||
|
||||
item.payType === '' ||
|
||||
item.payAmount === null ||
|
||||
item.payAmount === undefined ||
|
||||
item.payAmount === ''
|
||||
(item) => item.payType === null || item.payType === undefined || item.payType === '' || item.payAmount === null || item.payAmount === undefined
|
||||
);
|
||||
return invalidIndex === -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user