/** * 流程用户组页面 * @author weidy * @date 2020-09-29 */ layui.define(['layer','element','form','table','dynamicCondition' ],function(exports){ var webUtil = $webUtil; var Class = function(){ this.MODELNAME = "platform/process/VciProcessUserGroup"; this.moduleKey = "WFWorkflowUserGroup"; this.backPath = configData.compatibility?path:configData.processServicePath; this.url = { controller:'wFWorkflowUserGroupController/', dataGrid:'gridWFWorkflowUserGroup', addSave:'addSave', editSave:'editSave', deleteUrl:'deleteData', enableData: 'enableData', disableData: 'disableData', getObjectByOid:'getObjectByOid' }; this.getContent=function(){ var that = this; var html = ""; html = [ '
', '
', '
', that.getToolbarHtml(), '
', '', '
', '
', '
' ].join(""); return html; }; this.getToolbarHtml =function(){ var that = this; var html = [ '
', '', '', '', '', '', '
' ].join(""); return html; }; this.createSearchHtml = function () { var that = this; webUtil.bindDefultButtonLisenter(that, that.id); webUtil.createSearchHtml({id:"编号",name:"名称"} ,$("[layui-filter='toolbar_" + that.id + "']"), "table_" + that.id); }; this.init = function(){ var that = this; webUtil.copyConfig(that,that.moduleKey); that.initMainTable(); that.createSearchHtml(); }; this.initMainTable = function (parentFieldName) { var that = this; var table = layui.table; that.checkColumns(); var tableWidth = $("#border_" + that.id).width()-225; var options = { elem: '#table_' + that.id, id: 'table_' + that.id, backPath:that.backPath, url: that.url.controller + that.url.dataGrid, page: { limit: 20, page: 1 }, width:tableWidth, selectMode:table.selectMode.muti, cols: [that.columns], done:function(res,cur,total){ if(!that.fristMainLoad ){ table.on('tool(' + that.id + ')',function(obj){ var data = obj.data;//当前选择行的数据 var layEvent = obj.event;//点的是什么按钮 if(layEvent == 'EDIT'){ that.addOrEdit(false,data.oid); } }); }else{ if(total>0) { table.selectRecord('table_' + that.id, {index:0}); } } that.fristMainLoad = true; } }; if(parentFieldName){ options.treeConfig = { treepid:parentFieldName, treeid:'id', showField:'name' }; } table.render(options); document.getElementById("toolbar_column_" + that.id).innerHTML = '编辑'; }; this.checkColumns = function(){ var that = this; var table = layui.table; if(that.columns==null || that.columns.length==0){ that.columns = [table.getIndexColumn(),table.getCheckColumn(), { title: '名称', field: 'name', width: 150 }, { title: '描述', field: 'description', width: 150 }, { title: '生命周期值', field: 'lcStatus', width: 150 }, { title: '编号', field: 'id', width: 150 } ]; } }; this.getFormItems = function(onlyShow) { var that = this; var table = layui.table; return [ { field: 'name', title: '名称', type: 'text', readOnly:onlyShow } , { field: 'description', title: '描述', type: 'text', readOnly:onlyShow } , { field: 'lcStatus', title: '生命周期值', type: 'text', readOnly:onlyShow } , { field: 'id', title: '编号', type: 'text', readOnly:onlyShow } ]; }; this.ADD = function () { var that = this; that.addOrEdit(true); }; this.EDIT = function(){ var that = this; var oid = webUtil.getOidFromGrid("table_" + that.id,true,true); if(!oid){ return false; } that.addOrEdit(false,oid); }; this.addOrEdit = function(add,oid) { var that = this; var form = layui.form; var filter ="form_" + that.id; var addSaveIndex =webUtil.dialog({ title:add?'添加流程用户组':'修改流程用户组', btn:['保存','取消'], skin:'layui-layer-lan', content:'
', fullScreen:true, resizing:function(layero){ form.doResize(filter); }, success:function(layero) { form.addItems(filter,that.getFormItems(false), function () { if(!add){ form.load(filter,{ backPath:that.backPath, url:that.url.controller + that.url.getObjectByOid, method:'get', params:{ oid:oid } }); }else{ var defaultValues = {}; //可以手动在此处添加默认值 form.setValues(defaultValues,filter); } }, {}, {defaultColumnOneRow: 2}); }, yes:function(layero){ if(form.validata(filter)){ var values = form.getValues(filter,true); var url = that.url.controller + (add?that.url.addSave:that.url.editSave); webUtil.ajax(add?'post':'put',url,values,function(result){ if(result.success){ webUtil.showMsgFromResult(result,(add ? "添加成功" : "修改成功")); layer.close(addSaveIndex); that.refresh(); }else{ webUtil.showErrorMsg(result.msg); } },function(xhr,err){ webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启"); },that.backPath); } }, btn2:function(layero){ layer.close(addSaveIndex); } }); }; this.DEL = function(){ var that = this; var oid = webUtil.getOidFromGrid("table_" +that.id,true,true); if(!oid){ return false; } var ts= webUtil.getOidFromGrid("table_" +that.id,false,false,"ts"); webUtil.showConfirmMsg("是否删除这条数据?如果被引用将不能被删除!",function () { webUtil.deleteRequest(that.url.controller + that.url.deleteUrl,{oid:oid,ts:ts},function(result){ if(result.success){ webUtil.showMsgFromResult(result,"删除成功"); that.refresh(); }else{ webUtil.showErrorMsg(result.msg); } },function(xhr,err){ webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启"); },that.backPath); }); }; this.refresh = function () { var that = this; var that = this; layui.table.reload("table_" + that.id); }; this.DISABLE = function () { var that = this; that.disableOrEnable(false); }; this.ENABLE = function () { var that = this; that.disableOrEnable(true); }; this.disableOrEnable = function (enable) { var that = this; var oid ; var ts ; oid = webUtil.getOidFromGrid("table_" + that.id,true,true); if(!oid){ return false; } ts = webUtil.getOidFromGrid("table_" + that.id,false,false,'ts'); webUtil.post(that.url.controller + (enable?that.url.enableData:that.url.disableData),{ oid:oid, ts:ts },function(result){ if(result.success){ webUtil.showMsgFromResult(result,(enable?'启用成功':'停用成功')); that.refresh(); }else{ webUtil.showErrorMsg(result.msg); } },function(xhr,err){ webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启"); },that.backPath); }; this.ADVQUERY = function () { var that = this; if(!that.serinorQueryInstance) { var dynamicCondition = layui.dynamicCondition; $('[layui-filter="toolbar_' + that.id + '"]').append('
'); var dataFields = that.columns; that.serinorQueryInstance = dynamicCondition.create({ fields: dataFields//查询字段 , tableId: "table_" + that.id//需要查询的表格 , type: "complex" //type:"simple"/"complex" 查询的方法 暂时写死为 complex //,conditionTextId:"#toolbar"+that.id//高级查询 按钮所在的div //,popupShowQueryBtn: true//显示高级查询按钮 , queryCallBack: function (requestData) {//查询之后的callback //console.log(JSON.stringify(requestData)) } }); } that.serinorQueryInstance.open(); }; }; var cs = new Class(); exports(cs.MODELNAME,cs); });