多数据源配置
属性栏组件BiDatasourceConfigComponent只能用于单数据源的配置。
开发者如果需要一个组件拥有多数据源属性,则需要用到BiDatasourceConfigForMultiComponent属性栏组件。
在该组件在用法上与单数据源组件BiDatasourceConfigComponent基本一致
区别:
该组件只能在PropertiesItemGroup中使用,如果脱离PropertiesItemGroup组件,会导致使用异常。
需要添加data属性的默认值
customInput属性下需要增加data属性,并为期添加默认值。默认值为一个对象
{....,"data":{"model_id": null,"datasourceInfo": {"dsUuid": "","table": "","name": "","mode": "","format": "","type": ""},"group": false,"filter": [],"requestParams": [],"measure": [],"dimension": [],"screen": true,"newFiels": [],"linkageFiels":[],"dataType":"datasource"},...}该组件的回调函数需要开发者自己设置,不是setData方法。
具体配置方法:
属性 | 值 | 备注 |
---|---|---|
type | BiDatasourceConfigForMultiComponent | 多数据源组件 |
- costomInput下可以配置的属性:
属性 | 类型 | 默认值 | 备注 |
---|---|---|---|
dimensionCount | Number | 1 | 控制维度的数量 |
measureCount | Number | 100 | 控制度量的数量 |
widgetCanDrillDown,canDrillDown | Boolean | false | 是否可以下钻(这两个值需要同时设置) |
showMeasure | Boolean | false | 是否是维度度量混合 |
isJustDimension | Boolean | false | 仅显示维度 |
justMeasure | Boolean | false | 仅显示度量 |
datasourceTitleName | string | 数据源 | 数据源名称 |
onlyDatasource | Boolean | false | 仅仅有数据源下拉框 |
groupbyDisable | Boolean | false | 禁用groupby功能 |
dimensionName | string | 维度 | 维度名称 |
measureName | string | 度量 | 度量名称 |
hasFilter | Boolean | true | 包含过滤功能 |
hasModel | Boolean | true | 是否包含物模型 |
measureGroup | Boolean | false | 度量聚合 |
formatHidden | Boolean | false | 隐藏数值格式、小数位、单位后缀、千分符 |
numberFormatDisable | Boolean | false | 数值格式配置禁用 |
haveOtherDimension | Boolean | false | 是否需要第二的唯独选择,例如桑基图需要一个源(维度)一个目的(维度)一个指标(度量) |
otherDimensionName | string | 维度 | 第二个维度的名称 |
otherDimensionCount | number | 1 | 第二个维度的数量限制 |
data | Object | 默认值是一个json对象 ,请参考data属性的默认值 |
data属性的默认值:
{
"model_id": null,
"datasourceInfo": {
"dsUuid": "",
"table": "",
"name": "",
"mode": "",
"format": "",
"type": ""
},
"group": false,
"filter": [],
"requestParams": [],
"measure": [],
"dimension": [],
"screen": true,
"newFiels": [],
"linkageFiels":[],
"dataType":"datasource"
}
- callback 需要开发者指定一个函数名作为回调函数。与但数据源的setData回调函数的区别是,会有第三个入参index,index的值是当前数据源所在属性组的索引值。 开发者可以根据此值区分是来自哪个数据源的数据。
{
"develop":{
"html":"index.html",
"css":["./styles/index.css"],
"entry":"./scripts/main.js",
"scripts":{
}
},
"plugins":[],
"services":["$customService","$eventDispatch"],
"libs":["https://cdn.jsdelivr.net/npm/vue/dist/vue.js"],
"customAttributes":{
"pro":[
],
"con":[
{
"type":"PropertiesItemGroup",
"name":"多数据源",
"customInput":{
"showSwitchButton":true,
"switchStatus":false,
"childItemArrowDisplay":true,
"rightOperator":"plus",
"children":[
[{
"type":"BiDatasourceConfigForMultiComponent",
"customInput":{
"canDrillDown":true,
"widgetCanDrillDown":true,
"data":{
"model_id": null,
"datasourceInfo": {
"dsUuid": "",
"table": "",
"name": "",
"mode": "",
"format": "",
"type": ""
},
"group": false,
"filter": [],
"requestParams": [],
"measure": [],
"dimension": [],
"screen": true,
"newFiels": [],
"linkageFiels":[],
"dataType":"datasource"
},
"dimensionCount":1},
"callback":"multiDataSourceSetData1"
}]
]
}
}
]
}
}
main.js中:
...
multiDataSourceSetData1(data,obj,index){
if(data&&obj){
vueData['table'+index].requesting=false;
let dimensionList=this.$customService.getDataSourceDimensionColumns(obj.data);
let measureList=this.$customService.getDataSourceMeasureColumns(obj.data);
vueData['table'+index].dimensions.splice(0,vueData['table'+index].dimensions.length);
vueData['table'+index].measures.splice(0,vueData['table'+index].measures.length);
let _index=dimensionList.findIndex(item=>item.type==='drill-folder');
if(_index>-1){
vueData['table'+index].drilldown=true;
let drilldownItem=dimensionList[0];
vueData['table'+index].dimensions.push(drilldownItem.list[drilldownItem.index]);
}else{
vueData['table'+index].dimensions.push(...dimensionList);
}
vueData['table'+index].measures.push(...measureList);
Object.keys(data.data).forEach(key=>{
vueData['table'+index].data[key]=data.data[key];
});
this['datasource'+index]=obj.data;
}
}
...