/**
|
* 功能模块菜单
|
* @author weidy@2018-06-04
|
* @constructor
|
*/
|
layui.define(['layer','element','form','table','tree'],function(exports){
|
var Class = function(){
|
this.MODELNAME = "platform/securityManage/SmFunction";
|
this.moduleKey = "SmFunction";
|
this.id='SmFunction';
|
this.sourceData={};
|
this.backPath = configData.compatibility?path:configData.frameworkPath;
|
this.buttonIconMap = {};
|
this.url={
|
tree:'smFunctionController/treeAllMenu',
|
getObject: 'smFunctionController/getObjectByOid',
|
add:'smFunctionController/addSave',
|
edit:'smFunctionController/editSave',
|
deleteUrl:'smFunctionController/delete',
|
referTree:'smFunctionController/refTreeMenu',
|
listButton:'smFunctionController/listButton',
|
referButton:'smFunctionController/referButton',
|
addButton:'smFunctionController/addButton',
|
editButton:'smFunctionController/editButton',
|
deleteButton:'smFunctionController/deleteButton',
|
batchAddButton:'smFunctionController/batchAddButton'
|
};
|
this.columns = [];
|
this.getContent=function(){//返回这个组件的基础html
|
var that = this;
|
var html = "";
|
html = [
|
that.getToolbarHtml(),
|
'<div class="layui-layout" style="display:block;overflow-y: hidden">',
|
'<div class="layui-vci-tree" style="width:250px;float: left;background-color:#ffffff;overflow-y: auto;">',
|
'<label class="layui-icon layui-icon-tree" style="line-height: 20px;color:red;font-size:20px;">功能模块菜单</label>',
|
'<ul layui-filter="tree_',that.id,'"><ul>',
|
'</div>',
|
'<div class="layui-layout-border" style="display:block;margin-top:0px;margin-left:255px;">',
|
'<div class="layui-center" style="overflow-y:auto;">',
|
'<form class="layui-form" lay-filter="form_',that.id,'"></form>',
|
'</div>',
|
'<div class="layui-south" >',
|
'<div layui-filter="toolbar_button_',that.id,'" class="layui-btn-container">',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_button_',that.id,'_selectButton"><i class="layui-icon layui-icon-add-1"></i>从按钮库中选择后添加</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_button_',that.id,'_addButton"><i class="layui-icon layui-icon-add-1"></i>添加按钮</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_button_',that.id,'_editButton"><i class="layui-icon layui-icon-edit"></i>修改按钮</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_button_',that.id,'_deleteButton"><i class="layui-icon layui-icon-delete"></i>移除按钮</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_button_',that.id,'_upButton"><i class="layui-icon layui-icon-up"></i>上移</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_button_',that.id,'_downButton"><i class="layui-icon layui-icon-down"></i>下移</button>',
|
'</div>',
|
'<table id="table_',that.id ,'" lay-filter="', that.id ,'"></table>',
|
'</div>',
|
'</div>',
|
'</div>'
|
].join("");
|
return html;
|
};
|
this.getToolbarHtml = function(){
|
var that =this;
|
return ['<div layui-filter="toolbar_',that.id, '" class="layui-btn-container">',//主列表的按钮
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_add"><i class="layui-icon layui-icon-add-1"></i>增加</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_edit"><i class="layui-icon layui-icon-edit"></i>修改</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_del"><i class="layui-icon layui-icon-delete"></i>删除</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_copy"><i class="layui-icon layui-icon-cart"></i>克隆</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_export"><i class="layui-icon layui-icon-share"></i>导出成json</button>',
|
'</div>'].join("");
|
};
|
this.init=function(){
|
//基础的html被添加后,再执行初始化
|
var that = this;
|
$webUtil.copyConfig(that,that.moduleKey);
|
$webUtil.bindDefultButtonLisenter(that, that.id);
|
if(that.sourceData && 'true' == that.sourceData['admin']){
|
that.admin = true;
|
$("div[layui-filter='toolbar_button_" + that.id + "']").parent().hide();
|
that.backPath = configData.compatibility?path:configData.adminServicePath;
|
}else{
|
that.admin = false;
|
}
|
var tree = layui.tree;
|
var scrollHeight = window.innerHeight;
|
var treeUL = $('[layui-filter="tree_' + that.id + '"]');
|
var treeHeight = scrollHeight - 200;
|
treeUL.parent().height(treeHeight);
|
tree.init("tree_" + that.id, treeUL, {
|
url: that.url.tree,
|
backPath: that.backPath,
|
extraParams: {
|
isMuti: false,
|
isQueryAllColumn: true
|
},
|
showSearch:true,
|
click: function (item, elem, options) {
|
that.setFormValues(item.attributes);
|
},
|
done: function (thisFilter) {
|
that.initForm();
|
}
|
});
|
};
|
this.initForm = function(){
|
var that = this;
|
var form = layui.form;
|
form.addItems("form_" + that.id, that.getFormItems(true), function () {
|
if(!that.admin) {
|
that.initButtonTable();
|
}
|
}, {}, {
|
defaultColumnOneRow: 2
|
});
|
};
|
this.initButtonTable = function(){
|
var that = this;
|
var table = layui.table;
|
that.checkColumns();//主列表中列。
|
table.render({
|
elem: '#table_' + that.id,
|
id: 'table_' + that.id,
|
url: that.backPath + that.url.listButton,
|
page: {
|
limit: 20,
|
page: 1
|
},
|
where:{
|
functionOid:'11'
|
},
|
selectMode:table.selectMode.muti,
|
cols: [that.columns],
|
done:function(res, cur, count){
|
that.buttonTotal = count;
|
}
|
});
|
$webUtil.bindDefultButtonLisenter(that, "button_" + that.id);
|
};
|
this.checkColumns = function(){
|
var that = this;
|
var table = layui.table;
|
if(that.columns==null || that.columns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
|
that.columns = [table.getIndexColumn(),table.getCheckColumn(),{
|
field:'id',
|
title:'按钮标识',
|
width:150
|
},{
|
field:'name',
|
title:'按钮名称',
|
width:200
|
},{
|
field:'iconCss',
|
title:'显示图标',
|
width:150
|
},{
|
field:'displayFlag',
|
title:'是否显示',
|
width:80,
|
templet:function(r){
|
return $webUtil.formateBoolean(r.displayFlag);
|
}
|
},{
|
field:'controlRightFlag',
|
title:'是否控制权限',
|
width:120,
|
templet:function(r){
|
return $webUtil.formateBoolean(r.displayFlag);
|
}
|
},{
|
field:'uiFlag',
|
title:'显示界面标识',
|
width:150
|
},{
|
field:'usedBySpecifyRole',
|
title:'指定访问角色',
|
width:150
|
}];
|
}
|
};
|
this.add=function(){
|
var that = this;
|
that.doAdd(false);
|
};
|
this.copy=function () {
|
var that = this;
|
that.doAdd(true);
|
};
|
this.doAdd = function(isCopy){
|
var that = this;
|
var filter ="addForm_" + that.id;
|
var form = layui.form;
|
var addSaveIndex = layer.open({
|
type:1,
|
title:'添加功能模块菜单',
|
btn:['保存','取消','保存新增'],
|
skin:'layui-layer-lan',
|
content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
|
area:['800px','510px'],
|
closeBtn:2,
|
shade:true,
|
shadeClose:true,
|
resize:true,
|
resizing:function(layero){
|
form.doResize(filter);
|
},
|
success:function(layero){
|
form.addItems(filter,that.getFormItems(), function(){
|
if(isCopy && that.selectTreeAttribute){
|
var copyAttribute = {};
|
for(var key in that.selectTreeAttribute){
|
if(key.toLocaleLowerCase() != 'oid'){
|
copyAttribute[key] = that.selectTreeAttribute[key];
|
}
|
}
|
form.setValues(copyAttribute, filter);
|
}else {
|
if (that.selectTreeAttribute) {
|
form.setValues({
|
id: that.selectTreeAttribute['id'],
|
parentFunctionId: that.selectTreeAttribute['oid'],
|
parentFunctionIdName: that.selectTreeAttribute['name'],
|
displayFlag: that.selectTreeAttribute['displayFlag'],
|
controlRightFlag: that.selectTreeAttribute['controlRightFlag']
|
}, filter);
|
} else {
|
form.setValues({
|
displayFlag: true,
|
controlRightFlag: true
|
}, filter);
|
}
|
}
|
},{},{defaultColumnOneRow:2,inDialog:true});
|
},
|
yes:function(layero){
|
if(form.validata(filter)){
|
var values = form.getValues(filter);
|
$webUtil.post(that.url.add,values,function(result){
|
if(result.success){
|
$webUtil.showMsg("添加菜单成功");
|
layer.close(addSaveIndex);
|
that.refresh();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function (xhr,error) {
|
$webUtil.showErrorMsg("添加菜单的时候出现了错误");
|
},that.backPath);
|
}
|
},
|
btn3:function(layero){
|
if(form.validata(filter)){
|
var values = form.getValues(filter);
|
$webUtil.post(that.url.add,values,function(result){
|
if(result.success){
|
$webUtil.showMsgFromResult(result,"添加菜单成功");
|
layer.close(addSaveIndex);
|
that.refresh();
|
that.add();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function (xhr,error) {
|
$webUtil.showErrorMsg("添加菜单的时候出现了错误");
|
},that.backPath);
|
}
|
},
|
btn2:function(layero){
|
layer.close(addSaveIndex);
|
that.refresh();
|
}
|
});
|
};
|
this.edit = function(){
|
var that = this;
|
if($webUtil.isNotNull(that.selectTreeOid )){
|
var filter ="editForm_" + that.id;
|
var form = layui.form;
|
var addSaveIndex = layer.open({
|
type:1,
|
title:'修改功能模块菜单',
|
btn:['保存','取消'],
|
skin:'layui-layer-lan',
|
content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
|
area:['800px','510px'],
|
closeBtn:2,
|
shade:true,
|
shadeClose:true,
|
resize:true,
|
resizing:function(layero){
|
form.doResize(filter);
|
},
|
success:function(layero){
|
form.addItems(filter,that.getFormItems(), function(){
|
form.setValues( that.selectTreeAttribute,filter);
|
},{},{defaultColumnOneRow:2,inDialog:true});
|
},
|
yes:function(layero){
|
if(form.validata(filter)){
|
var values = form.getValues(filter);
|
var submitValues = {};
|
for(var key in that.selectTreeAttribute){
|
submitValues[key] = that.selectTreeAttribute[key];
|
}
|
for(var key in values){
|
submitValues[key] = values[key];
|
}
|
if(!( "displayFlag" in values)){
|
submitValues['displayFlag'] = false;
|
}
|
if(!( "controlRightFlag" in values)){
|
submitValues['controlRightFlag'] = false;
|
}
|
$webUtil.put(that.url.edit,submitValues,function(result){
|
if(result.success){
|
$webUtil.showMsg("修改功能模块菜单成功");
|
layer.close(addSaveIndex);
|
that.refresh();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function (xhr,error) {
|
$webUtil.showErrorMsg("修改菜单的时候出现了错误");
|
},that.backPath);
|
}
|
},
|
btn2:function(layero){
|
layer.close(addSaveIndex);
|
that.refresh();
|
}
|
});
|
}else{
|
$webUtil.showErrorMsg("没有选择菜单");
|
}
|
};
|
this.del = function(){
|
var that = this;
|
if($webUtil.isNotNull(that.selectTreeOid )){
|
$webUtil.showConfirmMsg("您是否要删除这个菜单?它的下级菜单将会被一同删除。",function(r){
|
if(r){
|
$webUtil.deleteRequest(that.url.deleteUrl,{oid:that.selectTreeOid},function(result){
|
if(result.success){
|
$webUtil.showMsg("删除菜单成功");
|
that.refresh();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function(xhr,error) {
|
$webUtil.showErrorMsg("删除菜单时请求服务器出现了错误");
|
},that.backPath);
|
}
|
});
|
}else{
|
$webUtil.showErrorMsg("没有选择菜单");
|
}
|
};
|
this.export = function(){
|
var that = this;
|
var form = layui.form;
|
$webUtil.get(that.url.tree,{},function (result) {
|
var filter = "export_form_" + that.id;
|
var addSaveIndex = layer.open({
|
type:1,
|
title:'请在下方的文本框中拷贝所有的json内容',
|
skin:'layui-layer-lan',
|
content:'<form id=' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
|
area:['1200px','500px'],
|
closeBtn:2,
|
shade:true,
|
shadeClose:true,
|
resize:true,
|
resizing:function(layero){
|
form.doResize(filter);
|
},
|
success:function(layero){
|
|
form.addItems(filter,[{
|
field: 'result',
|
text: 'json内容',
|
type:'textarea',
|
inputWidth:1000,
|
height:400
|
}], function(){
|
form.setValues({result:JSON.stringify(result)},filter);
|
},{},{defaultColumnOneRow:2,inDialog:true});
|
}
|
});
|
},function(xhr,err){},that.backPath);
|
|
};
|
this.setFormValues = function(attributes){
|
var that = this;
|
if(attributes){
|
that.selectTreeOid =attributes['oid'];
|
that.selectTreeAttribute = attributes;
|
try{
|
var form = layui.form;
|
form.clear("form_" + that.id,true);
|
form.setValues(attributes,"form_" + that.id);//不需要转换对象,因为attributes已经是对象格式了
|
}catch (e){
|
$webUtil.showDebugMsg(e);
|
}
|
layui.table.reload("table_" + that.id,{
|
where:{
|
functionOid: that.selectTreeOid
|
}
|
});
|
}
|
};
|
this.refresh = function(parentNodeOid){
|
var that = this;
|
var tree = layui.tree;
|
if(parentNodeOid){
|
tree.reloadNode("tree_" + that.id,parentNodeOid);
|
}else {
|
that.selectTreeOid = null;
|
that.selectTreeAttribute = null;
|
tree.reload("tree_" + that.id);
|
}
|
layui.table.reload("table_" + that.id);
|
};
|
this.getFormItems = function(onlyShow){
|
var that = this;
|
var resourceField = {};
|
if(that.admin){
|
resourceField = {
|
field:'resourceControlType',
|
text:'资源控制类型',
|
type:'combox',
|
required:true,
|
data:[{key:"resourceControlType_bs",value:"B/S"}],
|
defaultValue:'resourceControlType_bs',
|
readOnly: onlyShow
|
}
|
}else{
|
resourceField = {
|
field:'resourceControlType',
|
text:'资源控制类型',
|
type:'combox',
|
required:true,
|
comboxKey:'resourceControlType',
|
hidden:that.admin,
|
readOnly: onlyShow
|
}
|
}
|
return [{
|
field: 'id',
|
text: '菜单编号',
|
required:true,
|
readOnly: onlyShow
|
}, {
|
field: 'name',
|
text: '菜单名称',
|
required:true,
|
readOnly: onlyShow
|
},resourceField, {
|
field: 'orderNum',
|
readOnly: onlyShow,
|
text: '排序号',
|
required:true,
|
type:'text',
|
verify:'number'
|
},{
|
field:'url',
|
text:'链接地址',
|
readOnly: onlyShow,
|
textWidth:530,
|
defaultValue:'USEJS:',
|
useAllWidth:true
|
}, {
|
field: 'displayFlag',
|
readOnly: onlyShow,
|
text: '是否显示',
|
defaultValue:true,
|
type:'boolean'
|
}, {
|
field: 'controlRightFlag',
|
readOnly: onlyShow,
|
text: '是否控制权限',
|
required:true,
|
defaultValue:true,
|
type:'boolean'
|
}, {
|
field: 'parentFunctionId',
|
readOnly: onlyShow,
|
text: '上级菜单',
|
type:'refer',
|
showField:'parentFunctionIdName',
|
referConfig:{
|
type:'tree',
|
url:that.url.referTree,
|
backPath:that.backPath,
|
textField:'name',
|
valueField:'oid',
|
isMuti:false
|
}
|
},{
|
field:'iconCss',
|
text:'显示图标',
|
readOnly: onlyShow
|
}, {
|
field: 'logName',
|
readOnly: onlyShow,
|
text: '日志名称',
|
readOnly: onlyShow
|
}, {
|
field: 'helpName',
|
readOnly: onlyShow,
|
text: '帮助文档名称'
|
},{
|
field:'usedBySpecifyRole',
|
text:'指定访问的角色',
|
readOnly: onlyShow,
|
textWidth:530,
|
useAllWidth:true
|
},{
|
field:'description',
|
text:'备注',
|
readOnly: onlyShow,
|
textWidth:530,
|
useAllWidth:true
|
}];
|
};
|
this.addButton = function(){
|
var that = this;
|
if($webUtil.isNull(that.selectTreeOid)){
|
$webUtil.showErrorMsg("请您先选择菜单");
|
return false;
|
}
|
var filter ="addButtonForm_" + that.id;
|
var form = layui.form;
|
var addSaveIndex = layer.open({
|
type:1,
|
title:'添加按钮',
|
btn:['保存','取消','保存并新增'],
|
skin:'layui-layer-lan',
|
content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
|
area:['800px','510px'],
|
closeBtn:2,
|
shade:true,
|
shadeClose:true,
|
resize:true,
|
resizing:function(layero){
|
form.doResize(filter);
|
},
|
success:function(layero){
|
form.addItems(filter,that.getButtonFormItems(), function(){
|
form.setValues({
|
displayFlag: 'true',
|
controlRightFlag: 'true'
|
}, filter);
|
},{},{defaultColumnOneRow:2,inDialog:true});
|
},
|
yes:function(layero){
|
if(form.validata(filter)){
|
var values = form.getValues(filter);
|
values['functionOid'] = that.selectTreeOid;
|
$webUtil.post(that.url.addButton,values,function(result){
|
if(result.success){
|
$webUtil.showMsg("添加按钮成功");
|
layer.close(addSaveIndex);
|
that.refreshButton();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function (xhr,error) {
|
$webUtil.showErrorMsg("添加按钮的时候出现了错误");
|
},that.backPath);
|
}
|
},
|
btn2:function(layero){
|
layer.close(addSaveIndex);
|
that.refreshButton();
|
},
|
btn3:function(layero){
|
if(form.validata(filter)){
|
var values = form.getValues(filter);
|
values['functionOid'] = that.selectTreeOid;
|
$webUtil.post(that.url.addButton,values,function(result){
|
if(result.success){
|
$webUtil.showMsg("添加按钮成功");
|
form.clear();
|
form.setValues({
|
displayFlag: 'true',
|
controlRightFlag: 'true'
|
}, filter);
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function (xhr,error) {
|
$webUtil.showErrorMsg("添加按钮的时候出现了错误");
|
},that.backPath);
|
}
|
}
|
});
|
};
|
this.editButton = function(){
|
var that = this;
|
var oid = $webUtil.getOidFromGrid("table_" + that.id,true,true);
|
if(!oid){
|
return false;
|
}
|
var selectRowData = layui.table.checkStatus("table_" + that.id);
|
if($webUtil.isNull(that.selectTreeOid)){
|
$webUtil.showErrorMsg("请您先选择菜单");
|
return false;
|
}
|
var filter ="addButtonForm_" + that.id;
|
var form = layui.form;
|
var addSaveIndex = layer.open({
|
type:1,
|
title:'修改按钮',
|
btn:['保存','取消'],
|
skin:'layui-layer-lan',
|
content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
|
area:['800px','510px'],
|
closeBtn:2,
|
shade:true,
|
shadeClose:true,
|
resize:true,
|
resizing:function(layero){
|
form.doResize(filter);
|
},
|
success:function(layero){
|
form.addItems(filter,that.getButtonFormItems(), function(){
|
form.setValues(selectRowData.data[0],filter);
|
},{},{defaultColumnOneRow:2,inDialog:true});
|
},
|
yes:function(layero){
|
if(form.validata(filter)){
|
var values = selectRowData.data[0];
|
var formValues = form.getValues(filter);
|
for(var key in formValues){
|
values[key] = formValues[key];
|
}
|
values['t_oid'] = selectRowData.data[0]['toid'];
|
values['functionOid'] = that.selectTreeOid;
|
$webUtil.put(that.url.editButton,values,function(result){
|
if(result.success){
|
$webUtil.showMsg("修改按钮成功");
|
layer.close(addSaveIndex);
|
that.refreshButton();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function (xhr,error) {
|
$webUtil.showErrorMsg("修改按钮的时候出现了错误");
|
},that.backPath);
|
}
|
},
|
btn2:function(layero){
|
layer.close(addSaveIndex);
|
that.refreshButton();
|
}
|
});
|
};
|
this.deleteButton = function () {
|
var that = this;
|
var oid = $webUtil.getOidFromGrid("table_" + that.id,true,false);
|
if(!oid){
|
return false;
|
}
|
var selectRowData = layui.table.checkStatus("table_" + that.id);
|
if($webUtil.isNull(that.selectTreeOid)){
|
$webUtil.showErrorMsg("请您先选择菜单");
|
return false;
|
}
|
$webUtil.showConfirmMsg("您是否确定删除这些按钮",function (r) {
|
if(r){
|
var submitValues = {
|
functionOid:that.selectTreeOid
|
};
|
layui.each(selectRowData.data,function(_index,_item){
|
submitValues['buttonDTOList[' + _index + '].t_oid'] = _item['toid'];
|
});
|
$webUtil.deleteRequest(that.url.deleteButton,submitValues,function (result) {
|
if(result.success){
|
$webUtil.showMsg("删除按钮成功");
|
that.refreshButton();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function (xhr,err) {
|
$webUtil.showErrorMsg("删除按钮的时候出现了错误");
|
},that.backPath);
|
}
|
});
|
};
|
this.selectButton = function(){
|
var that = this;
|
if($webUtil.isNull(that.selectTreeOid)){
|
$webUtil.showErrorMsg("请您先选择菜单");
|
return false;
|
}
|
var filter ="selectButton_" + that.id;
|
var addSaveIndex = layer.open({
|
type:1,
|
title:'从按钮库中选择',
|
btn:['确定并继续','确定并关闭','取消'],
|
skin:'layui-layer-lan',
|
content:'<div layui-filter="search_form_for_table_' + filter + '" class="layui-form" >' +
|
'<div class="layui-form-item" style="height:24px;float:left;display:inline-block"> ' +
|
'<div class="layui-input-inline" style="height:24px;line-height:24px;width:150px">' +
|
'<select name="search_for_table_'+ filter + '" style="height:24px;width:120px;padding-right: 30px;">' +
|
'<option value="id" >按钮标识</option>' +
|
'<option value="name" >按钮名称</option>' +
|
'</select>' +
|
'</div>' +
|
'<div class="layui-input-inline">' +
|
'<input type="text" style="height:24px" name="searchvalue_for_table_'+ filter + '" placeholder="输入值后进行模糊查询" class="layui-input" >' +
|
'</div>'+
|
'</div>' +
|
'</div>' +
|
'<table id="table_' + filter + '" lay-filter="' + filter + '" style="margin-top:40px" ></table>',
|
area:['800px','510px'],
|
closeBtn:2,
|
shade:true,
|
shadeClose:true,
|
resize:true,
|
resizing:function(layero){
|
form.doResize(filter);
|
},
|
success:function(layero){
|
layui.form.render('select');
|
layui.table.render({
|
elem: '#table_' + filter,
|
id:filter,
|
url:that.backPath + that.url.referButton,
|
page:{
|
limit:20,
|
page:1
|
},
|
where:{
|
functionOid:that.selectTreeOid
|
},
|
cols: [that.getReferButtonColums()]
|
});
|
$('[name="searchvalue_for_table_' + filter + '"]').keydown(function(e){
|
if(e.which == 13){
|
//按下回车键
|
var searchField = $(this).parent().parent().find('select').val();
|
var searchValue = $(this).val();
|
if($webUtil.isNotNull(searchValue)){
|
searchValue = "*" + searchValue + "*";
|
}
|
var requestData = {};
|
requestData['conditionMap["' + searchField + '"]'] = searchValue;
|
layui.table.reload(
|
filter, {
|
where: requestData
|
}
|
);
|
}
|
});
|
},
|
yes:function(layero){
|
var selectData = layui.table.checkStatus(filter);
|
if(!selectData || !selectData.data || selectData.data.length == 0){
|
$webUtil.showErrorMsg("没有选择按钮,无法继续");
|
return false;
|
}
|
selectData = selectData.data;
|
var submitValue = {
|
functionOid: that.selectTreeOid
|
};
|
layui.each(selectData,function(_index,_item){
|
submitValue['buttonDTOList[' + _index + '].oid'] = _item.oid;
|
submitValue['buttonDTOList[' + _index + '].id'] = _item.id;
|
submitValue['buttonDTOList[' + _index + '].name'] = _item.name;
|
submitValue['buttonDTOList[' + _index + '].iconCss'] = _item.iconCss;
|
submitValue['buttonDTOList[' + _index + '].displayFlag'] = true;
|
submitValue['buttonDTOList[' + _index + '].controlRightFlag'] = true;
|
submitValue['buttonDTOList[' + _index + '].orderNum'] = that.buttonTotal? (that.buttonTotal+1 + _index) : (_index + 1);
|
submitValue['buttonDTOList[' + _index + '].uiFlag'] = 'main';
|
});
|
$webUtil.post(that.url.batchAddButton,submitValue,function(result){
|
if(result.success){
|
$webUtil.showAutoMsg("批量添加按钮成功");
|
layui.table.reload(filter);
|
that.refreshButton();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function(xhr,error){
|
$webUtil.showErrorMsg("批量添加按钮时出现了错误");
|
},that.backPath);
|
},
|
btn2:function(layero){
|
var selectData = layui.table.checkStatus(filter);
|
if(!selectData || !selectData.data || selectData.data.length == 0){
|
$webUtil.showErrorMsg("没有选择按钮,无法继续");
|
return false;
|
}
|
selectData = selectData.data;
|
var submitValue = {
|
functionOid: that.selectTreeOid
|
};
|
layui.each(selectData,function(_index,_item){
|
submitValue['buttonDTOList[' + _index + '].oid'] = _item.oid;
|
submitValue['buttonDTOList[' + _index + '].id'] = _item.id;
|
submitValue['buttonDTOList[' + _index + '].name'] = _item.name;
|
submitValue['buttonDTOList[' + _index + '].iconCss'] = _item.iconCss;
|
submitValue['buttonDTOList[' + _index + '].displayFlag'] = true;
|
submitValue['buttonDTOList[' + _index + '].controlRightFlag'] = true;
|
submitValue['buttonDTOList[' + _index + '].orderNum'] = that.buttonTotal? (that.buttonTotal+1 + _index) : (_index + 1);
|
submitValue['buttonDTOList[' + _index + '].uiFlag'] = 'main';
|
});
|
$webUtil.post(that.url.batchAddButton,submitValue,function(result){
|
if(result.success){
|
$webUtil.showMsg("批量添加按钮成功");
|
layer.close(addSaveIndex);
|
that.refreshButton();
|
}else{
|
$webUtil.showErrorMsg(result.msg);
|
}
|
},function(xhr,error){
|
$webUtil.showErrorMsg("批量添加按钮时出现了错误");
|
},that.backPath);
|
},
|
btn3:function(layero){
|
layer.close(addSaveIndex);
|
that.refreshButton();
|
}
|
});
|
};
|
this.getReferButtonColums = function () {
|
var table = layui.table;
|
return [table.getIndexColumn(),table.getCheckColumn(),{
|
field:'id',
|
title:'按钮标识',
|
width:150
|
},{
|
field:'name',
|
title:'按钮名称',
|
width:200
|
},{
|
field:'iconCss',
|
title:'显示图标',
|
width:150
|
}];
|
};
|
this.getButtonFormItems = function () {
|
var that = this;
|
return [{
|
field: 'id',
|
text: '按钮标识',
|
required:true
|
}, {
|
field: 'name',
|
text: '按钮名称',
|
required:true
|
},{
|
field:'uiFlag',
|
text:'显示位置所属页面标识',
|
defaultValue:'main'
|
}, {
|
field: 'orderNum',
|
text: '排序号',
|
required:true,
|
verify:'number'
|
}, {
|
field: 'displayFlag',
|
text: '是否显示',
|
required:true,
|
type:'boolean'
|
}, {
|
field: 'controlRightFlag',
|
text: '是否控制权限',
|
required:true,
|
type:'boolean'
|
},{
|
field:'iconCss',
|
text:'显示图标'
|
},{
|
field:'usedBySpecifyRole',
|
text:'指定访问的角色',
|
textWidth:530,
|
useAllWidth:true
|
}];
|
};
|
this.refreshButton = function(){
|
var that = this;
|
layui.table.reload("table_" + that.id);
|
};
|
};
|
var c = new Class();
|
exports(c.MODELNAME,c);
|
});
|