/** ***** BEGIN LICENSE BLOCK *****
* |------------------------------------------------------------------------------|
* | O2OA 活力办公 创意无限 o2m.api.js |
* |------------------------------------------------------------------------------|
* | Distributed under the AGPL license: |
* |------------------------------------------------------------------------------|
* | Copyright © 2018, o2oa.net, o2server.io O2 Team |
* | All rights reserved. |
* |------------------------------------------------------------------------------|
*
* This file is part of O2OA.
*
* O2OA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* O2OA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see
* o2m 只有在O2OA移动端APP中才能提供能力
* @namespace o2m
* @o2cn 平台移动APP API
* @o2category mobile
* @o2ordernumber 13
* @o2range {流程表单|门户}
* @o2syntax
* // 可以在移动端 流程表单、门户 上使用
* window.o2m
*
*/
(function () {
this.o2m = {
version: {
v: "1.1.0",
build: "2021.01.20",
info: "O2OA 活力办公 创意无限. Copyright © 2021, o2oa.net O2 Team All rights reserved."
},
log: function (message) {
window.o2android && window.o2android.o2mLog ? window.o2android.o2mLog(message) : window.webkit.messageHandlers.o2mLog.postMessage(message);
}
};
/** ***** BEGIN NOTIFICATION BLOCK *****
@ignore
@summary notification 模块
alert
confirm
prompt
vibrate
toast
actionSheet
showLoading
hideLoading
* ***** END NOTIFICATION BLOCK ******/
this.o2m.notification = {};
var _notification_post = function (body, onFail) {
if (body == null) {
if (onFail && typeof onFail === "function") {
onFail("参数异常!");
return
}
}
var message = JSON.stringify(body);
if (window.flutter_inappwebview && window.flutter_inappwebview.callHandler) {
window.flutter_inappwebview.callHandler('o2mNotification', message);
} else if (window.o2mNotification && window.o2mNotification.postMessage) {
window.o2mNotification.postMessage(message);
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mNotification) {
window.webkit.messageHandlers.o2mNotification.postMessage(message);
} else {
if (onFail && typeof onFail === "function") {
onFail("请在O2OA移动端使用!");
return
}
}
};
this.o2m.notification.alertSuccess = function () {
console.log("notification alert back");
};
var _o2m_n_alert = function (alert) {
var message = alert && alert.message ? alert.message : "";
var title = alert && alert.title ? alert.title : "";
var buttonName = alert && alert.buttonName ? alert.buttonName : "";
var onSuccess = alert && alert.onSuccess ? alert.onSuccess : null;
var onFail = alert && alert.onFail ? alert.onFail : null;
if (message === "") {
if (typeof onFail === "function") { onFail("消息内容不能为空!"); }
return;
}
if (onSuccess && typeof onSuccess === "function") {
o2m.notification.alertSuccess = onSuccess;
}
var body = {
type: "alert",
callback: "o2m.notification.alertSuccess",
data: {
message: message,
title: title,
buttonName: buttonName,
}
};
_notification_post(body, onFail);
};
/**
* 原生Alert提示弹出窗
* @method alert
* @memberOf o2m
* @o2membercategory notification
* @static
* @param {Object} obj 提示窗传入对象
*
{
* "title": "提示", //消息标题,可为空
* "message": "这里是消息内容", //消息内容
* "buttonName": "确定", //确定按钮名称
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* "title": "提示", //消息标题,可为空
* "message": "这里是消息内容", //消息内容
* "buttonLabels": ["确定", "取消"], //按钮名称 Array[String]
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* "title": "提示", //消息标题,可为空
* "message": "这里是消息内容", //消息内容
* "buttonLabels": ['继续', '不玩了'], //按钮名称 Array[String]
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* "duration": 300, //震动时间,android可配置 iOS忽略
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.notification.vibrate({
* duration: 300,
* onSuccess : function() {
* },
* onFail : function(err) {}
* });
*
*/
this.o2m.notification.vibrate = _o2m_n_vibrate;
//notification.toast
this.o2m.notification.toastSuccess = function () {
console.log("notification toast back, click button");
};
var _o2m_n_toast = function (c) {
var duration = c && c.duration ? c.duration : 300;
var message = c && c.message ? c.message : "";
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (message === "") {
if (typeof onFail === "function") { onFail("消息内容message不能为空!"); }
return;
}
if (onSuccess && typeof onSuccess === "function") {
o2m.notification.toastSuccess = onSuccess;
}
var body = {
type: "toast",
callback: "o2m.notification.toastSuccess",
data: {
duration: duration,
message: message
}
};
_notification_post(body, onFail);
};
/**
* toast提示
* @method toast
* @memberOf o2m
* @o2membercategory notification
* @static
* @param {Object} obj toast需要传入对象
* {
* "message": "这里是提示信息",
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.notification.toast({
* message: "提示消息内容",
* onSuccess : function() {
* },
* onFail : function(err) {}
* });
*
*/
this.o2m.notification.toast = _o2m_n_toast;
//notification.actionSheet
this.o2m.notification.actionSheetSuccess = function (buttonIndex) {
console.log("notification actionSheet back, click button:" + buttonIndex);
};
var _o2m_n_actionSheet = function (c) {
var title = c && c.title ? c.title : "";
var cancelButton = c && c.cancelButton ? c.cancelButton : "取消";
var otherButtons = c && c.otherButtons ? c.otherButtons : [];
var tooManyButtons = c && c.tooManyButtons ? c.tooManyButtons : false;
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (otherButtons.length < 1) {
if (typeof onFail === "function") { onFail("其他按钮列表不能为空!"); }
return;
}
if (onSuccess && typeof onSuccess === "function") {
o2m.notification.actionSheetSuccess = onSuccess;
}
var body = {
type: "actionSheet",
callback: "o2m.notification.actionSheetSuccess",
data: {
title: title,
cancelButton: cancelButton,
otherButtons: otherButtons,
tooManyButtons: tooManyButtons
}
};
_notification_post(body, onFail);
};
/**
* 底部弹出菜单
* @method actionSheet
* @memberOf o2m
* @o2membercategory notification
* @static
* @param {Object} obj actionSheet需要传入对象
* {
* "title": "谁是最棒哒?",//标题
* "cancelButton": '取消', //取消按钮文本
* "otherButtons": ["孙悟空","猪八戒","唐僧","沙和尚"], //其他选项按钮名称
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* text: "使劲加载中..", //loading显示的字符,空表示不显示文字
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.notification.hideLoading({
* onSuccess : function() {
* },
* onFail : function(err) {}
* });
*
*/
this.o2m.notification.hideLoading = _o2m_n_hideLoading;
/** ***** BEGIN UTIL BLOCK *****
* @ignore
* @summary
util 模块
date
o2m.util.date.datePicker
o2m.util.date.timePicker
o2m.util.date.dateTimePicker
calendar
o2m.util.calendar.chooseOneDay
o2m.util.calendar.chooseDateTime
o2m.util.calendar.chooseInterval
device
o2m.util.device.getPhoneInfo
o2m.util.device.scan
o2m.util.deveice.location
navigation
o2m.util.navigation.setTitle
o2m.util.navigation.close
o2m.util.navigation.goBack
o2m.util.navigation.openInnerApp
o2m.util.navigation.openOtherApp
o2m.util.navigation.openWindow
o2m.util.navigation.share
* ***** END UTIL BLOCK ******/
this.o2m.util = {
date: {},
calendar: {},
device: {},
navigation: {}
};
var _util_post = function (body, onFail) {
if (body == null) {
if (onFail && typeof onFail === "function") {
onFail("参数异常!");
return;
}
}
var message = JSON.stringify(body);
if (window.flutter_inappwebview && window.flutter_inappwebview.callHandler) {
window.flutter_inappwebview.callHandler('o2mUtil', message);
} else if (window.o2mUtil && window.o2mUtil.postMessage) {
window.o2mUtil.postMessage(message);
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mUtil) {
window.webkit.messageHandlers.o2mUtil.postMessage(message);
} else {
if (onFail && typeof onFail === "function") {
onFail("请在O2OA移动端使用!");
}
}
};
//o2m.util.date.datePicker
this.o2m.util.date.datePickerSuccess = function (result) {
console.log("util date datePicker back, result:" + result);
};
var _o2m_u_date_datePicker = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
var value = c && c.value ? c.value : "";
if (onSuccess && typeof onSuccess === "function") {
o2m.util.date.datePickerSuccess = onSuccess;
}
var body = {
type: "date.datePicker",
callback: "o2m.util.date.datePickerSuccess",
data: {
value: value
}
};
_util_post(body, onFail);
};
/**
* 日期选择器
* @method datePicker
* @memberOf o2m
* @o2membercategory util.date
* @static
* @param {Object} obj datePicker需要传入对象
* {
* value: '2019-04-17', //默认显示日期
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* value: '14:00', //默认显示时间
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* value: '2019-05-05 14:00', //默认显示时间
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* value: '2019-05-05', //默认显示日期
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* value: '2019-05-05 11:00', //默认显示时间
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* startDate: '2019-05-05',
* endDate: '2019-05-06',
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.util.device.getPhoneInfo({
* onSuccess : function(result) {
* {
* screenWidth: 1080, // 手机屏幕宽度
* screenHeight: 1920, // 手机屏幕高度
* brand:'Mi', // 手机品牌
* model:'Note4', // 手机型号
* version:'7.0'. // 版本
* netInfo:'wifi' , // 网络类型 wifi/4g/3g
* operatorType :'xx' // 运营商信息
* }
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.device.getPhoneInfo = _o2m_u_device_getPhoneInfo;
//o2m.util.device.rotate
this.o2m.util.device.rotateSuccess = function (result) {
console.log("util device rotate back, result:" + result);
};
var _o2m_u_device_rotate = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.device.rotateSuccess = onSuccess;
}
var body = {
type: "device.rotate",
callback: "o2m.util.device.rotateSuccess",
data: {
}
};
_util_post(body, onFail);
};
/**
* 旋转屏幕
* @method rotate
* @memberOf o2m
* @o2membercategory util.device
* @static
* @param {Object} obj rotate
* {
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.util.device.rotate({
* onSuccess : function(result) {
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.device.rotate = _o2m_u_device_rotate;
//o2m.util.device.scan
this.o2m.util.device.scanSuccess = function (result) {
console.log("util device scan back, result:" + result);
};
var _o2m_u_device_scan = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.device.scanSuccess = onSuccess;
}
var body = {
type: "device.scan",
callback: "o2m.util.device.scanSuccess",
data: {
}
};
_util_post(body, onFail);
};
/**
* 扫二维码
* @method scan
* @memberOf o2m
* @o2membercategory util.device
* @static
* @param {Object} obj scan需要传入对象
* {
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.util.device.scan({
* onSuccess : function(result) {
* // result返回结果就是扫码的结果
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.device.scan = _o2m_u_device_scan;
//o2m.util.device.location
this.o2m.util.device.locationSuccess = function (result) {
console.log("util device location back, result:" + result);
};
var _o2m_u_device_location = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.device.locationSuccess = onSuccess;
}
var body = {
type: "device.location",
callback: "o2m.util.device.locationSuccess",
data: {
}
};
_util_post(body, onFail);
};
/**
* 单次定位
* @method location
* @memberOf o2m
* @o2membercategory util.device
* @static
* @param {Object} obj location需要传入对象
* {
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.util.device.location({
* onSuccess : function(result) {
* //这里返回百度坐标系的定位信息
* {
* 'latitude': 39.903578, // 纬度
* 'longitude': 116.473565, // 经度
* 'address': '地址描述'
* }
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.device.location = _o2m_u_device_location;
//o2m.util.device.localAuth
this.o2m.util.device.localAuthSuccess = function (result) {
console.log("util device localAuth back, result:" + result);
};
/**
* 移动端生物识别认证
* @method localAuth
* @memberOf o2m
* @o2membercategory util.device
* @static
* @param {Object} obj localAuth 需要传入对象
* {
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.util.device.localAuth({
* onSuccess : function(result) {
* // result 是一个 json 字符串
* {
* "value": false // 是否授权成功
* }
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.device.localAuth = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.device.localAuthSuccess = onSuccess;
}
var body = {
type: "device.localAuth",
callback: "o2m.util.device.localAuthSuccess",
data: {}
};
_util_post(body, onFail);
};
//o2m.util.navigation.setTitle
this.o2m.util.navigation.setTitleSuccess = function (result) {
console.log("util calendar chooseInterval back, result:" + result);
};
var _o2m_u_navigation_setTitle = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
var title = c && c.title ? c.title : "";
if (onSuccess && typeof onSuccess === "function") {
o2m.util.navigation.setTitleSuccess = onSuccess;
}
var body = {
type: "navigation.setTitle",
callback: "o2m.util.navigation.setTitleSuccess",
data: {
title: title
}
};
_util_post(body, onFail);
};
/**
* 设置原生页面标题
* @method setTitle
* @memberOf o2m
* @o2membercategory util.navigation
* @static
* @param {Object} obj setTitle需要传入对象
* {
* title : '导航标题',
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.util.navigation.setTitle({
* title : '导航标题',
* onSuccess : function() {
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.navigation.setTitle = _o2m_u_navigation_setTitle;
//o2m.util.navigation.close
this.o2m.util.navigation.closeSuccess = function (result) {
console.log("util calendar chooseInterval back, result:" + result);
};
var _o2m_u_navigation_close = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.navigation.closeSuccess = onSuccess;
}
var body = {
type: "navigation.close",
callback: "o2m.util.navigation.closeSuccess",
data: {
}
};
_util_post(body, onFail);
};
/**
* 关闭当前原生页面
* @method close
* @memberOf o2m
* @o2membercategory util.navigation
* @static
* @example
* o2m.util.navigation.close();
*/
this.o2m.util.navigation.close = _o2m_u_navigation_close;
//o2m.util.navigation.goBack
this.o2m.util.navigation.goBackSuccess = function (result) {
console.log("util calendar chooseInterval back, result:" + result);
};
var _o2m_u_navigation_goBack = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.navigation.goBackSuccess = onSuccess;
}
var body = {
type: "navigation.goBack",
callback: "o2m.util.navigation.goBackSuccess",
data: {
}
};
_util_post(body, onFail);
};
/**
* 返回上级原生页面
* @method goBack
* @memberOf o2m
* @o2membercategory util.navigation
* @static
* @example
* o2m.util.navigation.goBack();
*/
this.o2m.util.navigation.goBack = _o2m_u_navigation_goBack;
//o2m.util.navigation.openInnerApp 内部应用打开 包含门户
this.o2m.util.navigation.openInnerAppSuccess = function (result) {
console.log("util navigation openInnerApp back, result:" + result);
};
var _o2m_u_navigation_openInnerApp = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.navigation.openInnerAppSuccess = onSuccess;
}
var appKey = c && c.appKey ? c.appKey : "";
var portalFlag = c && c.portalFlag ? c.portalFlag : "";
var portalTitle = c && c.portalTitle ? c.portalTitle : "";
var portalPage = c && c.portalPage ? c.portalPage : "";
var parameters = c && c.parameters ? c.parameters : {};
var body = {
type: "navigation.openInnerApp",
callback: "o2m.util.navigation.openInnerAppSuccess",
data: {
appKey: appKey,
portalFlag: portalFlag,
portalTitle: portalTitle,
portalPage: portalPage,
parameters: parameters
}
};
_util_post(body, onFail);
};
/**
* 打开内部应用
* @method openInnerApp
* @memberOf o2m
* @o2membercategory util.navigation
* @static
* @param {Object} obj openInnerApp需要传入对象
* {
* appKey : 'attendance', // 对应用的 key: task(待办)、taskcompleted(已办)、read(待阅)、readcompleted(已阅)、meeting(会议管理)、clouddisk(网盘)、bbs(论坛)、cms(信息中心)、attendance(考勤)、calendar(日程)、mindMap(脑图)、portal(门户,门户需要传入portalFlag和portalTitle)
* portalFlag : '门户标识',
* portalTitle : '门户标题',
* portalPage : '门户页面 id',
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.util.navigation.openInnerApp({
* appKey : 'attendance',
* onSuccess : function() {
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.navigation.openInnerApp = _o2m_u_navigation_openInnerApp;
//o2m.util.navigation.openOtherApp 功能不完整,有很多限制。暂时不开放
this.o2m.util.navigation.openOtherAppSuccess = function (result) {
console.log("util navigation openOtherApp back, result:" + result);
};
var _o2m_u_navigation_openOtherApp = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.navigation.openOtherAppSuccess = onSuccess;
}
var schema = c && c.schema ? c.schema : "";
var body = {
type: "navigation.openOtherApp",
callback: "o2m.util.navigation.openOtherAppSuccess",
data: {
schema: schema
}
};
_util_post(body, onFail);
};
this.o2m.util.navigation.openOtherApp = _o2m_u_navigation_openOtherApp;
//o2m.util.navigation.openWindow 新窗口打开网页 门户
this.o2m.util.navigation.openWindowSuccess = function (result) {
console.log("util navigation openWindow back, result:" + result);
};
var _o2m_u_navigation_openWindow = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.navigation.openWindowSuccess = onSuccess;
}
var url = c && c.url ? c.url : "";
var body = {
type: "navigation.openWindow",
callback: "o2m.util.navigation.openWindowSuccess",
data: {
url: url
}
};
_util_post(body, onFail);
};
/**
* 新窗口打开网页
* @method openWindow
* @memberOf o2m
* @o2membercategory util.navigation
* @static
* @param {Object} obj openWindow需要传入对象
* {
* url : 'https://www.o2oa.net', // 打开的网址
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* o2m.util.navigation.openWindow({
* url : 'https://www.o2oa.net',
* onSuccess : function() {
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.navigation.openWindow = _o2m_u_navigation_openWindow;
//o2m.util.navigation.openInBrowser 手机默认浏览器打开当前页面
this.o2m.util.navigation.openInBrowserSuccess = function (result) {
console.log("util navigation openInBrowser back, result:" + result);
};
var _o2m_u_navigation_openInBrowser = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.navigation.openInBrowserSuccess = onSuccess;
}
var body = {
type: "navigation.openInBrowser",
callback: "o2m.util.navigation.openInBrowserSuccess",
data: {}
};
_util_post(body, onFail);
};
/**
* 手机默认浏览器打开当前页面
* @method openInBrowser
* @memberOf o2m
* @o2membercategory util.navigation
* @static
* @example
* o2m.util.navigation.openInBrowser({
* onSuccess : function() {
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.navigation.openInBrowser = _o2m_u_navigation_openInBrowser;
//o2m.util.navigation.clearCache 清理缓存并刷新页面
this.o2m.util.navigation.clearCacheSuccess = function (result) {
console.log("util navigation clearCache back, result:" + result);
};
var _o2m_u_navigation_clearCache = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.util.navigation.clearCacheSuccess = onSuccess;
}
var body = {
type: "navigation.clearCache",
callback: "o2m.util.navigation.clearCacheSuccess",
data: {}
};
_util_post(body, onFail);
};
/**
* 清理缓存并刷新页面
* @method clearCache
* @memberOf o2m
* @o2membercategory util.navigation
* @static
* @example
* o2m.util.navigation.clearCache({
* onSuccess : function() {
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.navigation.clearCache = _o2m_u_navigation_clearCache;
//o2m.util.navigation.share 分享图片
this.o2m.util.navigation.shareSuccess = function (result) {
console.log("util navigation share back, result:" + result);
};
var _o2m_u_navigation_share = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
var base64 = c && c.base64 ? c.base64 : "";
if (onSuccess && typeof onSuccess === "function") {
o2m.util.navigation.shareSuccess = onSuccess;
}
var body = {
type: "navigation.share",
callback: "o2m.util.navigation.shareSuccess",
data: {
base64: base64
}
};
_util_post(body, onFail);
};
/**
* 分享图片功能,目前只支持 base64 进行分享
* @method share
* @memberOf o2m
* @o2membercategory util.navigation
* @static
* @example
* o2m.util.navigation.share({
* base64: '图片的 base64 编码';
* onSuccess : function() {
* },
* onFail : function(err) {}
*});
*/
this.o2m.util.navigation.share = _o2m_u_navigation_share;
/** ***** BEGIN BIZ BLOCK *****
* @ignore
* @summary
biz 模块
contact
o2m.biz.contact.PersonPicker
o2m.biz.contact.IdentityPicker
o2m.biz.contact.departmentsPicker
o2m.biz.contact.ComplexPicker
o2m.biz.contact.GroupPicker
o2m.biz.file.previewDoc
* ***** END UTIL BLOCK ******/
this.o2m.biz = {
contact: {},
file:{}
};
var _biz_post = function (body, onFail) {
if (body == null) {
if (onFail && typeof onFail === "function") {
onFail("参数异常!");
return;
}
}
var message = JSON.stringify(body);
if (window.flutter_inappwebview && window.flutter_inappwebview.callHandler) {
window.flutter_inappwebview.callHandler('o2mBiz', message);
} else if (window.o2mBiz && window.o2mBiz.postMessage) {
window.o2mBiz.postMessage(message)
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mBiz) {
window.webkit.messageHandlers.o2mBiz.postMessage(message);
} else {
if (onFail && typeof onFail === "function") {
onFail("请在O2OA移动端使用!");
}
}
};
//o2m.biz.workClose()
var _o2m_b_work_close = function () {
if (window.o2android && window.o2android.closeWork) {
window.o2android.closeWork("");
} else if (window.o2android && window.o2android.postMessage) {
var body = {
type: "closeWork"
};
window.o2android.postMessage(JSON.stringify(body));
} else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.closeWork) {
window.webkit.messageHandlers.closeWork.postMessage("");
} else {
console.log("请在O2OA移动端使用, workClose");
}
}
/**
* 关闭当前工作页面,只能在工作表单中可以使用
* @method workClose
* @memberOf o2m
* @o2membercategory biz
* @static
* @example
* o2m.biz.workClose();
*/
this.o2m.biz.workClose = _o2m_b_work_close;
//o2m.biz.contact.departmentsPicker
this.o2m.biz.contact.departmentsPickerSuccess = function (result) {
console.log("biz contact departmentsPicker back, result:" + result);
};
var _o2m_b_contact_department_picker = function (c) {
var onSuccess = c && c.onSuccess ? c.onSuccess : null;
var onFail = c && c.onFail ? c.onFail : null;
if (onSuccess && typeof onSuccess === "function") {
o2m.biz.contact.departmentsPickerSuccess = onSuccess;
}
var topList = c && c.topList ? c.topList : [];
var orgType = c && c.orgType ? c.orgType : "";
var multiple = c && c.multiple ? c.multiple : false;
var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
var pickedDepartments = c && c.pickedDepartments ? c.pickedDepartments : [];
var body = {
type: "contact.departmentPicker",
callback: "o2m.biz.contact.departmentsPickerSuccess",
data: {
topList: topList,
orgType: orgType,
multiple: multiple,
maxNumber: maxNumber,
pickedDepartments: pickedDepartments,
}
};
_biz_post(body, onFail);
};
/**
* 通讯录选部门
* @method departmentsPicker
* @memberOf o2m
* @o2membercategory biz
* @static
* @param {Object} obj departmentsPicker需要传入对象
* {
* topList: [],//Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
* orgType: "",//String 可选择的组织类别。为空就是全部组织类型都可以
* multiple:true, //是否多选
* maxNumber: 0, //Int 当multiple为true的时候,最多可选择的部门数
* pickedDepartments:[],//Array[String] 已经选择的部门distinguishedName列表
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* topList: [],//Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
* multiple:true, //Boolean 是否多选
* maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
* pickedIdentities:[],//Array[String] 已经选择的身份distinguishedName列表
* duty: [],//Array[String] 可选择的人员职责
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* multiple:true, //Boolean 是否多选
* maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
* pickedGroups:[],//Array[String] 已经选择的群组distinguishedName列表
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* multiple:true, //Boolean 是否多选
* maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
* pickedUsers:[],//Array[String] 已经选择的人员distinguishedName列表
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
* {
* pickMode: ["departmentPicker", "identityPicker"], //Array[String] 选择器类型,可传入值:departmentPicker、identityPicker、groupPicker、personPicker
* topList:Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
* duty: Array[String] 可选择的人员职责
* orgType:String 可选择的组织类别。为空就是全部组织类型都可以
* multiple:true, //Boolean 是否多选
* maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
* pickedDepartments:Array[String] 已经选择的部门distinguishedName列表
* pickedIdentities:Array[String] 已经选择的身份distinguishedName列表
* pickedGroups: Array[String] 已经选择的群组distinguishedName列表
* pickedUsers:[],//Array[String] 已经选择的人员distinguishedName列表
* "onSuccess": function, //成功回调
* "onFail": function, //失败回调
* }
* @example
*