完成物业缴费是否允许跳付的逻辑

This commit is contained in:
赵毅 2025-10-28 10:25:25 +08:00
parent f0189c6f2c
commit c8c4cd6bd4

View File

@ -57,7 +57,9 @@
<view class="payItem_tit">
<view class="payItem_left">
<checkbox :checked="item.check" @click="checkChange(item, index)"
v-if="item.community_order_rows.some(itemObj => itemObj.pay_status == 1)"></checkbox>
v-if="item.community_order_rows.some(itemObj => itemObj.pay_status == 1)"
:disabled="!canSelectBill(index)">
</checkbox>
<view style="margin-left: 24rpx">{{ item.order_date }}</view>
</view>
<view class="payItem_right">
@ -73,8 +75,8 @@
</view>
<view v-if="item.more">
<view class="payItem_List" v-for="(items, indes) in item.community_order_rows" :key="items.order_id">
<checkbox :checked="items.check" @click="itemsCheckChange(items, indes, index)"
v-if="items.pay_status == 1"></checkbox>
<checkbox :checked="items.check" @click="itemsCheckChange(items, indes, index)" v-if="items.pay_status == 1"
:disabled="!canSelectItem(indes, index)"></checkbox>
<view class="Item_time" v-if="items.billing_cycle == 1">
{{ items.order_date }}
</view>
@ -279,6 +281,7 @@ export default {
currentCommunity: "", //
currentCommunityAddr: "", //
Bill: "", //
Bill2: "", //
balanceMoney: 0, //
currentMoney: 0, //
@ -289,6 +292,7 @@ export default {
page_num: 1,
payOrderList: [],
flag: false,
isAllow: false,
};
},
onLoad(options) {
@ -387,9 +391,10 @@ export default {
page_num: 1,
page_size: 50,
}).then((res) => {
this.isAllow = res.rows[0].community.bill_allow_skip_payment === 1;
this.roomList = res.rows;
if (!this.currentRoom.room_id) {
this.currentRoom = this.roomList[0]
this.currentRoom = this.roomList[0]
}
this.selectedRoomId = this.currentRoom.room_id;
this.getOrderList().then(() => {
@ -405,6 +410,7 @@ export default {
//
selectRoom(item) {
this.getRoomSelect()
// ID
this.selectedRoomId = item.room_id;
//
@ -451,7 +457,30 @@ export default {
ite.check = false;
});
});
//
res.rows.sort((a, b) => {
// community_order_rowsorder_date
const yearA = a.community_order_rows && a.community_order_rows.length > 0 ? parseInt(a.community_order_rows[0].order_date) : 0;
const yearB = b.community_order_rows && b.community_order_rows.length > 0 ? parseInt(b.community_order_rows[0].order_date) : 0;
//
if (yearA !== yearB) {
return yearA - yearB;
}
//
const monthA = a.community_order_rows && a.community_order_rows.length > 0 ? parseInt(a.community_order_rows[0].order_datetime) : 0;
const monthB = b.community_order_rows && b.community_order_rows.length > 0 ? parseInt(b.community_order_rows[0].order_datetime) : 0;
return monthA - monthB;
});
this.Bill = res.rows;
this.Bill2 = res.rows.reduce((result, item) => {
const paidOrders = item.community_order_rows.filter(ite => ite.pay_status == 1);
return result.concat(paidOrders);
}, []);
resolve();
}).catch((error) => {
reject(error);
@ -462,49 +491,107 @@ export default {
changeCheck(e, index) {
this.Bill[index].more = !this.Bill[index].more;
},
//
canSelectBill(index) {
if (this.isAllow) return true;
//
if (index === 0) return true;
//
for (let i = 0; i < index; i++) {
const yearBill = this.Bill[i];
//
const hasUnpaid = yearBill.community_order_rows.some(item => item.pay_status === 1);
if (hasUnpaid) {
return false;
}
}
return true;
},
//
canSelectItem(indes, index) {
if (this.isAllow) return true;
//
if (!this.canSelectBill(index)) {
return false;
}
//
if (indes === 0) return true;
//
const yearBill = this.Bill[index];
for (let i = 0; i < indes; i++) {
if (yearBill.community_order_rows[i].pay_status === 1) {
return false;
}
}
return true;
},
//
checkChange(e, index) {
this.Bill[index].check = !this.Bill[index].check;
this.Bill[index].community_order_rows.forEach((item) => {
if (item.pay_status == 1) {
item.check = this.Bill[index].check;
}
});
//
let money = 0;
this.Bill.forEach((item) => {
item.community_order_rows.forEach((ite) => {
if (ite.check && ite.pay_status == 1) {
money += ite.money;
//
if (this.canSelectBill(index)) {
this.Bill[index].check = !this.Bill[index].check;
this.Bill[index].community_order_rows.forEach((item, indes) => {
//
if (item.pay_status == 1 && this.canSelectItem(indes, index)) {
item.check = this.Bill[index].check;
}
});
});
this.currentMoney = money ? money.toFixed(2) : 0.00;
//
let money = 0;
this.Bill.forEach((item) => {
item.community_order_rows.forEach((ite) => {
if (ite.check && ite.pay_status == 1) {
money += ite.money;
}
});
});
this.currentMoney = money ? money.toFixed(2) : 0.00;
}
},
//
itemsCheckChange(e, indes, index) {
this.Bill[index].community_order_rows[indes].check =
!this.Bill[index].community_order_rows[indes].check;
//
let isAll = this.Bill[index].community_order_rows.every((item) => {
return item.check;
});
if (isAll) {
this.Bill[index].check = true;
} else {
this.Bill[index].check = false;
}
//Billcommunity_order_rows
let money = 0;
this.Bill.forEach((item) => {
item.community_order_rows.forEach((ite) => {
if (ite.check) {
money += ite.money;
//
if (this.canSelectItem(indes, index)) {
this.Bill[index].community_order_rows[indes].check =
!this.Bill[index].community_order_rows[indes].check;
//
let isAll = this.Bill[index].community_order_rows.every((item, idx) => {
//
if (item.pay_status === 1 && this.canSelectItem(idx, index)) {
return item.check;
}
//
return true;
});
});
this.currentMoney = money ? money.toFixed(2) : 0.00;
if (isAll) {
this.Bill[index].check = true;
} else {
this.Bill[index].check = false;
}
//
let money = 0;
this.Bill.forEach((item) => {
item.community_order_rows.forEach((ite) => {
if (ite.check && ite.pay_status == 1) {
money += ite.money;
}
});
});
this.currentMoney = money ? money.toFixed(2) : 0.00;
}
},
//
changePayType(e) {