Files
PropertyDeployment/resources/Web/MicroCommunityIotWeb/html/components/car/editParkingBox/editParkingBox.js
2025-12-09 20:22:03 +08:00

134 lines
5.1 KiB
JavaScript

(function(vc, vm) {
vc.extends({
data: {
editParkingBoxInfo: {
boxId: '',
boxName: '',
tempCarIn: '',
tempAuth: '',
fee: '',
blueCarIn: '',
yelowCarIn: '',
remark: '',
paId: '',
parkingAreas: []
}
},
_initMethod: function() {
$that._loadEditParkingBoxs();
},
_initEvent: function() {
vc.on('editParkingBox', 'openEditParkingBoxModal', function(_params) {
$that.refreshEditParkingBoxInfo();
$('#editParkingBoxModel').modal('show');
vc.copyObject(_params, $that.editParkingBoxInfo);
$that.editParkingBoxInfo.communityId = vc.getCurrentCommunity().communityId;
});
},
methods: {
editParkingBoxValidate: function() {
return vc.validate.validate({
editParkingBoxInfo: $that.editParkingBoxInfo
}, {
'editParkingBoxInfo.boxName': [{
limit: "required",
param: "",
errInfo: "岗亭名称不能为空"
},
{
limit: "maxLength",
param: "64",
errInfo: "岗亭名称不能超过64"
}
],
'editParkingBoxInfo.paId': [{
limit: "required",
param: "",
errInfo: "停车场不能为空"
}],
'editParkingBoxInfo.tempCarIn': [{
limit: "required",
param: "",
errInfo: "临时车是否进场不能为空"
}],
'editParkingBoxInfo.fee': [{
limit: "required",
param: "",
errInfo: "是否收费不能为空"
}],
'editParkingBoxInfo.blueCarIn': [{
limit: "required",
param: "",
errInfo: "蓝牌车进场不能为空"
}],
'editParkingBoxInfo.yelowCarIn': [{
limit: "required",
param: "",
errInfo: "黄牌车进场不能为空"
}]
});
},
editParkingBox: function() {
if (!$that.editParkingBoxValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.http.apiPost(
'/parkingBox.updateParkingBox',
JSON.stringify($that.editParkingBoxInfo), {
emulateJSON: true
},
function(json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#editParkingBoxModel').modal('hide');
vc.emit('parkingBox', 'listParkingBox', {});
vc.toast("修改成功");
return;
} else {
vc.toast(_json.msg);
}
},
function(errInfo, error) {
console.log('请求失败处理');
vc.message(errInfo);
});
},
_loadEditParkingBoxs: function() {
let param = {
params: {
page: 1,
row: 50,
communityId: vc.getCurrentCommunity().communityId
}
};
//发送get请求
vc.http.apiGet('/parkingArea.listParkingArea', param,
function(json, res) {
let _parkingAreaManageInfo = JSON.parse(json);
$that.editParkingBoxInfo.parkingAreas = _parkingAreaManageInfo.data;
},
function(errInfo, error) {
console.log('请求失败处理');
});
},
refreshEditParkingBoxInfo: function() {
let _parkingAreas = $that.editParkingBoxInfo.parkingAreas;
$that.editParkingBoxInfo = {
boxId: '',
boxName: '',
tempCarIn: '',
tempAuth: '',
fee: '',
blueCarIn: '',
yelowCarIn: '',
remark: '',
paId: '',
parkingAreas: _parkingAreas
}
}
}
});
})(window.vc, window.$that);