o2m.api.js 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968
  1. /** ***** BEGIN LICENSE BLOCK *****
  2. * |------------------------------------------------------------------------------|
  3. * | O2OA 活力办公 创意无限 o2m.api.js |
  4. * |------------------------------------------------------------------------------|
  5. * | Distributed under the AGPL license: |
  6. * |------------------------------------------------------------------------------|
  7. * | Copyright © 2018, o2oa.net, o2server.io O2 Team |
  8. * | All rights reserved. |
  9. * |------------------------------------------------------------------------------|
  10. *
  11. * This file is part of O2OA.
  12. *
  13. * O2OA is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License as published by
  15. * the Free Software Foundation, either version 3 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * O2OA is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
  25. *
  26. * ***** END LICENSE BLOCK ******/
  27. /**
  28. * @summary
  29. * <b>o2m</b> 是O2OA移动端APP提供的调用原生控件的能力,帮助开发者高效使用拍照、定位等手机系统的能力,同时可以直接使用扫一扫、打开原生应用、选择时间,人员,组织等业务的能力,带给门户接近原生代码的体验
  30. * <br/>
  31. * <b>o2m</b> 只有在O2OA移动端APP中才能提供能力
  32. * @namespace o2m
  33. * @o2cn 平台移动APP API
  34. * @o2category mobile
  35. * @o2ordernumber 13
  36. * @o2range {流程表单|门户}
  37. * @o2syntax
  38. * // 可以在移动端 流程表单、门户 上使用
  39. * window.o2m
  40. *
  41. */
  42. (function () {
  43. this.o2m = {
  44. version: {
  45. v: "1.1.0",
  46. build: "2021.01.20",
  47. info: "O2OA 活力办公 创意无限. Copyright © 2021, o2oa.net O2 Team All rights reserved."
  48. },
  49. log: function (message) {
  50. window.o2android && window.o2android.o2mLog ? window.o2android.o2mLog(message) : window.webkit.messageHandlers.o2mLog.postMessage(message);
  51. }
  52. };
  53. /** ***** BEGIN NOTIFICATION BLOCK *****
  54. @ignore
  55. @summary notification 模块
  56. alert
  57. confirm
  58. prompt
  59. vibrate
  60. toast
  61. actionSheet
  62. showLoading
  63. hideLoading
  64. * ***** END NOTIFICATION BLOCK ******/
  65. this.o2m.notification = {};
  66. var _notification_post = function (body, onFail) {
  67. if (body == null) {
  68. if (onFail && typeof onFail === "function") {
  69. onFail("参数异常!");
  70. return
  71. }
  72. }
  73. var message = JSON.stringify(body);
  74. if (window.flutter_inappwebview && window.flutter_inappwebview.callHandler) {
  75. window.flutter_inappwebview.callHandler('o2mNotification', message);
  76. } else if (window.o2mNotification && window.o2mNotification.postMessage) {
  77. window.o2mNotification.postMessage(message);
  78. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mNotification) {
  79. window.webkit.messageHandlers.o2mNotification.postMessage(message);
  80. } else {
  81. if (onFail && typeof onFail === "function") {
  82. onFail("请在O2OA移动端使用!");
  83. return
  84. }
  85. }
  86. };
  87. this.o2m.notification.alertSuccess = function () {
  88. console.log("notification alert back");
  89. };
  90. var _o2m_n_alert = function (alert) {
  91. var message = alert && alert.message ? alert.message : "";
  92. var title = alert && alert.title ? alert.title : "";
  93. var buttonName = alert && alert.buttonName ? alert.buttonName : "";
  94. var onSuccess = alert && alert.onSuccess ? alert.onSuccess : null;
  95. var onFail = alert && alert.onFail ? alert.onFail : null;
  96. if (message === "") {
  97. if (typeof onFail === "function") { onFail("消息内容不能为空!"); }
  98. return;
  99. }
  100. if (onSuccess && typeof onSuccess === "function") {
  101. o2m.notification.alertSuccess = onSuccess;
  102. }
  103. var body = {
  104. type: "alert",
  105. callback: "o2m.notification.alertSuccess",
  106. data: {
  107. message: message,
  108. title: title,
  109. buttonName: buttonName,
  110. }
  111. };
  112. _notification_post(body, onFail);
  113. };
  114. /**
  115. * 原生Alert提示弹出窗
  116. * @method alert
  117. * @memberOf o2m
  118. * @o2membercategory notification
  119. * @static
  120. * @param {Object} obj 提示窗传入对象
  121. * <pre><code class='language-js'>{
  122. * "title": "提示", //消息标题,可为空
  123. * "message": "这里是消息内容", //消息内容
  124. * "buttonName": "确定", //确定按钮名称
  125. * "onSuccess": function, //成功回调
  126. * "onFail": function, //失败回调
  127. * }</code></pre>
  128. * @example
  129. * <caption>
  130. * 样例效果:<br/>
  131. * <img src="img/module/o2m/notification_alert.jpeg">
  132. * </caption>
  133. * o2m.notification.alert({
  134. * message: "亲爱的",
  135. * title: "提示",//可传空
  136. * buttonName: "收到",
  137. * onSuccess : function() {//onSuccess将在点击button之后回调},
  138. * onFail : function(err) {}
  139. * });
  140. *
  141. */
  142. this.o2m.notification.alert = _o2m_n_alert;
  143. //notification.confirm
  144. this.o2m.notification.confirmSuccess = function (index) {
  145. console.log("notification confirm back, click button index: " + index);
  146. };
  147. var _o2m_n_confirm = function (c) {
  148. var buttonLabels = c && c.buttonLabels ? c.buttonLabels : ["确定", "取消"];
  149. var message = c && c.message ? c.message : "";
  150. var title = c && c.title ? c.title : "";
  151. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  152. var onFail = c && c.onFail ? c.onFail : null;
  153. if (message === "") {
  154. if (typeof onFail === "function") { onFail("消息内容message不能为空!"); }
  155. return;
  156. }
  157. if (buttonLabels.length != 2) {
  158. if (typeof onFail === "function") { onFail("按钮名称数组长度只能是2!"); }
  159. return;
  160. }
  161. if (onSuccess && typeof onSuccess === "function") {
  162. o2m.notification.confirmSuccess = onSuccess;
  163. }
  164. var body = {
  165. type: "confirm",
  166. callback: "o2m.notification.confirmSuccess",
  167. data: {
  168. message: message,
  169. title: title,
  170. buttonLabels: buttonLabels,
  171. }
  172. };
  173. _notification_post(body, onFail);
  174. }
  175. /**
  176. * 原生confirm提示弹出窗
  177. * @method confirm
  178. * @memberOf o2m
  179. * @o2membercategory notification
  180. * @static
  181. * @param {Object} obj 提示窗传入对象
  182. * <pre><code class='language-js'>{
  183. * "title": "提示", //消息标题,可为空
  184. * "message": "这里是消息内容", //消息内容
  185. * "buttonLabels": ["确定", "取消"], //按钮名称 Array[String]
  186. * "onSuccess": function, //成功回调
  187. * "onFail": function, //失败回调
  188. * }</code></pre>
  189. * @example
  190. * <caption>
  191. * 样例效果:<br/>
  192. * <img src="img/module/o2m/notification_confirm.jpeg">
  193. * </caption>
  194. * o2m.notification.confirm({
  195. * message: "你爱我吗",
  196. * title: "提示",//可传空
  197. * buttonLabels: ['爱', '不爱'],
  198. * onSuccess : function(buttonIndex) {
  199. * //onSuccess将在点击button之后回调
  200. * //buttonIndex: 0 被点击按钮的索引值,Number类型,从0开始
  201. * },
  202. * onFail : function(err) {}
  203. * });
  204. *
  205. */
  206. this.o2m.notification.confirm = _o2m_n_confirm;
  207. //notification.prompt
  208. this.o2m.notification.promptSuccess = function (result) {
  209. console.log("notification prompt back, click button result: " + result);
  210. };
  211. var _o2m_n_prompt = function (c) {
  212. var buttonLabels = c && c.buttonLabels ? c.buttonLabels : ["确定", "取消"];
  213. var message = c && c.message ? c.message : "";
  214. var title = c && c.title ? c.title : "";
  215. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  216. var onFail = c && c.onFail ? c.onFail : null;
  217. if (message === "") {
  218. if (typeof onFail === "function") { onFail("消息内容message不能为空!"); }
  219. return;
  220. }
  221. if (buttonLabels.length != 2) {
  222. if (typeof onFail === "function") { onFail("按钮名称数组长度只能是2!"); }
  223. return;
  224. }
  225. if (onSuccess && typeof onSuccess === "function") {
  226. o2m.notification.promptSuccess = onSuccess;
  227. }
  228. var body = {
  229. type: "prompt",
  230. callback: "o2m.notification.promptSuccess",
  231. data: {
  232. message: message,
  233. title: title,
  234. buttonLabels: buttonLabels,
  235. }
  236. };
  237. _notification_post(body, onFail);
  238. }
  239. /**
  240. * 原生prompt提示弹出窗
  241. * @method prompt
  242. * @memberOf o2m
  243. * @o2membercategory notification
  244. * @static
  245. * @param {Object} obj prompt需要传入对象
  246. * <pre><code class='language-js'>{
  247. * "title": "提示", //消息标题,可为空
  248. * "message": "这里是消息内容", //消息内容
  249. * "buttonLabels": ['继续', '不玩了'], //按钮名称 Array[String]
  250. * "onSuccess": function, //成功回调
  251. * "onFail": function, //失败回调
  252. * }</code></pre>
  253. * @example
  254. * <caption>
  255. * 样例效果:<br/>
  256. * <img src="img/module/o2m/notification_prompt.jpeg">
  257. * </caption>
  258. * o2m.notification.prompt({
  259. * message: "再说一遍?",
  260. * title: "提示",//可传空
  261. * buttonLabels: ['继续', '不玩了'],
  262. * onSuccess : function(result) {
  263. * //result是一个字符串,格式是json格式,内容如下:
  264. * //{
  265. * // buttonIndex: 0, //被点击按钮的索引值,Number类型,从0开始
  266. * // value: '' //输入的值
  267. * //}
  268. * },
  269. * onFail : function(err) {}
  270. * });
  271. *
  272. */
  273. this.o2m.notification.prompt = _o2m_n_prompt;
  274. //notification.vibrate
  275. this.o2m.notification.vibrateSuccess = function () {
  276. console.log("notification vibrate back, click button");
  277. };
  278. var _o2m_n_vibrate = function (c) {
  279. var duration = c && c.duration ? c.duration : 300;
  280. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  281. var onFail = c && c.onFail ? c.onFail : null;
  282. if (onSuccess && typeof onSuccess === "function") {
  283. o2m.notification.vibrateSuccess = onSuccess;
  284. }
  285. var body = {
  286. type: "vibrate",
  287. callback: "o2m.notification.vibrateSuccess",
  288. data: {
  289. duration: duration
  290. }
  291. };
  292. _notification_post(body, onFail);
  293. };
  294. /**
  295. * 手机震动
  296. * @method vibrate
  297. * @memberOf o2m
  298. * @o2membercategory notification
  299. * @static
  300. * @param {Object} obj 震动需要传入对象
  301. * <pre><code class='language-js'>{
  302. * "duration": 300, //震动时间,android可配置 iOS忽略
  303. * "onSuccess": function, //成功回调
  304. * "onFail": function, //失败回调
  305. * }</code></pre>
  306. * @example
  307. * o2m.notification.vibrate({
  308. * duration: 300,
  309. * onSuccess : function() {
  310. * },
  311. * onFail : function(err) {}
  312. * });
  313. *
  314. */
  315. this.o2m.notification.vibrate = _o2m_n_vibrate;
  316. //notification.toast
  317. this.o2m.notification.toastSuccess = function () {
  318. console.log("notification toast back, click button");
  319. };
  320. var _o2m_n_toast = function (c) {
  321. var duration = c && c.duration ? c.duration : 300;
  322. var message = c && c.message ? c.message : "";
  323. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  324. var onFail = c && c.onFail ? c.onFail : null;
  325. if (message === "") {
  326. if (typeof onFail === "function") { onFail("消息内容message不能为空!"); }
  327. return;
  328. }
  329. if (onSuccess && typeof onSuccess === "function") {
  330. o2m.notification.toastSuccess = onSuccess;
  331. }
  332. var body = {
  333. type: "toast",
  334. callback: "o2m.notification.toastSuccess",
  335. data: {
  336. duration: duration,
  337. message: message
  338. }
  339. };
  340. _notification_post(body, onFail);
  341. };
  342. /**
  343. * toast提示
  344. * @method toast
  345. * @memberOf o2m
  346. * @o2membercategory notification
  347. * @static
  348. * @param {Object} obj toast需要传入对象
  349. * <pre><code class='language-js'>{
  350. * "message": "这里是提示信息",
  351. * "onSuccess": function, //成功回调
  352. * "onFail": function, //失败回调
  353. * }</code></pre>
  354. * @example
  355. * o2m.notification.toast({
  356. * message: "提示消息内容",
  357. * onSuccess : function() {
  358. * },
  359. * onFail : function(err) {}
  360. * });
  361. *
  362. */
  363. this.o2m.notification.toast = _o2m_n_toast;
  364. //notification.actionSheet
  365. this.o2m.notification.actionSheetSuccess = function (buttonIndex) {
  366. console.log("notification actionSheet back, click button:" + buttonIndex);
  367. };
  368. var _o2m_n_actionSheet = function (c) {
  369. var title = c && c.title ? c.title : "";
  370. var cancelButton = c && c.cancelButton ? c.cancelButton : "取消";
  371. var otherButtons = c && c.otherButtons ? c.otherButtons : [];
  372. var tooManyButtons = c && c.tooManyButtons ? c.tooManyButtons : false;
  373. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  374. var onFail = c && c.onFail ? c.onFail : null;
  375. if (otherButtons.length < 1) {
  376. if (typeof onFail === "function") { onFail("其他按钮列表不能为空!"); }
  377. return;
  378. }
  379. if (onSuccess && typeof onSuccess === "function") {
  380. o2m.notification.actionSheetSuccess = onSuccess;
  381. }
  382. var body = {
  383. type: "actionSheet",
  384. callback: "o2m.notification.actionSheetSuccess",
  385. data: {
  386. title: title,
  387. cancelButton: cancelButton,
  388. otherButtons: otherButtons,
  389. tooManyButtons: tooManyButtons
  390. }
  391. };
  392. _notification_post(body, onFail);
  393. };
  394. /**
  395. * 底部弹出菜单
  396. * @method actionSheet
  397. * @memberOf o2m
  398. * @o2membercategory notification
  399. * @static
  400. * @param {Object} obj actionSheet需要传入对象
  401. * <pre><code class='language-js'>{
  402. * "title": "谁是最棒哒?",//标题
  403. * "cancelButton": '取消', //取消按钮文本
  404. * "otherButtons": ["孙悟空","猪八戒","唐僧","沙和尚"], //其他选项按钮名称
  405. * "onSuccess": function, //成功回调
  406. * "onFail": function, //失败回调
  407. * }</code></pre>
  408. * @example
  409. * <caption>
  410. * 样例效果:<br/>
  411. * <img src="img/module/o2m/notification_action_sheet.jpeg">
  412. * </caption>
  413. * o2m.notification.actionSheet({
  414. * title: "谁是最棒哒?", //标题
  415. * cancelButton: '取消', //取消按钮文本
  416. * otherButtons: ["孙悟空","猪八戒","唐僧","沙和尚"],
  417. * onSuccess : function(buttonIndex) {
  418. * //buttonIndex: 0 被点击按钮的索引值,Number,从0开始, 取消按钮为-1
  419. * },
  420. * onFail : function(err) {}
  421. * });
  422. *
  423. */
  424. this.o2m.notification.actionSheet = _o2m_n_actionSheet;
  425. //notification.showLoading
  426. this.o2m.notification.showLoadingSuccess = function () {
  427. console.log("notification showLoading back");
  428. };
  429. var _o2m_n_showLoading = function (c) {
  430. var text = c && c.text ? c.text : "";
  431. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  432. var onFail = c && c.onFail ? c.onFail : null;
  433. if (onSuccess && typeof onSuccess === "function") {
  434. o2m.notification.showLoadingSuccess = onSuccess;
  435. }
  436. var body = {
  437. type: "showLoading",
  438. callback: "o2m.notification.showLoadingSuccess",
  439. data: {
  440. text: text
  441. }
  442. };
  443. _notification_post(body, onFail);
  444. };
  445. /**
  446. * 显示Loading浮层,请和hideLoading配合使用
  447. * @method showLoading
  448. * @memberOf o2m
  449. * @o2membercategory notification
  450. * @static
  451. * @param {Object} obj showLoading需要传入对象
  452. * <pre><code class='language-js'>{
  453. * text: "使劲加载中..", //loading显示的字符,空表示不显示文字
  454. * "onSuccess": function, //成功回调
  455. * "onFail": function, //失败回调
  456. * }</code></pre>
  457. * @example
  458. * <caption>
  459. * 样例效果:<br/>
  460. * <img src="img/module/o2m/notification_showLoading.jpeg">
  461. * </caption>
  462. * o2m.notification.showLoading({
  463. * text: "使劲加载中..", //loading显示的字符,空表示不显示文字
  464. * onSuccess : function() {
  465. * },
  466. * onFail : function(err) {}
  467. * });
  468. *
  469. */
  470. this.o2m.notification.showLoading = _o2m_n_showLoading;
  471. //notification.hideLoading
  472. this.o2m.notification.hideLoadingSuccess = function () {
  473. console.log("notification hideLoading back");
  474. };
  475. var _o2m_n_hideLoading = function (c) {
  476. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  477. var onFail = c && c.onFail ? c.onFail : null;
  478. if (onSuccess && typeof onSuccess === "function") {
  479. o2m.notification.hideLoadingSuccess = onSuccess;
  480. }
  481. var body = {
  482. type: "hideLoading",
  483. callback: "o2m.notification.hideLoadingSuccess",
  484. data: {
  485. }
  486. };
  487. _notification_post(body, onFail);
  488. }
  489. /**
  490. * 隐藏Loading浮层
  491. * @method hideLoading
  492. * @memberOf o2m
  493. * @o2membercategory notification
  494. * @static
  495. * @param {Object} obj hideLoading需要传入对象
  496. * <pre><code class='language-js'>{
  497. * "onSuccess": function, //成功回调
  498. * "onFail": function, //失败回调
  499. * }</code></pre>
  500. * @example
  501. * o2m.notification.hideLoading({
  502. * onSuccess : function() {
  503. * },
  504. * onFail : function(err) {}
  505. * });
  506. *
  507. */
  508. this.o2m.notification.hideLoading = _o2m_n_hideLoading;
  509. /** ***** BEGIN UTIL BLOCK *****
  510. * @ignore
  511. * @summary
  512. util 模块
  513. date
  514. o2m.util.date.datePicker
  515. o2m.util.date.timePicker
  516. o2m.util.date.dateTimePicker
  517. calendar
  518. o2m.util.calendar.chooseOneDay
  519. o2m.util.calendar.chooseDateTime
  520. o2m.util.calendar.chooseInterval
  521. device
  522. o2m.util.device.getPhoneInfo
  523. o2m.util.device.scan
  524. o2m.util.deveice.location
  525. navigation
  526. o2m.util.navigation.setTitle
  527. o2m.util.navigation.close
  528. o2m.util.navigation.goBack
  529. o2m.util.navigation.openInnerApp
  530. o2m.util.navigation.openOtherApp
  531. o2m.util.navigation.openWindow
  532. o2m.util.navigation.share
  533. * ***** END UTIL BLOCK ******/
  534. this.o2m.util = {
  535. date: {},
  536. calendar: {},
  537. device: {},
  538. navigation: {}
  539. };
  540. var _util_post = function (body, onFail) {
  541. if (body == null) {
  542. if (onFail && typeof onFail === "function") {
  543. onFail("参数异常!");
  544. return;
  545. }
  546. }
  547. var message = JSON.stringify(body);
  548. if (window.flutter_inappwebview && window.flutter_inappwebview.callHandler) {
  549. window.flutter_inappwebview.callHandler('o2mUtil', message);
  550. } else if (window.o2mUtil && window.o2mUtil.postMessage) {
  551. window.o2mUtil.postMessage(message);
  552. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mUtil) {
  553. window.webkit.messageHandlers.o2mUtil.postMessage(message);
  554. } else {
  555. if (onFail && typeof onFail === "function") {
  556. onFail("请在O2OA移动端使用!");
  557. }
  558. }
  559. };
  560. //o2m.util.date.datePicker
  561. this.o2m.util.date.datePickerSuccess = function (result) {
  562. console.log("util date datePicker back, result:" + result);
  563. };
  564. var _o2m_u_date_datePicker = function (c) {
  565. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  566. var onFail = c && c.onFail ? c.onFail : null;
  567. var value = c && c.value ? c.value : "";
  568. if (onSuccess && typeof onSuccess === "function") {
  569. o2m.util.date.datePickerSuccess = onSuccess;
  570. }
  571. var body = {
  572. type: "date.datePicker",
  573. callback: "o2m.util.date.datePickerSuccess",
  574. data: {
  575. value: value
  576. }
  577. };
  578. _util_post(body, onFail);
  579. };
  580. /**
  581. * 日期选择器
  582. * @method datePicker
  583. * @memberOf o2m
  584. * @o2membercategory util.date
  585. * @static
  586. * @param {Object} obj datePicker需要传入对象
  587. * <pre><code class='language-js'>{
  588. * value: '2019-04-17', //默认显示日期
  589. * "onSuccess": function, //成功回调
  590. * "onFail": function, //失败回调
  591. * }</code></pre>
  592. * @example
  593. * <caption>
  594. * 样例效果:<br/>
  595. * <img src="img/module/o2m/util_date_picker.jpeg">
  596. * </caption>
  597. * o2m.util.date.datePicker({
  598. * value: '2019-04-17', //默认显示日期
  599. * onSuccess : function(result) {
  600. * //onSuccess将在点击完成之后回调
  601. * {
  602. * value: "2019-02-10"
  603. * }
  604. * },
  605. * onFail : function(err) {}
  606. *});
  607. */
  608. this.o2m.util.date.datePicker = _o2m_u_date_datePicker;
  609. //o2m.util.date.timePicker
  610. this.o2m.util.date.timePickerSuccess = function (result) {
  611. console.log("util date timePicker back, result:" + result);
  612. };
  613. var _o2m_u_date_timePicker = function (c) {
  614. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  615. var onFail = c && c.onFail ? c.onFail : null;
  616. var value = c && c.value ? c.value : "";
  617. if (onSuccess && typeof onSuccess === "function") {
  618. o2m.util.date.timePickerSuccess = onSuccess;
  619. }
  620. var body = {
  621. type: "date.timePicker",
  622. callback: "o2m.util.date.timePickerSuccess",
  623. data: {
  624. value: value
  625. }
  626. };
  627. _util_post(body, onFail);
  628. };
  629. /**
  630. * 时间选择器
  631. * @method timePicker
  632. * @memberOf o2m
  633. * @o2membercategory util.date
  634. * @static
  635. * @param {Object} obj timePicker需要传入对象
  636. * <pre><code class='language-js'>{
  637. * value: '14:00', //默认显示时间
  638. * "onSuccess": function, //成功回调
  639. * "onFail": function, //失败回调
  640. * }</code></pre>
  641. * @example
  642. * <caption>
  643. * 样例效果:<br/>
  644. * <img src="img/module/o2m/util_time_picker.jpeg">
  645. * </caption>
  646. * o2m.util.date.timePicker({
  647. * value: '14:00', //默认显示时间
  648. * onSuccess : function(result) {
  649. * //onSuccess将在点击完成之后回调
  650. * {
  651. * value: "18:10"
  652. * }
  653. * },
  654. * onFail : function(err) {}
  655. *});
  656. */
  657. this.o2m.util.date.timePicker = _o2m_u_date_timePicker;
  658. //o2m.util.date.dateTimePicker
  659. this.o2m.util.date.dateTimePickerSuccess = function (result) {
  660. console.log("util date dateTimePicker back, result:" + result);
  661. };
  662. var _o2m_u_date_dateTimePicker = function (c) {
  663. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  664. var onFail = c && c.onFail ? c.onFail : null;
  665. var value = c && c.value ? c.value : "";
  666. if (onSuccess && typeof onSuccess === "function") {
  667. o2m.util.date.dateTimePickerSuccess = onSuccess;
  668. }
  669. var body = {
  670. type: "date.dateTimePicker",
  671. callback: "o2m.util.date.dateTimePickerSuccess",
  672. data: {
  673. value: value
  674. }
  675. };
  676. _util_post(body, onFail);
  677. };
  678. /**
  679. * 日期时间选择器
  680. * @method dateTimePicker
  681. * @memberOf o2m
  682. * @o2membercategory util.date
  683. * @static
  684. * @param {Object} obj dateTimePicker需要传入对象
  685. * <pre><code class='language-js'>{
  686. * value: '2019-05-05 14:00', //默认显示时间
  687. * "onSuccess": function, //成功回调
  688. * "onFail": function, //失败回调
  689. * }</code></pre>
  690. * @example
  691. * <caption>
  692. * 样例效果:<br/>
  693. * <img src="img/module/o2m/util_date_time_picker.jpeg">
  694. * </caption>
  695. * o2m.util.date.dateTimePicker({
  696. * value: '2019-05-05 14:00', //默认显示时间
  697. * onSuccess : function(result) {
  698. * //onSuccess将在点击完成之后回调
  699. * {
  700. * value: "2019-03-18 18:10"
  701. * }
  702. * },
  703. * onFail : function(err) {}
  704. *});
  705. */
  706. this.o2m.util.date.dateTimePicker = _o2m_u_date_dateTimePicker;
  707. //o2m.util.calendar.chooseOneDay
  708. this.o2m.util.calendar.chooseOneDaySuccess = function (result) {
  709. console.log("util calendar chooseOneDay back, result:" + result);
  710. };
  711. var _o2m_u_calendar_chooseOneDay = function (c) {
  712. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  713. var onFail = c && c.onFail ? c.onFail : null;
  714. var value = c && c.value ? c.value : "";
  715. if (onSuccess && typeof onSuccess === "function") {
  716. o2m.util.calendar.chooseOneDaySuccess = onSuccess;
  717. }
  718. var body = {
  719. type: "calendar.chooseOneDay",
  720. callback: "o2m.util.calendar.chooseOneDaySuccess",
  721. data: {
  722. value: value
  723. }
  724. };
  725. _util_post(body, onFail);
  726. };
  727. /**
  728. * 月历日期选择器
  729. * @method chooseOneDay
  730. * @memberOf o2m
  731. * @o2membercategory util.calendar
  732. * @static
  733. * @param {Object} obj chooseOneDay需要传入对象
  734. * <pre><code class='language-js'>{
  735. * value: '2019-05-05', //默认显示日期
  736. * "onSuccess": function, //成功回调
  737. * "onFail": function, //失败回调
  738. * }</code></pre>
  739. * @example
  740. * <caption>
  741. * 样例效果:<br/>
  742. * <img src="img/module/o2m/util_choose_one_day.jpeg">
  743. * </caption>
  744. * o2m.util.calendar.chooseOneDay({
  745. * value: '2019-05-05', //默认显示日期
  746. * onSuccess : function(result) {
  747. * //onSuccess将在点击完成之后回调
  748. * {
  749. * value: "2019-03-18"
  750. * }
  751. * },
  752. * onFail : function(err) {}
  753. *});
  754. */
  755. this.o2m.util.calendar.chooseOneDay = _o2m_u_calendar_chooseOneDay;
  756. //o2m.util.calendar.chooseDateTime
  757. this.o2m.util.calendar.chooseDateTimeSuccess = function (result) {
  758. console.log("util calendar chooseDateTime back, result:" + result);
  759. };
  760. var _o2m_u_calendar_chooseDateTime = function (c) {
  761. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  762. var onFail = c && c.onFail ? c.onFail : null;
  763. var value = c && c.value ? c.value : "";
  764. if (onSuccess && typeof onSuccess === "function") {
  765. o2m.util.calendar.chooseDateTimeSuccess = onSuccess;
  766. }
  767. var body = {
  768. type: "calendar.chooseDateTime",
  769. callback: "o2m.util.calendar.chooseDateTimeSuccess",
  770. data: {
  771. value: value
  772. }
  773. };
  774. _util_post(body, onFail);
  775. };
  776. /**
  777. * 月历日期时间选择器
  778. * @method chooseDateTime
  779. * @memberOf o2m
  780. * @o2membercategory util.calendar
  781. * @static
  782. * @param {Object} obj chooseDateTime需要传入对象
  783. * <pre><code class='language-js'>{
  784. * value: '2019-05-05 11:00', //默认显示时间
  785. * "onSuccess": function, //成功回调
  786. * "onFail": function, //失败回调
  787. * }</code></pre>
  788. * @example
  789. * <caption>
  790. * 样例效果:<br/>
  791. * <img src="img/module/o2m/util_choose_date_time.jpeg">
  792. * </caption>
  793. * o2m.util.calendar.chooseDateTime({
  794. * value: '2019-05-05 11:00', //默认显示时间
  795. * onSuccess : function(result) {
  796. * //onSuccess将在点击完成之后回调
  797. * {
  798. * value: "2019-03-18 18:45"
  799. * }
  800. * },
  801. * onFail : function(err) {}
  802. *});
  803. */
  804. this.o2m.util.calendar.chooseDateTime = _o2m_u_calendar_chooseDateTime;
  805. //o2m.util.calendar.chooseInterval
  806. this.o2m.util.calendar.chooseIntervalSuccess = function (result) {
  807. console.log("util calendar chooseInterval back, result:" + result);
  808. };
  809. var _o2m_u_calendar_chooseInterval = function (c) {
  810. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  811. var onFail = c && c.onFail ? c.onFail : null;
  812. var startDate = c && c.startDate ? c.startDate : "";
  813. var endDate = c && c.endDate ? c.endDate : "";
  814. if (onSuccess && typeof onSuccess === "function") {
  815. o2m.util.calendar.chooseIntervalSuccess = onSuccess;
  816. }
  817. var body = {
  818. type: "calendar.chooseInterval",
  819. callback: "o2m.util.calendar.chooseIntervalSuccess",
  820. data: {
  821. startDate: startDate,
  822. endDate: endDate
  823. }
  824. };
  825. _util_post(body, onFail);
  826. };
  827. /**
  828. * 月历日期区间选择器
  829. * @method chooseInterval
  830. * @memberOf o2m
  831. * @o2membercategory util.calendar
  832. * @static
  833. * @param {Object} obj chooseInterval需要传入对象
  834. * <pre><code class='language-js'>{
  835. * startDate: '2019-05-05',
  836. * endDate: '2019-05-06',
  837. * "onSuccess": function, //成功回调
  838. * "onFail": function, //失败回调
  839. * }</code></pre>
  840. * @example
  841. * <caption>
  842. * 样例效果:<br/>
  843. * <img src="img/module/o2m/util_choose_interval.jpeg">
  844. * </caption>
  845. * o2m.util.calendar.chooseInterval({
  846. * startDate: '2019-05-05',
  847. * endDate: '2019-05-06',
  848. * onSuccess : function(result) {
  849. * //onSuccess将在点击完成之后回调
  850. * {
  851. * startDate: "2019-05-05",
  852. endDate: "2019-05-06",
  853. * }
  854. * },
  855. * onFail : function(err) {}
  856. *});
  857. */
  858. this.o2m.util.calendar.chooseInterval = _o2m_u_calendar_chooseInterval;
  859. //o2m.util.device.getPhoneInfo
  860. this.o2m.util.device.getPhoneInfoSuccess = function (result) {
  861. console.log("util calendar chooseInterval back, result:" + result);
  862. };
  863. var _o2m_u_device_getPhoneInfo = function (c) {
  864. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  865. var onFail = c && c.onFail ? c.onFail : null;
  866. if (onSuccess && typeof onSuccess === "function") {
  867. o2m.util.device.getPhoneInfoSuccess = onSuccess;
  868. }
  869. var body = {
  870. type: "device.getPhoneInfo",
  871. callback: "o2m.util.device.getPhoneInfoSuccess",
  872. data: {
  873. }
  874. };
  875. _util_post(body, onFail);
  876. };
  877. /**
  878. * 获取手机基础信息
  879. * @method getPhoneInfo
  880. * @memberOf o2m
  881. * @o2membercategory util.device
  882. * @static
  883. * @param {Object} obj getPhoneInfo需要传入对象
  884. * <pre><code class='language-js'>{
  885. * "onSuccess": function, //成功回调
  886. * "onFail": function, //失败回调
  887. * }</code></pre>
  888. * @example
  889. * o2m.util.device.getPhoneInfo({
  890. * onSuccess : function(result) {
  891. * {
  892. * screenWidth: 1080, // 手机屏幕宽度
  893. * screenHeight: 1920, // 手机屏幕高度
  894. * brand:'Mi', // 手机品牌
  895. * model:'Note4', // 手机型号
  896. * version:'7.0'. // 版本
  897. * netInfo:'wifi' , // 网络类型 wifi/4g/3g
  898. * operatorType :'xx' // 运营商信息
  899. * }
  900. * },
  901. * onFail : function(err) {}
  902. *});
  903. */
  904. this.o2m.util.device.getPhoneInfo = _o2m_u_device_getPhoneInfo;
  905. //o2m.util.device.rotate
  906. this.o2m.util.device.rotateSuccess = function (result) {
  907. console.log("util device rotate back, result:" + result);
  908. };
  909. var _o2m_u_device_rotate = function (c) {
  910. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  911. var onFail = c && c.onFail ? c.onFail : null;
  912. if (onSuccess && typeof onSuccess === "function") {
  913. o2m.util.device.rotateSuccess = onSuccess;
  914. }
  915. var body = {
  916. type: "device.rotate",
  917. callback: "o2m.util.device.rotateSuccess",
  918. data: {
  919. }
  920. };
  921. _util_post(body, onFail);
  922. };
  923. /**
  924. * 旋转屏幕
  925. * @method rotate
  926. * @memberOf o2m
  927. * @o2membercategory util.device
  928. * @static
  929. * @param {Object} obj rotate
  930. * <pre><code class='language-js'>{
  931. * "onSuccess": function, //成功回调
  932. * "onFail": function, //失败回调
  933. * }</code></pre>
  934. * @example
  935. * o2m.util.device.rotate({
  936. * onSuccess : function(result) {
  937. * },
  938. * onFail : function(err) {}
  939. *});
  940. */
  941. this.o2m.util.device.rotate = _o2m_u_device_rotate;
  942. //o2m.util.device.scan
  943. this.o2m.util.device.scanSuccess = function (result) {
  944. console.log("util device scan back, result:" + result);
  945. };
  946. var _o2m_u_device_scan = function (c) {
  947. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  948. var onFail = c && c.onFail ? c.onFail : null;
  949. if (onSuccess && typeof onSuccess === "function") {
  950. o2m.util.device.scanSuccess = onSuccess;
  951. }
  952. var body = {
  953. type: "device.scan",
  954. callback: "o2m.util.device.scanSuccess",
  955. data: {
  956. }
  957. };
  958. _util_post(body, onFail);
  959. };
  960. /**
  961. * 扫二维码
  962. * @method scan
  963. * @memberOf o2m
  964. * @o2membercategory util.device
  965. * @static
  966. * @param {Object} obj scan需要传入对象
  967. * <pre><code class='language-js'>{
  968. * "onSuccess": function, //成功回调
  969. * "onFail": function, //失败回调
  970. * }</code></pre>
  971. * @example
  972. * o2m.util.device.scan({
  973. * onSuccess : function(result) {
  974. * // result返回结果就是扫码的结果
  975. * },
  976. * onFail : function(err) {}
  977. *});
  978. */
  979. this.o2m.util.device.scan = _o2m_u_device_scan;
  980. //o2m.util.device.location
  981. this.o2m.util.device.locationSuccess = function (result) {
  982. console.log("util device location back, result:" + result);
  983. };
  984. var _o2m_u_device_location = function (c) {
  985. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  986. var onFail = c && c.onFail ? c.onFail : null;
  987. if (onSuccess && typeof onSuccess === "function") {
  988. o2m.util.device.locationSuccess = onSuccess;
  989. }
  990. var body = {
  991. type: "device.location",
  992. callback: "o2m.util.device.locationSuccess",
  993. data: {
  994. }
  995. };
  996. _util_post(body, onFail);
  997. };
  998. /**
  999. * 单次定位
  1000. * @method location
  1001. * @memberOf o2m
  1002. * @o2membercategory util.device
  1003. * @static
  1004. * @param {Object} obj location需要传入对象
  1005. * <pre><code class='language-js'>{
  1006. * "onSuccess": function, //成功回调
  1007. * "onFail": function, //失败回调
  1008. * }</code></pre>
  1009. * @example
  1010. * o2m.util.device.location({
  1011. * onSuccess : function(result) {
  1012. * //这里返回百度坐标系的定位信息
  1013. * {
  1014. * 'latitude': 39.903578, // 纬度
  1015. * 'longitude': 116.473565, // 经度
  1016. * 'address': '地址描述'
  1017. * }
  1018. * },
  1019. * onFail : function(err) {}
  1020. *});
  1021. */
  1022. this.o2m.util.device.location = _o2m_u_device_location;
  1023. //o2m.util.device.localAuth
  1024. this.o2m.util.device.localAuthSuccess = function (result) {
  1025. console.log("util device localAuth back, result:" + result);
  1026. };
  1027. /**
  1028. * 移动端生物识别认证
  1029. * @method localAuth
  1030. * @memberOf o2m
  1031. * @o2membercategory util.device
  1032. * @static
  1033. * @param {Object} obj localAuth 需要传入对象
  1034. * <pre><code class='language-js'>{
  1035. * "onSuccess": function, //成功回调
  1036. * "onFail": function, //失败回调
  1037. * }</code></pre>
  1038. * @example
  1039. * o2m.util.device.localAuth({
  1040. * onSuccess : function(result) {
  1041. * // result 是一个 json 字符串
  1042. * {
  1043. * "value": false // 是否授权成功
  1044. * }
  1045. * },
  1046. * onFail : function(err) {}
  1047. *});
  1048. */
  1049. this.o2m.util.device.localAuth = function (c) {
  1050. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1051. var onFail = c && c.onFail ? c.onFail : null;
  1052. if (onSuccess && typeof onSuccess === "function") {
  1053. o2m.util.device.localAuthSuccess = onSuccess;
  1054. }
  1055. var body = {
  1056. type: "device.localAuth",
  1057. callback: "o2m.util.device.localAuthSuccess",
  1058. data: {}
  1059. };
  1060. _util_post(body, onFail);
  1061. };
  1062. //o2m.util.navigation.setTitle
  1063. this.o2m.util.navigation.setTitleSuccess = function (result) {
  1064. console.log("util calendar chooseInterval back, result:" + result);
  1065. };
  1066. var _o2m_u_navigation_setTitle = function (c) {
  1067. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1068. var onFail = c && c.onFail ? c.onFail : null;
  1069. var title = c && c.title ? c.title : "";
  1070. if (onSuccess && typeof onSuccess === "function") {
  1071. o2m.util.navigation.setTitleSuccess = onSuccess;
  1072. }
  1073. var body = {
  1074. type: "navigation.setTitle",
  1075. callback: "o2m.util.navigation.setTitleSuccess",
  1076. data: {
  1077. title: title
  1078. }
  1079. };
  1080. _util_post(body, onFail);
  1081. };
  1082. /**
  1083. * 设置原生页面标题
  1084. * @method setTitle
  1085. * @memberOf o2m
  1086. * @o2membercategory util.navigation
  1087. * @static
  1088. * @param {Object} obj setTitle需要传入对象
  1089. * <pre><code class='language-js'>{
  1090. * title : '导航标题',
  1091. * "onSuccess": function, //成功回调
  1092. * "onFail": function, //失败回调
  1093. * }</code></pre>
  1094. * @example
  1095. * o2m.util.navigation.setTitle({
  1096. * title : '导航标题',
  1097. * onSuccess : function() {
  1098. * },
  1099. * onFail : function(err) {}
  1100. *});
  1101. */
  1102. this.o2m.util.navigation.setTitle = _o2m_u_navigation_setTitle;
  1103. //o2m.util.navigation.close
  1104. this.o2m.util.navigation.closeSuccess = function (result) {
  1105. console.log("util calendar chooseInterval back, result:" + result);
  1106. };
  1107. var _o2m_u_navigation_close = function (c) {
  1108. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1109. var onFail = c && c.onFail ? c.onFail : null;
  1110. if (onSuccess && typeof onSuccess === "function") {
  1111. o2m.util.navigation.closeSuccess = onSuccess;
  1112. }
  1113. var body = {
  1114. type: "navigation.close",
  1115. callback: "o2m.util.navigation.closeSuccess",
  1116. data: {
  1117. }
  1118. };
  1119. _util_post(body, onFail);
  1120. };
  1121. /**
  1122. * 关闭当前原生页面
  1123. * @method close
  1124. * @memberOf o2m
  1125. * @o2membercategory util.navigation
  1126. * @static
  1127. * @example
  1128. * o2m.util.navigation.close();
  1129. */
  1130. this.o2m.util.navigation.close = _o2m_u_navigation_close;
  1131. //o2m.util.navigation.goBack
  1132. this.o2m.util.navigation.goBackSuccess = function (result) {
  1133. console.log("util calendar chooseInterval back, result:" + result);
  1134. };
  1135. var _o2m_u_navigation_goBack = function (c) {
  1136. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1137. var onFail = c && c.onFail ? c.onFail : null;
  1138. if (onSuccess && typeof onSuccess === "function") {
  1139. o2m.util.navigation.goBackSuccess = onSuccess;
  1140. }
  1141. var body = {
  1142. type: "navigation.goBack",
  1143. callback: "o2m.util.navigation.goBackSuccess",
  1144. data: {
  1145. }
  1146. };
  1147. _util_post(body, onFail);
  1148. };
  1149. /**
  1150. * 返回上级原生页面
  1151. * @method goBack
  1152. * @memberOf o2m
  1153. * @o2membercategory util.navigation
  1154. * @static
  1155. * @example
  1156. * o2m.util.navigation.goBack();
  1157. */
  1158. this.o2m.util.navigation.goBack = _o2m_u_navigation_goBack;
  1159. //o2m.util.navigation.openInnerApp 内部应用打开 包含门户
  1160. this.o2m.util.navigation.openInnerAppSuccess = function (result) {
  1161. console.log("util navigation openInnerApp back, result:" + result);
  1162. };
  1163. var _o2m_u_navigation_openInnerApp = function (c) {
  1164. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1165. var onFail = c && c.onFail ? c.onFail : null;
  1166. if (onSuccess && typeof onSuccess === "function") {
  1167. o2m.util.navigation.openInnerAppSuccess = onSuccess;
  1168. }
  1169. var appKey = c && c.appKey ? c.appKey : "";
  1170. var portalFlag = c && c.portalFlag ? c.portalFlag : "";
  1171. var portalTitle = c && c.portalTitle ? c.portalTitle : "";
  1172. var portalPage = c && c.portalPage ? c.portalPage : "";
  1173. var parameters = c && c.parameters ? c.parameters : {};
  1174. var body = {
  1175. type: "navigation.openInnerApp",
  1176. callback: "o2m.util.navigation.openInnerAppSuccess",
  1177. data: {
  1178. appKey: appKey,
  1179. portalFlag: portalFlag,
  1180. portalTitle: portalTitle,
  1181. portalPage: portalPage,
  1182. parameters: parameters
  1183. }
  1184. };
  1185. _util_post(body, onFail);
  1186. };
  1187. /**
  1188. * 打开内部应用
  1189. * @method openInnerApp
  1190. * @memberOf o2m
  1191. * @o2membercategory util.navigation
  1192. * @static
  1193. * @param {Object} obj openInnerApp需要传入对象
  1194. * <pre><code class='language-js'>{
  1195. * appKey : 'attendance', // 对应用的 key: task(待办)、taskcompleted(已办)、read(待阅)、readcompleted(已阅)、meeting(会议管理)、clouddisk(网盘)、bbs(论坛)、cms(信息中心)、attendance(考勤)、calendar(日程)、mindMap(脑图)、portal(门户,门户需要传入portalFlag和portalTitle)
  1196. * portalFlag : '门户标识',
  1197. * portalTitle : '门户标题',
  1198. * portalPage : '门户页面 id',
  1199. * "onSuccess": function, //成功回调
  1200. * "onFail": function, //失败回调
  1201. * }</code></pre>
  1202. * @example
  1203. * o2m.util.navigation.openInnerApp({
  1204. * appKey : 'attendance',
  1205. * onSuccess : function() {
  1206. * },
  1207. * onFail : function(err) {}
  1208. *});
  1209. */
  1210. this.o2m.util.navigation.openInnerApp = _o2m_u_navigation_openInnerApp;
  1211. //o2m.util.navigation.openOtherApp 功能不完整,有很多限制。暂时不开放
  1212. this.o2m.util.navigation.openOtherAppSuccess = function (result) {
  1213. console.log("util navigation openOtherApp back, result:" + result);
  1214. };
  1215. var _o2m_u_navigation_openOtherApp = function (c) {
  1216. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1217. var onFail = c && c.onFail ? c.onFail : null;
  1218. if (onSuccess && typeof onSuccess === "function") {
  1219. o2m.util.navigation.openOtherAppSuccess = onSuccess;
  1220. }
  1221. var schema = c && c.schema ? c.schema : "";
  1222. var body = {
  1223. type: "navigation.openOtherApp",
  1224. callback: "o2m.util.navigation.openOtherAppSuccess",
  1225. data: {
  1226. schema: schema
  1227. }
  1228. };
  1229. _util_post(body, onFail);
  1230. };
  1231. this.o2m.util.navigation.openOtherApp = _o2m_u_navigation_openOtherApp;
  1232. //o2m.util.navigation.openWindow 新窗口打开网页 门户
  1233. this.o2m.util.navigation.openWindowSuccess = function (result) {
  1234. console.log("util navigation openWindow back, result:" + result);
  1235. };
  1236. var _o2m_u_navigation_openWindow = function (c) {
  1237. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1238. var onFail = c && c.onFail ? c.onFail : null;
  1239. if (onSuccess && typeof onSuccess === "function") {
  1240. o2m.util.navigation.openWindowSuccess = onSuccess;
  1241. }
  1242. var url = c && c.url ? c.url : "";
  1243. var body = {
  1244. type: "navigation.openWindow",
  1245. callback: "o2m.util.navigation.openWindowSuccess",
  1246. data: {
  1247. url: url
  1248. }
  1249. };
  1250. _util_post(body, onFail);
  1251. };
  1252. /**
  1253. * 新窗口打开网页
  1254. * @method openWindow
  1255. * @memberOf o2m
  1256. * @o2membercategory util.navigation
  1257. * @static
  1258. * @param {Object} obj openWindow需要传入对象
  1259. * <pre><code class='language-js'>{
  1260. * url : 'https://www.o2oa.net', // 打开的网址
  1261. * "onSuccess": function, //成功回调
  1262. * "onFail": function, //失败回调
  1263. * }</code></pre>
  1264. * @example
  1265. * o2m.util.navigation.openWindow({
  1266. * url : 'https://www.o2oa.net',
  1267. * onSuccess : function() {
  1268. * },
  1269. * onFail : function(err) {}
  1270. *});
  1271. */
  1272. this.o2m.util.navigation.openWindow = _o2m_u_navigation_openWindow;
  1273. //o2m.util.navigation.openInBrowser 手机默认浏览器打开当前页面
  1274. this.o2m.util.navigation.openInBrowserSuccess = function (result) {
  1275. console.log("util navigation openInBrowser back, result:" + result);
  1276. };
  1277. var _o2m_u_navigation_openInBrowser = function (c) {
  1278. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1279. var onFail = c && c.onFail ? c.onFail : null;
  1280. if (onSuccess && typeof onSuccess === "function") {
  1281. o2m.util.navigation.openInBrowserSuccess = onSuccess;
  1282. }
  1283. var body = {
  1284. type: "navigation.openInBrowser",
  1285. callback: "o2m.util.navigation.openInBrowserSuccess",
  1286. data: {}
  1287. };
  1288. _util_post(body, onFail);
  1289. };
  1290. /**
  1291. * 手机默认浏览器打开当前页面
  1292. * @method openInBrowser
  1293. * @memberOf o2m
  1294. * @o2membercategory util.navigation
  1295. * @static
  1296. * @example
  1297. * o2m.util.navigation.openInBrowser({
  1298. * onSuccess : function() {
  1299. * },
  1300. * onFail : function(err) {}
  1301. *});
  1302. */
  1303. this.o2m.util.navigation.openInBrowser = _o2m_u_navigation_openInBrowser;
  1304. //o2m.util.navigation.clearCache 清理缓存并刷新页面
  1305. this.o2m.util.navigation.clearCacheSuccess = function (result) {
  1306. console.log("util navigation clearCache back, result:" + result);
  1307. };
  1308. var _o2m_u_navigation_clearCache = function (c) {
  1309. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1310. var onFail = c && c.onFail ? c.onFail : null;
  1311. if (onSuccess && typeof onSuccess === "function") {
  1312. o2m.util.navigation.clearCacheSuccess = onSuccess;
  1313. }
  1314. var body = {
  1315. type: "navigation.clearCache",
  1316. callback: "o2m.util.navigation.clearCacheSuccess",
  1317. data: {}
  1318. };
  1319. _util_post(body, onFail);
  1320. };
  1321. /**
  1322. * 清理缓存并刷新页面
  1323. * @method clearCache
  1324. * @memberOf o2m
  1325. * @o2membercategory util.navigation
  1326. * @static
  1327. * @example
  1328. * o2m.util.navigation.clearCache({
  1329. * onSuccess : function() {
  1330. * },
  1331. * onFail : function(err) {}
  1332. *});
  1333. */
  1334. this.o2m.util.navigation.clearCache = _o2m_u_navigation_clearCache;
  1335. //o2m.util.navigation.share 分享图片
  1336. this.o2m.util.navigation.shareSuccess = function (result) {
  1337. console.log("util navigation share back, result:" + result);
  1338. };
  1339. var _o2m_u_navigation_share = function (c) {
  1340. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1341. var onFail = c && c.onFail ? c.onFail : null;
  1342. var base64 = c && c.base64 ? c.base64 : "";
  1343. if (onSuccess && typeof onSuccess === "function") {
  1344. o2m.util.navigation.shareSuccess = onSuccess;
  1345. }
  1346. var body = {
  1347. type: "navigation.share",
  1348. callback: "o2m.util.navigation.shareSuccess",
  1349. data: {
  1350. base64: base64
  1351. }
  1352. };
  1353. _util_post(body, onFail);
  1354. };
  1355. /**
  1356. * 分享图片功能,目前只支持 base64 进行分享
  1357. * @method share
  1358. * @memberOf o2m
  1359. * @o2membercategory util.navigation
  1360. * @static
  1361. * @example
  1362. * o2m.util.navigation.share({
  1363. * base64: '图片的 base64 编码';
  1364. * onSuccess : function() {
  1365. * },
  1366. * onFail : function(err) {}
  1367. *});
  1368. */
  1369. this.o2m.util.navigation.share = _o2m_u_navigation_share;
  1370. /** ***** BEGIN BIZ BLOCK *****
  1371. * @ignore
  1372. * @summary
  1373. biz 模块
  1374. contact
  1375. o2m.biz.contact.PersonPicker
  1376. o2m.biz.contact.IdentityPicker
  1377. o2m.biz.contact.departmentsPicker
  1378. o2m.biz.contact.ComplexPicker
  1379. o2m.biz.contact.GroupPicker
  1380. o2m.biz.file.previewDoc
  1381. * ***** END UTIL BLOCK ******/
  1382. this.o2m.biz = {
  1383. contact: {},
  1384. file:{}
  1385. };
  1386. var _biz_post = function (body, onFail) {
  1387. if (body == null) {
  1388. if (onFail && typeof onFail === "function") {
  1389. onFail("参数异常!");
  1390. return;
  1391. }
  1392. }
  1393. var message = JSON.stringify(body);
  1394. if (window.flutter_inappwebview && window.flutter_inappwebview.callHandler) {
  1395. window.flutter_inappwebview.callHandler('o2mBiz', message);
  1396. } else if (window.o2mBiz && window.o2mBiz.postMessage) {
  1397. window.o2mBiz.postMessage(message)
  1398. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mBiz) {
  1399. window.webkit.messageHandlers.o2mBiz.postMessage(message);
  1400. } else {
  1401. if (onFail && typeof onFail === "function") {
  1402. onFail("请在O2OA移动端使用!");
  1403. }
  1404. }
  1405. };
  1406. //o2m.biz.workClose()
  1407. var _o2m_b_work_close = function () {
  1408. if (window.o2android && window.o2android.closeWork) {
  1409. window.o2android.closeWork("");
  1410. } else if (window.o2android && window.o2android.postMessage) {
  1411. var body = {
  1412. type: "closeWork"
  1413. };
  1414. window.o2android.postMessage(JSON.stringify(body));
  1415. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.closeWork) {
  1416. window.webkit.messageHandlers.closeWork.postMessage("");
  1417. } else {
  1418. console.log("请在O2OA移动端使用, workClose");
  1419. }
  1420. }
  1421. /**
  1422. * 关闭当前工作页面,<b>只能在工作表单中可以使用</b>
  1423. * @method workClose
  1424. * @memberOf o2m
  1425. * @o2membercategory biz
  1426. * @static
  1427. * @example
  1428. * o2m.biz.workClose();
  1429. */
  1430. this.o2m.biz.workClose = _o2m_b_work_close;
  1431. //o2m.biz.contact.departmentsPicker
  1432. this.o2m.biz.contact.departmentsPickerSuccess = function (result) {
  1433. console.log("biz contact departmentsPicker back, result:" + result);
  1434. };
  1435. var _o2m_b_contact_department_picker = function (c) {
  1436. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1437. var onFail = c && c.onFail ? c.onFail : null;
  1438. if (onSuccess && typeof onSuccess === "function") {
  1439. o2m.biz.contact.departmentsPickerSuccess = onSuccess;
  1440. }
  1441. var topList = c && c.topList ? c.topList : [];
  1442. var orgType = c && c.orgType ? c.orgType : "";
  1443. var multiple = c && c.multiple ? c.multiple : false;
  1444. var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
  1445. var pickedDepartments = c && c.pickedDepartments ? c.pickedDepartments : [];
  1446. var body = {
  1447. type: "contact.departmentPicker",
  1448. callback: "o2m.biz.contact.departmentsPickerSuccess",
  1449. data: {
  1450. topList: topList,
  1451. orgType: orgType,
  1452. multiple: multiple,
  1453. maxNumber: maxNumber,
  1454. pickedDepartments: pickedDepartments,
  1455. }
  1456. };
  1457. _biz_post(body, onFail);
  1458. };
  1459. /**
  1460. * 通讯录选部门
  1461. * @method departmentsPicker
  1462. * @memberOf o2m
  1463. * @o2membercategory biz
  1464. * @static
  1465. * @param {Object} obj departmentsPicker需要传入对象
  1466. * <pre><code class='language-js'>{
  1467. * topList: [],//Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
  1468. * orgType: "",//String 可选择的组织类别。为空就是全部组织类型都可以
  1469. * multiple:true, //是否多选
  1470. * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的部门数
  1471. * pickedDepartments:[],//Array[String] 已经选择的部门distinguishedName列表
  1472. * "onSuccess": function, //成功回调
  1473. * "onFail": function, //失败回调
  1474. * }</code></pre>
  1475. * @example
  1476. * <caption>
  1477. * 样例效果:<br/>
  1478. * <img src="img/module/o2m/biz_dept_choose.png">
  1479. * </caption>
  1480. * o2m.biz.contact.departmentsPicker({
  1481. * topList: [],//不传或者空列表,显示全部组织
  1482. * orgType: "",//可传空 只显示某种类型的组织
  1483. * multiple:true, //是否多选
  1484. * maxNumber: 0, //最大选择数量
  1485. * pickedDepartments:[],//已选部门
  1486. * onSuccess : function(result) {
  1487. * //返回结果样例
  1488. * {
  1489. * departments:[{
  1490. * "id":"xxxx",
  1491. * "name":"部门名称",
  1492. * "unique":"xxxx",
  1493. * "distinguishedName":"部门@xxxx@U",
  1494. * "typeList":["xxxx"],
  1495. * "shortName":"xxxx",
  1496. * "level": 0,
  1497. * "levelName":"xxxx",
  1498. * }]
  1499. * }
  1500. *
  1501. * },
  1502. * onFail : function(err) {}
  1503. * });
  1504. */
  1505. this.o2m.biz.contact.departmentsPicker = _o2m_b_contact_department_picker;
  1506. //o2m.biz.contact.IdentityPicker
  1507. this.o2m.biz.contact.IdentityPickerSuccess = function (result) {
  1508. console.log("biz contact IdentityPicker back, result:" + result);
  1509. };
  1510. var _o2m_b_contact_identity_picker = function (c) {
  1511. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1512. var onFail = c && c.onFail ? c.onFail : null;
  1513. if (onSuccess && typeof onSuccess === "function") {
  1514. o2m.biz.contact.IdentityPickerSuccess = onSuccess;
  1515. }
  1516. var topList = c && c.topList ? c.topList : [];
  1517. var multiple = c && c.multiple ? c.multiple : false;
  1518. var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
  1519. var pickedIdentities = c && c.pickedIdentities ? c.pickedIdentities : [];
  1520. var duty = c && c.duty ? c.duty : [];
  1521. var body = {
  1522. type: "contact.identityPicker",
  1523. callback: "o2m.biz.contact.IdentityPickerSuccess",
  1524. data: {
  1525. topList: topList,
  1526. multiple: multiple,
  1527. maxNumber: maxNumber,
  1528. pickedIdentities: pickedIdentities,
  1529. duty: duty,
  1530. }
  1531. };
  1532. _biz_post(body, onFail);
  1533. };
  1534. /**
  1535. * 通讯录选身份
  1536. * @method IdentityPicker
  1537. * @memberOf o2m
  1538. * @o2membercategory biz
  1539. * @static
  1540. * @param {Object} obj IdentityPicker需要传入对象
  1541. * <pre><code class='language-js'>{
  1542. * topList: [],//Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
  1543. * multiple:true, //Boolean 是否多选
  1544. * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
  1545. * pickedIdentities:[],//Array[String] 已经选择的身份distinguishedName列表
  1546. * duty: [],//Array[String] 可选择的人员职责
  1547. * "onSuccess": function, //成功回调
  1548. * "onFail": function, //失败回调
  1549. * }</code></pre>
  1550. * @example
  1551. * <caption>
  1552. * 样例效果:<br/>
  1553. * <img src="img/module/o2m/biz_identity_choose.png">
  1554. * </caption>
  1555. * o2m.biz.contact.IdentityPicker({
  1556. * topList: [],//不传或者空列表,显示全部组织
  1557. * multiple:true, //是否多选
  1558. * maxNumber: 0, //最大选择数量
  1559. * pickedIdentities:[],//已选身份列表
  1560. * duty: [],//人员职责
  1561. * onSuccess : function(result) {
  1562. * //返回结果样例
  1563. * {
  1564. * identities:[{
  1565. * "id":"xxxx",
  1566. * "name":"姓名",
  1567. * "distinguishedName":"姓名@xxxx@I",
  1568. * "person":"xxx",
  1569. * "unique":"xxxx",
  1570. * "unit":"xxx",
  1571. * "unitName":"xxxx",
  1572. * "unitLevel": 0,
  1573. * "unitLevelName":"xxxx",
  1574. * "personName":"xxxx",
  1575. * "personUnique":"xxx",
  1576. * "personDn":"xxx"
  1577. * }]
  1578. * }
  1579. *
  1580. * },
  1581. * onFail : function(err) {}
  1582. * });
  1583. */
  1584. this.o2m.biz.contact.IdentityPicker = _o2m_b_contact_identity_picker;
  1585. //o2m.biz.contact.GroupPicker
  1586. this.o2m.biz.contact.GroupPickerSuccess = function (result) {
  1587. console.log("biz contact GroupPicker back, result:" + result);
  1588. };
  1589. var _o2m_b_contact_group_picker = function (c) {
  1590. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1591. var onFail = c && c.onFail ? c.onFail : null;
  1592. if (onSuccess && typeof onSuccess === "function") {
  1593. o2m.biz.contact.GroupPickerSuccess = onSuccess;
  1594. }
  1595. var multiple = c && c.multiple ? c.multiple : false;
  1596. var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
  1597. var pickedGroups = c && c.pickedGroups ? c.pickedGroups : [];
  1598. var body = {
  1599. type: "contact.groupPicker",
  1600. callback: "o2m.biz.contact.GroupPickerSuccess",
  1601. data: {
  1602. multiple: multiple,
  1603. maxNumber: maxNumber,
  1604. pickedGroups: pickedGroups,
  1605. }
  1606. };
  1607. _biz_post(body, onFail);
  1608. };
  1609. /**
  1610. * 群组选择
  1611. * @method GroupPicker
  1612. * @memberOf o2m
  1613. * @o2membercategory biz
  1614. * @static
  1615. * @param {Object} obj GroupPicker需要传入对象
  1616. * <pre><code class='language-js'>{
  1617. * multiple:true, //Boolean 是否多选
  1618. * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
  1619. * pickedGroups:[],//Array[String] 已经选择的群组distinguishedName列表
  1620. * "onSuccess": function, //成功回调
  1621. * "onFail": function, //失败回调
  1622. * }</code></pre>
  1623. * @example
  1624. * <caption>
  1625. * 样例效果:<br/>
  1626. * <img src="img/module/o2m/biz_group_choose.png">
  1627. * </caption>
  1628. * o2m.biz.contact.GroupPicker({
  1629. * multiple:true, //是否多选
  1630. * maxNumber: 0, //最大选择数量
  1631. * pickedGroups:[],//已选群组列表
  1632. * onSuccess : function(result) {
  1633. * //返回结果样例
  1634. * {
  1635. * groups:[{
  1636. * "id":"xxxx",
  1637. * "name":"群组名称",
  1638. * "distinguishedName":"群组名称@xxxx@G"
  1639. * "unique":"xxxx",
  1640. * }]
  1641. * }
  1642. *
  1643. * },
  1644. * onFail : function(err) {}
  1645. * });
  1646. */
  1647. this.o2m.biz.contact.GroupPicker = _o2m_b_contact_group_picker;
  1648. //o2m.biz.contact.PersonPicker
  1649. this.o2m.biz.contact.PersonPickerSuccess = function (result) {
  1650. console.log("biz contact PersonPicker back, result:" + result);
  1651. };
  1652. var _o2m_b_contact_person_picker = function (c) {
  1653. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1654. var onFail = c && c.onFail ? c.onFail : null;
  1655. if (onSuccess && typeof onSuccess === "function") {
  1656. o2m.biz.contact.PersonPickerSuccess = onSuccess;
  1657. }
  1658. var multiple = c && c.multiple ? c.multiple : false;
  1659. var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
  1660. var pickedUsers = c && c.pickedUsers ? c.pickedUsers : [];
  1661. var body = {
  1662. type: "contact.personPicker",
  1663. callback: "o2m.biz.contact.PersonPickerSuccess",
  1664. data: {
  1665. multiple: multiple,
  1666. maxNumber: maxNumber,
  1667. pickedUsers: pickedUsers,
  1668. }
  1669. };
  1670. _biz_post(body, onFail);
  1671. };
  1672. /**
  1673. * 人员选择
  1674. * @method PersonPicker
  1675. * @memberOf o2m
  1676. * @o2membercategory biz
  1677. * @static
  1678. * @param {Object} obj PersonPicker需要传入对象
  1679. * <pre><code class='language-js'>{
  1680. * multiple:true, //Boolean 是否多选
  1681. * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
  1682. * pickedUsers:[],//Array[String] 已经选择的人员distinguishedName列表
  1683. * "onSuccess": function, //成功回调
  1684. * "onFail": function, //失败回调
  1685. * }</code></pre>
  1686. * @example
  1687. * <caption>
  1688. * 样例效果:<br/>
  1689. * <img src="img/module/o2m/biz_person_choose.png">
  1690. * </caption>
  1691. * o2m.biz.contact.PersonPicker({
  1692. * multiple:true, //是否多选
  1693. * maxNumber: 0, //最大选择数量
  1694. * pickedUsers:[],//已选人员列表
  1695. * onSuccess : function(result) {
  1696. * //返回结果样例
  1697. * {
  1698. * users:[{
  1699. * "id":"xxx",
  1700. * "name":"姓名",
  1701. * "unique":"xxx",
  1702. * "distinguishedName":"姓名@xxxx@P"
  1703. * "genderType":"xxx",
  1704. * "employee":"xxx",
  1705. * "mail":"xxx",
  1706. * "weixin":"xxx",
  1707. * "qq":"xxx",
  1708. * "mobile":"xxx",
  1709. * "officePhone":"xxx"
  1710. * }]
  1711. * }
  1712. *
  1713. * },
  1714. * onFail : function(err) {}
  1715. * });
  1716. */
  1717. this.o2m.biz.contact.PersonPicker = _o2m_b_contact_person_picker;
  1718. //o2m.biz.contact.ComplexPicker
  1719. this.o2m.biz.contact.ComplexPickerSuccess = function (result) {
  1720. console.log("biz contact ComplexPicker back, result:" + result);
  1721. };
  1722. var _o2m_b_contact_complex_picker = function (c) {
  1723. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1724. var onFail = c && c.onFail ? c.onFail : null;
  1725. if (onSuccess && typeof onSuccess === "function") {
  1726. o2m.biz.contact.ComplexPickerSuccess = onSuccess;
  1727. }
  1728. var pickMode = c && c.pickMode ? c.pickMode : [];
  1729. var multiple = c && c.multiple ? c.multiple : false;
  1730. var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
  1731. var topList = c && c.topList ? c.topList : [];
  1732. var orgType = c && c.orgType ? c.orgType : "";
  1733. var duty = c && c.duty ? c.duty : [];
  1734. var pickedGroups = c && c.pickedGroups ? c.pickedGroups : [];
  1735. var pickedUsers = c && c.pickedUsers ? c.pickedUsers : [];
  1736. var pickedIdentities = c && c.pickedIdentities ? c.pickedIdentities : [];
  1737. var pickedDepartments = c && c.pickedDepartments ? c.pickedDepartments : [];
  1738. var body = {
  1739. type: "contact.complexPicker",
  1740. callback: "o2m.biz.contact.ComplexPickerSuccess",
  1741. data: {
  1742. pickMode: pickMode,
  1743. multiple: multiple,
  1744. maxNumber: maxNumber,
  1745. topList: topList,
  1746. orgType: orgType,
  1747. duty: duty,
  1748. pickedGroups: pickedGroups,
  1749. pickedUsers: pickedUsers,
  1750. pickedIdentities: pickedIdentities,
  1751. pickedDepartments: pickedDepartments,
  1752. }
  1753. };
  1754. _biz_post(body, onFail);
  1755. };
  1756. /**
  1757. * 复合选择器,可配置选择多种数据
  1758. * @method ComplexPicker
  1759. * @memberOf o2m
  1760. * @o2membercategory biz
  1761. * @static
  1762. * @param {Object} obj ComplexPicker需要传入对象
  1763. * <pre><code class='language-js'>{
  1764. * pickMode: ["departmentPicker", "identityPicker"], //Array[String] 选择器类型,可传入值:departmentPicker、identityPicker、groupPicker、personPicker
  1765. * topList:Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
  1766. * duty: Array[String] 可选择的人员职责
  1767. * orgType:String 可选择的组织类别。为空就是全部组织类型都可以
  1768. * multiple:true, //Boolean 是否多选
  1769. * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
  1770. * pickedDepartments:Array[String] 已经选择的部门distinguishedName列表
  1771. * pickedIdentities:Array[String] 已经选择的身份distinguishedName列表
  1772. * pickedGroups: Array[String] 已经选择的群组distinguishedName列表
  1773. * pickedUsers:[],//Array[String] 已经选择的人员distinguishedName列表
  1774. * "onSuccess": function, //成功回调
  1775. * "onFail": function, //失败回调
  1776. * }</code></pre>
  1777. * @example
  1778. * <caption>
  1779. * 样例效果:<br/>
  1780. * <img src="img/module/o2m/biz_complex_choose.png">
  1781. * </caption>
  1782. * o2m.biz.contact.ComplexPicker({
  1783. * pickMode: ["departmentPicker", "identityPicker"], //选择器类型
  1784. * topList: [],//不传或者空列表,显示全部组织
  1785. * orgType: "",//可传空 只显示某种类型的组织
  1786. * duty: [],//人员职责
  1787. * multiple:true, //是否多选
  1788. * maxNumber: 0, //最大选择数量
  1789. * pickedDepartments:[],//已选部门
  1790. * pickedIdentities:[],//已选身份列表
  1791. * pickedGroups:[],//已选群组列表
  1792. * pickedUsers:[],//已选人员列表
  1793. * onSuccess : function(result) {
  1794. * //返回结果样例
  1795. * {
  1796. * departments:[{
  1797. * "id":"xxxx",
  1798. * "name":"部门名称",
  1799. * "unique":"xxxx",
  1800. * "distinguishedName":"部门@xxxx@U",
  1801. * "typeList":["xxxx"],
  1802. * "shortName":"xxxx",
  1803. * "level": 0,
  1804. * "levelName":"xxxx",
  1805. * }],
  1806. * identities:[{
  1807. * "id":"xxxx",
  1808. * "name":"姓名",
  1809. * "distinguishedName":"姓名@xxxx@I",
  1810. * "person":"xxx",
  1811. * "unique":"xxxx",
  1812. * "unit":"xxx",
  1813. * "unitName":"xxxx",
  1814. * "unitLevel": 0,
  1815. * "unitLevelName":"xxxx",
  1816. * "personName":"xxxx",
  1817. * "personUnique":"xxx",
  1818. * "personDn":"xxx"
  1819. * }],
  1820. * groups:[{
  1821. * "id":"xxxx",
  1822. * "name":"群组名称",
  1823. * "distinguishedName":"群组名称@xxxx@G"
  1824. * "unique":"xxxx",
  1825. * }],
  1826. * users:[{
  1827. * "id":"xxx",
  1828. * "name":"姓名",
  1829. * "unique":"xxx",
  1830. * "distinguishedName":"姓名@xxxx@P"
  1831. * "genderType":"xxx",
  1832. * "employee":"xxx",
  1833. * "mail":"xxx",
  1834. * "weixin":"xxx",
  1835. * "qq":"xxx",
  1836. * "mobile":"xxx",
  1837. * "officePhone":"xxx"
  1838. * }]
  1839. * }
  1840. * },
  1841. * onFail : function(err) {}
  1842. * });
  1843. */
  1844. this.o2m.biz.contact.ComplexPicker = _o2m_b_contact_complex_picker;
  1845. this.o2m.biz.file.PreviewDocSuccess = function (result) {
  1846. console.log("biz file preview doc back, result:" + result);
  1847. };
  1848. var _o2m_b_file_preview = function (c) {
  1849. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1850. var onFail = c && c.onFail ? c.onFail : null;
  1851. if (onSuccess && typeof onSuccess === "function") {
  1852. o2m.biz.file.PreviewDocSuccess = onSuccess;
  1853. }
  1854. var fileUrl = c && c.url ? c.url : "";
  1855. var fileName = c && c.fileName ? c.fileName : "";
  1856. var body = {
  1857. type: "file.previewDoc",
  1858. callback: "o2m.biz.file.PreviewDocSuccess ",
  1859. data: {
  1860. url: fileUrl,
  1861. fileName: fileName
  1862. }
  1863. };
  1864. _biz_post(body, onFail);
  1865. };
  1866. // 文件预览 后续要删除
  1867. this.o2m.biz.file.PreviewDoc = _o2m_b_file_preview;
  1868. })();