/**
* web调用的api
* @author weidy
*/
layui.define(['layer','element','form','table','util'],function(exports){
var Class = function(){
this.MODELNAME = "platform/objectService/OsWebApi";
this.moduleKey = "OsWebApi";
this.id='OsWebApi';
this.sourceData={};
this.columns = [];
this.backPath = configData.compatibility?path:configData.objectServicePath;
this.url={
controller:'webApiController/',
dataGrid:'gridWebApi',
listMethods:'gridWebApiMethodByApiOid'
};
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 = [
'
'
].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: 30,
page: 1
},
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 == 'listMethods'){
that.showMethods(data.oid,data.text);
}
});
that.fristMainLoad = true;
}
}
});
$webUtil.createSearchHtml({
showtext:'接口中文名称',
name:'接口名称'
},$("[layui-filter='toolbar_button_" + that.id + "']"),'table_' + that.id);
$webUtil.bindDefultButtonLisenter(that, that.id);
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(),{
field:'name',
title:'名称',
width:600
},{
field:'text',
title:'中文',
width:250
},{
field:'ts',
title:'最后修改时间',
width:150,
templet:function(d){
return $webUtil.formateDateTime(d.ts);
}
},{
field:'options',
title:'操作',
width:80,
toolbar:'#toolbar_column_' + that.id
}];
}
};
this.showMethods = function(apiOid,text){
var that = this;
portal.showTabByMenu(that.id + "_methods_" + apiOid,{
id:that.id + "_methods_" + apiOid,
text:"查看后台接口[" + text + "]",
bsUrl:'USEJS:platform/objectService/OsWebMethods?apiOid=' + apiOid,
});
};
};
var cs = new Class();
exports(cs.MODELNAME,cs);
});