情景:
由於activiti與系統應用主題樣式出入較大,協商後決定將activiti的editor-app放在前臺。
ps:主要iframe解決多項目集成,重寫httpRequest添加token,但都2020年了,其實優選微前端方案集成。
步驟:
- 將activiti放在public即靜態目錄下。
- 通過iframe在相應的前臺工作流界面引入activiti的model.html(最外層的主html,名字可能有出入)。
- mounted時將this,即vuecompoennt對象賦值給iframe,這樣可以在保存後進行頁面切換,或者某個接口回調後控制vue界面的狀態。
mounted(){ window.getMyVue = this;//全局存入當前vue實例,供activiti調用 }
- 因爲涉及到了權限問題,而通過iframe引入的頁面本身不會跟我們系統的請求頭一致,需要在頁面主html文件加上下面一段代碼。
//model.html <script> ( function(open){ XMLHttpRequest.prototype.open = function(method,url,async,user,pass){ open.call(this,method,url,async,user,pass);//this指XMLHttpRequest this.setRequestHeader("token",window.parent.getMyVue.token);//mounted時傳入的token } } )(XMLHttpRequest.prototype.open) </script>
- 配置下url的config文件,通過network調試查看那個接口有問題