优化代码

This commit is contained in:
wuxw 2023-11-27 21:33:13 +08:00
parent c9d481ec80
commit 9ec2bf6caf

View File

@ -5,7 +5,7 @@
<picker bindchange="PickerChange" :value="payerObjIndex" :range="payerObjs" :range-key="'payerObjName'" <picker bindchange="PickerChange" :value="payerObjIndex" :range="payerObjs" :range-key="'payerObjName'"
@change="_payerObjectChange"> @change="_payerObjectChange">
<view class="picker"> <view class="picker">
{{payerObjName?payerObjName:'请选择'}} {{payerObjs[payerObjIndex].payerObjName}}
</view> </view>
</picker> </picker>
</view> </view>
@ -114,7 +114,6 @@
scrollLeft: 0, scrollLeft: 0,
amount: 0, amount: 0,
receivableAmount: 0.00, receivableAmount: 0.00,
orgReceivableAmount: 0.00,
communityId: '', communityId: '',
communityName: '', communityName: '',
appId: '', appId: '',
@ -123,7 +122,6 @@
storeId: '', storeId: '',
payerObjs: [], payerObjs: [],
payerObjId: '', payerObjId: '',
payerObjName: '',
payerObjIndex: 0, payerObjIndex: 0,
feeIds: [], feeIds: [],
selectUserAccount: [], // selectUserAccount: [], //
@ -142,7 +140,7 @@
autoLogin(options); autoLogin(options);
let _that = this; let _that = this;
setTimeout(function() { setTimeout(function() {
_that.$refs.vcUserAccountRef._listOwnerAccount('', _that.communityId); _that.$refs.vcUserAccountRef._listOwnerAccount(_that.communityId);
}, 1500) }, 1500)
}, },
onShow() { onShow() {
@ -164,7 +162,6 @@
communityId: this.communityId, communityId: this.communityId,
payObjId: this.payerObjId payObjId: this.payerObjId
} }
_that.orgReceivableAmount = 0;
_that.feeIds = []; _that.feeIds = [];
getRoomOweFees(_objData) getRoomOweFees(_objData)
.then(function(_fees) { .then(function(_fees) {
@ -174,11 +171,9 @@
_that.fees = _fees; _that.fees = _fees;
_fees.forEach(function(_item) { _fees.forEach(function(_item) {
if (_item.payOnline == 'Y') { if (_item.payOnline == 'Y') {
_that.orgReceivableAmount += _item.feeTotalPrice;
_that.feeIds.push(_item.feeId); _that.feeIds.push(_item.feeId);
} }
}); });
_that.orgReceivableAmount = _that.orgReceivableAmount.toFixed(2);
_that.computeFeeObj(_fees); _that.computeFeeObj(_fees);
_that.computeReceivableAmount(); _that.computeReceivableAmount();
return _fees; return _fees;
@ -201,7 +196,7 @@
return; return;
} }
let _acctId = ''; let _acctId = '';
if(this.selectUserAccount && this.selectUserAccount.length>0){ if (this.selectUserAccount && this.selectUserAccount.length > 0) {
_acctId = this.selectUserAccount[0].acctId; _acctId = this.selectUserAccount[0].acctId;
} }
let _objData = { let _objData = {
@ -215,7 +210,7 @@
//appId: uni.getStorageSync(mapping.W_APP_ID), //appId: uni.getStorageSync(mapping.W_APP_ID),
storeId: this.storeId, storeId: this.storeId,
feeIds: this.feeIds, feeIds: this.feeIds,
acctId:_acctId, acctId: _acctId,
}; };
uni.setStorageSync('doing_cashier', _objData); uni.setStorageSync('doing_cashier', _objData);
uni.navigateTo({ uni.navigateTo({
@ -246,7 +241,10 @@
if (this.payerObjId) { if (this.payerObjId) {
return; return;
} }
_that.payerObjs = []; _that.payerObjs = [{
payerObjId:'',
payerObjName:'全部'
}];
let _allBatchFees = this.fees; let _allBatchFees = this.fees;
_allBatchFees.forEach(_fee => { _allBatchFees.forEach(_fee => {
if (!this._hasPayerObj(_fee)) { if (!this._hasPayerObj(_fee)) {
@ -267,9 +265,9 @@
return _hasIn; return _hasIn;
}, },
_payerObjectChange: function(e) { _payerObjectChange: function(e) {
this.payerObjIndex =e.detail.value;
let _curPayerObj = this.payerObjs[e.detail.value]; let _curPayerObj = this.payerObjs[e.detail.value];
this.payerObjId = _curPayerObj.payerObjId; this.payerObjId = _curPayerObj.payerObjId;
this.payerObjName = _curPayerObj.payerObjName;
this._loadOweFee(); this._loadOweFee();
}, },
getUserAmount: function(_accInfo) { getUserAmount: function(_accInfo) {
@ -280,14 +278,18 @@
this.computeReceivableAmount(); this.computeReceivableAmount();
}, },
computeReceivableAmount() { computeReceivableAmount() {
let orgReceivableAmount = this.orgReceivableAmount; let _that = this;
let _receivableAmount = parseFloat(orgReceivableAmount); let _feeIds = this.feeIds;
if (this.accountAmount) { let _receivableAmount = 0.0;
_receivableAmount = _receivableAmount - parseFloat(this.accountAmount); this.fees.forEach(_item => {
} _feeIds.forEach(_feeId => {
if (_item.feeId == _feeId) {
_receivableAmount += parseFloat(_item.feeTotalPrice);
}
})
});
_receivableAmount = _receivableAmount.toFixed(2); _receivableAmount = _receivableAmount.toFixed(2);
_receivableAmount = _receivableAmount < 0 ? 0.00:_receivableAmount; _receivableAmount = _receivableAmount < 0 ? 0.00 : _receivableAmount;
this.receivableAmount = _receivableAmount; this.receivableAmount = _receivableAmount;
} }
} }