| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- var spaceConsole = {};
- /**
- * 回收TOKEN
- * @param {Object} removeUrl url
- * @param {Object} param tokenList
- */
- spaceConsole.recycleToken = function (removeUrl, param) {
- $.ajax({
- type: "post",
- url: removeUrl,
- async: true,
- data: param
- });
- }
- /**
- * 业务程序组件
- */
- spaceConsole.appWindow = {
- // 显示
- show: function (setting) {
- if (!this.vaildation(setting)) {
- this.close();
- return;
- }
- this.hideBackBtn();
- this.winSetting = setting;
- space.plugin.loading.show();
- setting.position = space.utils.isNull(setting.position) ? "bottom" : setting.position;
- space.vue.$data.appWindow.position = setting.position;
- // 设置父窗口对象
- this.windowMap.set(space.vue.$data.appWindow.index, setting);
- // 解析 param
- if (setting.param) {
- var keys = Object.keys(setting.param);
- for (var i = 0; i < keys.length; i++) {
- setting.url += ("&" + keys[i] + "=" + setting.param[keys[i]]);
- }
- }
- space.vue.$data.appWindow.appWindowTitle = setting.title;
- space.vue.$data.appWindow.appWindowUrl = setting.url;
- space.vue.$data.appWindow.isShowAppWindow = true;
- },
- // 判断是否显示返回按钮
- autoControlBackBtn: function () {
- return false;
- // var appWin = this.getAppWindowObject();
- // if (!appWin) {
- // this.hideBackBtn();
- // return false;
- // }
- // try {
- // var laySize = appWin.space.plugin.layer.getLayCount();
- // if (laySize == 0) {
- // this.hideBackBtn();
- // }
- // else {
- // $("#appWindow-back").show();
- // }
- // } catch (error) {
- // this.hideBackBtn();
- // console.error(" autoControlBackBtn Error! " + error);
- // }
- },
- // 隐藏掉返回按钮
- hideBackBtn: function () {
- $("#appWindow-back").hide();
- },
- // 关闭 AppWindow 里面的弹出层
- closeAppWinLayer: function () {
- try {
- var appWin = this.getAppWindowObject();
- if (appWin) {
- appWin.space.plugin.layer.autoClose();
- }
- else {
- this.autoControlBackBtn();
- }
- } catch (error) {
- console.log(error);
- this.close({ type: 'cancel' });
- }
- },
- // 获取 APP Window Frame 对象
- getAppWindowObject: function () {
- var appWindowFrame = $("#appWindow-iframe");
- if (appWindowFrame.length == 0) {
- return undefined;
- }
- return $(appWindowFrame)[0].contentWindow;
- },
- // 获取父窗口对象
- getAppWinParentWin: function () {
- var winSetting = this.windowMap.get(space.vue.$data.appWindow.index);
- return winSetting == undefined ? undefined : winSetting.parentWin;
- },
- // 取消
- cancel: function () {
- try {
- var appWin = this.getAppWindowObject();
- if (!appWin) {
- return false;
- }
- // 逐一关闭 AppWin 的子页面,最后再关闭 AppWin 窗口
- var laySize = appWin.space.plugin.layer.getLayCount();
- if (laySize == 0) {
- this.close({ type: 'cancel' });
- } else {
- this.closeAppWinLayer();
- }
- } catch (error) {
- console.log(error);
- this.closeAppWinLayer();
- }
- },
- // 关闭,需清理掉 iframe 的 src
- close: function (params) {
- var contentWindow = $("#appWindow-iframe")[0].contentWindow;
- contentWindow.$("body").html("<div style='text-align: center;color: #999;margin-top: 49%'>加载中</div>");
- try {
- contentWindow.onunload(0);
- } catch (error) {
- console.error("contentWindow.onunload Error");
- }
- // 关闭回调,如果是右上角的关闭按钮则不进行回调
- var winSetting = this.windowMap.get(space.vue.$data.appWindow.index);
- if (!params || params.type != 'cancel') {
- if (winSetting && winSetting.close) {
- winSetting.close();
- }
- }
- // 关闭回调,百分百调用
- if (winSetting && winSetting.closeCallback) {
- winSetting.closeCallback();
- }
- // 删除父窗口对象
- this.windowMap.delete(space.vue.$data.appWindow.index);
- // 下标自增长
- space.vue.$data.appWindow.index++;
- space.vue.$data.appWindow.appWindowUrl = "javascript:false";
- space.vue.$nextTick(function () {
- space.vue.$data.appWindow.isShowAppWindow = false; // 关闭动画
- })
- this.autoControlBackBtn();
- },
- // 更新
- update: function (setting) {
- if (space.utils.isNull(setting)) {
- space.message.warning("AppWindow update setting is null");
- return false;
- }
- if (space.utils.isNull(setting.title)) {
- space.message.warning("AppWindow update setting.title is null");
- return false;
- }
- // 是弹出层调用,动画为:从右渐入
- var isLayerFlag = setting.target != undefined && setting.target == 'layer';
- if (isLayerFlag) {
- $("#appWinTitle").addClass("animate__animated animate__fadeIn");
- // $("#appWinTitle").addClass("animate__animated animate__fadeInRight");
- }
- else {
- $("#appWinTitle").addClass("animate__animated animate__fadeIn");
- }
- space.vue.$data.appWindow.appWindowTitle = setting.title;
- setTimeout(() => {
- $("#appWinTitle").removeAttr("class");
- }, 300);
- },
- // 窗口对象
- windowMap: new Map(),
- // 校验
- vaildation: function (setting) {
- if (space.utils.isNull(setting)) {
- space.message.warning("AppWindow setting is null");
- return false;
- }
- if (space.utils.isNull(setting.title)) {
- space.message.warning("AppWindow setting.title is null");
- return false;
- }
- if (space.utils.isNull(setting.url)) {
- space.message.warning("AppWindow setting.url is null");
- return false;
- }
- return true;
- }
- }
- spaceConsole.CMSSave = function (obj) {
- $.ajax({
- type: "post",
- url: cmsUrl,
- data: obj,
- async: true,
- cache: false
- });
- }
|