```
//添加
function add_e(optionss,callback,sub,id_) {
var defaults = {
dialog:'Dialog_',
formId:'editForm',
title:'小窗口',
model_name:'',
id:undefined,
queryParams:{},
width:644,
height:500,
datagrid:"grid",
};
var optionss = $.extend(defaults, optionss);
$.post(optionss.model_name+(sub==undefined?'/edit/':sub)+(id_==undefined?'':id_),
{queryParams:optionss.queryParams,}, function(str){
layer.open({
type: 1,
area: [optionss.width,optionss.height],
fix: false, //不固定
maxmin: false,
shade:0.4,
title:(id_==undefined?"新增":"编辑")+"-"+optionss.title,
content: str,
success:function () {
try{
editor=KindEditor.create('.keditor', {
themeType : 'default',
uploadJson : '/file/up',
fileManagerJson : '/file/manager',
allowFileManager : false
});
}catch(e){}
},
end: function(){
var table = layui.table;
table.reload(optionss.datagrid, {});
},
btn: ['保存', '取消']
,yes: function(index, layero){
var form=layui.form;
form.on('submit('+optionss.submitbtn+')', function (data) {
$.post(optionss.model_name+'/save',$('#'+optionss.formId).serialize(),function (result) {
var json = result;//$.parseJSON(result);
if (json && json.success) {
layer.msg(result.msg,{
icon : 6,
time : 1200
},function () {
layer.closeAll();
});
}else{
layer.msg(result.msg,{
icon : 5,
time : 1200
})
}
})
return false;
});
document.getElementById(optionss.submitbtn).click();
},btn2: function(index, layero){
layer.closeAll();
}
});
});
}
/*使用方法*/
var eoption = {
submitbtn:'staff_form_submit',
formId:'eeditForm',
datagrid:'staffgrid',
title:'人员',
model_name:'/logistical/staff',
height:631,
};
//添加员工
function staff_add() {
add_e(eoption);
}
//编辑员工
function edits() {edit_e(eoption);
}
```
网友评论