优化代码

This commit is contained in:
wuxw 2022-11-06 03:24:36 +08:00
parent ef741dffd5
commit 6cea0ee689
2 changed files with 100 additions and 29 deletions

View File

@ -46,6 +46,22 @@
</select>
</div>
</div>
<div class="form-group row" v-if="parkingAreaControlCustomCarInoutInfo.type != '1101' && parkingAreaControlCustomCarInoutInfo.coupons.length>0">
<label class="col-sm-2 col-form-label"><span><vc:i18n name="优惠券" namespace="parkingAreaControlCustomCarInout"></vc:i18n></span></label>
<div class="col-sm-10">
<div class="checkbox custom-control-inline" v-for="(coupon,index) in parkingAreaControlCustomCarInoutInfo.coupons">
<label>
<input type="checkbox" v-model="parkingAreaControlCustomCarInoutInfo.pccIds" @change="_computeCouponMoney"
:value="coupon.pccId">
<span>{{coupon.couponName}}-</span>
<span v-if="coupon.typeCd == '1001'">{{coupon.value}}分钟</span>
<span v-if="coupon.typeCd == '2002'">{{coupon.value}}元</span>
<span v-if="coupon.typeCd == '3003'">{{coupon.value}}折</span>
<span v-if="coupon.typeCd == '4004'">全免</span>
</label>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span><vc:i18n name="备注" namespace="parkingAreaControlCustomCarInout"></vc:i18n></span></label>

View File

@ -1,4 +1,4 @@
(function(vc, vm) {
(function (vc, vm) {
vc.extends({
data: {
@ -15,16 +15,18 @@
payType: '',
payTypes: [],
inoutId: '',
machines: []
machines: [],
coupons: [],
pccIds: [],
}
},
_initMethod: function() {
vc.getDict('car_inout_payment', 'pay_type', function(_data) {
_initMethod: function () {
vc.getDict('car_inout_payment', 'pay_type', function (_data) {
$that.parkingAreaControlCustomCarInoutInfo.payTypes = _data;
})
},
_initEvent: function() {
vc.on('parkingAreaControlCustomCarInout', 'open', function(_params) {
_initEvent: function () {
vc.on('parkingAreaControlCustomCarInout', 'open', function (_params) {
vc.component.refreshParkingAreaControlCustomCarInoutInfo();
$('#parkingAreaControlCustomCarInoutModel').modal('show');
// = _params;
@ -34,7 +36,7 @@
});
},
methods: {
parkingAreaControlCustomCarInoutValidate: function() {
parkingAreaControlCustomCarInoutValidate: function () {
return vc.validate.validate({
parkingAreaControlCustomCarInoutInfo: vc.component.parkingAreaControlCustomCarInoutInfo
}, {
@ -45,7 +47,7 @@
}]
});
},
parkingAreaControlCustomCarInout: function() {
parkingAreaControlCustomCarInout: function () {
if (!vc.component.parkingAreaControlCustomCarInoutValidate()) {
vc.toast(vc.validate.errInfo);
return;
@ -53,9 +55,9 @@
vc.http.apiPost(
'/machine.customCarInOutCmd',
JSON.stringify(vc.component.parkingAreaControlCustomCarInoutInfo), {
emulateJSON: true
},
function(json, res) {
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _data = JSON.parse(json);
if (_data.code != 0) {
@ -66,13 +68,13 @@
vc.emit('parkingAreaControlFee', 'clear', {})
}
},
function(errInfo, error) {
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
},
refreshParkingAreaControlCustomCarInoutInfo: function() {
refreshParkingAreaControlCustomCarInoutInfo: function () {
let _payTypes = $that.parkingAreaControlCustomCarInoutInfo.payTypes;
vc.component.parkingAreaControlCustomCarInoutInfo = {
carNum: '',
@ -87,10 +89,12 @@
payType: '',
payTypes: _payTypes,
inoutId: '',
machines: []
machines: [],
coupons: [],
pccIds: [],
}
},
_loadParkingAreaControlCustomCarInoutData: function() {
_loadParkingAreaControlCustomCarInoutData: function () {
let param = {
params: {
page: 1,
@ -104,7 +108,7 @@
//发送get请求
vc.http.apiGet('/carInout.listCarInParkingAreaCmd',
param,
function(json) {
function (json) {
let _feeConfigInfo = JSON.parse(json);
let _data = _feeConfigInfo.data;
@ -117,12 +121,12 @@
$that.parkingAreaControlCustomCarInoutInfo.inoutId = _data[0].inoutId;
$that.parkingAreaControlCustomCarInoutInfo.costMin = _data[0].hours + "时" + _data[0].min + "分";
},
function() {
function () {
console.log('请求失败处理');
}
);
},
_queryCustomCarMoney: function() {
_queryCustomCarMoney: function () {
if (!$that.parkingAreaControlCustomCarInoutInfo.carNum) {
return;
}
@ -133,26 +137,77 @@
$that._loadOutMachinesByPaId();
}
$that._loadParkingAreaControlCustomCarInoutData();
$that._loadOutCoupons();
},
_loadOutMachinesByPaId: function() {
_loadOutMachinesByPaId: function () {
let param = {
params: {
paId: $that.parkingAreaTotalControlVideoInfo.paId,
page: 1,
row: 100,
direction: '3307',
communityId: vc.getCurrentCommunity().communityId
}
params: {
paId: $that.parkingAreaTotalControlVideoInfo.paId,
page: 1,
row: 100,
direction: '3307',
communityId: vc.getCurrentCommunity().communityId
}
//发送get请求
}
//发送get请求
vc.http.apiGet('/machine.listParkingAreaMachines',
param,
function(json, res) {
function (json, res) {
let _machineManageInfo = JSON.parse(json);
let _machines = _machineManageInfo.data;
$that.parkingAreaControlCustomCarInoutInfo.machines = _machines;
},
function(errInfo, error) {
function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_loadOutCoupons: function () {
let param = {
params: {
paId: $that.parkingAreaTotalControlVideoInfo.paId,
page: 1,
row: 30,
state: '1001',
carNum: $that.parkingAreaTotalControlVideoInfo.carNum
}
}
//发送get请求
vc.http.apiGet('/parkingCoupon.listParkingCouponCar',
param,
function (json, res) {
let _machineManageInfo = JSON.parse(json);
let _coupons = _machineManageInfo.data;
$that.parkingAreaControlCustomCarInoutInfo.coupons = _coupons;
},
function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_computeCouponMoney: function () {
let _pccIds = $that.parkingAreaTotalControlVideoInfo.pccIds;
if(!_pccIds || _pccIds.length<1){
return;
}
let param = {
params: {
paId: $that.parkingAreaTotalControlVideoInfo.paId,
pccIds: $that.parkingAreaTotalControlVideoInfo.pccIds.join(","),
carNum: $that.parkingAreaTotalControlVideoInfo.carNum
}
}
//发送get请求
vc.http.apiGet('/tempCarFee.getTempCarFeeOrder',
param,
function (json, res) {
let _machineManageInfo = JSON.parse(json);
let data = _machineManageInfo.data;
$that.parkingAreaControlCustomCarInoutInfo.payCharge = data.amount;
$that.parkingAreaControlCustomCarInoutInfo.amount = data.amount;
},
function (errInfo, error) {
console.log('请求失败处理');
}
);