/**
|
* 属性的工具类,可以获取表单和表格的显示信息
|
* @author weidy
|
*/
|
layui.define(['layer','element','form','table','util'],function(exports){
|
var Class = function() {
|
this.MODELNAME = "platform/objectService/OsAttributeUtil";
|
this.moduleKey = "OsAttributeUtil";
|
this.id = 'OsAttributeUtil';
|
this.sourceData = {};
|
this.backPath = configData.compatibility?path:configData.objectServicePath;
|
this.url ={
|
};
|
this.vciFieldType = {
|
'VTString':'VTString',
|
'VTInteger':'VTInteger',
|
'VTLong':'VTLong',
|
'VTDobble':'VTDobble',
|
'VTDateTime':'VTDateTime',
|
'VTDate':'VTDate',
|
'VTTime':'VTTime',
|
'VTBoolean':'VTBoolean'
|
};
|
this.getFormItemsByAttributes = function(attributes){
|
var that = this;
|
//使用属性获取表单的元素
|
if(attributes){
|
//说明有属性
|
var formItems = [];
|
layui.each(attributes,function(_index,record) {
|
var formItem = {};
|
formItem['name'] = record.id;
|
formItem['title'] = record.name;
|
if (!record.nullableFlag) {
|
formItem['required'] = true;
|
}
|
if (!$webUtil.isNotNull(record.defaultValue)) {
|
formItem['defaultValue'] = record.defaultValue;
|
}
|
//如果是参照
|
if (that.vciFieldType.VTString == record.attrDataType){
|
if (record.referFlag) {
|
formItem['type'] = 'refer';
|
formItem['referConfig'] = {
|
type: 'grid',
|
url: that.url.commondRefer,
|
backPath: that.backPath,
|
textField: 'name',
|
where: {
|
"btmTypeId": record.referBtmTypeId
|
},
|
valueField: 'oid',
|
tableConfig: {
|
page: {
|
limit: 15,
|
page: 1
|
},
|
cols: [layui.table.getIndexColumn(), layui.table.getCheckColumn(), {
|
field: 'id',
|
title: '编号',
|
sort: true,
|
width: 150
|
}, {
|
field: 'name',
|
title: '名称',
|
sort: true,
|
width: 150
|
}],
|
queryColumns: [{
|
field: 'id',
|
title: '编号'
|
}, {
|
field: 'name',
|
title: '名称'
|
}]
|
}
|
};
|
} else if (record.enumFlag) {
|
//说明是枚举
|
formItem['type'] = 'combox';
|
formItem['comboxKey'] = record.enumId;
|
}else {
|
//就是普通的字符串,这里不再处理
|
}
|
}else if(that.vciFieldType.VTInteger == record.attrDataType
|
|| that.vciFieldType.VTLong == record.attrDataType
|
|| that.vciFieldType.VTDobble == record.attrDataType){
|
formItem['verify'] = 'number';
|
}else if(that.vciFieldType.VTBoolean == record.attrDataType){
|
formItem['type'] = 'trueorfalse'
|
}else if(that.vciFieldType.VTDateTime == record.attrDataType){
|
formItem['type'] = 'datetime';
|
}else if(that.vciFieldType.VTDate == record.attrDataType){
|
formItem['type'] = 'date';
|
}else if(that.vciFieldType.VTTime == record.attrDataType){
|
formItem['type'] = 'time';
|
}else{
|
|
}
|
formItems.push(formItem);
|
});
|
return formItems;
|
}else{
|
return [];
|
}
|
};
|
|
};
|
var cs = new Class();
|
exports(cs.MODELNAME,cs);
|
});
|