/**
* 枚举类型
* @author weidy@2020-07-27
*/
layui.define(['layer','element','form','table','util'],function(exports){
var Class = function(){
this.MODELNAME = "platform/objectService/OsEnum";
this.moduleKey = "OsEnum";
this.id='OsEnum';
this.sourceData={};
this.columns = [];
this.backPath = configData.compatibility?path:configData.objectServicePath;
this.url={
controller:(configData.compatibility?"webEnumController/":'enumController/'),
dataGrid:'gridEnum',
listItems:'gridEnumItemByOid'
};
this.buttonIconMap = {
SEARCH:'layui-icon-refresh-2',
SENIORSEARCH:'layui-icon-query',
ADD:'layui-icon-add-1',
EDIT:'layui-icon-edit',
DELETE:'layui-icon-delete'
};
this.getContent=function(){//返回这个组件的基础html
var that = this;
var html = "";
html = [
'
',
'
',
that.getToolbarHtml(),
'
',
'
',
'
',
'
'
].join("");
return html;
};
this.getToolbarHtml =function(){
var that = this;
var html = [
'',
'',
'',
'',
'',
'',
'
',
].join("");
return html;
};
this.init=function(){//基础的html被添加后,再执行初始化
var that = this;
$webUtil.copyConfig(that,that.moduleKey);
var table = layui.table;
that.checkColumns();//主列表中列。
that.firstGridLoad = false;
table.render({
elem: '#table_' + that.id,
id: 'table_' + that.id,
url: that.url.controller + that.url.dataGrid,
backPath:that.backPath,
page: {
limit: 25,
page: 1
},
selectMode:table.selectMode.muti,
cols: [that.columns],
rowClick:function(filter,data){
if(data){
that.gridItemsByOid(data.oid);
}
},
done:function(res, cur, count){
if(!that.firstGridLoad) {
that.initDetailTable(((res && res.data) ? res.data[0].oid : ""));
that.firstGridLoad = true;
}else{
if(count>0){
that.gridItemsByOid(res.data[0].oid);
}
}
}
});
$webUtil.createSearchHtml({
id:'英文名称',
name:'中文名称'
},$("[layui-filter='toolbar_button_" + that.id + "']"),'table_' + that.id);
$webUtil.bindDefultButtonLisenter(that, 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:150
},{
field:'description',
title:'描述',
width:250
},{
field:'enumValueDataTypeText',
title:'数据类型',
width:80
}];
}
};
this.gridItemsByOid = function(pkEnum){
var that = this;
if($webUtil.isNull(pkEnum)){
return;
}
layui.table.reload("detail_" + that.id,{
where:{
pkEnum: pkEnum
}
});
};
this.initDetailTable = function(pkEnum){
var that = this;
var table = layui.table;
that.checkDetailColumns();
table.render({
elem: '#detail_table_' + that.id,
id: 'detail_' + that.id,
backPath:that.backPath,
url: that.url.controller + that.url.listItems,
where:{
pkEnum:pkEnum
},
cols: [that.detailColumns]
});
};
this.checkDetailColumns = function () {
var that = this;
var table = layui.table;
if(that.detailColumns==null || that.detailColumns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
that.detailColumns = [table.getIndexColumn(),table.getCheckColumn(),{
field:'id',
title:'枚举值',
width:150
},{
field:'name',
title:'枚举名称',
width:200
},{
field:'description',
title:'描述',
width:280
}];
}
};
this.refresh = function(){
var that = this;
layui.table.reload("table_" + that.id);
};
};
var cs = new Class();
exports(cs.MODELNAME,cs);
});