提交 b64f1cfa 编写于 作者: 楼国栋

Merge branch 'feature/dingding_pc_open_msg' into 'wrdp'

钉钉pc一键下载打印带上token,钉钉pc消息应用内打开

See merge request o2oa/o2oa!6383
...@@ -33,9 +33,15 @@ public class DingdingConsumeQueue extends AbstractQueue<Message> { ...@@ -33,9 +33,15 @@ public class DingdingConsumeQueue extends AbstractQueue<Message> {
if (needTransferLink(message.getType())) { if (needTransferLink(message.getType())) {
String workUrl = getDingdingOpenWorkUrl(message.getBody()); String workUrl = getDingdingOpenWorkUrl(message.getBody());
if (StringUtils.isNotEmpty(workUrl)) { if (StringUtils.isNotEmpty(workUrl)) {
logger.debug("工作url: "+workUrl);
// dingtalk://dingtalkclient/action/openapp?corpid=免登企业corpId&container_type=work_platform&app_id=0_{应用agentid}&redirect_type=jump&redirect_url=跳转url
String dingtalkUrl = "dingtalk://dingtalkclient/action/openapp?corpid=" + Config.dingding().getCorpId() +
"&container_type=work_platform&app_id=0_" + Config.dingding().getAgentId() +
"&redirect_type=jump&redirect_url="+ URLEncoder.encode(workUrl, DefaultCharset.name);
logger.debug("钉钉pc 打开消息 url:"+dingtalkUrl);
m.getMsg().setMsgtype("markdown"); m.getMsg().setMsgtype("markdown");
m.getMsg().getMarkdown().setTitle(message.getTitle()); m.getMsg().getMarkdown().setTitle(message.getTitle());
m.getMsg().getMarkdown().setText("["+message.getTitle()+"]("+workUrl+")"); m.getMsg().getMarkdown().setText("["+message.getTitle()+"]("+dingtalkUrl+")");
}else { }else {
m.getMsg().getText().setContent(message.getTitle()); m.getMsg().getText().setContent(message.getTitle());
} }
......
...@@ -3404,7 +3404,13 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class( ...@@ -3404,7 +3404,13 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class(
htmlFormId = htmlFormId.replace("#", "%23"); htmlFormId = htmlFormId.replace("#", "%23");
var url = "/x_processplatform_assemble_surface/jaxrs/attachment/batch/download/work/" + this.businessData.work.id + "/site/(0)/stream"; var url = "/x_processplatform_assemble_surface/jaxrs/attachment/batch/download/work/" + this.businessData.work.id + "/site/(0)/stream";
url = o2.filterUrl(o2.Actions.getHost("x_processplatform_assemble_surface") + url); url = o2.filterUrl(o2.Actions.getHost("x_processplatform_assemble_surface") + url);
window.open(o2.filterUrl(url + "?fileName=&flag=" + htmlFormId));
var downloadUrl = o2.filterUrl(url + "?fileName=&flag=" + htmlFormId);
if (this.isDingtalkPc()) {
var xtoken = Cookie.read(o2.tokenName);
downloadUrl += "&" + o2.tokenName + "=" + xtoken;
}
window.open(downloadUrl);
}, },
resetWork: function () { resetWork: function () {
if (!this.businessData.control["allowReset"]) { if (!this.businessData.control["allowReset"]) {
...@@ -4381,10 +4387,20 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class( ...@@ -4381,10 +4387,20 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class(
} }
if (this.businessData.workCompleted) { if (this.businessData.workCompleted) {
var application = app || this.businessData.workCompleted.application; var application = app || this.businessData.workCompleted.application;
window.open(o2.filterUrl("../x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form)); var url = o2.filterUrl("../x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form);
if (this.isDingtalkPc()) {
var xtoken = Cookie.read(o2.tokenName);
url += "&" + o2.tokenName + "=" + xtoken;
}
window.open(url);
} else { } else {
var application = app || this.businessData.work.application; var application = app || this.businessData.work.application;
window.open(o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form)); var url = o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form);
if (this.isDingtalkPc()) {
var xtoken = Cookie.read(o2.tokenName);
url += "&" + o2.tokenName + "=" + xtoken;
}
window.open(url);
} }
}, },
/** /**
...@@ -4548,10 +4564,20 @@ debugger; ...@@ -4548,10 +4564,20 @@ debugger;
} }
if (this.businessData.workCompleted) { if (this.businessData.workCompleted) {
var application = app || this.businessData.workCompleted.application; var application = app || this.businessData.workCompleted.application;
window.open(o2.filterUrl("../x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form)); var url = o2.filterUrl("../x_desktop/printWork.html?workCompletedId=" + this.businessData.workCompleted.id + "&app=" + application + "&form=" + form);
if (this.isDingtalkPc()) {
var xtoken = Cookie.read(o2.tokenName);
url += "&" + o2.tokenName + "=" + xtoken;
}
window.open(url);
} else { } else {
var application = app || this.businessData.work.application; var application = app || this.businessData.work.application;
window.open(o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form)); var url = o2.filterUrl("../x_desktop/printWork.html?workid=" + this.businessData.work.id + "&app=" + application + "&form=" + form);
if (this.isDingtalkPc()) {
var xtoken = Cookie.read(o2.tokenName);
url += "&" + o2.tokenName + "=" + xtoken;
}
window.open(url);
} }
//window.open("../x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form); //window.open("../x_desktop/printWork.html?workid="+this.businessData.work.id+"&app="+this.businessData.work.application+"&form="+form);
}, },
...@@ -4645,16 +4671,22 @@ debugger; ...@@ -4645,16 +4671,22 @@ debugger;
}, },
// 判断是否是钉钉pc上 // 判断是否是钉钉pc上
dingTalkPcCloseOrAppClose: function () { dingTalkPcCloseOrAppClose: function () {
// 判断是否是钉钉环境 是否是独立窗口 if (this.isDingtalkPc() && layout.inBrowser) { // 如果是钉钉pc上 并且是浏览器模式
var ua = navigator.userAgent.toLowerCase();
debugger;
if (layout.inBrowser && ua.indexOf('dingtalk') >= 0) {
var centerUrl = o2.filterUrl("../x_desktop/app.html?app=process.TaskCenter"); var centerUrl = o2.filterUrl("../x_desktop/app.html?app=process.TaskCenter");
history.replaceState(null, "work", centerUrl); history.replaceState(null, "work", centerUrl);
centerUrl.toURI().go(); centerUrl.toURI().go();
} else { } else {
this.app.close(); this.app.close();
} }
},
// 判断是否是钉钉环境
isDingtalkPc: function () {
var ua = navigator.userAgent.toLowerCase();
if (!(o2.session.isMobile || layout.mobile) && ua.indexOf('dingtalk') >= 0) {
return true;
} else {
return false;
}
}, },
/** /**
* @summary 获取组件的类型(小写). * @summary 获取组件的类型(小写).
......
...@@ -63,18 +63,29 @@ o2.addReady(function () { ...@@ -63,18 +63,29 @@ o2.addReady(function () {
action.invoke({ action.invoke({
"name": "auth", "async": true, "parameter": { "code": info.code }, "name": "auth", "async": true, "parameter": { "code": info.code },
"success": function (json) { "success": function (json) {
//document.all.testaaa.set("value", "auth"); // var ua = navigator.userAgent.toLowerCase();
// "appMobile.html?app=process.TaskCenter".toURI().go(); // console.log(ua);
// console.log(dd.pc);
// console.log(dd.android);
// console.log(dd.ios);
if (redirect) { if (redirect) {
history.replaceState(null, "page", redirect); var uri = redirect;
redirect.toURI().go(); if (dd.pc) { // 判断是否是PC端,目前测试这个参数可用
uri = redirect.replace("workmobilewithaction.html", "work.html");
}
history.replaceState(null, "page", uri);
uri.toURI().go();
} else { } else {
history.replaceState(null, "page", "../x_desktop/appMobile.html?app=process.TaskCenter"); var uri = "../x_desktop/appMobile.html?app=process.TaskCenter";
"appMobile.html?app=process.TaskCenter".toURI().go(); if (dd.pc) { // 判断是否是PC端,目前测试这个参数可用
uri = "../x_desktop/app.html?app=process.TaskCenter"
}
history.replaceState(null, "page", uri);
uri.toURI().go();
} }
}.bind(this), "failure": function (xhr, text, error) { }.bind(this), "failure": function (xhr, text, error) {
console.log("单点失败。。。。");
history.replaceState(null, "page", "../x_desktop/appMobile.html?app=process.TaskCenter"); history.replaceState(null, "page", "../x_desktop/appMobile.html?app=process.TaskCenter");
"appMobile.html?app=process.TaskCenter".toURI().go(); "appMobile.html?app=process.TaskCenter".toURI().go();
}.bind(this) }.bind(this)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册