Files
PropertyDeployment/resources/Web/MicroCommunityWeb/html/components/property/editInspectionRoute/editInspectionRoute.js
2025-12-09 20:22:03 +08:00

103 lines
4.1 KiB
JavaScript

(function (vc, vm) {
vc.extends({
data: {
editInspectionRouteInfo: {
inspectionRouteId: '',
routeName: '',
seq: '1',
remark: ''
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('editInspectionRoute', 'openEditInspectionRouteModal',
function (_params) {
vc.component.refreshEditInspectionRouteInfo();
$('#editInspectionRouteModel').modal('show');
vc.copyObject(_params, vc.component.editInspectionRouteInfo);
vc.component.editInspectionRouteInfo.communityId = vc.getCurrentCommunity().communityId;
});
},
methods: {
editInspectionRouteValidate: function () {
return vc.validate.validate({
editInspectionRouteInfo: vc.component.editInspectionRouteInfo
}, {
'editInspectionRouteInfo.routeName': [
{
limit: "required",
param: "",
errInfo: "路线名称不能为空"
},
{
limit: "maxin",
param: "1,100",
errInfo: "路线名称字数不能超过100个"
}
],
'editInspectionRouteInfo.seq': [
{
limit: "required",
param: "",
errInfo: "顺序不能为空"
},
{
limit: "num",
param: "",
errInfo: "顺序必须是数字"
}
],
'editInspectionRouteInfo.remark': [
{
limit: "maxin",
param: "0,200",
errInfo: "备注不能超过200位"
}
],
'editInspectionRouteInfo.inspectionRouteId': [
{
limit: "required",
param: "",
errInfo: "路线ID不能为空"
}
]
});
},
editInspectionRoute: function () {
if (!vc.component.editInspectionRouteValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.component.editInspectionRouteInfo.communityId = vc.getCurrentCommunity().communityId;
vc.http.apiPost('/inspectionRoute.updateInspectionRoute', JSON.stringify(vc.component.editInspectionRouteInfo), {
emulateJSON: true
},
function (json, res) {
let _json = JSON.parse(json)
if (_json.code == 0) {
//关闭model
$('#editInspectionRouteModel').modal('hide');
vc.emit('inspectionRoute', 'listInspectionRoute', {});
vc.toast("修改成功");
return;
} else {
vc.toast(_json.msg);
}
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
},
refreshEditInspectionRouteInfo: function () {
vc.component.editInspectionRouteInfo = {
inspectionRouteId: '',
routeName: '',
seq: '',
remark: ''
}
}
}
});
})(window.vc, window.vc.component);