MicroCommunityWeb/public/components/examine/addExamineProject/addExamineProject.js
2023-03-07 18:54:19 +08:00

140 lines
4.4 KiB
JavaScript

(function(vc){
vc.extends({
propTypes: {
callBackListener:vc.propTypes.string, //父组件名称
callBackFunction:vc.propTypes.string //父组件监听方法
},
data:{
addExamineProjectInfo:{
projectId:'',
name:'',
postCd:'',
weight:'',
state:'',
}
},
_initMethod:function(){
},
_initEvent:function(){
vc.on('addExamineProject','openAddExamineProjectModal',function(){
$('#addExamineProjectModel').modal('show');
});
},
methods:{
addExamineProjectValidate(){
return vc.validate.validate({
addExamineProjectInfo:vc.component.addExamineProjectInfo
},{
'addExamineProjectInfo.name':[
{
limit:"required",
param:"",
errInfo:"项目名称不能为空"
},
{
limit:"maxLength",
param:"64",
errInfo:"项目名称不能超过64"
},
],
'addExamineProjectInfo.postCd':[
{
limit:"required",
param:"",
errInfo:"岗位不能为空"
},
{
limit:"maxLength",
param:"30",
errInfo:"岗位编号不能超过30"
},
],
'addExamineProjectInfo.weight':[
{
limit:"required",
param:"",
errInfo:"比重不能为空"
},
{
limit:"maxLength",
param:"12",
errInfo:"比重不能超过12"
},
],
'addExamineProjectInfo.state':[
{
limit:"required",
param:"",
errInfo:"状态不能为空"
},
{
limit:"maxLength",
param:"12",
errInfo:"状态不能超过12"
},
],
});
},
saveExamineProjectInfo:function(){
if(!vc.component.addExamineProjectValidate()){
vc.toast(vc.validate.errInfo);
return ;
}
vc.component.addExamineProjectInfo.communityId = vc.getCurrentCommunity().communityId;
//不提交数据将数据 回调给侦听处理
if(vc.notNull($props.callBackListener)){
vc.emit($props.callBackListener,$props.callBackFunction,vc.component.addExamineProjectInfo);
$('#addExamineProjectModel').modal('hide');
return ;
}
vc.http.apiPost(
'examineProject.saveExamineProject',
JSON.stringify(vc.component.addExamineProjectInfo),
{
emulateJSON:true
},
function(json,res){
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#addExamineProjectModel').modal('hide');
vc.component.clearAddExamineProjectInfo();
vc.emit('examineProjectManage','listExamineProject',{});
return ;
}
vc.message(_json.msg);
},
function(errInfo,error){
console.log('请求失败处理');
vc.message(errInfo);
});
},
clearAddExamineProjectInfo:function(){
vc.component.addExamineProjectInfo = {
name:'',
postCd:'',
weight:'',
state:'',
};
}
}
});
})(window.vc);