您的当前位置:首页SmartBI拓展包二开入门开发

SmartBI拓展包二开入门开发

来源:锐游网

前言

新接到一个项目拓展包三开的需求,没有相关经验,学习开发,本文尝试通过简单的定位以及指导,确定修改点

登录

http://localhost:18080/smartbi/vision/index.jsp

后台配置

上传拓展包,先看看以前有什么功能

http://localhost:18080/smartbi/vision/config.jsp

重启

上传拓展包后 服务需要重启,也可以在WIN视窗找到对应的服务图标

重新登录

登录后,因为我做的是钉钉二开,我知道东西大概在哪里放着,所以寻找,自己根据自己需求来找对应页面,我目前功能需要修改这两个名字

F12定位

定位当前页面使用JS在那个位置,因为SmartBI依靠的是复写追加模式

页面元素定位

通过页面元素检索

前端代码

搜索关键字

我们要修改这个按钮名字:PushPreview,发现他是一个语言包用UNICODE转码的,那我们把要修改的字段配置值修改下即可,在拓展包-直接打开-找到对应位置-修改好-重新上传拓展包-覆盖理论即可解决,找个在线转码翻译下

重复上传

原因

E:\smartbi\Tomcat\bin\exts-smartbi

解决

使用无痕浏览器,重新加载
完成一个需求

代码

放一段修改代码,看下钉钉安装包开发逻辑,入门

 var DingDingPushPanel = jsloader.resolve("bof.schedule.panel.DingDingPushPanel");

TaskCustom.prototype.initTaskType_DingDingPushTask = TaskCustom.prototype.initTaskType; 

//初始化任务类型
TaskCustom.prototype.initTaskType = function(isNew){
	this.initTaskType_DingDingPushTask.apply(this, arguments);
	this.cb_taskType.insertItem("DINGDING_PUSH", "${DingDingPush}");
//	this.cb_taskType.setSelectedItem("DINGDING_PUSH", "${DingDingPush}");  // 先默认选择这个 方便开发测试少点一次
}


//初始化不同类型下 界面
TaskCustom.prototype._DingDingPushTask_initPanel = TaskCustom.prototype.initPanel;
TaskCustom.prototype.initPanel = function(){
	if (this.cb_taskType.getSelectedId() == "DINGDING_PUSH") {
		this.initDingDingPushPanel();
	} else {
		this._DingDingPushTask_initPanel.apply(this, arguments);
	}
}

TaskCustom.prototype._DingDingPushTask_elemTaskType_change_handler = TaskCustom.prototype.elemTaskType_change_handler;
//根据任务类型进行不同类型任务界面切换
TaskCustom.prototype.elemTaskType_change_handler = function(obj,oldSelectedId, newSelectedId, oldTitle, newTitle) {
	if (newSelectedId == "DINGDING_PUSH") {  
		this.setTaskPanel("DINGDING_PUSH");
	} else {
		this._DingDingPushTask_elemTaskType_change_handler.apply(this, arguments);
	}
}
//界面变化
TaskCustom.prototype._DingDingPushTask_setTaskPanel = TaskCustom.prototype.setTaskPanel;
TaskCustom.prototype.setTaskPanel = function(type){
	this._DingDingPushTask_setTaskPanel.apply(this, arguments);
	if (this.dingDingPushPanel) {
		this.dingDingPushPanel.hide();
	} 
	if (type == "DINGDING_PUSH") {
        //三开 临时修改变量名称
        this.elemButtonTest.value ="推送正式群";
		if (this.dingDingPushPanel) {
			this.dingDingPushPanel.show();
		} else {
			this.initDingDingPushPanel();
		}
	} else{
	//ExtJumpReport
	this.elemButtonTest.value ="测试运行(T)";
	}

}

//初始化DINGDING_PUSH类型的界面
TaskCustom.prototype.initDingDingPushPanel = function(){
	this.dingDingPushPanel = new DingDingPushPanel(this.elemTasksDiv,this.oldTaskInfo);
	this.dingDingPushPanel.onPushPreview.subscribe(this.ddPushPreview, this);
}

//任务信息
TaskCustom.prototype._DingDingPushTask_getTaskInfo = TaskCustom.prototype.getTaskInfo;
TaskCustom.prototype.getTaskInfo = function(){
	var taskInfo = this._DingDingPushTask_getTaskInfo.apply(this, arguments);
	if (!taskInfo) {
		return taskInfo;
	}
	var msg;
	if(this.cb_taskType.getSelectedId() == "DINGDING_PUSH") { 
		var ddPushInfo = this.dingDingPushPanel.getValue();
		var msg = this.dingDingPushPanel.validate(ddPushInfo);
		if (msg) {
			alert(msg);
			return false;
		} 		
		this.taskInfo.ddPushInfo = ddPushInfo;
	}
	return this.taskInfo;
}

// 保存
TaskCustom.prototype._DingDingPushTask_doSave = TaskCustom.prototype.doSave ;
TaskCustom.prototype.doSave = function(parentId) {
	parentId = parentId || this.parentFolderId;
	if (this.taskInfo.type == "DINGDING_PUSH") {
		if (this.dingDingPushTaskSave(parentId)){
			this.DefaultOptionType = this.OptionType_MODIFY;
			this.elemButtonTest.disabled = false;
			this.copySaveToCache();
			this.elemTaskName.disabled = true;
			this.cb_taskType.setEnabled(false);
			this.doOnClose();
		}
	} else {
		this._DingDingPushTask_doSave(parentId);
	}
}

/**
 * 保存操作
 */
TaskCustom.prototype.dingDingPushTaskSave = function(parentId){
	if (this.DefaultOptionType == this.OptionType_ADD) {
		var ret = util.remoteInvokeEx("CatalogService", "isCatalogElementAccessible", [ parentId, "WRITE" ]);
		if (ret && ret.succeeded) {
			if (!ret.result) {
				alert("${Youdonothavetheresources}${Leftdoublequote}${Toedit}${Rightdoublequote}${Permission}${Exclamation}\n" + parentId);
				return false;
			}
		} else {
			return false;
		}
	}
	var ret = false;
	if(this.taskInfo.taskAlias == ""){
		this.taskInfo.taskAlias = this.taskInfo.taskName;
		this.elemTaskAlias.value = this.taskInfo.taskName;
	}
	// clone一个新对象 并把参数设置分割出来 后面分开处理
	if (this.taskInfo.type == "DINGDING_PUSH") {// 报表订阅
		if (this.DefaultOptionType == this.OptionType_ADD) {// 任务新增
			ret = util.remoteInvokeEx("DDPushTaskModule",
					"createDDPushTask", [ this.taskInfo.taskName,
							this.taskInfo.taskAlias, this.taskInfo.taskNote,
							this.taskInfo.ddPushInfo, parentId ]);
		} else if (this.DefaultOptionType == this.OptionType_MODIFY) {// 任务修改
			ret = util.remoteInvokeEx("DDPushTaskModule",
					"updateDDPushTask", [ this.taskId,
							this.taskInfo.taskName, this.taskInfo.taskAlias,
							this.taskInfo.taskNote, this.taskInfo.ddPushInfo]);
		}
	} 
		
	if (ret && ret.succeeded && ret.result) {	
		this.taskId = ret.result;
		alert("${Theoperationissuccessful}${Exclamation}");
		this.needRefresh.fire(this, parentId || ret.result);
		this.onUpdateInfo.fire(this, ret.result);
		return true;
	} 
}



/**
 * 修改任务的时候初始化面板
 */
//初始化其他的定制开发的任务类型
TaskCustom.prototype._DingDingPushTask_initOtherTask = TaskCustom.prototype.initOtherTask;
TaskCustom.prototype.initOtherTask = function(result) {	
	this._DingDingPushTask_initOtherTask.apply(this, arguments);
	this.setTaskPanel(result.type);
}


/**
 * 缓存修改时进入的定制信息。
 */
TaskCustom.prototype._DingDingPushTask_cacheModifyCustomInfo = TaskCustom.prototype.cacheModifyCustomInfo;
TaskCustom.prototype.cacheModifyCustomInfo = function(){
	this._DingDingPushTask_cacheModifyCustomInfo();
	if (this.oldTaskInfo.type == 'DINGDING_PUSH') {
		this.oldCustomInfo.ddPushInfo = $.extend(true, {}, this.oldTaskInfo.ddPushInfo);
	}
}

/**
* 推送预览 推送到测试群
*/
TaskCustom.prototype.ddPushPreview = function() {
	if(!this.getTaskInfo()) {
		return;
	}
	if (!this.taskInfo.ddPushInfo.testWebhook) {
		alert("【${DingDingSettings}】【${TestGroup}】${PleaseInputWebhookAddress}");
		return;
	}
	if (!this.taskInfo.ddPushInfo.testSignSecret) {
		alert("【${DingDingSettings}】【${TestGroup}】${PleaseInputSignSecret}!");
		return;
	}
	var taskInfo = $.extend(true, {}, this.taskInfo);
	taskInfo.ddPushInfo.webhook = taskInfo.ddPushInfo.testWebhook;
	taskInfo.ddPushInfo.signSecret = taskInfo.ddPushInfo.testSignSecret;
	taskInfo.currentUserName = registry.get("currentUserName")
	taskInfo.isPushPreview = true;
	taskInfo.ddPushInfo.isPushPreview = true;
	taskInfo.type = this.cb_taskType.getSelectedId();
	var dialogConfig = {};
	dialogConfig.title = "${PushPreview}";
	dialogConfig.size = DialogFactory.getInstance().size.SMALL;
	dialogConfig.fullName = "bof.schedule.dialog.TestRunningDialog";
	DialogFactory.getInstance().showDialog(dialogConfig, taskInfo, null, this);
}

//全局销毁函数
TaskCustom.prototype._DingDingPushTask_destroy  = TaskCustom.prototype.destroy;
TaskCustom.prototype.destroy = function(){
	if(this.dingDingPushPanel){
		this.dingDingPushPanel.onPushPreview.unsubscribe(this.ddPushPreview, this);
		this.dingDingPushPanel.destroy();
	}
	this._DingDingPushTask_destroy();
}

因篇幅问题不能全部显示,请点此查看更多更全内容

Top