优化代码

This commit is contained in:
wuxw 2022-05-09 20:34:15 +08:00
parent 47fe424341
commit 04b399f82c
6 changed files with 259 additions and 19 deletions

View File

@ -1,8 +1,11 @@
<div id = "chooseFeeComboModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="chooseFeeComboModelLabel" aria-hidden="true" >
<div id="chooseFeeComboModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="chooseFeeComboModelLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="chooseFeeComboModelLabel"> <span><vc:i18n name="选择费用套餐" namespace="chooseFeeCombo"></vc:i18n></span></h3>
<h3 class="modal-title" id="chooseFeeComboModelLabel"> <span>
<vc:i18n name="选择费用套餐" namespace="chooseFeeCombo"></vc:i18n>
</span></h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
@ -17,11 +20,16 @@
</div>
<div class="col-sm-5">
<div class="input-group">
<input :placeholder="vc.i18n('输入费用套餐名称','chooseFeeCombo')" type="text" v-model="chooseFeeComboInfo._currentFeeComboName" class="form-control form-control-sm">
<input :placeholder="vc.i18n('输入费用套餐名称','chooseFeeCombo')" type="text"
v-model="chooseFeeComboInfo._currentFeeComboName"
class="form-control form-control-sm">
<span class="input-group-append">
<button type="button" class="btn btn-sm btn-primary" v-on:click="queryFeeCombos()">
<span><vc:i18n name="查询"></vc:i18n></span></button>
</span>
<button type="button" class="btn btn-sm btn-primary"
v-on:click="queryFeeCombos()">
<span>
<vc:i18n name="查询"></vc:i18n>
</span></button>
</span>
</div>
</div>
</div>
@ -29,21 +37,33 @@
<table class="table table-striped">
<thead>
<tr>
<th class="text-center"><span><vc:i18n name='编号' namespace='choosefeeCombo'></vc:i18n></span></th>
<th class="text-center"><span><vc:i18n name='套餐名称' namespace='choosefeeCombo'></vc:i18n></span> </th>
<th class="text-center"><span><vc:i18n name='操作'></vc:i18n></span></th>
<th class="text-center"><span>
<vc:i18n name='套餐名称' namespace='choosefeeCombo'></vc:i18n>
</span> </th>
<th class="text-center"><span>
<vc:i18n name='创建时间' ></vc:i18n>
</span> </th>
<th class="text-center"><span>
<vc:i18n name='说明' namespace='choosefeeCombo'></vc:i18n>
</span></th>
<th class="text-center"><span>
<vc:i18n name='操作'></vc:i18n>
</span></th>
</tr>
</thead>
<tbody>
<tr v-for="feeCombo in chooseFeeComboInfo.feeCombos">
<td class="text-center">{{feeCombo.comboId}}</td>
<td class="text-center">{{feeCombo.comboName}}</td>
<td class="text-center">{{feeCombo.comboName}}</td>
<td class="text-center">{{feeCombo.createTime}}</td>
<td class="text-center">{{feeCombo.remark}}</td>
<td>
<button class="btn btn-primary btn-xs" v-on:click="chooseFeeCombo(feeCombo)">
<span><vc:i18n name="选择"></vc:i18n></span>
</button>
<button class="btn btn-primary btn-xs"
v-on:click="chooseFeeCombo(feeCombo)">
<span>
<vc:i18n name="选择"></vc:i18n>
</span>
</button>
</td>
</tr>
</tbody>
@ -56,4 +76,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@ -31,11 +31,11 @@
};
//发送get请求
vc.http.apiGet('feeCombo.listFeeCombos',
vc.http.apiGet('/feeCombo.listFeeCombo',
param,
function(json){
var _feeComboInfo = JSON.parse(json);
vc.component.chooseFeeComboInfo.feeCombos = _feeComboInfo.feeCombos;
vc.component.chooseFeeComboInfo.feeCombos = _feeComboInfo.data;
},function(){
console.log('请求失败处理');
}

View File

@ -0,0 +1,72 @@
<div>
<div class="row">
<div class="col-lg-12">
<div class="ibox">
<div class="ibox-title">
<h5>{{createFeeByComboInfo.payerObjName}}<span><vc:i18n name="创建费用(根据费用套餐创建)" namespace="createFeeByCombo"></vc:i18n></span></h5>
<div class="ibox-tools" style="top:10px;">
<button type="button" class="btn btn-primary btn-sm" v-on:click="_chooseFeeCombo()">
选择费用套餐
</button>
<button type="button" class="btn btn-white btn-sm" v-on:click="_goBack()">
返回
</button>
</div>
</div>
<div class="ibox-content">
<table class="footable table table-stripped toggle-arrow-tiny" data-page-size="15">
<thead>
<tr>
<th class="text-center"><input type="checkbox" class="i-checks" @click="checkAll($event)"></th>
<th class="text-center"><span><vc:i18n name="费用类型" namespace="createFeeByCombo"></vc:i18n></span></th>
<th class="text-center"><span><vc:i18n name="费用项目" namespace="createFeeByCombo"></vc:i18n></span></th>
<th class="text-center"><span><vc:i18n name="费用标识" namespace="createFeeByCombo"></vc:i18n></span></th>
<th class="text-center"><span><vc:i18n name="计费起始时间" namespace="createFeeByCombo"></vc:i18n></span></th>
<th class="text-center"><span><vc:i18n name="计费结束时间" namespace="createFeeByCombo"></vc:i18n></span></th>
</tr>
</thead>
<tbody>
<tr v-for="feeConfig in createFeeByComboInfo.feeConfigs">
<td class="text-center">
<input type="checkbox" class="i-checks checkItem" v-bind:value="feeConfig.configId" v-model="createFeeByComboInfo.selectConfigIds">
</td>
<td class="text-center">{{feeConfig.feeTypeCdName}}</td>
<td class="text-center">{{feeConfig.feeName}}</td>
<td class="text-center">{{feeConfig.feeFlagName}}</td>
<td class="text-center">
<input v-model="feeConfig.startTime" type="text"
:placeholder="vc.i18n('必填,请填写开始时间','createFeeByCombo')" class="form-control" :class="'startTime'+feeConfig.configId">
</td>
<td class="text-center" v-if="feeConfig.feeFlag != '1003006'">
<input v-model="feeConfig.endTime" type="text"
:placeholder="vc.i18n('必填,请填写结束时间','createFeeByCombo')" class="form-control" :class="'endTime'+feeConfig.configId">
</td>
<td class="text-center" v-else>
费用项结束时间
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="8">
<ul class="pagination float-right"></ul>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-10"></div>
<div class="col-md-1 " style="margin-bottom:10px; text-align:right">
<button type="button" class="btn btn-primary btn-lg btn-block" style="margin-left:10px;" v-on:click="_createFee()"><span><vc:i18n name="创建" namespace="createFeeByCombo"></vc:i18n></span>
</button>
</div>
</div>
<vc:create path="property/chooseFeeCombo" emitChooseFeeCombo="createFeeByCombo" emitLoadData="createFeeByCombo"></vc:create>
</div>

View File

@ -0,0 +1,139 @@
(function(vc) {
var DEFAULT_PAGE = 1;
var DEFAULT_ROWS = 10;
vc.extends({
data: {
createFeeByComboInfo: {
feeConfigs: [],
selectConfigIds: [],
communityId: vc.getCurrentCommunity().communityId,
payerObjId: '',
payerObjName: '',
payerObjType: '',
}
},
_initMethod: function() {
let _payerObjId = vc.getParam('payerObjId');
let _payerObjType = vc.getParam('payerObjType');
let _payerObjName = vc.getParam('payerObjName');
$that.createFeeByComboInfo.payerObjId = _payerObjId;
$that.createFeeByComboInfo.payerObjType = _payerObjType;
$that.createFeeByComboInfo.payerObjName = _payerObjName;
},
_initEvent: function() {
vc.on('createFeeByCombo','chooseFeeCombo',function(_feeCombo){
$that._listFeeComboMembers(_feeCombo);
})
},
methods: {
_chooseFeeCombo:function(){
vc.emit('chooseFeeCombo','openChooseFeeComboModel',{});
},
_listFeeComboMembers: function (_feeCombo) {
let param = {
params: {
page:1,
row:100,
comboId:_feeCombo.comboId
}
};
//发送get请求
vc.http.apiGet('/feeComboMember.listFeeComboMember',
param,
function (json, res) {
let _feeComboMemberManageInfo = JSON.parse(json);
_feeComboMemberManageInfo.data.forEach(config =>{
config.startTime='';
config.endTime=''
})
vc.component.createFeeByComboInfo.feeConfigs = _feeComboMemberManageInfo.data;
$that.$forceUpdate();
setTimeout(()=>{
_feeComboMemberManageInfo.data.forEach(config =>{
vc.initDate('startTime'+config.configId,function(_value){
config.startTime = _value;
})
vc.initDate('endTime'+config.configId,function(_value){
config.endTime = _value;
})
})
},1000)
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_doPayFee: function() {
let _fees = [];
let _printFees = [];
if ($that.createFeeByComboInfo.primeRate == '') {
vc.toast('请选择支付方式');
return;
}
$that.createFeeByComboInfo.selectConfigIds.forEach(function(_item) {
$that.createFeeByComboInfo.batchFees.forEach(function(_batchFeeItem) {
if (_item == _batchFeeItem.feeId) {
_batchFeeItem.primeRate = $that.createFeeByComboInfo.primeRate;
_fees.push(_batchFeeItem);
_printFees.push({
feeId: _item,
squarePrice: _batchFeeItem.squarePrice,
additionalAmount: _batchFeeItem.additionalAmount,
feeName: _batchFeeItem.feeName,
amount: _batchFeeItem.feePrice,
roomName: $that.createFeeByComboInfo.roomName,
primeRate: $that.createFeeByComboInfo.primeRate
});
}
})
})
if (_fees.length < 1) {
vc.toast('未选中要缴费的项目');
return;
}
let _data = {
communityId: vc.getCurrentCommunity().communityId,
fees: _fees
}
vc.http.apiPost(
'/fee.payBatchFee',
JSON.stringify(_data), {
emulateJSON: true
},
function(json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
vc.toast(_json.msg);
if (_json.code == 0) {
vc.goBack();
return;
}
},
function(errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
},
_back: function() {
$('#payFeeResult').modal("hide");
vc.getBack();
},
checkAll: function(e) {
var checkObj = document.querySelectorAll('.checkItem'); // 获取所有checkbox项
if (e.target.checked) { // 判定全选checkbox的勾选状态
for (var i = 0; i < checkObj.length; i++) {
if (!checkObj[i].checked) { // 将未勾选的checkbox选项push到绑定数组中
vc.component.createFeeByComboInfo.selectConfigIds.push(checkObj[i].value);
}
}
} else { // 如果是去掉全选则清空checkbox选项绑定数组
vc.component.createFeeByComboInfo.selectConfigIds = [];
}
}
}
});
})(window.vc);

View File

@ -13,6 +13,9 @@
<button type="button" class="btn btn-primary btn-sm" style="margin-left:10px" v-on:click="_openAddMeterWaterModal()" v-if="listRoomCreateFeeInfo.hireOwnerFee == '0'">
水电抄表
</button>
<button type="button" class="btn btn-primary btn-sm" style="margin-left:10px" v-on:click="_openRoomCreateFeeComboModal()" v-if="listRoomCreateFeeInfo.hireOwnerFee == '0'">
创建费用套餐
</button>
<button type="button" class="btn btn-primary btn-sm" style="margin-left:10px" v-on:click="_openRoomCreateFeeAddModal()" v-if="listRoomCreateFeeInfo.hireOwnerFee == '0'">
创建费用
</button>

View File

@ -118,6 +118,12 @@
room: $that.listRoomCreateFeeInfo
});
},
_openRoomCreateFeeComboModal:function(){
vc.jumpToPage('/#/pages/property/createFeeByCombo?payerObjId='
+$that.listRoomCreateFeeInfo.roomId
+"&payerObjName="+$that.listRoomCreateFeeInfo.roomName
+"&payerObjType=3333")
},
_openAddMeterWaterModal: function() {
vc.emit('addMeterWater', 'openAddMeterWaterModal', {
roomId: $that.listRoomCreateFeeInfo.roomId,