接口说明文档:https://smartbi.feishu.cn/docx/XWaddBPPYoJXmvxZQLkcJH08nif
Markdown |
---|
## BaseAdHocAnalysisExtender 基类 透视分析扩展点需继承此类,在自定义的 Extender 类中可通过 this 指针调用 BaseAdHocAnalysisExtender 中的方法 | | <strong>名称</strong> | <strong>参数</strong> | <strong>返回值</strong> | <strong>说明</strong> | | --------------------- | --------------------- | --------------------- | ----------------------- | --------------------- | | <strong>方法</strong> | on | 事件、事件回调 | - | 添加接口监听事件 | ### 二开接口 #### AD_HOC_ANALYSIS_ON_INIT <strong>触发时机:</strong>透视分析界面初始化时 <strong>作用</strong>:暂无对外接口 | | <strong>名称</strong> | <strong>类型</strong> | <strong>说明</strong> | | ------------------------- | --------------------- | --------------------- | --------------------- | | <strong>输入参数</strong> | adHocAnalysisImpl | IAdHocAnalysis | 即席查询对象 | #### AD_HOC_DATA_PANEL_ON_INIT <strong>触发时机:</strong>右侧数据来源选择面板初始化时 <strong>作用:</strong>对下拉菜单进行加减、禁用切换数据源 | | <strong>名称</strong> | <strong>类型</strong> | <strong>说明</strong> | | ------------------------- | --------------------- | --------------------- | --------------------- | | <strong>输入参数</strong> | adHocDataPanelImpl | IAdHocDataPanel | 数据来源面板对象 | <strong>示例代码</strong> ```typescript this.on(AD_HOC_DATA_PANEL_ON_INIT, async (impl) => { // 禁止切换数据集 if (!impl.getCurrentDatasetId()) { impl.setSelectDatasetDisabled(true) } // 屏蔽数据面板下拉部分菜单 impl.setDropDownBtnsFilter(menu => { // 屏蔽编辑和切换数据集菜单 return menu.id !== 'EDIT' && menu.id !== 'SWITCH_DATASET' }) }) } ``` #### AD_HOC_SAVE_DIALOG_ON_INIT <strong>触发时机:</strong>保存弹窗初始化时 <strong>作用:</strong>指定用户的可保存的目录 | | <strong>名称</strong> | <strong>类型</strong> | <strong>说明</strong> | | ------------------------- | --------------------- | --------------------- | --------------------- | | <strong>输入参数</strong> | saveDialogImpl | ISaveDialog | 保存弹窗对象 | <strong>示例代码</strong> ```typescript this.on(AD_HOC_SAVE_DIALOG_ON_INIT, async (saveDialogImpl) => { saveDialogImpl.setNodeFilter((node) => { return node.id != 'PUBLIC_ANALYSIS' }) }) ``` #### AD_HOC_DATASET_SELECTOR_ON_INIT <strong>触发时机:</strong>右侧数据来源选择面板初始化时 <strong>作用:</strong>对数据来源选择进行限制 | | <strong>名称</strong> | <strong>类型</strong> | <strong>说明</strong> | | ------------------------- | ------------------------ | --------------------- | --------------------- | | <strong>输入参数</strong> | adHocDatasetSelectorImpl | IAdHocDatasetSelector | 选择数据集弹窗对象 | <strong>示例代码</strong> ```typescript this.on(AD_HOC_DATASET_SELECTOR_ON_INIT, async (impl) => { impl.setRootNodeId('DEFAULT_TREENODE') } ``` #### AD_HOC_TOOLBAR_ON_INIT <strong>触发时机:</strong>工具栏初始化时 <strong>作用:</strong>对工具栏增加自定义项,删除某项 | | <strong>名称</strong> | <strong>类型</strong> | <strong>说明</strong> | | ------------------------- | --------------------- | --------------------- | --------------------- | | <strong>输入参数</strong> | toolbarImpl | IDQueryToolbar | 工具栏对象 | <strong>示例代码</strong> ```typescript this.on(AD_HOC_TOOLBAR_ON_INIT, async (toolbarImpl) => { // 添加自定义按钮 toolbarImpl.addItem({ id: 'test', label: '自定义按钮', icon: 'sx-icon-data-panel-toggle', handler: () => { alert('点击自定义按钮') } }) }) ``` #### AD_HOC_ON_BEFORE_EXPORT_DIALOG <strong>触发时机:</strong>打开导出弹窗前 <strong>作用:</strong>预设导出弹窗里选项的默认值, 可编辑性, 可见性, 或阻止弹窗 | | <strong>名称</strong> | <strong>类型</strong> | <strong>说明</strong> | | ------------------------- | --------------------- | --------------------- | --------------------- | | <strong>输入参数</strong> | adHocAnalysisImpl | IAdHocAnalysisQuery | 透视分析对象 | | | options | Object | 选项, 开发时可以打印这个值, 查看都有哪些可设置项 | | | options.openDialog | Boolean | 是否打开导出弹窗, 设置为false可阻止弹窗打开 | | | options.props | Object | 弹窗设置, props都是有值的, 开发时可console打印查看 | | | options.props.exportType | String | 导出类型, CSV或EXCEL, 不允许修改 | | | options.props.visibles | Map<选项key, Boolean> | 配置选项的可见性, 选空key见[ExportSetting](https://smartbi.feishu.cn/docx/JZbXdJiSFoZHrMxMowmc01Kxnce#VCTYd7LbkorGf6xAYhWc6uPSn3f). 设为false就不显示在弹窗中 | | | options.props.disables | Map<选项key, Boolean> | 配置选项的可编辑性, 选空key见[ExportSetting](https://smartbi.feishu.cn/docx/JZbXdJiSFoZHrMxMowmc01Kxnce#VCTYd7LbkorGf6xAYhWc6uPSn3f). 设为true在弹窗中就是不可编辑的 | | | options.props.defaultValue | [ExportSetting](https://smartbi.feishu.cn/docx/JZbXdJiSFoZHrMxMowmc01Kxnce#VCTYd7LbkorGf6xAYhWc6uPSn3f) | 导出选项默认值 | <strong>示例代码</strong> ```typescript // 不显示导出弹窗 this.on(AD_HOC_ON_BEFORE_EXPORT_DIALOG, (adHocAnalysisImpl, options) => { // 如果默认值有"导出过滤条件", 设置默认不导出 if (options.props.defaultValue.exportFilters !== undefined) { options.props.defaultValue.exportFilters = 'false'; } options.openDialog = false }) ``` #### AD_HOC_ON_BEFORE_EXPORT <strong>触发时机:</strong>导出动作执行前 (如点击导出下拉菜单的EXCEL选项) <strong>作用:</strong>阻止系统默认的导出实现, 定制自己的导出 | | <strong>名称</strong> | <strong>类型</strong> | <strong>说明</strong> | | ------------------------- | --------------------- | --------------------- | --------------------- | | <strong>输入参数</strong> | adHocAnalysisImpl | IAdHocAnalysisQuery | 透视分析对象 | | | options | Object | 选项 | | | options.exportType | String | 导出类型, CSV或EXCEL | <strong>示例代码</strong> ```typescript this.on(AD_HOC_ON_BEFORE_EXPORT, (adHocAnalysisImpl, { exportType }) => { // 获取默认的导出设置 let setting = adHocAnalysisImpl.execGenerateExportSetting({ exportType }) // 使用prompt弹窗询问文件名 let fileName = prompt('请输入文件名', "定制组件导出弹窗"); if (fileName === null) { // 取消导出 return; } if (fileName === '') { // 不输入文件名 return; } setting.fileName = fileName; // 调用系统导出 adHocAnalysisImpl.execExportWithSetting({ exportType, setting }) }) ``` ## 接口对象 ### IAdHocAnalysisQuery(透视分析界面) 见: [IAdHocAnalysisQuery](https://smartbi.feishu.cn/docx/JZbXdJiSFoZHrMxMowmc01Kxnce#UJszdTATDofLbdx419eceKhMnhf) ### IAdHocDataPanel(数据面板) IAdHocDataPanel 继承 [IDatasetPanel](https://smartbi.feishu.cn/docx/NMCmdBVh0ogQBDx3maOc0lVin2g#WVJadvRxDoHiPlxAGYQcxn04nNd) ### ISaveDialog(保存弹窗) 见:[ISaveDialog](https://smartbi.feishu.cn/docx/NMCmdBVh0ogQBDx3maOc0lVin2g#BRJtd7zU3osgeGx1wwPczYubnly) ### IAdHocDatasetSelector(选择数据集弹窗) IAdHocDatasetSelector 继承 [IDatasetSelector](https://smartbi.feishu.cn/docx/NMCmdBVh0ogQBDx3maOc0lVin2g#QjnEd8SwPoqwX4x0aOwcg4msnKf) ### IAdHocToolbar(工具栏) IAdHocToolbar 继承 [IBaseToolbar](https://smartbi.feishu.cn/docx/NMCmdBVh0ogQBDx3maOc0lVin2g#MZpFdg1O2oKLVLxntd2c1ecintd) ## 二开示例 [【透视分析】二开示例](https://wiki.smartbi.com.cn/pages/viewpage.action?pageId=114997830) |