mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-27 00:20:01 +08:00
144 lines
5.3 KiB
JavaScript
144 lines
5.3 KiB
JavaScript
(function (vc, vm) {
|
|
|
|
vc.extends({
|
|
data: {
|
|
editChargeMachineInfo: {
|
|
machineId: '',
|
|
machineName: '',
|
|
machineCode: '',
|
|
implBean: '',
|
|
durationPrice: '',
|
|
energyPrice: '',
|
|
|
|
}
|
|
},
|
|
_initMethod: function () {
|
|
|
|
},
|
|
_initEvent: function () {
|
|
vc.on('editChargeMachine', 'openEditChargeMachineModal', function (_params) {
|
|
vc.component.refreshEditChargeMachineInfo();
|
|
$('#editChargeMachineModel').modal('show');
|
|
vc.copyObject(_params, vc.component.editChargeMachineInfo);
|
|
vc.component.editChargeMachineInfo.communityId = vc.getCurrentCommunity().communityId;
|
|
});
|
|
},
|
|
methods: {
|
|
editChargeMachineValidate: function () {
|
|
return vc.validate.validate({
|
|
editChargeMachineInfo: vc.component.editChargeMachineInfo
|
|
}, {
|
|
'editChargeMachineInfo.machineName': [
|
|
{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "名称不能为空"
|
|
},
|
|
{
|
|
limit: "maxLength",
|
|
param: "200",
|
|
errInfo: "名称不能超过200"
|
|
},
|
|
],
|
|
'editChargeMachineInfo.machineCode': [
|
|
{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "设备编号不能为空"
|
|
},
|
|
{
|
|
limit: "maxLength",
|
|
param: "30",
|
|
errInfo: "设备编号不能超过30"
|
|
},
|
|
],
|
|
'editChargeMachineInfo.implBean': [
|
|
{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "厂家不能为空"
|
|
},
|
|
{
|
|
limit: "maxLength",
|
|
param: "30",
|
|
errInfo: "厂家不能超过30"
|
|
},
|
|
],
|
|
'editChargeMachineInfo.durationPrice': [
|
|
{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "小时电价不能为空"
|
|
},
|
|
{
|
|
limit: "maxLength",
|
|
param: "12",
|
|
errInfo: "小时电价不能超过12"
|
|
},
|
|
],
|
|
'editChargeMachineInfo.energyPrice': [
|
|
{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "用量电价不能为空"
|
|
},
|
|
{
|
|
limit: "maxLength",
|
|
param: "12",
|
|
errInfo: "用量电价不能超过12"
|
|
},
|
|
],
|
|
'editChargeMachineInfo.machineId': [
|
|
{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "编号不能为空"
|
|
}]
|
|
|
|
});
|
|
},
|
|
editChargeMachine: function () {
|
|
if (!vc.component.editChargeMachineValidate()) {
|
|
vc.toast(vc.validate.errInfo);
|
|
return;
|
|
}
|
|
|
|
vc.http.apiPost(
|
|
'/chargeMachine.updateChargeMachine',
|
|
JSON.stringify(vc.component.editChargeMachineInfo),
|
|
{
|
|
emulateJSON: true
|
|
},
|
|
function (json, res) {
|
|
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
|
|
let _json = JSON.parse(json);
|
|
if (_json.code == 0) {
|
|
//关闭model
|
|
$('#editChargeMachineModel').modal('hide');
|
|
vc.emit('chargeMachineManage', 'listChargeMachine', {});
|
|
return;
|
|
}
|
|
vc.message(_json.msg);
|
|
},
|
|
function (errInfo, error) {
|
|
console.log('请求失败处理');
|
|
|
|
vc.message(errInfo);
|
|
});
|
|
},
|
|
refreshEditChargeMachineInfo: function () {
|
|
vc.component.editChargeMachineInfo = {
|
|
machineId: '',
|
|
machineName: '',
|
|
machineCode: '',
|
|
implBean: '',
|
|
durationPrice: '',
|
|
energyPrice: '',
|
|
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
})(window.vc, window.vc.component);
|