|
|
@@ -1,259 +1,146 @@
|
|
|
-layout = window.layout || {};
|
|
|
-var locate = window.location;
|
|
|
-layout.protocol = locate.protocol;
|
|
|
-var href = locate.href;
|
|
|
-if (href.indexOf("debugger") != -1) layout.debugger = true;
|
|
|
-layout.desktop = layout;
|
|
|
-layout.session = layout.session || {};
|
|
|
-o2.xApplication = o2.xApplication || {};
|
|
|
|
|
|
-(function (layout) {
|
|
|
- var _requireApp = function (appNames, callback, clazzName) {
|
|
|
- var appPath = appNames.split(".");
|
|
|
- var baseObject = o2.xApplication;
|
|
|
- appPath.each(function (path, i) {
|
|
|
- if (i < (appPath.length - 1)) {
|
|
|
- baseObject[path] = baseObject[path] || {};
|
|
|
- } else {
|
|
|
- baseObject[path] = baseObject[path] || { "options": Object.clone(o2.xApplication.Common.options) };
|
|
|
- }
|
|
|
- baseObject = baseObject[path];
|
|
|
- }.bind(this));
|
|
|
- if (!baseObject.options) baseObject.options = Object.clone(o2.xApplication.Common.options);
|
|
|
|
|
|
- var _lpLoaded = false;
|
|
|
- o2.xDesktop.requireApp(appNames, "lp." + o2.language, {
|
|
|
- "failure": function () {
|
|
|
- o2.xDesktop.requireApp(appNames, "lp.zh-cn", null, false);
|
|
|
- }.bind(this)
|
|
|
- }, false);
|
|
|
-
|
|
|
- o2.xDesktop.requireApp(appNames, clazzName, function () {
|
|
|
- if (callback) callback(baseObject);
|
|
|
+layout.addReady(function(){
|
|
|
+ //重写 base_simple.js中的方法 这里是单点登录企业微信
|
|
|
+ layout.openLogin = function () {
|
|
|
+ console.log("开始login。。。。。。。。。。。。。");
|
|
|
+ var uri = locate.href.toURI();
|
|
|
+ var redirect = uri.getData("redirect");
|
|
|
+ var processId = uri.getData("processId");
|
|
|
+ var applicationId = uri.getData("appId");
|
|
|
+ MWF.require("MWF.xDesktop.Actions.RestActions", function () {
|
|
|
+ console.log("执行单点。。。。。。。。。。");
|
|
|
+ var action = new MWF.xDesktop.Actions.RestActions("", "x_organization_assemble_authentication", "");
|
|
|
+ action.getActions = function (actionCallback) {
|
|
|
+ this.actions = { "sso": { "uri": "/jaxrs/qiyeweixin/code/{code}", "method": "GET" } };
|
|
|
+ if (actionCallback) actionCallback();
|
|
|
+ };
|
|
|
+ action.invoke({
|
|
|
+ "name": "sso", "async": true, "parameter": { "code": uri.getData("code") }, "success": function (json) {
|
|
|
+ console.log("单点成功。");
|
|
|
+ console.log(json);
|
|
|
+ //基础数据。。。。
|
|
|
+ layout.session.user = json.data;
|
|
|
+ layout.content = $(document.body);
|
|
|
+ layout.app = layout;
|
|
|
+
|
|
|
+ //开始启动
|
|
|
+ layout.startProcess(applicationId, processId, redirect);
|
|
|
+ }.bind(this), "failure": function (xhr, text, error) {
|
|
|
+ var n = document.getElementById("loaddingArea");
|
|
|
+ if (n) { n.destroy(); }
|
|
|
+ document.id("layout").set("html", "<div>企业微信单点异常!</div>")
|
|
|
+ }.bind(this)
|
|
|
+ });
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- var _createNewApplication = function (e, appNamespace, appName, options, statusObj) {
|
|
|
- var app = new appNamespace["Main"](layout, options);
|
|
|
- app.desktop = layout;
|
|
|
- app.inBrowser = true;
|
|
|
- app.status = statusObj;
|
|
|
-
|
|
|
- app.load(true);
|
|
|
+ layout.startProcess = function (appId, pId, redirect) {
|
|
|
+ console.log("开始startProcess。。。。。。。。");
|
|
|
+ console.log(appId);
|
|
|
+ console.log(pId);
|
|
|
+ MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(pId, appId, function (json) {
|
|
|
+
|
|
|
+ if (json.data) {
|
|
|
+ MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function () {
|
|
|
+ var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, layout.app, {
|
|
|
+ "workData": {},
|
|
|
+ "identity": null,
|
|
|
+ "latest": false,
|
|
|
+ "onStarted": function (data, title, processName) {
|
|
|
+ console.log("进入 onStarted。。。。");
|
|
|
+ debugger;
|
|
|
+ if (data.work){
|
|
|
+ layout.startProcessDraft(data, title, processName, redirect);
|
|
|
+ }else{
|
|
|
+ layout.startProcessInstance(data, title, processName, redirect);
|
|
|
+ }
|
|
|
+
|
|
|
+ }.bind(this)
|
|
|
|
|
|
- var appId = appName;
|
|
|
- if (options.appId) {
|
|
|
- appId = options.appId;
|
|
|
- } else {
|
|
|
- if (appNamespace.options.multitask) appId = appId + "-" + (new o2.widget.UUID());
|
|
|
- }
|
|
|
- app.appId = appId;
|
|
|
- layout.app = app;
|
|
|
- layout.desktop.currentApp = app;
|
|
|
-
|
|
|
- var mask = document.getElementById("appContentMask");
|
|
|
- if (mask) mask.destroy();
|
|
|
- };
|
|
|
- var _openWorkHTML = function (options) {
|
|
|
- var uri = new URI(window.location.href);
|
|
|
- var redirectlink = uri.getData("redirectlink");
|
|
|
- if (!redirectlink) {
|
|
|
- redirectlink = encodeURIComponent(locate.pathname + locate.search);
|
|
|
- } else {
|
|
|
- redirectlink = encodeURIComponent(redirectlink);
|
|
|
- }
|
|
|
- if (options.workId) {
|
|
|
- window.location = "workmobilewithaction.html?workid=" + options.workId + ((layout.debugger) ? "&debugger" : "") + "&redirectlink=" + redirectlink;
|
|
|
- } else if (options.workCompletedId) {
|
|
|
- window.location = "workmobilewithaction.html?workcompletedid=" + options.workCompletedId + ((layout.debugger) ? "&debugger" : "") + "&redirectlink=" + redirectlink;
|
|
|
- }
|
|
|
+ });
|
|
|
+ var mask = document.getElementById("loaddingArea");
|
|
|
+ if (mask) mask.destroy();
|
|
|
+ starter.load();
|
|
|
+ }.bind(this));
|
|
|
+ }
|
|
|
+ }.bind(this));
|
|
|
};
|
|
|
|
|
|
- layout.openApplication = function (e, appNames, options, statusObj) {
|
|
|
- if (layout.app) {
|
|
|
- if (layout.mobile) {
|
|
|
- _openWorkHTML(options, statusObj);
|
|
|
- } else {
|
|
|
- var par = "app=" + encodeURIComponent(appNames) + "&status=" + encodeURIComponent((statusObj) ? JSON.encode(statusObj) : "") + "&option=" + encodeURIComponent((options) ? JSON.encode(options) : "");
|
|
|
+ layout.startProcessDraft = function(data, title, processName, redirect){
|
|
|
+ console.log("草稿模式。。。。");
|
|
|
+ console.log(data);
|
|
|
+ o2.require("o2.widget.UUID", function () {
|
|
|
+ var work = data.work;
|
|
|
+ var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false};
|
|
|
+ //先修改当前url为配置的门户地址
|
|
|
+ if (redirect) {
|
|
|
+ history.replaceState(null, "startProcess", redirect);
|
|
|
|
|
|
- if (layout.app.$openWithSelf) {
|
|
|
- return window.location = "app.html?" + par + ((layout.debugger) ? "&debugger" : "");
|
|
|
- } else {
|
|
|
- return window.open("app.html?" + par + ((layout.debugger) ? "&debugger" : ""), par);
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ history.replaceState(null, "startProcess", "/x_desktop/appMobile.html?app=process.TaskCenter");
|
|
|
+
|
|
|
}
|
|
|
- } else {
|
|
|
- var appPath = appNames.split(".");
|
|
|
- var appName = appPath[appPath.length - 1];
|
|
|
debugger;
|
|
|
- _requireApp(appNames, function (appNamespace) {
|
|
|
- _createNewApplication(e, appNamespace, appName, options, statusObj);
|
|
|
- }.bind(this));
|
|
|
- }
|
|
|
+ // layout.openApplication(null, "process.Work", options);
|
|
|
+ layout.openWorkIn(options);
|
|
|
+ });
|
|
|
+
|
|
|
};
|
|
|
-})(layout);
|
|
|
-
|
|
|
-o2.addReady(function () {
|
|
|
- o2.load(["../o2_lib/mootools/plugin/mBox.Notice.js", "../o2_lib/mootools/plugin/mBox.Tooltip.js"], { "sequence": true }, function () {
|
|
|
- MWF.loadLP("zh-cn");
|
|
|
- MWF.require("MWF.widget.Common", null, false);
|
|
|
- MWF.require("MWF.xDesktop.Common", null, false);
|
|
|
- MWF.require("MWF.xAction.RestActions", null, false);
|
|
|
- MWF.require("MWF.xDesktop.Authentication", null, false);
|
|
|
- MWF.require("MWF.xDesktop.Layout", function () {
|
|
|
-
|
|
|
- (function () {
|
|
|
- layout.load = function () {
|
|
|
- var uri = href.toURI();
|
|
|
- var redirect = uri.getData("redirect");
|
|
|
- var processId = uri.getData("processId");
|
|
|
- var applicationId = uri.getData("appId");
|
|
|
-
|
|
|
- layout.isAuthentication(function () {
|
|
|
- //开始启动
|
|
|
- layout.startProcess(applicationId, processId, redirect);
|
|
|
- }, function(){
|
|
|
- MWF.require("MWF.xDesktop.Actions.RestActions", function () {
|
|
|
- var action = new MWF.xDesktop.Actions.RestActions("", "x_organization_assemble_authentication", "");
|
|
|
- action.getActions = function (actionCallback) {
|
|
|
- this.actions = { "sso": { "uri": "/jaxrs/qiyeweixin/code/{code}", "method": "GET" } };
|
|
|
- if (actionCallback) actionCallback();
|
|
|
- };
|
|
|
- action.invoke({
|
|
|
- "name": "sso", "async": true, "parameter": { "code": uri.getData("code") }, "success": function (json) {
|
|
|
- //基础数据。。。。
|
|
|
- layout.session.user = json.data;
|
|
|
- layout.content = $(document.body);
|
|
|
- layout.app = layout;
|
|
|
-
|
|
|
- //开始启动
|
|
|
- layout.startProcess(applicationId, processId, redirect);
|
|
|
- }.bind(this), "failure": function (xhr, text, error) {
|
|
|
- var n = document.getElementById("loaddingArea");
|
|
|
- if (n) { n.destroy(); }
|
|
|
- document.id("layout").set("html", "<div>企业微信单点异常!</div>")
|
|
|
- }.bind(this)
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- layout.startProcess = function (appId, pId, redirect) {
|
|
|
- MWF.Actions.get("x_processplatform_assemble_surface").getProcessByName(pId, appId, function (json) {
|
|
|
-
|
|
|
- if (json.data) {
|
|
|
- MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function () {
|
|
|
- var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(json.data, layout.app, {
|
|
|
- "workData": {},
|
|
|
- "identity": null,
|
|
|
- "latest": false,
|
|
|
- "onStarted": function (data, title, processName) {
|
|
|
-
|
|
|
- debugger;
|
|
|
- var currentTask = [];
|
|
|
- data.each(function (work) {
|
|
|
- if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
|
|
|
- }.bind(this));
|
|
|
-
|
|
|
- if (currentTask.length == 1) {
|
|
|
- var options = { "workId": currentTask[0], "appId": currentTask[0] };
|
|
|
-
|
|
|
- //先修改当前url为配置的门户地址
|
|
|
- if (redirect) {
|
|
|
- history.replaceState(null, "startProcess", redirect);
|
|
|
- // var workUrl = "workmobilewithaction.html?workid=" + options.workId + ((layout.debugger) ? "&debugger" : "") + "&redirectlink=" + redirect;
|
|
|
- // workUrl.toURI().go();
|
|
|
+ layout.startProcessInstance = function(data, title, processName, redirect){
|
|
|
+ console.log("实例模式。。。。");
|
|
|
+ console.log(data);
|
|
|
+ var currentTask = [];
|
|
|
+ data.each(function (work) {
|
|
|
+ if (work.currentTaskIndex != -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
|
|
|
+ }.bind(this));
|
|
|
|
|
|
- } else {
|
|
|
- history.replaceState(null, "startProcess", "/x_desktop/appMobile.html?app=process.TaskCenter");
|
|
|
- // var workUrl = "workmobilewithaction.html?workid=" + options.workId + ((layout.debugger) ? "&debugger" : "") + "&redirectlink=appMobile.html%3Fapp%3Dprocess.TaskCenter";
|
|
|
- // workUrl.toURI().go();
|
|
|
- }
|
|
|
- // layout.app = null;
|
|
|
- layout.openApplication(null, "process.Work", options);
|
|
|
- } else { }
|
|
|
+ if (currentTask.length == 1) {
|
|
|
+ var options = { "workId": currentTask[0], "appId": currentTask[0] };
|
|
|
|
|
|
- }.bind(this)
|
|
|
+ //先修改当前url为配置的门户地址
|
|
|
+ if (redirect) {
|
|
|
+ history.replaceState(null, "startProcess", redirect);
|
|
|
|
|
|
- });
|
|
|
- var mask = document.getElementById("loaddingArea");
|
|
|
- if (mask) mask.destroy();
|
|
|
- starter.load();
|
|
|
- }.bind(this));
|
|
|
- }
|
|
|
- }.bind(this));
|
|
|
- };
|
|
|
+ } else {
|
|
|
+ history.replaceState(null, "startProcess", "/x_desktop/appMobile.html?app=process.TaskCenter");
|
|
|
+ }
|
|
|
|
|
|
- layout.isAuthentication = function (callback, failure) {
|
|
|
- layout.authentication = new MWF.xDesktop.Authentication({
|
|
|
- "onLogin": layout.load.bind(layout)
|
|
|
- });
|
|
|
+ // layout.openApplication(null, "process.Work", options);
|
|
|
+ layout.openWorkIn(options);
|
|
|
|
|
|
- // var returnValue = true;
|
|
|
- this.authentication.isAuthenticated(function (json) {
|
|
|
- if (json.data.tokenType != "anonymous") {
|
|
|
- //基础数据。。。。
|
|
|
- layout.session.user = json.data;
|
|
|
- layout.content = $(document.body);
|
|
|
- layout.app = layout;
|
|
|
- if (callback) callback();
|
|
|
- } else {
|
|
|
- // returnValue = false;
|
|
|
- if (failure) failure();
|
|
|
- }
|
|
|
- }.bind(this), function () {
|
|
|
- // returnValue = false;
|
|
|
- if (failure) failure();
|
|
|
- }.bind(this));
|
|
|
- // console.log("back................."+returnValue);
|
|
|
- // return returnValue;
|
|
|
- };
|
|
|
+ } else { }
|
|
|
+ };
|
|
|
+ layout.openWorkIn = function(options){
|
|
|
+ o2.requireApp("Common", "", function() {
|
|
|
+ var uri = new URI(window.location.href);
|
|
|
+ var redirectlink = uri.getData("redirectlink");
|
|
|
+ if (!redirectlink) {
|
|
|
+ redirectlink = encodeURIComponent(locate.pathname + locate.search);
|
|
|
+ } else {
|
|
|
+ redirectlink = encodeURIComponent(redirectlink);
|
|
|
+ }
|
|
|
+ var appName="process.Work", m_status=null;
|
|
|
+ options.redirectlink = redirectlink;
|
|
|
+ layout.app = null;//创建工作界面
|
|
|
+ layout.openApplication(null, appName, options, m_status);
|
|
|
+ }, true);
|
|
|
+ };
|
|
|
|
|
|
+ (function(layout){
|
|
|
+ console.log("开始执行。。。。。。。。");
|
|
|
+ var uri = locate.href.toURI();
|
|
|
+ var redirect = uri.getData("redirect");
|
|
|
+ var processId = uri.getData("processId");
|
|
|
+ var applicationId = uri.getData("appId");
|
|
|
+ console.log(uri);
|
|
|
+ layout.content = $(document.body);
|
|
|
+ layout.app = layout;
|
|
|
+ layout.startProcess(applicationId, processId, redirect);
|
|
|
+ })(layout);
|
|
|
+});
|
|
|
|
|
|
- layout.notice = function (content, type, target, where, offset) {
|
|
|
- if (!where) where = { "x": "right", "y": "top" };
|
|
|
- if (!target) target = this.content;
|
|
|
- if (!type) type = "ok";
|
|
|
- var noticeTarget = target || $(document.body);
|
|
|
- var off = offset;
|
|
|
- if (!off) {
|
|
|
- off = {
|
|
|
- x: 10,
|
|
|
- y: where.y.toString().toLowerCase() == "bottom" ? 10 : 10
|
|
|
- };
|
|
|
- }
|
|
|
|
|
|
- new mBox.Notice({
|
|
|
- type: type,
|
|
|
- position: where,
|
|
|
- move: false,
|
|
|
- target: noticeTarget,
|
|
|
- delayClose: (type == "error") ? 10000 : 5000,
|
|
|
- offset: off,
|
|
|
- content: content
|
|
|
- });
|
|
|
- };
|
|
|
|
|
|
- MWF.getJSON("res/config/config.json", function (config) {
|
|
|
- layout.config = config;
|
|
|
- MWF.xDesktop.getServiceAddress(layout.config, function (service, center) {
|
|
|
- layout.serviceAddressList = service;
|
|
|
- layout.centerServer = center;
|
|
|
- layout.load();
|
|
|
- }.bind(this));
|
|
|
- });
|
|
|
|
|
|
- window.addEventListener('popstate', function (event) {
|
|
|
- debugger
|
|
|
- var ua = navigator.userAgent.toLowerCase()
|
|
|
- var isiOS = /(iPhone|iPad|iPod|iOS)/i.test(ua)
|
|
|
- if (isiOS) {
|
|
|
- console.log("is IOs");
|
|
|
- window.location.reload();
|
|
|
- }
|
|
|
- }.bind(this));
|
|
|
- })();
|
|
|
- });
|
|
|
- });
|
|
|
-});
|
|
|
|