/**
|
* 生命周期
|
* @author weidy@2020-07-27
|
*/
|
layui.define(['layer','element','form','table','util'],function(exports){
|
var Class = function(){
|
this.MODELNAME = "platform/objectService/VciOsLifeCycle";
|
this.moduleKey = "VciOsLifeCycle";
|
this.id='VciLifeCycle';
|
this.sourceData={};
|
this.columns = [];
|
this.backPath = configData.compatibility?path:configData.objectServicePath;
|
this.url={
|
controller:'lifeCycleController/',
|
dataGrid:'gridLifeCycle',
|
addSave:'addSave',
|
editSave:'editSave',
|
deleteUrl:'deleteData',
|
getObjectByOid:'getObjectByOid',
|
listUsed:'listUsed',
|
listLines:'listLineByOid',
|
listLinesPic:'listLinesPic',
|
gridEvent:'gridLifeEvents'
|
};
|
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 = [
|
'<div class="layui-layout-border">',
|
'<div class="layui-center">',
|
that.getToolbarHtml(),
|
'<table id="table_', that.id , '" lay-filter="',that.id , '" style="overflow-x:auto;"></table>',
|
'</div>',
|
'<div class="layui-east" id="pic_',that.id,'" style="float:right;width:200px;height:425px;margin-top:100px;margin-right:13px;">',
|
'</div>',
|
'<div class="layui-south" >',
|
'<table id="detail_table_',that.id ,'" lay-filter="detail_table_', that.id ,'"></table>',
|
'</div>',
|
'</div>'
|
].join("");
|
return html;
|
};
|
this.getToolbarHtml =function(){
|
var that = this;
|
var html = [
|
'<div layui-filter="toolbar_',that.id,'" class="layui-btn-container">',
|
!configData.compatibility?
|
[ '<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,'_DEL"><i class="layui-icon layui-icon-delete"></i>删除</button>',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_EVENTS"><i class="layui-icon layui-icon-util"></i>生命周期事件管理</button>'
|
].join(''):'',
|
'<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_refresh"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
|
'</div>',
|
].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: 15,
|
page: 1
|
},
|
selectMode:table.selectMode.muti,
|
cols: [that.columns],
|
done:function(res, cur, count){
|
if(!that.firstGridLoad) {
|
if(!configData.compatibility) {
|
that.initDetailTable(((res && res.data) ? res.data[0].oid : ""));
|
$(".layui-south").hide();
|
}
|
that.firstGridLoad = true;
|
}else{
|
if(count>0){
|
that.gridItemsByOid(res.data[0].oid);
|
}
|
}
|
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(layEvent == 'listUsed'){
|
that.listUsed(data);
|
}else if(layEvent == 'exportCode'){
|
that.exportCode(data);
|
}else if(layEvent == 'viewLine'){
|
that.viewLinePic(data);
|
}
|
});
|
},
|
rowClick:function(filter,data){
|
if(data && !configData.compatibility){
|
that.gridItemsByOid(data.oid);
|
}
|
}
|
});
|
$webUtil.createSearchHtml({
|
id:'英文名称',
|
name:'中文名称'
|
},$("[layui-filter='toolbar_" + 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:'英文名称',
|
sort:true,
|
width:150
|
},{
|
field:'name',
|
title:'中文名称',
|
sort:true,
|
width:200
|
},{
|
field: 'startStatusName',
|
title: '起始状态',
|
sort:true,
|
width: 90
|
},{
|
field:'description',
|
title:'描述',
|
width:150
|
},{
|
field: "options",
|
title:'操作',
|
width:230,
|
templet:function (d){
|
if(configData.compatibility){
|
return '<a class="layui-btn layui-btn-intable" lay-event="viewLine" >查看连接线</a>';
|
}else {
|
return ['<a class="layui-btn layui-btn-intable" lay-event="edit" >编辑</a>',
|
'<a class="layui-btn layui-btn-intable" lay-event="listUsed" >查看应用范围</a>',
|
'<a class="layui-btn layui-btn-intable" lay-event="exportCode" >导出代码</a>'].join('');
|
}
|
}
|
}];
|
}
|
};
|
this.initDetailTable = function(pkLife){
|
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.listLines,
|
where:{
|
oid:pkLife
|
},
|
cols: [that.detailColumns],
|
done:function (res, cur, count){
|
table.on('tool(detail_' + that.id + ')',function(obj) {
|
var data = obj.data;//当前选择行的数据
|
var layEvent = obj.event;//点的是什么按钮
|
if (layEvent == 'viewEvent') {
|
that.viewEvent(data);
|
}
|
});
|
}
|
});
|
};
|
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:'sourceLifeStatusName',
|
title:'源状态',
|
width:150
|
},{
|
field:'targetLifeStatusName',
|
title:'目标状态',
|
width:150
|
},{
|
field:'name',
|
title:'业务描述',
|
width:150
|
},{
|
field:'options',
|
title: '操作',
|
width: 100,
|
templet:function (d){
|
if(d.events&& d.events.length > 0) {
|
return '<a class="layui-btn layui-btn-intable" lay-event="viewEvent" >查看事件</a>';
|
}else{
|
return '';
|
}
|
}
|
}];
|
}
|
};
|
this.gridItemsByOid = function(pkLife){
|
var that = this;
|
if($webUtil.isNull(pkLife)){
|
return;
|
}
|
layui.table.reload("detail_" + that.id,{
|
where:{
|
oid: pkLife
|
}
|
});
|
};
|
this.getFormItems = function(onlyShow,edit) {
|
return [
|
{
|
field: 'id',
|
title: '英文名称(唯一)',
|
required: true,
|
readOnly:(onlyShow||edit)
|
} , {
|
field: 'name',
|
title: '中文名称',
|
required: true,
|
readOnly:onlyShow
|
} ,{
|
field: ''
|
}, {
|
field: 'description',
|
title: '描述',
|
type: 'text',
|
inputWidth:535,
|
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:['保存','取消'],
|
content:'<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
|
fullScreen:true,
|
shadeClose:false,
|
resizing:function(layero){
|
form.doResize(filter);
|
},
|
success:function(layero) {
|
form.addItems(filter,that.getFormItems(false,!add),
|
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,labelWidth:130});
|
},
|
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,false);
|
if(!oid){
|
return false;
|
}
|
webUtil.showConfirmMsg("是否删除这条数据?如果被引用将不能被删除!",function () {
|
webUtil.deleteRequest(that.url.controller + that.url.deleteUrl,{oids:oid},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;
|
layui.table.reload("table_" + that.id);
|
};
|
this.listUsed = function (data){
|
var that = this;
|
if(!data){
|
return false;
|
}
|
var filter = data.oid;
|
webUtil.dialog({
|
title: '查看生命周期[' + data.name + "(" + data.id + ")]的应用范围",
|
content: '<table id="used_' + filter + '" lay-filter="' + filter + '" style="margin-top:5px;margin-left:5px;" ></table>',
|
area: ['950px', '600px'],
|
success: function (layero) {
|
layui.table.render({
|
elem: '#used_' + filter,
|
id: 'used_' + filter,
|
url: that.url.controller + that.url.listUsed,
|
backPath:that.backPath,
|
where:{
|
oid:data.oid
|
},
|
cols: [[{
|
field:'id',
|
title:'业务类型英文名称',
|
width:150
|
},{
|
field: 'name',
|
title: '业务类型名称',
|
width: 250
|
},{
|
field: 'description',
|
title:'描述',
|
width: 200
|
},{
|
field: 'implClass',
|
title: '实现类',
|
width: 300
|
}]]
|
});
|
}
|
});
|
};
|
this.viewEvent = function (data){
|
var that = this;
|
if(!data){
|
return false;
|
}
|
if(!data.events || data.events.length == 0){
|
$webUtil.showAutoMsg('没有事件');
|
return false;
|
}
|
var filter = data.oid;
|
webUtil.dialog({
|
title: '查看生命周期事件',
|
content: '<table id="events_' + filter + '" lay-filter="' + filter + '" style="margin-top:5px;margin-left:5px;" ></table>',
|
area: ['950px', '500px'],
|
success: function (layero) {
|
layui.table.render({
|
elem: '#events_' + filter,
|
id: 'events_' + filter,
|
data:data.events,
|
cols: [[{
|
field:'eventFullName',
|
title:'全路径',
|
width: 600
|
},{
|
field: 'eventShowName',
|
title: '事件名称',
|
width: 250
|
}]]
|
});
|
}
|
});
|
};
|
this.EVENTS = function (){
|
var that = this;
|
var filter = "event_" + that.id;
|
webUtil.dialog({
|
title: '查看已经注册的生命周期事件',
|
content: '<table id="events_' + filter + '" lay-filter="' + filter + '" style="margin-top:5px;margin-left:5px;" ></table>',
|
area: ['950px', '500px'],
|
success: function (layero) {
|
layui.table.render({
|
elem: '#events_' + filter,
|
id: 'events_' + filter,
|
backPath:that.backPath,
|
url:that.url.controller + that.url.gridEvent,
|
cols: [[{
|
field:'eventFullName',
|
title:'全路径',
|
width: 400
|
},{
|
field: 'eventShowName',
|
title: '事件名称',
|
width: 250
|
},{
|
field: 'description',
|
title: '描述',
|
width: 200
|
}]]
|
});
|
}
|
});
|
};
|
this.viewLinePic = function (data) {
|
var that = this;
|
layui.use('platform/objectService/er/erContent', function () {
|
var erContent = layui['platform/objectService/er/erContent'];
|
var filter = "er_" + that.id;
|
var erIndex = $webUtil.dialog({
|
title: "查看生命周期[" + data.name + "]的内容",
|
content: '<div id="' + filter + '" ></div>',
|
fullScreen: true,
|
success: function (layero) {
|
var oid = data.id + "_linkType";
|
$("#" + filter).html(erContent.getContent(oid));
|
erContent.init(oid, {
|
id: data.id,
|
url: that.url.controller + that.url.listLinesPic
|
});
|
}
|
});
|
});
|
};
|
|
};
|
var cs = new Class();
|
exports(cs.MODELNAME,cs);
|
});
|