/**
* 链接类型
* @author weidy@2023-03-26
*/
layui.define(['layer','element','form','table','util','platform/objectService/er/erContent'],function(exports){
var Class = function(){
this.MODELNAME = "platform/objectService/OsLinkType";
this.moduleKey = "OsLinkType";
this.id='OsLinkType';
this.sourceData={};
this.columns = [];
this.backPath = configData.compatibility?path:configData.objectServicePath;
this.url={
controller:'linkTypeController/',
dataGrid:'gridLinkType',
listAttribute:'gridAttributeByLinkTypeOid'
};
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.vciFieldTypeMap = {
VTBoolean:"布尔型",
VTClob: "长文本",
VTDate:"日期",
VTDateTime:"日期时间",
VTTime:"时间",
VTLong:"长整型",
VTDouble:"金额/双精度",
VTInteger:"整形",
VTFilePath:"文件",
VTString:"字符串"
};
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.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: 20,
page: 1
},
selectMode:table.selectMode.muti,
cols: [that.columns],
rowClick:function(filter,data){
if(data){
that.gridAttributeByOid(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.gridAttributeByOid(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:130
},{
field:'name',
title:'中文名称',
width:150
},{
field:'fromBtmTypeName',
title:'from端',
width:300
},{
field:'toBtmTypeName',
title:'to端',
width:300,
}, {
field: 'description',
title: '描述',
width: 150
}];
}
};
this.gridAttributeByOid = function(linkTypeOid){
var that = this;
if($webUtil.isNull(linkTypeOid)){
return;
}
layui.table.reload("detail_" + that.id,{
where:{
linkTypeOid: linkTypeOid
}
});
};
this.initDetailTable = function(linkTypeOid){
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.listAttribute,
where:{
linkTypeOid:linkTypeOid
},
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:'attributeLength',
title:'长度',
width:80,
templet:function (d){
return d.attrLength || d.attributeLength;
}
},{
field:'attrDataType',
title:'数据类型',
width:80,
templet:function(d){
return that.vciFieldTypeMap[d.attrDataType] || that.vciFieldTypeMap[d.attributeDataType];
}
},{
field:'nullableFlag',
title:'是否可以为空',
width:120,
templet:function(d){
return $webUtil.formateBoolean(d.nullableFlag);
}
},{
field:'defaultValue',
title:'默认值',
width:80
},{
field:'precisionLength',
title:'小数精度',
width:80
},{
field:'scaleLength',
title:'小数刻度',
width:80
},{
field:'range',
title:'取值范围',
width:100
},{
field:'referFlag',
title:'是否参照',
width:130,
templet:function(d){
if(!d.referFlag){
return '否';
}else{
return d.referBtmTypeId
}
}
},{
field:'enumFlag',
title:'是否枚举',
width:130,
templet:function(d){
if(!d.enumFlag){
return '否';
}else{
return d.enumId
}
}
}];
}
};
this.refresh = function(){
var that = this;
layui.table.reload("table_" + that.id);
};
this.checkAttrDiff = function (){
var that = this;
var oid = $webUtil.getOidFromGrid("table_" + that.id,true,true);
if(!oid){
return false;
}
$webUtil.post (that.url.controller + "/checkAttributeTypeDifferent",{linkTypeOid:oid},function (result){
if(result.success ){
$webUtil.showMsg("没有属性是不同的");
}else{
$webUtil.showErrorMsg(result.data);
}
},function (err,xhr){
$webUtil.showErrorMsg("服务可能没有启动");
},that.backPath);
};
};
var cs = new Class();
exports(cs.MODELNAME,cs);
});