o2m.api.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581
  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. * <b>o2m</b> 是O2OA移动端APP提供的调用原生控件的能力,帮助开发者高效使用拍照、定位等手机系统的能力,同时可以直接使用扫一扫、打开原生应用、选择时间,人员,组织等业务的能力,带给门户接近原生代码的体验
  29. * <br/>
  30. * <b>o2m</b> 只有在O2OA移动端APP中才能提供能力
  31. * @module o2m
  32. * @o2ordernumber 160
  33. * @o2range {流程表单|门户}
  34. * @o2syntax
  35. * // 可以在移动端 流程表单、门户 上使用
  36. * this.o2m
  37. *
  38. */
  39. (function () {
  40. this.o2m = {
  41. version: {
  42. v: "1.1.0",
  43. build: "2021.01.20",
  44. info: "O2OA 活力办公 创意无限. Copyright © 2021, o2oa.net O2 Team All rights reserved."
  45. },
  46. log: function (message) {
  47. window.o2android && window.o2android.o2mLog ? window.o2android.o2mLog(message) : window.webkit.messageHandlers.o2mLog.postMessage(message);
  48. }
  49. };
  50. /** ***** BEGIN NOTIFICATION BLOCK *****
  51. notification 模块
  52. alert
  53. confirm
  54. prompt
  55. vibrate
  56. toast
  57. actionSheet
  58. showLoading
  59. hideLoading
  60. * ***** END NOTIFICATION BLOCK ******/
  61. this.o2m.notification = {};
  62. var _notification_post = function (body, onFail) {
  63. if (body == null) {
  64. if (onFail && typeof onFail === "function") {
  65. onFail("参数异常!");
  66. return
  67. }
  68. }
  69. var message = JSON.stringify(body);
  70. if ((window.o2mNotification && window.o2mNotification.postMessage) || (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mNotification)) {
  71. window.o2mNotification && window.o2mNotification.postMessage ? window.o2mNotification.postMessage(message) : window.webkit.messageHandlers.o2mNotification.postMessage(message);
  72. } else {
  73. if (onFail && typeof onFail === "function") {
  74. onFail("请在O2OA移动端使用!");
  75. return
  76. }
  77. }
  78. };
  79. this.o2m.notification.alertSuccess = function () {
  80. console.log("notification alert back");
  81. };
  82. var _o2m_n_alert = function (alert) {
  83. var message = alert && alert.message ? alert.message : "";
  84. var title = alert && alert.title ? alert.title : "";
  85. var buttonName = alert && alert.buttonName ? alert.buttonName : "";
  86. var onSuccess = alert && alert.onSuccess ? alert.onSuccess : null;
  87. var onFail = alert && alert.onFail ? alert.onFail : null;
  88. if (message === "") {
  89. if (typeof onFail === "function") { onFail("消息内容不能为空!"); }
  90. return;
  91. }
  92. if (onSuccess && typeof onSuccess === "function") {
  93. o2m.notification.alertSuccess = onSuccess;
  94. }
  95. var body = {
  96. type: "alert",
  97. callback: "o2m.notification.alertSuccess",
  98. data: {
  99. message: message,
  100. title: title,
  101. buttonName: buttonName,
  102. }
  103. };
  104. _notification_post(body, onFail);
  105. };
  106. /**
  107. * 原生Alert提示弹出窗
  108. * @method alert
  109. * @o2membercategory notification
  110. * @static
  111. * @param {Object} obj 提示窗传入对象
  112. * <pre><code class='language-js'>{
  113. * "title": "提示", //消息标题,可为空
  114. * "message": "这里是消息内容", //消息内容
  115. * "buttonName": "确定", //确定按钮名称
  116. * "onSuccess": function, //成功回调
  117. * "onFail": function, //失败回调
  118. * }</code></pre>
  119. * @example
  120. * <caption>
  121. * 样例效果:<br/>
  122. * <img src="img/module/o2m/notification_alert.jpeg">
  123. * </caption>
  124. * o2m.notification.alert({
  125. * message: "亲爱的",
  126. * title: "提示",//可传空
  127. * buttonName: "收到",
  128. * onSuccess : function() {//onSuccess将在点击button之后回调},
  129. * onFail : function(err) {}
  130. * });
  131. *
  132. */
  133. this.o2m.notification.alert = _o2m_n_alert;
  134. //notification.confirm
  135. this.o2m.notification.confirmSuccess = function (index) {
  136. console.log("notification confirm back, click button index: " + index);
  137. };
  138. var _o2m_n_confirm = function (c) {
  139. var buttonLabels = c && c.buttonLabels ? c.buttonLabels : ["确定", "取消"];
  140. var message = c && c.message ? c.message : "";
  141. var title = c && c.title ? c.title : "";
  142. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  143. var onFail = c && c.onFail ? c.onFail : null;
  144. if (message === "") {
  145. if (typeof onFail === "function") { onFail("消息内容message不能为空!"); }
  146. return;
  147. }
  148. if (buttonLabels.length != 2) {
  149. if (typeof onFail === "function") { onFail("按钮名称数组长度只能是2!"); }
  150. return;
  151. }
  152. if (onSuccess && typeof onSuccess === "function") {
  153. o2m.notification.confirmSuccess = onSuccess;
  154. }
  155. var body = {
  156. type: "confirm",
  157. callback: "o2m.notification.confirmSuccess",
  158. data: {
  159. message: message,
  160. title: title,
  161. buttonLabels: buttonLabels,
  162. }
  163. };
  164. _notification_post(body, onFail);
  165. }
  166. /**
  167. * 原生confirm提示弹出窗
  168. * @method confirm
  169. * @o2membercategory notification
  170. * @static
  171. * @param {Object} obj 提示窗传入对象
  172. * <pre><code class='language-js'>{
  173. * "title": "提示", //消息标题,可为空
  174. * "message": "这里是消息内容", //消息内容
  175. * "buttonLabels": ["确定", "取消"], //按钮名称 Array[String]
  176. * "onSuccess": function, //成功回调
  177. * "onFail": function, //失败回调
  178. * }</code></pre>
  179. * @example
  180. * <caption>
  181. * 样例效果:<br/>
  182. * <img src="img/module/o2m/notification_confirm.jpeg">
  183. * </caption>
  184. * o2m.notification.confirm({
  185. * message: "你爱我吗",
  186. * title: "提示",//可传空
  187. * buttonLabels: ['爱', '不爱'],
  188. * onSuccess : function(buttonIndex) {
  189. * //onSuccess将在点击button之后回调
  190. * //buttonIndex: 0 被点击按钮的索引值,Number类型,从0开始
  191. * },
  192. * onFail : function(err) {}
  193. * });
  194. *
  195. */
  196. this.o2m.notification.confirm = _o2m_n_confirm;
  197. //notification.prompt
  198. this.o2m.notification.promptSuccess = function (result) {
  199. console.log("notification prompt back, click button result: " + result);
  200. };
  201. var _o2m_n_prompt = function (c) {
  202. var buttonLabels = c && c.buttonLabels ? c.buttonLabels : ["确定", "取消"];
  203. var message = c && c.message ? c.message : "";
  204. var title = c && c.title ? c.title : "";
  205. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  206. var onFail = c && c.onFail ? c.onFail : null;
  207. if (message === "") {
  208. if (typeof onFail === "function") { onFail("消息内容message不能为空!"); }
  209. return;
  210. }
  211. if (buttonLabels.length != 2) {
  212. if (typeof onFail === "function") { onFail("按钮名称数组长度只能是2!"); }
  213. return;
  214. }
  215. if (onSuccess && typeof onSuccess === "function") {
  216. o2m.notification.promptSuccess = onSuccess;
  217. }
  218. var body = {
  219. type: "prompt",
  220. callback: "o2m.notification.promptSuccess",
  221. data: {
  222. message: message,
  223. title: title,
  224. buttonLabels: buttonLabels,
  225. }
  226. };
  227. _notification_post(body, onFail);
  228. }
  229. /**
  230. * 原生prompt提示弹出窗
  231. * @method prompt
  232. * @o2membercategory notification
  233. * @static
  234. * @param {Object} obj prompt需要传入对象
  235. * <pre><code class='language-js'>{
  236. * "title": "提示", //消息标题,可为空
  237. * "message": "这里是消息内容", //消息内容
  238. * "buttonLabels": ['继续', '不玩了'], //按钮名称 Array[String]
  239. * "onSuccess": function, //成功回调
  240. * "onFail": function, //失败回调
  241. * }</code></pre>
  242. * @example
  243. * <caption>
  244. * 样例效果:<br/>
  245. * <img src="img/module/o2m/notification_prompt.jpeg">
  246. * </caption>
  247. * o2m.notification.prompt({
  248. * message: "再说一遍?",
  249. * title: "提示",//可传空
  250. * buttonLabels: ['继续', '不玩了'],
  251. * onSuccess : function(result) {
  252. * //result是一个字符串,格式是json格式,内容如下:
  253. * //{
  254. * // buttonIndex: 0, //被点击按钮的索引值,Number类型,从0开始
  255. * // value: '' //输入的值
  256. * //}
  257. * },
  258. * onFail : function(err) {}
  259. * });
  260. *
  261. */
  262. this.o2m.notification.prompt = _o2m_n_prompt;
  263. //notification.vibrate
  264. this.o2m.notification.vibrateSuccess = function () {
  265. console.log("notification vibrate back, click button");
  266. };
  267. var _o2m_n_vibrate = function (c) {
  268. var duration = c && c.duration ? c.duration : 300;
  269. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  270. var onFail = c && c.onFail ? c.onFail : null;
  271. if (onSuccess && typeof onSuccess === "function") {
  272. o2m.notification.vibrateSuccess = onSuccess;
  273. }
  274. var body = {
  275. type: "vibrate",
  276. callback: "o2m.notification.vibrateSuccess",
  277. data: {
  278. duration: duration
  279. }
  280. };
  281. _notification_post(body, onFail);
  282. };
  283. /**
  284. * 手机震动
  285. * @method vibrate
  286. * @o2membercategory notification
  287. * @static
  288. * @param {Object} obj 震动需要传入对象
  289. * <pre><code class='language-js'>{
  290. * "duration": 300, //震动时间,android可配置 iOS忽略
  291. * "onSuccess": function, //成功回调
  292. * "onFail": function, //失败回调
  293. * }</code></pre>
  294. * @example
  295. * o2m.notification.vibrate({
  296. * duration: 300,
  297. * onSuccess : function() {
  298. * },
  299. * onFail : function(err) {}
  300. * });
  301. *
  302. */
  303. this.o2m.notification.vibrate = _o2m_n_vibrate;
  304. //notification.toast
  305. this.o2m.notification.toastSuccess = function () {
  306. console.log("notification toast back, click button");
  307. };
  308. var _o2m_n_toast = function (c) {
  309. var duration = c && c.duration ? c.duration : 300;
  310. var message = c && c.message ? c.message : "";
  311. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  312. var onFail = c && c.onFail ? c.onFail : null;
  313. if (message === "") {
  314. if (typeof onFail === "function") { onFail("消息内容message不能为空!"); }
  315. return;
  316. }
  317. if (onSuccess && typeof onSuccess === "function") {
  318. o2m.notification.toastSuccess = onSuccess;
  319. }
  320. var body = {
  321. type: "toast",
  322. callback: "o2m.notification.toastSuccess",
  323. data: {
  324. duration: duration,
  325. message: message
  326. }
  327. };
  328. _notification_post(body, onFail);
  329. };
  330. /**
  331. * toast提示
  332. * @method toast
  333. * @o2membercategory notification
  334. * @static
  335. * @param {Object} obj toast需要传入对象
  336. * <pre><code class='language-js'>{
  337. * "message": "这里是提示信息",
  338. * "onSuccess": function, //成功回调
  339. * "onFail": function, //失败回调
  340. * }</code></pre>
  341. * @example
  342. * o2m.notification.toast({
  343. * message: "提示消息内容",
  344. * onSuccess : function() {
  345. * },
  346. * onFail : function(err) {}
  347. * });
  348. *
  349. */
  350. this.o2m.notification.toast = _o2m_n_toast;
  351. //notification.actionSheet
  352. this.o2m.notification.actionSheetSuccess = function (buttonIndex) {
  353. console.log("notification actionSheet back, click button:" + buttonIndex);
  354. };
  355. var _o2m_n_actionSheet = function (c) {
  356. var title = c && c.title ? c.title : "";
  357. var cancelButton = c && c.cancelButton ? c.cancelButton : "取消";
  358. var otherButtons = c && c.otherButtons ? c.otherButtons : [];
  359. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  360. var onFail = c && c.onFail ? c.onFail : null;
  361. if (title === "") {
  362. if (typeof onFail === "function") { onFail("title标题不能为空!"); }
  363. return;
  364. }
  365. if (otherButtons.length < 1) {
  366. if (typeof onFail === "function") { onFail("其他按钮列表不能为空!"); }
  367. return;
  368. }
  369. if (onSuccess && typeof onSuccess === "function") {
  370. o2m.notification.actionSheetSuccess = onSuccess;
  371. }
  372. var body = {
  373. type: "actionSheet",
  374. callback: "o2m.notification.actionSheetSuccess",
  375. data: {
  376. title: title,
  377. cancelButton: cancelButton,
  378. otherButtons: otherButtons
  379. }
  380. };
  381. _notification_post(body, onFail);
  382. };
  383. /**
  384. * 底部弹出菜单
  385. * @method actionSheet
  386. * @o2membercategory notification
  387. * @static
  388. * @param {Object} obj actionSheet需要传入对象
  389. * <pre><code class='language-js'>{
  390. * "title": "谁是最棒哒?",//标题
  391. * "cancelButton": '取消', //取消按钮文本
  392. * "otherButtons": ["孙悟空","猪八戒","唐僧","沙和尚"], //其他选项按钮名称
  393. * "onSuccess": function, //成功回调
  394. * "onFail": function, //失败回调
  395. * }</code></pre>
  396. * @example
  397. * <caption>
  398. * 样例效果:<br/>
  399. * <img src="img/module/o2m/notification_action_sheet.jpeg">
  400. * </caption>
  401. * o2m.notification.actionSheet({
  402. * title: "谁是最棒哒?", //标题
  403. * cancelButton: '取消', //取消按钮文本
  404. * otherButtons: ["孙悟空","猪八戒","唐僧","沙和尚"],
  405. * onSuccess : function(buttonIndex) {
  406. * //buttonIndex: 0 被点击按钮的索引值,Number,从0开始, 取消按钮为-1
  407. * },
  408. * onFail : function(err) {}
  409. * });
  410. *
  411. */
  412. this.o2m.notification.actionSheet = _o2m_n_actionSheet;
  413. //notification.showLoading
  414. this.o2m.notification.showLoadingSuccess = function () {
  415. console.log("notification showLoading back");
  416. };
  417. var _o2m_n_showLoading = function (c) {
  418. var text = c && c.text ? c.text : "";
  419. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  420. var onFail = c && c.onFail ? c.onFail : null;
  421. if (onSuccess && typeof onSuccess === "function") {
  422. o2m.notification.showLoadingSuccess = onSuccess;
  423. }
  424. var body = {
  425. type: "showLoading",
  426. callback: "o2m.notification.showLoadingSuccess",
  427. data: {
  428. text: text
  429. }
  430. };
  431. _notification_post(body, onFail);
  432. };
  433. /**
  434. * 显示Loading浮层,请和hideLoading配合使用
  435. * @method showLoading
  436. * @o2membercategory notification
  437. * @static
  438. * @param {Object} obj showLoading需要传入对象
  439. * <pre><code class='language-js'>{
  440. * text: "使劲加载中..", //loading显示的字符,空表示不显示文字
  441. * "onSuccess": function, //成功回调
  442. * "onFail": function, //失败回调
  443. * }</code></pre>
  444. * @example
  445. * <caption>
  446. * 样例效果:<br/>
  447. * <img src="img/module/o2m/notification_showLoading.jpeg">
  448. * </caption>
  449. * o2m.notification.showLoading({
  450. * text: "使劲加载中..", //loading显示的字符,空表示不显示文字
  451. * onSuccess : function() {
  452. * },
  453. * onFail : function(err) {}
  454. * });
  455. *
  456. */
  457. this.o2m.notification.showLoading = _o2m_n_showLoading;
  458. //notification.hideLoading
  459. this.o2m.notification.hideLoadingSuccess = function () {
  460. console.log("notification hideLoading back");
  461. };
  462. var _o2m_n_hideLoading = function (c) {
  463. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  464. var onFail = c && c.onFail ? c.onFail : null;
  465. if (onSuccess && typeof onSuccess === "function") {
  466. o2m.notification.hideLoadingSuccess = onSuccess;
  467. }
  468. var body = {
  469. type: "hideLoading",
  470. callback: "o2m.notification.hideLoadingSuccess",
  471. data: {
  472. }
  473. };
  474. _notification_post(body, onFail);
  475. }
  476. /**
  477. * 隐藏Loading浮层
  478. * @method hideLoading
  479. * @o2membercategory notification
  480. * @static
  481. * @param {Object} obj hideLoading需要传入对象
  482. * <pre><code class='language-js'>{
  483. * "onSuccess": function, //成功回调
  484. * "onFail": function, //失败回调
  485. * }</code></pre>
  486. * @example
  487. * o2m.notification.hideLoading({
  488. * onSuccess : function() {
  489. * },
  490. * onFail : function(err) {}
  491. * });
  492. *
  493. */
  494. this.o2m.notification.hideLoading = _o2m_n_hideLoading;
  495. /** ***** BEGIN UTIL BLOCK *****
  496. util 模块
  497. date
  498. o2m.util.date.datePicker
  499. o2m.util.date.timePicker
  500. o2m.util.date.dateTimePicker
  501. calendar
  502. o2m.util.calendar.chooseOneDay
  503. o2m.util.calendar.chooseDateTime
  504. o2m.util.calendar.chooseInterval
  505. device
  506. o2m.util.device.getPhoneInfo
  507. o2m.util.device.scan
  508. o2m.util.deveice.location
  509. navigation
  510. o2m.util.navigation.setTitle
  511. o2m.util.navigation.close
  512. o2m.util.navigation.goBack
  513. * ***** END UTIL BLOCK ******/
  514. this.o2m.util = {
  515. date: {},
  516. calendar: {},
  517. device: {},
  518. navigation: {}
  519. };
  520. var _util_post = function (body, onFail) {
  521. if (body == null) {
  522. if (onFail && typeof onFail === "function") {
  523. onFail("参数异常!");
  524. return;
  525. }
  526. }
  527. var message = JSON.stringify(body);
  528. if ((window.o2mUtil && window.o2mUtil.postMessage) || (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mUtil)) {
  529. window.o2mUtil && window.o2mUtil.postMessage ? window.o2mUtil.postMessage(message) : window.webkit.messageHandlers.o2mUtil.postMessage(message);
  530. } else {
  531. if (onFail && typeof onFail === "function") {
  532. onFail("请在O2OA移动端使用!");
  533. }
  534. }
  535. };
  536. //o2m.util.date.datePicker
  537. this.o2m.util.date.datePickerSuccess = function (result) {
  538. console.log("util date datePicker back, result:" + result);
  539. };
  540. var _o2m_u_date_datePicker = function (c) {
  541. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  542. var onFail = c && c.onFail ? c.onFail : null;
  543. var value = c && c.value ? c.value : "";
  544. if (onSuccess && typeof onSuccess === "function") {
  545. o2m.util.date.datePickerSuccess = onSuccess;
  546. }
  547. var body = {
  548. type: "date.datePicker",
  549. callback: "o2m.util.date.datePickerSuccess",
  550. data: {
  551. value: value
  552. }
  553. };
  554. _util_post(body, onFail);
  555. };
  556. /**
  557. * 日期选择器
  558. * @method datePicker
  559. * @o2membercategory util.date
  560. * @static
  561. * @param {Object} obj datePicker需要传入对象
  562. * <pre><code class='language-js'>{
  563. * value: '2019-04-17', //默认显示日期
  564. * "onSuccess": function, //成功回调
  565. * "onFail": function, //失败回调
  566. * }</code></pre>
  567. * @example
  568. * <caption>
  569. * 样例效果:<br/>
  570. * <img src="img/module/o2m/util_date_picker.jpeg">
  571. * </caption>
  572. * o2m.util.date.datePicker({
  573. * value: '2019-04-17', //默认显示日期
  574. * onSuccess : function(result) {
  575. * //onSuccess将在点击完成之后回调
  576. * {
  577. * value: "2019-02-10"
  578. * }
  579. * },
  580. * onFail : function(err) {}
  581. *});
  582. */
  583. this.o2m.util.date.datePicker = _o2m_u_date_datePicker;
  584. //o2m.util.date.timePicker
  585. this.o2m.util.date.timePickerSuccess = function (result) {
  586. console.log("util date timePicker back, result:" + result);
  587. };
  588. var _o2m_u_date_timePicker = function (c) {
  589. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  590. var onFail = c && c.onFail ? c.onFail : null;
  591. var value = c && c.value ? c.value : "";
  592. if (onSuccess && typeof onSuccess === "function") {
  593. o2m.util.date.timePickerSuccess = onSuccess;
  594. }
  595. var body = {
  596. type: "date.timePicker",
  597. callback: "o2m.util.date.timePickerSuccess",
  598. data: {
  599. value: value
  600. }
  601. };
  602. _util_post(body, onFail);
  603. };
  604. /**
  605. * 时间选择器
  606. * @method timePicker
  607. * @o2membercategory util.date
  608. * @static
  609. * @param {Object} obj timePicker需要传入对象
  610. * <pre><code class='language-js'>{
  611. * value: '14:00', //默认显示时间
  612. * "onSuccess": function, //成功回调
  613. * "onFail": function, //失败回调
  614. * }</code></pre>
  615. * @example
  616. * <caption>
  617. * 样例效果:<br/>
  618. * <img src="img/module/o2m/util_time_picker.jpeg">
  619. * </caption>
  620. * o2m.util.date.timePicker({
  621. * value: '14:00', //默认显示时间
  622. * onSuccess : function(result) {
  623. * //onSuccess将在点击完成之后回调
  624. * {
  625. * value: "18:10"
  626. * }
  627. * },
  628. * onFail : function(err) {}
  629. *});
  630. */
  631. this.o2m.util.date.timePicker = _o2m_u_date_timePicker;
  632. //o2m.util.date.dateTimePicker
  633. this.o2m.util.date.dateTimePickerSuccess = function (result) {
  634. console.log("util date dateTimePicker back, result:" + result);
  635. };
  636. var _o2m_u_date_dateTimePicker = function (c) {
  637. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  638. var onFail = c && c.onFail ? c.onFail : null;
  639. var value = c && c.value ? c.value : "";
  640. if (onSuccess && typeof onSuccess === "function") {
  641. o2m.util.date.dateTimePickerSuccess = onSuccess;
  642. }
  643. var body = {
  644. type: "date.dateTimePicker",
  645. callback: "o2m.util.date.dateTimePickerSuccess",
  646. data: {
  647. value: value
  648. }
  649. };
  650. _util_post(body, onFail);
  651. };
  652. /**
  653. * 日期时间选择器
  654. * @method dateTimePicker
  655. * @o2membercategory util.date
  656. * @static
  657. * @param {Object} obj dateTimePicker需要传入对象
  658. * <pre><code class='language-js'>{
  659. * value: '2019-05-05 14:00', //默认显示时间
  660. * "onSuccess": function, //成功回调
  661. * "onFail": function, //失败回调
  662. * }</code></pre>
  663. * @example
  664. * <caption>
  665. * 样例效果:<br/>
  666. * <img src="img/module/o2m/util_date_time_picker.jpeg">
  667. * </caption>
  668. * o2m.util.date.dateTimePicker({
  669. * value: '2019-05-05 14:00', //默认显示时间
  670. * onSuccess : function(result) {
  671. * //onSuccess将在点击完成之后回调
  672. * {
  673. * value: "2019-03-18 18:10"
  674. * }
  675. * },
  676. * onFail : function(err) {}
  677. *});
  678. */
  679. this.o2m.util.date.dateTimePicker = _o2m_u_date_dateTimePicker;
  680. //o2m.util.calendar.chooseOneDay
  681. this.o2m.util.calendar.chooseOneDaySuccess = function (result) {
  682. console.log("util calendar chooseOneDay back, result:" + result);
  683. };
  684. var _o2m_u_calendar_chooseOneDay = function (c) {
  685. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  686. var onFail = c && c.onFail ? c.onFail : null;
  687. var value = c && c.value ? c.value : "";
  688. if (onSuccess && typeof onSuccess === "function") {
  689. o2m.util.calendar.chooseOneDaySuccess = onSuccess;
  690. }
  691. var body = {
  692. type: "calendar.chooseOneDay",
  693. callback: "o2m.util.calendar.chooseOneDaySuccess",
  694. data: {
  695. value: value
  696. }
  697. };
  698. _util_post(body, onFail);
  699. };
  700. /**
  701. * 月历日期选择器
  702. * @method chooseOneDay
  703. * @o2membercategory util.date
  704. * @static
  705. * @param {Object} obj chooseOneDay需要传入对象
  706. * <pre><code class='language-js'>{
  707. * value: '2019-05-05', //默认显示日期
  708. * "onSuccess": function, //成功回调
  709. * "onFail": function, //失败回调
  710. * }</code></pre>
  711. * @example
  712. * <caption>
  713. * 样例效果:<br/>
  714. * <img src="img/module/o2m/util_choose_one_day.jpeg">
  715. * </caption>
  716. * o2m.util.date.chooseOneDay({
  717. * value: '2019-05-05', //默认显示日期
  718. * onSuccess : function(result) {
  719. * //onSuccess将在点击完成之后回调
  720. * {
  721. * value: "2019-03-18"
  722. * }
  723. * },
  724. * onFail : function(err) {}
  725. *});
  726. */
  727. this.o2m.util.calendar.chooseOneDay = _o2m_u_calendar_chooseOneDay;
  728. //o2m.util.calendar.chooseDateTime
  729. this.o2m.util.calendar.chooseDateTimeSuccess = function (result) {
  730. console.log("util calendar chooseDateTime back, result:" + result);
  731. };
  732. var _o2m_u_calendar_chooseDateTime = function (c) {
  733. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  734. var onFail = c && c.onFail ? c.onFail : null;
  735. var value = c && c.value ? c.value : "";
  736. if (onSuccess && typeof onSuccess === "function") {
  737. o2m.util.calendar.chooseDateTimeSuccess = onSuccess;
  738. }
  739. var body = {
  740. type: "calendar.chooseDateTime",
  741. callback: "o2m.util.calendar.chooseDateTimeSuccess",
  742. data: {
  743. value: value
  744. }
  745. };
  746. _util_post(body, onFail);
  747. };
  748. /**
  749. * 月历日期时间选择器
  750. * @method chooseDateTime
  751. * @o2membercategory util.date
  752. * @static
  753. * @param {Object} obj chooseDateTime需要传入对象
  754. * <pre><code class='language-js'>{
  755. * value: '2019-05-05 11:00', //默认显示时间
  756. * "onSuccess": function, //成功回调
  757. * "onFail": function, //失败回调
  758. * }</code></pre>
  759. * @example
  760. * <caption>
  761. * 样例效果:<br/>
  762. * <img src="img/module/o2m/util_choose_date_time.jpeg">
  763. * </caption>
  764. * o2m.util.date.chooseDateTime({
  765. * value: '2019-05-05 11:00', //默认显示时间
  766. * onSuccess : function(result) {
  767. * //onSuccess将在点击完成之后回调
  768. * {
  769. * value: "2019-03-18 18:45"
  770. * }
  771. * },
  772. * onFail : function(err) {}
  773. *});
  774. */
  775. this.o2m.util.calendar.chooseDateTime = _o2m_u_calendar_chooseDateTime;
  776. //o2m.util.calendar.chooseInterval
  777. this.o2m.util.calendar.chooseIntervalSuccess = function (result) {
  778. console.log("util calendar chooseInterval back, result:" + result);
  779. };
  780. var _o2m_u_calendar_chooseInterval = function (c) {
  781. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  782. var onFail = c && c.onFail ? c.onFail : null;
  783. var startDate = c && c.startDate ? c.startDate : "";
  784. var endDate = c && c.endDate ? c.endDate : "";
  785. if (onSuccess && typeof onSuccess === "function") {
  786. o2m.util.calendar.chooseIntervalSuccess = onSuccess;
  787. }
  788. var body = {
  789. type: "calendar.chooseInterval",
  790. callback: "o2m.util.calendar.chooseIntervalSuccess",
  791. data: {
  792. startDate: startDate,
  793. endDate: endDate
  794. }
  795. };
  796. _util_post(body, onFail);
  797. };
  798. /**
  799. * 月历日期区间选择器
  800. * @method chooseInterval
  801. * @o2membercategory util.date
  802. * @static
  803. * @param {Object} obj chooseInterval需要传入对象
  804. * <pre><code class='language-js'>{
  805. * startDate: '2019-05-05',
  806. * endDate: '2019-05-06',
  807. * "onSuccess": function, //成功回调
  808. * "onFail": function, //失败回调
  809. * }</code></pre>
  810. * @example
  811. * <caption>
  812. * 样例效果:<br/>
  813. * <img src="img/module/o2m/util_choose_interval.jpeg">
  814. * </caption>
  815. * o2m.util.date.chooseInterval({
  816. * value: '2019-05-05 11:00', //默认显示时间
  817. * onSuccess : function(result) {
  818. * //onSuccess将在点击完成之后回调
  819. * {
  820. * startDate: "2019-05-05",
  821. endDate: "2019-05-06",
  822. * }
  823. * },
  824. * onFail : function(err) {}
  825. *});
  826. */
  827. this.o2m.util.calendar.chooseInterval = _o2m_u_calendar_chooseInterval;
  828. //o2m.util.device.getPhoneInfo
  829. this.o2m.util.device.getPhoneInfoSuccess = function (result) {
  830. console.log("util calendar chooseInterval back, result:" + result);
  831. };
  832. var _o2m_u_device_getPhoneInfo = function (c) {
  833. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  834. var onFail = c && c.onFail ? c.onFail : null;
  835. if (onSuccess && typeof onSuccess === "function") {
  836. o2m.util.device.getPhoneInfoSuccess = onSuccess;
  837. }
  838. var body = {
  839. type: "device.getPhoneInfo",
  840. callback: "o2m.util.device.getPhoneInfoSuccess",
  841. data: {
  842. }
  843. };
  844. _util_post(body, onFail);
  845. };
  846. /**
  847. * 获取手机基础信息
  848. * @method getPhoneInfo
  849. * @o2membercategory util.device
  850. * @static
  851. * @param {Object} obj getPhoneInfo需要传入对象
  852. * <pre><code class='language-js'>{
  853. * "onSuccess": function, //成功回调
  854. * "onFail": function, //失败回调
  855. * }</code></pre>
  856. * @example
  857. * o2m.util.device.getPhoneInfo({
  858. * onSuccess : function(result) {
  859. * {
  860. * screenWidth: 1080, // 手机屏幕宽度
  861. * screenHeight: 1920, // 手机屏幕高度
  862. * brand:'Mi', // 手机品牌
  863. * model:'Note4', // 手机型号
  864. * version:'7.0'. // 版本
  865. * netInfo:'wifi' , // 网络类型 wifi/4g/3g
  866. * operatorType :'xx' // 运营商信息
  867. * }
  868. * },
  869. * onFail : function(err) {}
  870. *});
  871. */
  872. this.o2m.util.device.getPhoneInfo = _o2m_u_device_getPhoneInfo;
  873. //o2m.util.device.scan
  874. this.o2m.util.device.scanSuccess = function (result) {
  875. console.log("util device scan back, result:" + result);
  876. };
  877. var _o2m_u_device_scan = function (c) {
  878. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  879. var onFail = c && c.onFail ? c.onFail : null;
  880. if (onSuccess && typeof onSuccess === "function") {
  881. o2m.util.device.scanSuccess = onSuccess;
  882. }
  883. var body = {
  884. type: "device.scan",
  885. callback: "o2m.util.device.scanSuccess",
  886. data: {
  887. }
  888. };
  889. _util_post(body, onFail);
  890. };
  891. /**
  892. * 扫二维码
  893. * @method scan
  894. * @o2membercategory util.device
  895. * @static
  896. * @param {Object} obj scan需要传入对象
  897. * <pre><code class='language-js'>{
  898. * "onSuccess": function, //成功回调
  899. * "onFail": function, //失败回调
  900. * }</code></pre>
  901. * @example
  902. * o2m.util.device.scan({
  903. * onSuccess : function(result) {
  904. * { 'text': '扫码内容'}
  905. * },
  906. * onFail : function(err) {}
  907. *});
  908. */
  909. this.o2m.util.device.scan = _o2m_u_device_scan;
  910. //o2m.util.device.location
  911. this.o2m.util.device.locationSuccess = function (result) {
  912. console.log("util device location back, result:" + result);
  913. };
  914. var _o2m_u_device_location = function (c) {
  915. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  916. var onFail = c && c.onFail ? c.onFail : null;
  917. if (onSuccess && typeof onSuccess === "function") {
  918. o2m.util.device.locationSuccess = onSuccess;
  919. }
  920. var body = {
  921. type: "device.location",
  922. callback: "o2m.util.device.locationSuccess",
  923. data: {
  924. }
  925. };
  926. _util_post(body, onFail);
  927. };
  928. /**
  929. * 单次定位
  930. * @method location
  931. * @o2membercategory util.device
  932. * @static
  933. * @param {Object} obj location需要传入对象
  934. * <pre><code class='language-js'>{
  935. * "onSuccess": function, //成功回调
  936. * "onFail": function, //失败回调
  937. * }</code></pre>
  938. * @example
  939. * o2m.util.device.location({
  940. * onSuccess : function(result) {
  941. * //这里返回百度坐标系的定位信息
  942. * {
  943. * 'latitude': 39.903578, // 纬度
  944. * 'longitude': 116.473565, // 经度
  945. * 'address': '地址描述'
  946. * }
  947. * },
  948. * onFail : function(err) {}
  949. *});
  950. */
  951. this.o2m.util.device.location = _o2m_u_device_location;
  952. //o2m.util.navigation.setTitle
  953. this.o2m.util.navigation.setTitleSuccess = function (result) {
  954. console.log("util calendar chooseInterval back, result:" + result);
  955. };
  956. var _o2m_u_navigation_setTitle = function (c) {
  957. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  958. var onFail = c && c.onFail ? c.onFail : null;
  959. var title = c && c.title ? c.title : "";
  960. if (onSuccess && typeof onSuccess === "function") {
  961. o2m.util.navigation.setTitleSuccess = onSuccess;
  962. }
  963. var body = {
  964. type: "navigation.setTitle",
  965. callback: "o2m.util.navigation.setTitleSuccess",
  966. data: {
  967. title: title
  968. }
  969. };
  970. _util_post(body, onFail);
  971. };
  972. /**
  973. * 设置原生页面标题
  974. * @method setTitle
  975. * @o2membercategory util.navigation
  976. * @static
  977. * @param {Object} obj setTitle需要传入对象
  978. * <pre><code class='language-js'>{
  979. * title : '导航标题',
  980. * "onSuccess": function, //成功回调
  981. * "onFail": function, //失败回调
  982. * }</code></pre>
  983. * @example
  984. * o2m.util.navigation.setTitle({
  985. * title : '导航标题',
  986. * onSuccess : function() {
  987. * },
  988. * onFail : function(err) {}
  989. *});
  990. */
  991. this.o2m.util.navigation.setTitle = _o2m_u_navigation_setTitle;
  992. //o2m.util.navigation.close
  993. this.o2m.util.navigation.closeSuccess = function (result) {
  994. console.log("util calendar chooseInterval back, result:" + result);
  995. };
  996. var _o2m_u_navigation_close = function (c) {
  997. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  998. var onFail = c && c.onFail ? c.onFail : null;
  999. if (onSuccess && typeof onSuccess === "function") {
  1000. o2m.util.navigation.closeSuccess = onSuccess;
  1001. }
  1002. var body = {
  1003. type: "navigation.close",
  1004. callback: "o2m.util.navigation.closeSuccess",
  1005. data: {
  1006. }
  1007. };
  1008. _util_post(body, onFail);
  1009. };
  1010. /**
  1011. * 关闭当前原生页面
  1012. * @method close
  1013. * @o2membercategory util.navigation
  1014. * @static
  1015. * @example
  1016. * o2m.util.navigation.close();
  1017. */
  1018. this.o2m.util.navigation.close = _o2m_u_navigation_close;
  1019. //o2m.util.navigation.goBack
  1020. this.o2m.util.navigation.goBackSuccess = function (result) {
  1021. console.log("util calendar chooseInterval back, result:" + result);
  1022. };
  1023. var _o2m_u_navigation_goBack = function (c) {
  1024. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1025. var onFail = c && c.onFail ? c.onFail : null;
  1026. if (onSuccess && typeof onSuccess === "function") {
  1027. o2m.util.navigation.goBackSuccess = onSuccess;
  1028. }
  1029. var body = {
  1030. type: "navigation.goBack",
  1031. callback: "o2m.util.navigation.goBackSuccess",
  1032. data: {
  1033. }
  1034. };
  1035. _util_post(body, onFail);
  1036. };
  1037. /**
  1038. * 返回上级原生页面
  1039. * @method goBack
  1040. * @o2membercategory util.navigation
  1041. * @static
  1042. * @example
  1043. * o2m.util.navigation.goBack();
  1044. */
  1045. this.o2m.util.navigation.goBack = _o2m_u_navigation_goBack;
  1046. /** ***** BEGIN BIZ BLOCK *****
  1047. biz 模块
  1048. contact
  1049. o2m.biz.contact.PersonPicker
  1050. o2m.biz.contact.IdentityPicker
  1051. o2m.biz.contact.departmentsPicker
  1052. o2m.biz.contact.ComplexPicker
  1053. o2m.biz.contact.GroupPicker
  1054. * ***** END UTIL BLOCK ******/
  1055. this.o2m.biz = {
  1056. contact: {}
  1057. };
  1058. var _biz_post = function (body, onFail) {
  1059. if (body == null) {
  1060. if (onFail && typeof onFail === "function") {
  1061. onFail("参数异常!");
  1062. return;
  1063. }
  1064. }
  1065. var message = JSON.stringify(body);
  1066. if ((window.o2mBiz && window.o2mBiz.postMessage) || (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mBiz)) {
  1067. window.o2mBiz && window.o2mBiz.postMessage ? window.o2mBiz.postMessage(message) : window.webkit.messageHandlers.o2mBiz.postMessage(message);
  1068. } else {
  1069. if (onFail && typeof onFail === "function") {
  1070. onFail("请在O2OA移动端使用!");
  1071. }
  1072. }
  1073. };
  1074. //o2m.biz.workClose()
  1075. var _o2m_b_work_close = function () {
  1076. if (window.o2android && window.o2android.closeWork) {
  1077. window.o2android.closeWork("");
  1078. } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.closeWork) {
  1079. window.webkit.messageHandlers.closeWork.postMessage("");
  1080. } else {
  1081. console.log("请在O2OA移动端使用, workClose");
  1082. }
  1083. }
  1084. /**
  1085. * 关闭当前工作页面,<b>只能在工作表单中可以使用</b>
  1086. * @method workClose
  1087. * @o2membercategory biz
  1088. * @static
  1089. * @example
  1090. * o2m.biz.workClose();
  1091. */
  1092. this.o2m.biz.workClose = _o2m_b_work_close;
  1093. //o2m.biz.contact.departmentsPicker
  1094. this.o2m.biz.contact.departmentsPickerSuccess = function (result) {
  1095. console.log("biz contact departmentsPicker back, result:" + result);
  1096. };
  1097. var _o2m_b_contact_department_picker = function (c) {
  1098. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1099. var onFail = c && c.onFail ? c.onFail : null;
  1100. if (onSuccess && typeof onSuccess === "function") {
  1101. o2m.biz.contact.departmentsPickerSuccess = onSuccess;
  1102. }
  1103. var topList = c && c.topList ? c.topList : [];
  1104. var orgType = c && c.orgType ? c.orgType : "";
  1105. var multiple = c && c.multiple ? c.multiple : false;
  1106. var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
  1107. var pickedDepartments = c && c.pickedDepartments ? c.pickedDepartments : [];
  1108. var body = {
  1109. type: "contact.departmentPicker",
  1110. callback: "o2m.biz.contact.departmentsPickerSuccess",
  1111. data: {
  1112. topList: topList,
  1113. orgType: orgType,
  1114. multiple: multiple,
  1115. maxNumber: maxNumber,
  1116. pickedDepartments: pickedDepartments,
  1117. }
  1118. };
  1119. _biz_post(body, onFail);
  1120. };
  1121. /**
  1122. * 通讯录选部门
  1123. * @method departmentsPicker
  1124. * @o2membercategory biz
  1125. * @static
  1126. * @param {Object} obj departmentsPicker需要传入对象
  1127. * <pre><code class='language-js'>{
  1128. * topList: [],//Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
  1129. * orgType: "",//String 可选择的组织类别。为空就是全部组织类型都可以
  1130. * multiple:true, //是否多选
  1131. * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的部门数
  1132. * pickedDepartments:[],//Array[String] 已经选择的部门distinguishedName列表
  1133. * "onSuccess": function, //成功回调
  1134. * "onFail": function, //失败回调
  1135. * }</code></pre>
  1136. * @example
  1137. * <caption>
  1138. * 样例效果:<br/>
  1139. * <img src="img/module/o2m/biz_dept_choose.png">
  1140. * </caption>
  1141. * o2m.biz.contact.departmentsPicker({
  1142. * topList: [],//不传或者空列表,显示全部组织
  1143. * orgType: "",//可传空 只显示某种类型的组织
  1144. * multiple:true, //是否多选
  1145. * maxNumber: 0, //最大选择数量
  1146. * pickedDepartments:[],//已选部门
  1147. * onSuccess : function(result) {
  1148. * //返回结果样例
  1149. * {
  1150. * departments:[{
  1151. * "id":"xxxx",
  1152. * "name":"部门名称",
  1153. * "unique":"xxxx",
  1154. * "distinguishedName":"部门@xxxx@U",
  1155. * "typeList":["xxxx"],
  1156. * "shortName":"xxxx",
  1157. * "level": 0,
  1158. * "levelName":"xxxx",
  1159. * }]
  1160. * }
  1161. *
  1162. * },
  1163. * onFail : function(err) {}
  1164. * });
  1165. */
  1166. this.o2m.biz.contact.departmentsPicker = _o2m_b_contact_department_picker;
  1167. //o2m.biz.contact.IdentityPicker
  1168. this.o2m.biz.contact.IdentityPickerSuccess = function (result) {
  1169. console.log("biz contact IdentityPicker back, result:" + result);
  1170. };
  1171. var _o2m_b_contact_identity_picker = function (c) {
  1172. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1173. var onFail = c && c.onFail ? c.onFail : null;
  1174. if (onSuccess && typeof onSuccess === "function") {
  1175. o2m.biz.contact.IdentityPickerSuccess = onSuccess;
  1176. }
  1177. var topList = c && c.topList ? c.topList : [];
  1178. var multiple = c && c.multiple ? c.multiple : false;
  1179. var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
  1180. var pickedIdentities = c && c.pickedIdentities ? c.pickedIdentities : [];
  1181. var duty = c && c.duty ? c.duty : [];
  1182. var body = {
  1183. type: "contact.identityPicker",
  1184. callback: "o2m.biz.contact.IdentityPickerSuccess",
  1185. data: {
  1186. topList: topList,
  1187. multiple: multiple,
  1188. maxNumber: maxNumber,
  1189. pickedIdentities: pickedIdentities,
  1190. duty: duty,
  1191. }
  1192. };
  1193. _biz_post(body, onFail);
  1194. };
  1195. /**
  1196. * 通讯录选身份
  1197. * @method IdentityPicker
  1198. * @o2membercategory biz
  1199. * @static
  1200. * @param {Object} obj IdentityPicker需要传入对象
  1201. * <pre><code class='language-js'>{
  1202. * topList: [],//Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
  1203. * multiple:true, //Boolean 是否多选
  1204. * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
  1205. * pickedIdentities:[],//Array[String] 已经选择的身份distinguishedName列表
  1206. * duty: [],//Array[String] 可选择的人员职责
  1207. * "onSuccess": function, //成功回调
  1208. * "onFail": function, //失败回调
  1209. * }</code></pre>
  1210. * @example
  1211. * <caption>
  1212. * 样例效果:<br/>
  1213. * <img src="img/module/o2m/biz_identity_choose.png">
  1214. * </caption>
  1215. * o2m.biz.contact.IdentityPicker({
  1216. * topList: [],//不传或者空列表,显示全部组织
  1217. * multiple:true, //是否多选
  1218. * maxNumber: 0, //最大选择数量
  1219. * pickedIdentities:[],//已选身份列表
  1220. * duty: [],//人员职责
  1221. * onSuccess : function(result) {
  1222. * //返回结果样例
  1223. * {
  1224. * identities:[{
  1225. * "id":"xxxx",
  1226. * "name":"姓名",
  1227. * "distinguishedName":"姓名@xxxx@I",
  1228. * "person":"xxx",
  1229. * "unique":"xxxx",
  1230. * "unit":"xxx",
  1231. * "unitName":"xxxx",
  1232. * "unitLevel": 0,
  1233. * "unitLevelName":"xxxx",
  1234. * "personName":"xxxx",
  1235. * "personUnique":"xxx",
  1236. * "personDn":"xxx"
  1237. * }]
  1238. * }
  1239. *
  1240. * },
  1241. * onFail : function(err) {}
  1242. * });
  1243. */
  1244. this.o2m.biz.contact.IdentityPicker = _o2m_b_contact_identity_picker;
  1245. //o2m.biz.contact.GroupPicker
  1246. this.o2m.biz.contact.GroupPickerSuccess = function (result) {
  1247. console.log("biz contact GroupPicker back, result:" + result);
  1248. };
  1249. var _o2m_b_contact_group_picker = function (c) {
  1250. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1251. var onFail = c && c.onFail ? c.onFail : null;
  1252. if (onSuccess && typeof onSuccess === "function") {
  1253. o2m.biz.contact.GroupPickerSuccess = onSuccess;
  1254. }
  1255. var multiple = c && c.multiple ? c.multiple : false;
  1256. var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
  1257. var pickedGroups = c && c.pickedGroups ? c.pickedGroups : [];
  1258. var body = {
  1259. type: "contact.groupPicker",
  1260. callback: "o2m.biz.contact.GroupPickerSuccess",
  1261. data: {
  1262. multiple: multiple,
  1263. maxNumber: maxNumber,
  1264. pickedGroups: pickedGroups,
  1265. }
  1266. };
  1267. _biz_post(body, onFail);
  1268. };
  1269. /**
  1270. * 群组选择
  1271. * @method GroupPicker
  1272. * @o2membercategory biz
  1273. * @static
  1274. * @param {Object} obj GroupPicker需要传入对象
  1275. * <pre><code class='language-js'>{
  1276. * multiple:true, //Boolean 是否多选
  1277. * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
  1278. * pickedGroups:[],//Array[String] 已经选择的群组distinguishedName列表
  1279. * "onSuccess": function, //成功回调
  1280. * "onFail": function, //失败回调
  1281. * }</code></pre>
  1282. * @example
  1283. * <caption>
  1284. * 样例效果:<br/>
  1285. * <img src="img/module/o2m/biz_group_choose.png">
  1286. * </caption>
  1287. * o2m.biz.contact.GroupPicker({
  1288. * multiple:true, //是否多选
  1289. * maxNumber: 0, //最大选择数量
  1290. * pickedGroups:[],//已选群组列表
  1291. * onSuccess : function(result) {
  1292. * //返回结果样例
  1293. * {
  1294. * groups:[{
  1295. * "id":"xxxx",
  1296. * "name":"群组名称",
  1297. * "distinguishedName":"群组名称@xxxx@G"
  1298. * "unique":"xxxx",
  1299. * }]
  1300. * }
  1301. *
  1302. * },
  1303. * onFail : function(err) {}
  1304. * });
  1305. */
  1306. this.o2m.biz.contact.GroupPicker = _o2m_b_contact_group_picker;
  1307. //o2m.biz.contact.PersonPicker
  1308. this.o2m.biz.contact.PersonPickerSuccess = function (result) {
  1309. console.log("biz contact PersonPicker back, result:" + result);
  1310. };
  1311. var _o2m_b_contact_person_picker = function (c) {
  1312. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1313. var onFail = c && c.onFail ? c.onFail : null;
  1314. if (onSuccess && typeof onSuccess === "function") {
  1315. o2m.biz.contact.PersonPickerSuccess = onSuccess;
  1316. }
  1317. var multiple = c && c.multiple ? c.multiple : false;
  1318. var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
  1319. var pickedUsers = c && c.pickedUsers ? c.pickedUsers : [];
  1320. var body = {
  1321. type: "contact.personPicker",
  1322. callback: "o2m.biz.contact.PersonPickerSuccess",
  1323. data: {
  1324. multiple: multiple,
  1325. maxNumber: maxNumber,
  1326. pickedUsers: pickedUsers,
  1327. }
  1328. };
  1329. _biz_post(body, onFail);
  1330. };
  1331. /**
  1332. * 人员选择
  1333. * @method PersonPicker
  1334. * @o2membercategory biz
  1335. * @static
  1336. * @param {Object} obj PersonPicker需要传入对象
  1337. * <pre><code class='language-js'>{
  1338. * multiple:true, //Boolean 是否多选
  1339. * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
  1340. * pickedUsers:[],//Array[String] 已经选择的人员distinguishedName列表
  1341. * "onSuccess": function, //成功回调
  1342. * "onFail": function, //失败回调
  1343. * }</code></pre>
  1344. * @example
  1345. * <caption>
  1346. * 样例效果:<br/>
  1347. * <img src="img/module/o2m/biz_person_choose.png">
  1348. * </caption>
  1349. * o2m.biz.contact.PersonPicker({
  1350. * multiple:true, //是否多选
  1351. * maxNumber: 0, //最大选择数量
  1352. * pickedUsers:[],//已选人员列表
  1353. * onSuccess : function(result) {
  1354. * //返回结果样例
  1355. * {
  1356. * users:[{
  1357. * "id":"xxx",
  1358. * "name":"姓名",
  1359. * "unique":"xxx",
  1360. * "distinguishedName":"姓名@xxxx@P"
  1361. * "genderType":"xxx",
  1362. * "employee":"xxx",
  1363. * "mail":"xxx",
  1364. * "weixin":"xxx",
  1365. * "qq":"xxx",
  1366. * "mobile":"xxx",
  1367. * "officePhone":"xxx"
  1368. * }]
  1369. * }
  1370. *
  1371. * },
  1372. * onFail : function(err) {}
  1373. * });
  1374. */
  1375. this.o2m.biz.contact.PersonPicker = _o2m_b_contact_person_picker;
  1376. //o2m.biz.contact.ComplexPicker
  1377. this.o2m.biz.contact.ComplexPickerSuccess = function (result) {
  1378. console.log("biz contact ComplexPicker back, result:" + result);
  1379. };
  1380. var _o2m_b_contact_complex_picker = function (c) {
  1381. var onSuccess = c && c.onSuccess ? c.onSuccess : null;
  1382. var onFail = c && c.onFail ? c.onFail : null;
  1383. if (onSuccess && typeof onSuccess === "function") {
  1384. o2m.biz.contact.ComplexPickerSuccess = onSuccess;
  1385. }
  1386. var pickMode = c && c.pickMode ? c.pickMode : [];
  1387. var multiple = c && c.multiple ? c.multiple : false;
  1388. var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
  1389. var topList = c && c.topList ? c.topList : [];
  1390. var orgType = c && c.orgType ? c.orgType : "";
  1391. var duty = c && c.duty ? c.duty : [];
  1392. var pickedGroups = c && c.pickedGroups ? c.pickedGroups : [];
  1393. var pickedUsers = c && c.pickedUsers ? c.pickedUsers : [];
  1394. var pickedIdentities = c && c.pickedIdentities ? c.pickedIdentities : [];
  1395. var pickedDepartments = c && c.pickedDepartments ? c.pickedDepartments : [];
  1396. var body = {
  1397. type: "contact.complexPicker",
  1398. callback: "o2m.biz.contact.ComplexPickerSuccess",
  1399. data: {
  1400. pickMode: pickMode,
  1401. multiple: multiple,
  1402. maxNumber: maxNumber,
  1403. topList: topList,
  1404. orgType: orgType,
  1405. duty: duty,
  1406. pickedGroups: pickedGroups,
  1407. pickedUsers: pickedUsers,
  1408. pickedIdentities: pickedIdentities,
  1409. pickedDepartments: pickedDepartments,
  1410. }
  1411. };
  1412. _biz_post(body, onFail);
  1413. };
  1414. /**
  1415. * 复合选择器,可配置选择多种数据
  1416. * @method ComplexPicker
  1417. * @o2membercategory biz
  1418. * @static
  1419. * @param {Object} obj ComplexPicker需要传入对象
  1420. * <pre><code class='language-js'>{
  1421. * pickMode: ["departmentPicker", "identityPicker"], //Array[String] 选择器类型,可传入值:departmentPicker、identityPicker、groupPicker、personPicker
  1422. * topList:Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
  1423. * duty: Array[String] 可选择的人员职责
  1424. * orgType:String 可选择的组织类别。为空就是全部组织类型都可以
  1425. * multiple:true, //Boolean 是否多选
  1426. * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
  1427. * pickedDepartments:Array[String] 已经选择的部门distinguishedName列表
  1428. * pickedIdentities:Array[String] 已经选择的身份distinguishedName列表
  1429. * pickedGroups: Array[String] 已经选择的群组distinguishedName列表
  1430. * pickedUsers:[],//Array[String] 已经选择的人员distinguishedName列表
  1431. * "onSuccess": function, //成功回调
  1432. * "onFail": function, //失败回调
  1433. * }</code></pre>
  1434. * @example
  1435. * <caption>
  1436. * 样例效果:<br/>
  1437. * <img src="img/module/o2m/biz_complex_choose.png">
  1438. * </caption>
  1439. * o2m.biz.contact.ComplexPicker({
  1440. * pickMode: ["departmentPicker", "identityPicker"], //选择器类型
  1441. * topList: [],//不传或者空列表,显示全部组织
  1442. * orgType: "",//可传空 只显示某种类型的组织
  1443. * duty: [],//人员职责
  1444. * multiple:true, //是否多选
  1445. * maxNumber: 0, //最大选择数量
  1446. * pickedDepartments:[],//已选部门
  1447. * pickedIdentities:[],//已选身份列表
  1448. * pickedGroups:[],//已选群组列表
  1449. * pickedUsers:[],//已选人员列表
  1450. * onSuccess : function(result) {
  1451. * //返回结果样例
  1452. * {
  1453. * departments:[{
  1454. * "id":"xxxx",
  1455. * "name":"部门名称",
  1456. * "unique":"xxxx",
  1457. * "distinguishedName":"部门@xxxx@U",
  1458. * "typeList":["xxxx"],
  1459. * "shortName":"xxxx",
  1460. * "level": 0,
  1461. * "levelName":"xxxx",
  1462. * }],
  1463. * identities:[{
  1464. * "id":"xxxx",
  1465. * "name":"姓名",
  1466. * "distinguishedName":"姓名@xxxx@I",
  1467. * "person":"xxx",
  1468. * "unique":"xxxx",
  1469. * "unit":"xxx",
  1470. * "unitName":"xxxx",
  1471. * "unitLevel": 0,
  1472. * "unitLevelName":"xxxx",
  1473. * "personName":"xxxx",
  1474. * "personUnique":"xxx",
  1475. * "personDn":"xxx"
  1476. * }],
  1477. * groups:[{
  1478. * "id":"xxxx",
  1479. * "name":"群组名称",
  1480. * "distinguishedName":"群组名称@xxxx@G"
  1481. * "unique":"xxxx",
  1482. * }],
  1483. * users:[{
  1484. * "id":"xxx",
  1485. * "name":"姓名",
  1486. * "unique":"xxx",
  1487. * "distinguishedName":"姓名@xxxx@P"
  1488. * "genderType":"xxx",
  1489. * "employee":"xxx",
  1490. * "mail":"xxx",
  1491. * "weixin":"xxx",
  1492. * "qq":"xxx",
  1493. * "mobile":"xxx",
  1494. * "officePhone":"xxx"
  1495. * }]
  1496. * }
  1497. * },
  1498. * onFail : function(err) {}
  1499. * });
  1500. */
  1501. this.o2m.biz.contact.ComplexPicker = _o2m_b_contact_complex_picker;
  1502. })();