var widgetNames = ['aa']; //定义数组存放控件名称
function getWidgetValueByName(name) {
var widget = _g().parameterEl.getWidgetByName(name); //根据控件名获取控件值
if (widget == undefined) return;
var obj = {};
obj[name] = widget.getValue();
console.log(obj);
return obj; //返回控件值组成的数组
}
var paramJson = widgetNames.map(getWidgetValueByName).reduce(function(a, b) {
return Object.assign(a, b)
});
var paramJsonStr = JSON.stringify(paramJson); //将json数据转换为字符串
var col = _g().getParameterContainer().getWidgetByName("col").getValue();//需导出的列
//alert(col);
//参数进行url编码
var colNames = encodeURIComponent(col)
//调用导出接口
_g().directExportToExcel("ds1", "名称", encodeURIComponent(paramJsonStr), colNames);