MicroCommunityWeb/public/pages/property/payFeeOrder/payFeeOrder.js
2020-08-20 15:21:22 +08:00

148 lines
5.9 KiB
JavaScript

(function (vc) {
var DEFAULT_PAGE = 1;
var DEFAULT_ROWS = 10;
vc.extends({
data: {
payFeeOrderInfo: {
feeId: '',
feeName: '',
feeTypeCdName: '',
endTime: '',
feeFlag: '',
feePrice: 0.00,
cycles: '1',
paymentCycles: [],
totalFeePrice: 0.00,
receivedAmount: '',
communityId: vc.getCurrentCommunity().communityId,
roomName:'',
squarePrice:'',
additionalAmount:'',
remark:''
}
},
_initMethod: function () {
if (vc.notNull(vc.getParam("feeId"))) {
vc.component.payFeeOrderInfo.feeId = vc.getParam('feeId');
vc.component.payFeeOrderInfo.feeName = vc.getParam('feeName');
vc.component.payFeeOrderInfo.feeTypeCdName = vc.getParam('feeTypeCdName');
vc.component.payFeeOrderInfo.endTime = vc.getParam('endTime').replace(/%3A/g, ':');
vc.component.payFeeOrderInfo.feePrice = vc.getParam('feePrice');
$that.payFeeOrderInfo.feeFlag = vc.getParam('feeFlag');
$that.payFeeOrderInfo.roomName = vc.getParam('roomName');
$that.payFeeOrderInfo.squarePrice = vc.getParam('squarePrice');
$that.payFeeOrderInfo.additionalAmount = vc.getParam('additionalAmount');
$that.payFeeOrderInfo.paymentCycles = [];
for (let _index = 1; _index < 7; _index++) {
$that.payFeeOrderInfo.paymentCycles.push(_index * vc.getParam('paymentCycle'))
}
};
vc.component.payFeeOrderInfo.totalFeePrice = vc.component.payFeeOrderInfo.feePrice;
vc.component.payFeeOrderInfo.receivedAmount = vc.component.payFeeOrderInfo.totalFeePrice;
},
_initEvent: function () {
},
methods: {
payFeeValidate: function () {
return vc.validate.validate({
payFeeOrderInfo: vc.component.payFeeOrderInfo
}, {
'payFeeOrderInfo.feeId': [
{
limit: "required",
param: "",
errInfo: "费用ID不能为空"
}
],
'payFeeOrderInfo.cycles': [
{
limit: "required",
param: "",
errInfo: "缴费周期不能为空"
}
],
'payFeeOrderInfo.receivedAmount': [
{
limit: "required",
param: "",
errInfo: "实收金额不能为空"
},
{
limit: "money",
param: "",
errInfo: "实收金额不是有效的金额"
}
]
});
},
_payFee: function (_page, _row) {
if (!vc.component.payFeeValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
let _printFees = [];
_printFees.push({
feeId: $that.payFeeOrderInfo.feeId,
squarePrice:$that.payFeeOrderInfo.squarePrice,
additionalAmount: $that.payFeeOrderInfo.additionalAmount,
feeName: $that.payFeeOrderInfo.feeName,
amount: $that.payFeeOrderInfo.feePrice
});
vc.http.post(
'propertyPay',
'payFee',
JSON.stringify(vc.component.payFeeOrderInfo),
{
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
if (res.status == 200) {
let _feeInfo = {
totalAmount: $that.payFeeOrderInfo.feePrice,
fees: _printFees
}
vc.saveData('_feeInfo',_feeInfo);
//关闭model
$("#payFeeResult").modal({
backdrop: "static",//点击空白处不关闭对话框
show: true
});
return;
}
vc.toast(json);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
},
_changeMonth: function (_cycles) {
if ('-101' == _cycles) {
vc.component.payFeeOrderInfo.totalFeePrice = 0.00;
vc.component.payFeeOrderInfo.receivedAmount = '';
return;
}
vc.component.payFeeOrderInfo.totalFeePrice = Math.floor(parseFloat(_cycles) * parseFloat(vc.component.payFeeOrderInfo.feePrice) * 100) / 100;
vc.component.payFeeOrderInfo.receivedAmount = vc.component.payFeeOrderInfo.totalFeePrice;
},
_back: function () {
$('#payFeeResult').modal("hide");
vc.getBack();
},
_printAndBack: function () {
//$('#payFeeResult').modal("hide");
window.open("/print.html#/pages/property/printPayFee?roomName=" + $that.payFeeOrderInfo.roomName)
}
}
});
})(window.vc);