优化代码

This commit is contained in:
wuxw 2023-10-12 08:59:06 +08:00
parent 427e275eae
commit b38e240777
4 changed files with 142 additions and 27 deletions

View File

@ -12,17 +12,17 @@
_initEvent:function(){
vc.on('deleteInvoiceApply','openDeleteInvoiceApplyModal',function(_params){
vc.component.deleteInvoiceApplyInfo = _params;
$that.deleteInvoiceApplyInfo = _params;
$('#deleteInvoiceApplyModel').modal('show');
});
},
methods:{
deleteInvoiceApply:function(){
vc.component.deleteInvoiceApplyInfo.communityId=vc.getCurrentCommunity().communityId;
$that.deleteInvoiceApplyInfo.communityId=vc.getCurrentCommunity().communityId;
vc.http.apiPost(
'invoiceApply.deleteInvoiceApply',
JSON.stringify(vc.component.deleteInvoiceApplyInfo),
'/invoice.deleteInvoiceApply',
JSON.stringify($that.deleteInvoiceApplyInfo),
{
emulateJSON:true
},
@ -32,14 +32,14 @@
if (_json.code == 0) {
//关闭model
$('#deleteInvoiceApplyModel').modal('hide');
vc.emit('invoiceApplyManage','listInvoiceApply',{});
vc.emit('invoiceApply','listInvoiceApply',{});
return ;
}
vc.message(_json.msg);
vc.toast(_json.msg);
},
function(errInfo,error){
console.log('请求失败处理');
vc.message(json);
vc.toast(json);
});
},
@ -49,4 +49,4 @@
}
});
})(window.vc,window.vc.component);
})(window.vc,window.$that);

View File

@ -39,7 +39,7 @@
});
vc.on('ownerDetailAccountReceipt', 'paginationPlus', 'page_event',
function(_currentPage) {
vc.component._listOwnerDetailAccountReceipt(_currentPage, DEFAULT_ROWS);
$that._listOwnerDetailAccountReceipt(_currentPage, DEFAULT_ROWS);
});
},
methods: {
@ -58,13 +58,13 @@
vc.http.apiGet('/receipt.listAccountReceipt',
param,
function(json, res) {
var _feeReceiptManageInfo = JSON.parse(json);
vc.component.ownerDetailAccountReceiptInfo.total = _feeReceiptManageInfo.total;
vc.component.ownerDetailAccountReceiptInfo.records = _feeReceiptManageInfo.records;
vc.component.ownerDetailAccountReceiptInfo.feeReceipts = _feeReceiptManageInfo.data;
let _json = JSON.parse(json);
$that.ownerDetailAccountReceiptInfo.total = _json.total;
$that.ownerDetailAccountReceiptInfo.records = _json.records;
$that.ownerDetailAccountReceiptInfo.feeReceipts = _json.data;
vc.emit('ownerDetailAccountReceipt', 'paginationPlus', 'init', {
total: vc.component.ownerDetailAccountReceiptInfo.records,
dataCount: vc.component.ownerDetailAccountReceiptInfo.total,
total: $that.ownerDetailAccountReceiptInfo.records,
dataCount: $that.ownerDetailAccountReceiptInfo.total,
currentPage: _page
});
},
@ -74,7 +74,7 @@
);
},
_queryFeeAccountReceiptMethod: function() {
vc.component._listOwnerDetailAccountReceipt(DEFAULT_PAGE, DEFAULT_ROWS);
$that._listOwnerDetailAccountReceipt(DEFAULT_PAGE, DEFAULT_ROWS);
},
_printFeeAccountReceipt: function(_receipt) {
if ($that.ownerDetailAccountReceiptInfo.selectReceipts.length < 1) {
@ -109,11 +109,11 @@
if (e.target.checked) { // 判定全选checkbox的勾选状态
for (var i = 0; i < checkObj.length; i++) {
if (!checkObj[i].checked) { // 将未勾选的checkbox选项push到绑定数组中
vc.component.ownerDetailAccountReceiptInfo.selectReceipts.push(checkObj[i].value);
$that.ownerDetailAccountReceiptInfo.selectReceipts.push(checkObj[i].value);
}
}
} else { // 如果是去掉全选则清空checkbox选项绑定数组
vc.component.ownerDetailAccountReceiptInfo.selectReceipts = [];
$that.ownerDetailAccountReceiptInfo.selectReceipts = [];
}
}
}

View File

@ -68,7 +68,7 @@
<vc:i18n name="开票内容" namespace="ownerApplyInvoice"></vc:i18n>
</label>
<div class="col-sm-4">
<select class="custom-select" v-model="ownerApplyInvoiceInfo.invoiceFlag">
<select class="custom-select" v-model="ownerApplyInvoiceInfo.invoiceFlag" @change="_changeInvoiceFlag">
<option selected disabled value="">{{vc.i18n('必填,请选择开票内容','ownerApplyInvoice')}}
</option>
<option value="FEE">{{vc.i18n('已缴费用','ownerApplyInvoice')}}</option>
@ -248,7 +248,7 @@
</div>
<div class="row">
<div class="col-md-12 text-right">
<button class="btn btn-primary" type="button" v-on:click="saveHandoverInfo()"><i
<button class="btn btn-primary" type="button" v-on:click="_ownerApplySubmit()"><i
class="fa fa-check"></i>&nbsp;提交</button>
</div>
</div>

View File

@ -2,6 +2,7 @@
vc.extends({
data: {
ownerApplyInvoiceInfo: {
oiId:'',
ownerId: '',
ownerName: '',
invoiceType: '',
@ -10,9 +11,9 @@
invoiceNum: '',
detailIds: [],
feeDetails: [],
invoiceFlag:'FEE',
arIds:[],
acctDetails:[]
invoiceFlag: 'FEE',
arIds: [],
acctDetails: []
}
},
watch: {
@ -44,10 +45,15 @@
_initEvent: function () {
vc.on('ownerApplyInvoice', 'chooseOwnerInvoice', function (_owner) {
vc.copyObject(_owner, $that.ownerApplyInvoiceInfo);
$that._loadFeeDetails();
$that.ownerApplyInvoiceInfo.arIds = [];
$that.ownerApplyInvoiceInfo.detailIds = [];
if ($that.ownerApplyInvoiceInfo.invoiceFlag == 'FEE') {
$that._loadFeeDetails();
} else {
$that._loadAcctDetails();
}
});
},
methods: {
@ -64,7 +70,6 @@
ownerId: $that.ownerApplyInvoiceInfo.ownerId,
}
};
$that.ownerApplyInvoiceInfo.detailIds = [];
//发送get请求
@ -100,6 +105,116 @@
$that.ownerApplyInvoiceInfo.detailIds = [];
}
},
_loadAcctDetails: function () {
let param = {
params: {
page: 1,
row: 50,
communityId: vc.getCurrentCommunity().communityId,
ownerId: $that.ownerApplyInvoiceInfo.ownerId,
}
};
$that.ownerApplyInvoiceInfo.arIds = [];
//发送get请求
vc.http.apiGet('/receipt.listAccountReceipt',
param,
function (json) {
let _json = JSON.parse(json);
$that.ownerApplyInvoiceInfo.acctDetails = _json.data;
if (_json.data && _json.data.length > 0) {
setTimeout(function () {
_json.data.forEach(_acct => {
$that.ownerApplyInvoiceInfo.arIds.push(_acct.arId);
});
}, 1000)
}
},
function () {
console.log('请求失败处理');
}
);
},
checkAllAcct: function (e) {
let checkObj = document.querySelectorAll('.checkItemAcct'); // 获取所有checkbox项
if (e.target.checked) { // 判定全选checkbox的勾选状态
for (let i = 0; i < checkObj.length; i++) {
if (!checkObj[i].checked) { // 将未勾选的checkbox选项push到绑定数组中
$that.ownerApplyInvoiceInfo.arIds.push(checkObj[i].value);
}
}
} else { // 如果是去掉全选则清空checkbox选项绑定数组
$that.ownerApplyInvoiceInfo.arIds = [];
}
},
_changeInvoiceFlag: function () {
let _ownerId = $that.ownerApplyInvoiceInfo.ownerId;
$that.ownerApplyInvoiceInfo.arIds = [];
$that.ownerApplyInvoiceInfo.detailIds = [];
if (!_ownerId) {
return;
}
if ($that.ownerApplyInvoiceInfo.invoiceFlag == 'FEE') {
$that._loadFeeDetails();
} else {
$that._loadAcctDetails();
}
},
_ownerApplySubmit: function () {
let _arIds = $that.ownerApplyInvoiceInfo.arIds;
let _detailIds = $that.ownerApplyInvoiceInfo.detailIds;
if ($that.ownerApplyInvoiceInfo.invoiceFlag == 'FEE' && !_detailIds) {
vc.toast('未选择已缴费费用');
return;
}
if ($that.ownerApplyInvoiceInfo.invoiceFlag == 'ACCT' && !_arIds) {
vc.toast('未选择账户预存');
return;
}
let _that = $that.ownerApplyInvoiceInfo;
let _data = {
invoiceAddress:_that.invoiceAddress,
invoiceFlag:_that.invoiceFlag,
invoiceName: _that.invoiceName,
invoiceNum:_that.invoiceNum,
invoiceType:_that.invoiceType,
ownerId:_that.ownerId,
ownerName:_that.ownerName,
oiId:_that.oiId,
detailIds:_detailIds,
arIds:_arIds,
communityId:vc.getCurrentCommunity().communityId,
}
vc.http.apiPost(
'/invoice.saveInvoiceApply',
JSON.stringify(_data),
{
emulateJSON: true
},
function (json, res) {
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
vc.goBack();
return;
}
vc.toast(_json.msg);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
}
}
});
})(window.vc);