FlowMobile.js 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651
  1. MWF.xDesktop.requireApp("process.Work", "Flow", null, false);
  2. MWF.xApplication.process.Work.FlowMobile = MWF.ProcessFlowMobile = new Class({
  3. Extends: MWF.ProcessFlow,
  4. Implements: [Options, Events],
  5. options: {
  6. mainColorEnable: true
  7. },
  8. initialize: function (container, task, options, form) {
  9. this.setOptions(options);
  10. this.path = "../x_component_process_Work/$FlowMobile/";
  11. this.lp = MWF.xApplication.process.Work.LP;
  12. this.task = task;
  13. this.container = $(container);
  14. this.form = form;
  15. this.businessData = this.form.businessData;
  16. this.load();
  17. },
  18. load: function () {
  19. this.container.loadCss( this.path + this.options.style + "/style.css", null, function () {
  20. this.cssLoaded = true;
  21. this.checkLoadEvent();
  22. }.bind(this));
  23. this.processEnable = this.options.processEnable && this.businessData.control["allowProcessing"];
  24. this.addTaskEnable = this.options.addTaskEnable && this.businessData.control["allowAddTask"];
  25. this.resetEnable = this.options.resetEnable && this.businessData.control["allowReset"];
  26. this.goBackEnable = this.options.goBackEnable && this.businessData.control["allowGoBack"];
  27. this.navi = [];
  28. if( this.processEnable )this.navi.push({ key: "process", label: this.lp.flowActions.process });
  29. if( this.addTaskEnable )this.navi.push({ key: "addTask", label: this.lp.flowActions.addTask });
  30. if( this.resetEnable )this.navi.push({ key: "reset", label: this.lp.flowActions.reset });
  31. if( this.goBackEnable )this.navi.push({ key: "goBack", label: this.lp.flowActions.goBack });
  32. var url = this.path+this.options.style+"/main.html";
  33. this.container.loadHtml(url, {"bind": {"lp": this.lp, "navi": this.navi}, "module": this}, function(){
  34. if( this.navi.length < 2 )this.naviNode.hide();
  35. if( this.options.mainColorEnable ){
  36. this.okButton.addClass("mainColor_bg");
  37. }
  38. this.node.getParent().setStyle("height", "100%");
  39. this.changeAction( this.navi[0].key );
  40. if( this.processEnable || this.resetEnable || this.addTaskEnable ){
  41. this.loadQuickSelect();
  42. }else{
  43. this.quickSelectNode.hide();
  44. }
  45. }.bind(this));
  46. },
  47. getSize: function(){
  48. return {
  49. y: this.contentWraper.getSize().y + this.getMarginY(this.contentWraper) + this.getOffsetY(this.node) + 1,
  50. x: this.node.getSize().x + this.getMarginY(this.node)
  51. };
  52. },
  53. checkLoadEvent: function(){
  54. if( this.cssLoaded && this.firstActionLoaded){
  55. this.fireEvent("load");
  56. }
  57. },
  58. changeAction: function( action, quickData ){
  59. if( this.currentAction ){
  60. this[ this.currentAction+"ContentNode" ].hide();
  61. this[ this.currentAction+"TitleNode" ].removeClass("o2flow-navi-item-active");
  62. if( this.options.mainColorEnable )this[ this.currentAction+"TitleNode" ].removeClass("mainColor_color").removeClass("mainColor_border");
  63. }
  64. this[ action+"ContentNode" ].show();
  65. this[ action+"TitleNode" ].addClass("o2flow-navi-item-active");
  66. if( this.options.mainColorEnable )this[ action+"TitleNode" ].addClass("mainColor_color").addClass("mainColor_border");
  67. this.currentAction = action;
  68. switch (action) {
  69. case "process":
  70. this.loadProcessor( quickData );
  71. break;
  72. case "addTask":
  73. this.loadAddTask( quickData );
  74. break;
  75. case "reset":
  76. this.loadReset( quickData );
  77. break;
  78. case "goBack":
  79. this.loadGoBack();
  80. break;
  81. }
  82. },
  83. loadProcessor: function ( quickData ) {
  84. if( this.processor ){
  85. if( quickData )this.processor.setQuickData( quickData );
  86. this.resize();
  87. return;
  88. }
  89. this.processor = new MWF.ProcessFlow.ProcessorMobile(
  90. this.processContentNode,
  91. this,
  92. Object.merge( this.options.processOptions, {
  93. onLoad: function () {
  94. if( this.firstActionLoaded ){
  95. this.resize();
  96. }else{
  97. this.firstActionLoaded = true;
  98. this.checkLoadEvent();
  99. }
  100. }.bind(this)
  101. })
  102. );
  103. this.processor.load( quickData );
  104. },
  105. loadReset: function( quickData ){
  106. if( this.reset ){
  107. if( quickData )this.reset.setQuickData( quickData );
  108. this.resize();
  109. return;
  110. }
  111. this.reset = new MWF.ProcessFlow.ResetMobile(
  112. this.resetContentNode,
  113. this,
  114. Object.merge( this.options.resetOptions, {
  115. onLoad: function () {
  116. if( this.firstActionLoaded ){
  117. this.resize();
  118. }else{
  119. this.firstActionLoaded = true;
  120. this.checkLoadEvent();
  121. }
  122. }.bind(this)
  123. })
  124. );
  125. this.reset.load( quickData );
  126. },
  127. loadAddTask: function( quickData ){
  128. if( this.addTask ){
  129. if( quickData )this.addTask.setQuickData( quickData );
  130. this.resize();
  131. return;
  132. }
  133. this.addTask = new MWF.ProcessFlow.AddTaskMobile(
  134. this.addTaskContentNode,
  135. this,
  136. Object.merge( this.options.addTaskOptions, {
  137. onLoad: function () {
  138. if( this.firstActionLoaded ){
  139. this.resize();
  140. }else{
  141. this.firstActionLoaded = true;
  142. this.checkLoadEvent();
  143. }
  144. }.bind(this)
  145. })
  146. );
  147. this.addTask.load( quickData );
  148. },
  149. loadGoBack: function(){
  150. if( this.goBack ){
  151. this.resize();
  152. return;
  153. }
  154. this.goBack = new MWF.ProcessFlow.GoBackMobile(
  155. this.goBackContentNode,
  156. this,
  157. Object.merge( this.options.goBackOptions, {
  158. onLoad: function () {
  159. if( this.firstActionLoaded ){
  160. this.resize();
  161. }else{
  162. this.firstActionLoaded = true;
  163. this.checkLoadEvent();
  164. }
  165. }.bind(this)
  166. })
  167. );
  168. this.goBack.load();
  169. },
  170. loadQuickSelect: function(){
  171. this.quickSelector = new MWF.ProcessFlow.widget.QuickSelectMobile(
  172. $(document.body), //this.form.app ? this.form.app.content :
  173. null, this.form.app, {}, {
  174. onPostLoad: function() {
  175. this.maskNode.setStyles({
  176. "z-index": 1001,
  177. "opacity": 0.5,
  178. "position": "absolute",
  179. "background-color": "#ccc"
  180. });
  181. }
  182. }
  183. );
  184. this.quickSelector.flow = this;
  185. this.quickSelectNode.addEvent("click", function () {
  186. this.quickSelector.load()
  187. }.bind(this))
  188. },
  189. cancel: function () {
  190. this.fireEvent("cancel");
  191. }
  192. });
  193. MWF.ProcessFlow.ResetMobile = new Class({
  194. Extends: MWF.ProcessFlow.Reset,
  195. setQuickData: function( data ){
  196. // if(this.keepOption)this.keepOption.setValue( data.keepTask ? "true" : null );
  197. if(this.opinion)this.opinion.setValue( data.opinion || "" );
  198. this.orgData = data.organizations ? (data.organizations.default || []) : [];
  199. this.orgContent.empty();
  200. this.loadOrgWidget(this.orgData, this.orgContent);
  201. },
  202. afterLoad: function () {
  203. if( this.flow.options.mainColorEnable ){
  204. this.orgIcon.addClass("mainColor_color");
  205. this.orgIcon.addClass("mainColor_border");
  206. }
  207. // this.keepOption = new MWF.ProcessFlow.widget.Radio2(this.keepOptionArea, this.flow, {
  208. // activeIcon: "o2icon-checkbox",
  209. // optionList: [{
  210. // text: this.lp.keepTask,
  211. // value: "true"
  212. // }],
  213. // value: (this.quickData.keepTask) ? "true" : null
  214. // });
  215. // this.keepOption.load();
  216. },
  217. destroy: function () {
  218. // if (this.orgItem && this.orgItem.clearTooltip){
  219. // this.orgItem.clearTooltip();
  220. // }
  221. if (this.node) this.node.empty();
  222. },
  223. loadOrg: function(){
  224. var quickData = this.quickData.organizations ? (this.quickData.organizations.default || [] ) : [];
  225. if( quickData.length ){
  226. this.orgData = quickData;
  227. this.orgContent.empty();
  228. this.loadOrgWidget(this.orgData, this.orgContent);
  229. }
  230. if(this.quickData.organizations)delete this.quickData.organizations.default;
  231. this.orgNode.addEvent("click", function () {
  232. this.getSelOptions( function (options) {
  233. options.values = this.orgData || [] ;
  234. setTimeout(function () {
  235. this.selector = new MWF.O2Selector($(document.body), options);
  236. }.bind(this), 100);
  237. }.bind(this) );
  238. }.bind(this));
  239. },
  240. getSelDefaultOptions: function(){
  241. var defaultOpt = {
  242. "type": "identity",
  243. "style": "default",
  244. "zIndex": 3000,
  245. "count": this.businessData.activity.resetCount || 0,
  246. "onComplete": function (items) {
  247. this.selectOnComplete(items);
  248. }.bind(this)
  249. };
  250. if (this.form.json.selectorStyle) {
  251. defaultOpt = Object.merge(Object.clone(this.form.json.selectorStyle), defaultOpt);
  252. if (this.form.json.selectorStyle.style) defaultOpt.style = this.form.json.selectorStyle.style;
  253. }
  254. return defaultOpt;
  255. },
  256. getSelOrgData: function () {
  257. return this.orgData ? this.orgData.map(function (item) {
  258. return typeOf( item ) === "string" ? item : item.distinguishedName;
  259. }) : [];
  260. },
  261. selectOnComplete: function (items) { //移动端才执行
  262. // var array = items.map(function (item) {
  263. // return item.data;
  264. // });
  265. // this.checkEmpower(array, function (data) {
  266. var values = items.map(function (item) {
  267. return MWF.org.parseOrgData(item.data, true, true)
  268. });
  269. this.orgData = values;
  270. this.orgContent.empty();
  271. this.loadOrgWidget(values, this.orgContent);
  272. this.selector = null;
  273. this.fireEvent("select", [items, values]);
  274. // }.bind(this))
  275. },
  276. loadOrgWidget: function (value, node) {
  277. var height = node.getStyle("height").toInt();
  278. if (node.getStyle("overflow") === "visible" && !height) node.setStyle("overflow", "hidden");
  279. if (value && value.length) {
  280. value.each(function (data) {
  281. if( typeOf(data) === "string" ){
  282. data = { distinguishedName : data, name : o2.name.cn(data) };
  283. }
  284. var flag = data.distinguishedName.substr(data.distinguishedName.length - 1, 1);
  285. var widget;
  286. switch (flag.toLowerCase()) {
  287. case "i":
  288. widget = new MWF.ProcessFlow.widget.O2IdentityMobile(data, node, this.getOrgWidgetOption());
  289. break;
  290. case "p":
  291. widget = new MWF.ProcessFlow.widget.O2PersonMobile(data, node, this.getOrgWidgetOption());
  292. break;
  293. case "u":
  294. widget = new MWF.ProcessFlow.widget.O2UnitMobile(data, node, this.getOrgWidgetOption());
  295. break;
  296. case "g":
  297. widget = new MWF.ProcessFlow.widget.O2GroupMobile(data, node, this.getOrgWidgetOption());
  298. break;
  299. default:
  300. widget = new MWF.ProcessFlow.widget.O2OtherMobile(data, node, this.getOrgWidgetOption());
  301. }
  302. widget.field = this;
  303. widget.load();
  304. }.bind(this));
  305. }
  306. },
  307. getOrgWidgetOption: function(){
  308. return {
  309. "mainColorEnable": this.flow.options.mainColorEnable,
  310. "removeByClick": true,
  311. "style": "flowmobile",
  312. "canRemove": false,
  313. "lazy": true,
  314. "disableInfor" : true,
  315. "onRemove" : this.removeWidgetItem,
  316. // "onPostLoad": this.loadWidgetItem,
  317. "delay": true
  318. };
  319. },
  320. // loadWidgetItem: function(){
  321. // //this 是 MWF.widget.O2Identity 之类的对象
  322. // var _self = this.field; //这个才是field
  323. // var dn = this.data.distinguishedName;
  324. // if( _self.flow.options.mainColorEnable ){
  325. // this.node.addClass("mainColor_bg");
  326. // }
  327. // },
  328. removeWidgetItem : function( widget, ev ){
  329. debugger;
  330. //this 是 MWF.widget.O2Identity 之类的对象
  331. var _self = this.field; //这个才是field
  332. var dn = this.data.distinguishedName;
  333. var data = _self.orgData;
  334. var index;
  335. _self.orgData.each( function ( d , i){
  336. if( d.distinguishedName == dn ){
  337. index = i;
  338. }
  339. });
  340. _self.orgData.splice( index, 1 );
  341. this.node.destroy();
  342. ev.stopPropagation();
  343. },
  344. });
  345. MWF.ProcessFlow.AddTaskMobile = new Class({
  346. Extends: MWF.ProcessFlow.AddTask,
  347. getUrl: function(){
  348. return this.flow.path+this.flow.options.style+"/addTask.html";
  349. },
  350. setQuickData: function( data ){
  351. if(this.position)this.position.setValue( data.routeId === "before" ? "true" : null ); //前后加签存在 routeId
  352. if(this.mode)this.mode.setValue( data.routeGroup || null ); //单人、并行、串行存在 routeGroup
  353. if(this.opinion)this.opinion.setValue( data.opinion || "" );
  354. this.orgData = data.organizations ? (data.organizations.default || []) : [];
  355. this.orgContent.empty();
  356. this.loadOrgWidget(this.orgData, this.orgContent);
  357. },
  358. afterLoad: function () {
  359. if( this.flow.options.mainColorEnable ){
  360. this.orgIcon.addClass("mainColor_color");
  361. this.orgIcon.addClass("mainColor_border");
  362. }
  363. this.mode = new MWF.ProcessFlow.widget.Radio2(this.modeArea, this.flow, {
  364. activeIcon: "o2icon-checkbox",
  365. optionList: [{
  366. text: this.lp.single,
  367. value: "single"
  368. },{
  369. text: this.lp.queue,
  370. value: "queue"
  371. },{
  372. text: this.lp.parallel,
  373. value: "parallel"
  374. }],
  375. value: this.quickData.mode || "single" //默认单人
  376. });
  377. this.mode.load();
  378. var position = "";
  379. if( this.quickData.routeId ){
  380. position = (this.quickData.routeId === "before") ? "true" : "false"
  381. }else{
  382. position = "false"; //默认为后加签
  383. }
  384. this.position = new MWF.ProcessFlow.widget.Radio2(this.positionArea, this.flow, {
  385. activeIcon: "o2icon-checkbox",
  386. optionList: [{
  387. text: this.lp.addTaskBefore,
  388. value: "true"
  389. },
  390. {
  391. text: this.lp.addTaskAfter,
  392. value: "false"
  393. }],
  394. value: position
  395. });
  396. this.position.load();
  397. },
  398. destroy: function () {
  399. if (this.node) this.node.empty();
  400. },
  401. loadOrg: function(){
  402. var quickData = this.quickData.organizations ? (this.quickData.organizations.default || [] ) : [];
  403. if( quickData.length ){
  404. this.orgData = quickData;
  405. this.orgContent.empty();
  406. this.loadOrgWidget(this.orgData, this.orgContent);
  407. }
  408. if(this.quickData.organizations)delete this.quickData.organizations.default;
  409. this.orgNode.addEvent("click", function () {
  410. this.getSelOptions( function (options) {
  411. options.values = this.orgData || [] ;
  412. setTimeout(function () {
  413. this.selector = new MWF.O2Selector($(document.body), options);
  414. }.bind(this), 100);
  415. }.bind(this) );
  416. }.bind(this));
  417. },
  418. getSelDefaultOptions: function(){
  419. var defaultOpt = {
  420. "type": "identity",
  421. "style": "default",
  422. "zIndex": 3000,
  423. "count": this.businessData.activity.resetCount || 0,
  424. "onComplete": function (items) {
  425. this.selectOnComplete(items);
  426. }.bind(this)
  427. };
  428. if (this.form.json.selectorStyle) {
  429. defaultOpt = Object.merge(Object.clone(this.form.json.selectorStyle), defaultOpt);
  430. if (this.form.json.selectorStyle.style) defaultOpt.style = this.form.json.selectorStyle.style;
  431. }
  432. return defaultOpt;
  433. },
  434. getSelOrgData: function () {
  435. return this.orgData ? this.orgData.map(function (item) {
  436. return typeOf( item ) === "string" ? item : item.distinguishedName;
  437. }) : [];
  438. },
  439. selectOnComplete: function (items) { //移动端才执行
  440. // var array = items.map(function (item) {
  441. // return item.data;
  442. // });
  443. // this.checkEmpower(array, function (data) {
  444. var values = items.map(function (item) {
  445. return MWF.org.parseOrgData(item.data, true, true)
  446. });
  447. this.orgData = values;
  448. this.orgContent.empty();
  449. this.loadOrgWidget(values, this.orgContent);
  450. this.selector = null;
  451. this.fireEvent("select", [items, values]);
  452. // }.bind(this))
  453. },
  454. loadOrgWidget: function (value, node) {
  455. var height = node.getStyle("height").toInt();
  456. if (node.getStyle("overflow") === "visible" && !height) node.setStyle("overflow", "hidden");
  457. if (value && value.length) {
  458. value.each(function (data) {
  459. if( typeOf(data) === "string" ){
  460. data = { distinguishedName : data, name : o2.name.cn(data) };
  461. }
  462. var flag = data.distinguishedName.substr(data.distinguishedName.length - 1, 1);
  463. var widget;
  464. switch (flag.toLowerCase()) {
  465. case "i":
  466. widget = new MWF.ProcessFlow.widget.O2IdentityMobile(data, node, this.getOrgWidgetOption());
  467. break;
  468. case "p":
  469. widget = MWF.ProcessFlow.widget.O2PersonMobile(data, node, this.getOrgWidgetOption());
  470. break;
  471. case "u":
  472. widget = new MWF.ProcessFlow.widget.O2UnitMobile(data, node, this.getOrgWidgetOption());
  473. break;
  474. case "g":
  475. widget = new MWF.ProcessFlow.widget.O2GroupMobile(data, node, this.getOrgWidgetOption());
  476. break;
  477. default:
  478. widget = new MWF.ProcessFlow.widget.O2OtherMobile(data, node, this.getOrgWidgetOption());
  479. }
  480. widget.field = this;
  481. widget.load();
  482. }.bind(this));
  483. }
  484. },
  485. getOrgWidgetOption: function(){
  486. return {
  487. "mainColorEnable": this.flow.options.mainColorEnable,
  488. "removeByClick": true,
  489. "style": "flowmobile",
  490. "canRemove": false,
  491. "lazy": true,
  492. "disableInfor" : true,
  493. "onRemove" : this.removeWidgetItem,
  494. // "onPostLoad": this.loadWidgetItem,
  495. "delay": true
  496. };
  497. },
  498. // loadWidgetItem: function(){
  499. // //this 是 MWF.widget.O2Identity 之类的对象
  500. // var _self = this.field; //这个才是field
  501. // var dn = this.data.distinguishedName;
  502. // if( _self.flow.options.mainColorEnable ){
  503. // this.node.addClass("mainColor_bg");
  504. // }
  505. // },
  506. removeWidgetItem : function( widget, ev ){
  507. debugger;
  508. //this 是 MWF.widget.O2Identity 之类的对象
  509. var _self = this.field; //这个才是field
  510. var dn = this.data.distinguishedName;
  511. var data = _self.orgData;
  512. var index;
  513. _self.orgData.each( function ( d , i){
  514. if( d.distinguishedName == dn ){
  515. index = i;
  516. }
  517. });
  518. _self.orgData.splice( index, 1 );
  519. this.node.destroy();
  520. ev.stopPropagation();
  521. },
  522. });
  523. MWF.ProcessFlow.GoBackMobile = new Class({
  524. Extends: MWF.ProcessFlow.GoBack,
  525. Implements: [Options, Events],
  526. options:{
  527. data: null,
  528. style: "default"
  529. },
  530. loadActivitys: function(){
  531. o2.Actions.load('x_processplatform_assemble_surface').WorkAction.V2ListActivityGoBack(this.task.work, function(json) {
  532. this.activitys = json.data;
  533. // this.activitys[0].lastIdentityList = this.activitys[0].lastIdentityList.concat(this.activitys[0].lastIdentityList);
  534. // this.activitys[0].lastIdentityList = this.activitys[0].lastIdentityList.concat(this.activitys[0].lastIdentityList);
  535. // this.activitys[0].lastIdentityList = this.activitys[0].lastIdentityList.concat(this.activitys[0].lastIdentityList);
  536. // this.activitys[0].lastIdentityList = this.activitys[0].lastIdentityList.concat(this.activitys[0].lastIdentityList);
  537. //
  538. // var act2 = Array.clone(this.activitys);
  539. // act2[0].way = "custom";
  540. // var act3 = Array.clone(this.activitys);
  541. // act3[0].way = "custom";
  542. // var act4 = Array.clone(this.activitys);
  543. // this.activitys = this.activitys.concat(act2, act3, act4);
  544. this.activitysArea.loadHtml(this.flow.path+this.flow.options.style+"/widget/gobackActivity.html",
  545. {"bind": {"lp": this.lp, "activityList":this.activitys}, "module": this},
  546. function(){
  547. if( this.activitys.length === 1 ){
  548. var el = this.activitysArea.getElement(".o2flow-section");
  549. this.check( el );
  550. }
  551. this.afterLoad();
  552. this.fireEvent("load");
  553. }.bind(this));
  554. }.bind(this));
  555. },
  556. loadWayRadio: function(ev, activityData){
  557. var wayRadio = new MWF.ProcessFlow.widget.Radio2(ev.target, this.flow, {
  558. activeIcon: "o2icon-checkbox",
  559. optionList: [{
  560. text: this.lp.goBackActivityWayStep,
  561. value: "step"
  562. },{
  563. text: this.lp.goBackActivityWayJump,
  564. value: "jump"
  565. }],
  566. value: "step", //默认为单人
  567. onLoad: function () {}
  568. });
  569. wayRadio.load();
  570. var parentNode = ev.target.getParent(".o2flow-section");
  571. parentNode.store("wayRadio", wayRadio);
  572. ev.target.hide();
  573. },
  574. loadIdentity: function(ev, activityData){
  575. var ids = activityData.lastIdentityList;
  576. if(ids.length>8){
  577. this.loadOrgWidget(ids.slice(0,8), ev.target);
  578. new Element("div.o2flow-identity-more", {
  579. text: "..."
  580. }).inject(ev.target);
  581. }else{
  582. this.loadOrgWidget(ids, ev.target);
  583. }
  584. },
  585. loadOrgWidget: function (value, node) {
  586. var height = node.getStyle("height").toInt();
  587. if (node.getStyle("overflow") === "visible" && !height) node.setStyle("overflow", "hidden");
  588. if (value && value.length) {
  589. value.each(function (data) {
  590. if( typeOf(data) === "string" ){
  591. data = { distinguishedName : data, name : o2.name.cn(data) };
  592. }
  593. var flag = data.distinguishedName.substr(data.distinguishedName.length - 1, 1);
  594. var widget;
  595. switch (flag.toLowerCase()) {
  596. case "i":
  597. widget = new MWF.ProcessFlow.widget.O2IdentityMobile(data, node, this.getOrgWidgetOption());
  598. break;
  599. case "p":
  600. widget = MWF.ProcessFlow.widget.O2PersonMobile(data, node, this.getOrgWidgetOption());
  601. break;
  602. case "u":
  603. widget = new MWF.ProcessFlow.widget.O2UnitMobile(data, node, this.getOrgWidgetOption());
  604. break;
  605. case "g":
  606. widget = new MWF.ProcessFlow.widget.O2GroupMobile(data, node, this.getOrgWidgetOption());
  607. break;
  608. default:
  609. widget = new MWF.ProcessFlow.widget.O2OtherMobile(data, node, this.getOrgWidgetOption());
  610. }
  611. widget.field = this;
  612. widget.load();
  613. }.bind(this));
  614. }
  615. },
  616. getOrgWidgetOption: function(){
  617. return {
  618. "mainColorEnable": this.flow.options.mainColorEnable,
  619. "removeByClick": false,
  620. "style": "flowmobile",
  621. "canRemove": false,
  622. "lazy": true,
  623. "disableInfor" : true,
  624. // "onPostLoad": this.loadWidgetItem,
  625. "delay": true
  626. };
  627. },
  628. showWayRadio: function(el){
  629. var parentNode = this.flow.getEl({target: el}, "o2flow-section");
  630. var wayRadio = parentNode.retrieve("wayRadio");
  631. if(wayRadio)wayRadio.container.show();
  632. },
  633. hideWayRadio: function(el){
  634. var parentNode = this.flow.getEl({target: el}, "o2flow-section");
  635. var wayRadio = parentNode.retrieve("wayRadio");
  636. if(wayRadio)wayRadio.container.hide();
  637. },
  638. toggle: function( ev ){
  639. var el = this.flow.getEl(ev, "o2flow-section");
  640. if( this.checkedItems.contains( el ) ){
  641. //if( this.options.cancelEnable )this.uncheck( el, true )
  642. }else{
  643. this.check( el );
  644. }
  645. },
  646. check: function(el){
  647. while( this.checkedItems.length ){
  648. this.uncheck( this.checkedItems[0] );
  649. }
  650. el.addClass("o2flow-section-active");
  651. if( this.flow.options.mainColorEnable )el.addClass("mainColor_color");
  652. el.getElement("i").removeClass("o2icon-icon_circle").addClass("o2icon-radio-checked").addClass("o2flow-radio2-icon");
  653. if( this.flow.options.mainColorEnable )el.getElement("i").addClass("mainColor_color");
  654. el.dataset["o2Checked"] = true;
  655. this.activitysArea.removeClass("o2flow-invalid-bg");
  656. this.checkedItems.push(el);
  657. this.showWayRadio(el);
  658. this.fireEvent("check", [el, el.dataset["o2Value"]])
  659. },
  660. uncheck: function(el, isFire){
  661. el.removeClass("o2flow-section-active");
  662. if( this.flow.options.mainColorEnable )el.removeClass("mainColor_color");
  663. el.getElement("i").removeClass("o2icon-radio-checked").addClass("o2icon-icon_circle").removeClass("o2flow-radio2-icon");
  664. if( this.flow.options.mainColorEnable )el.getElement("i").removeClass("mainColor_color");
  665. el.dataset["o2Checked"] = false;
  666. this.checkedItems.erase(el);
  667. this.hideWayRadio(el);
  668. if(isFire)this.fireEvent("uncheck", [el, el.dataset["o2Value"]])
  669. },
  670. });
  671. MWF.ProcessFlow.ProcessorMobile = new Class({
  672. Extends: MWF.ProcessFlow.Processor,
  673. Implements: [Options, Events],
  674. options: {
  675. "style": "default",
  676. "defaultRouteGroup": "",
  677. "defaultRoute": ""
  678. },
  679. initialize: function (container, flow, options) {
  680. this.setOptions(options);
  681. this.container = $(container);
  682. this.node = this.container;
  683. this.flow = flow;
  684. this.task = flow.task;
  685. this.form = flow.form;
  686. this.lp = flow.lp;
  687. this.businessData = this.form.businessData;
  688. this.routeOrgMap = {};
  689. },
  690. load: function( quickData ){
  691. this.quickData = quickData;
  692. if( quickData )quickData.rId = quickData.routeId;
  693. if( quickData && (quickData.routeId || quickData.routeName) ){
  694. this.options.defaultRoute = quickData.routeId || quickData.routeName;
  695. delete quickData.routeId;
  696. delete quickData.routeName;
  697. this.options.defaultRouteGroup = quickData.routeGroup;
  698. delete quickData.routeGroup;
  699. }
  700. this.container.loadHtml(this.flow.path+this.flow.options.style+"/process.html", {"bind": {"lp": this.lp}, "module": this}, function(){
  701. this.loadOpinion();
  702. this.loadRouteOrGroupList();
  703. //this.loadOrg();
  704. //this.afterLoad();
  705. }.bind(this));
  706. },
  707. checkLoadEvent: function(){
  708. if( !this.loadEventFired ){
  709. this.fireEvent("load");
  710. this.loadEventFired = true;
  711. }
  712. },
  713. setQuickData: function( quickData ){
  714. this.quickData = quickData;
  715. if(quickData)quickData.rId = quickData.routeId;
  716. if( this.routeGroupRadio && quickData.routeGroup ){
  717. if( quickData.routeId || quickData.routeName ){
  718. this.options.defaultRoute = quickData.routeId || quickData.routeName;
  719. delete quickData.routeId;
  720. delete quickData.routeName;
  721. }
  722. this.routeGroupRadio.setValue( quickData.routeGroup );
  723. delete quickData.routeGroup;
  724. }else{
  725. this.routeRadio.setValue( quickData.routeId );
  726. delete quickData.routeId;
  727. }
  728. if(this.opinion){
  729. this.opinion.setValue( quickData.opinion || "" );
  730. delete quickData.opinion;
  731. }
  732. //if(this.selector && this.selector.selector)this.selector.selector.setValues( data.organizations ? (data.organizations.default || []) : [] );
  733. },
  734. loadOpinion: function(){
  735. var opt = Object.clone(this.flow.options.opinionOptions);
  736. opt.isHandwriting = this.options.isHandwriting;
  737. if( this.quickData && this.quickData.opinion ){
  738. opt.opinion = this.quickData.opinion;
  739. delete this.quickData.opinion;
  740. }
  741. this.opinion = new MWF.ProcessFlow.widget.OpinionMobile( this.opinionContent, this.flow, opt );
  742. this.opinion.load();
  743. },
  744. loadRouteOrGroupList: function () {
  745. this.getRouteGroupConfig();
  746. if (this.hasRouteGroup) {
  747. this.loadRouteGroupList();
  748. } else {
  749. this.routeGroupWraper.destroy();
  750. this.loadRouteList();
  751. }
  752. },
  753. loadRouteGroupList: function(){
  754. var keys = this.routeGroupNameList;
  755. keys.sort(function (a, b) {
  756. var aIdx = parseInt(this.flow.splitByStartNumber(a).order || "9999999");
  757. var bIdx = parseInt(this.flow.splitByStartNumber(b).order || "9999999");
  758. return aIdx - bIdx;
  759. }.bind(this));
  760. var routeGroupNames = keys.map(function (k) { return this.flow.splitByStartNumber(k).name; }.bind(this));
  761. var defaultValue;
  762. if( keys.length === 1 ) {
  763. defaultValue = routeGroupNames[0];
  764. }else if( this.opinion.defaultRouteGroup ){
  765. defaultValue = this.opinion.defaultRouteGroup;
  766. this.opinion.defaultRouteGroup = "";
  767. }else if( this.options.defaultRoute ){
  768. routeGroupNames.each(function (routeGroupName) {
  769. if( defaultValue )return;
  770. var routeList = this.routeGroupObject[routeGroupName];
  771. var matchRoutes = routeList.filter(function(r){ return r.id === this.options.defaultRoute || r.name === this.options.defaultRoute; }.bind(this));
  772. if( matchRoutes.length )defaultValue = routeGroupName;
  773. }.bind(this));
  774. }
  775. var optionList = routeGroupNames.map(function (routeGroupName) {
  776. return {
  777. text: routeGroupName,
  778. value: routeGroupName,
  779. data: this.routeGroupObject[routeGroupName]
  780. };
  781. }.bind(this));
  782. var _self = this;
  783. this.routeGroupRadio = new MWF.ProcessFlow.widget.Radio2(this.routeGroupArea, this.flow, {
  784. optionList: optionList,
  785. cancelEnable: false,
  786. onCheck: function(el, value){
  787. var routeConfigList = this.getData().data;
  788. _self.loadRouteList( routeConfigList );
  789. },
  790. onLoad: function(){
  791. if( defaultValue ){
  792. this.setValue( defaultValue );
  793. }else{
  794. _self.loadOrgs();
  795. }
  796. }
  797. });
  798. this.routeGroupRadio.load();
  799. },
  800. loadRouteList: function (routeConfigList) {
  801. var _self = this;
  802. this.routeArea.empty();
  803. if (!routeConfigList) routeConfigList = this.getRouteConfigList();
  804. var optionList = [], isSelectedDefault = false, defaultRoute;
  805. routeConfigList.each(function (route, i) {
  806. if ( route.hiddenScriptText ) {
  807. if (this.form.Macro.exec(route.hiddenScriptText, this).toString() === "true") return;
  808. }
  809. var routeName = route.name;
  810. if (route.displayNameScriptText && this.form && this.form.Macro) {
  811. routeName = this.form.Macro.exec(route.displayNameScriptText, this);
  812. }
  813. optionList.push({
  814. value: route.id,
  815. text: routeName,
  816. data: route
  817. });
  818. if( route.id === this.options.defaultRoute || route.name === this.options.defaultRoute) {
  819. defaultRoute = route.id;
  820. this.options.defaultRoute = "";
  821. isSelectedDefault = true;
  822. }else if ( !isSelectedDefault && (routeConfigList.length == 1 || route.sole )) { //sole表示优先路由
  823. defaultRoute = route.id;
  824. }
  825. }.bind(this));
  826. this.routeRadio = new MWF.ProcessFlow.widget.Radio2(this.routeArea, this.flow, {
  827. optionList: optionList,
  828. activeIcon: "o2icon-checkbox",
  829. onCheck: function(el, value){
  830. var routeConfig = this.getData().data;
  831. var checkOpinion = function(){
  832. var op = _self.opinion.getValue();
  833. if( op === (_self.lastDefaultOpinion || "") || op === "" ){
  834. _self.lastDefaultOpinion = routeConfig.opinion || "";
  835. _self.opinion.setValue( _self.lastDefaultOpinion );
  836. }
  837. };
  838. if( _self.opinion.loaded ){
  839. checkOpinion()
  840. }else{
  841. _self.opinion.addEvent("load", checkOpinion);
  842. }
  843. _self.loadOrgs( routeConfig );
  844. },
  845. onUncheck: function(el, value){
  846. var routeConfig = this.getData( value ).data;
  847. var op = _self.opinion.getValue();
  848. if (op === (routeConfig.opinion || "") || op === "" ) {
  849. _self.lastDefaultOpinion = "";
  850. _self.opinion.setValue("");
  851. }
  852. _self.loadOrgs();
  853. },
  854. onLoad: function(){
  855. if( defaultRoute ){
  856. this.setValue( defaultRoute );
  857. }else{
  858. _self.loadOrgs();
  859. }
  860. }
  861. });
  862. this.routeRadio.load();
  863. },
  864. loadOrgs: function( routeConfig ){
  865. for( var r in this.routeOrgMap ){
  866. this.routeOrgMap[r].hide();
  867. }
  868. var notFireResize = !this.loadEventFired;
  869. if( routeConfig ){
  870. var routeId = routeConfig.id;
  871. var orgList = this.routeOrgMap[routeId];
  872. if( orgList ){
  873. orgList.load( notFireResize );
  874. }else{
  875. orgList = new MWF.ProcessFlow.Processor.OrgListMobile(this, {
  876. routeId: routeId
  877. });
  878. this.routeOrgMap[routeId] = orgList;
  879. orgList.load( notFireResize );
  880. }
  881. this.currentOrgList = orgList;
  882. }else{
  883. this.orgsWraper.hide();
  884. //this.setSize(0);
  885. if( !notFireResize )this.flow.resize();
  886. this.currentOrgList = null;
  887. }
  888. this.checkLoadEvent();
  889. },
  890. cancel: function(){
  891. this.destroy();
  892. this.fireEvent("cancel");
  893. },
  894. submit: function (ev) {
  895. if (this.hasRouteGroup && !this.routeGroupRadio.getValue() ) {
  896. this.routeGroupRadio.setRequireStyle();
  897. this.flow.noticeError(
  898. MWF.xApplication.process.Work.LP.mustSelectRouteGroup,
  899. this.routeGroupArea,
  900. null,
  901. {"x": "center", "y": "top"}
  902. );
  903. return false;
  904. }
  905. if (!this.routeRadio.getValue()) {
  906. this.routeRadio.setRequireStyle();
  907. this.flow.noticeError(
  908. MWF.xApplication.process.Work.LP.mustSelectRoute,
  909. this.routeArea,
  910. null, //{"x": 0, "y": 30}
  911. {"x": "center", "y": "top"}
  912. );
  913. return false;
  914. }
  915. var routeName = this.routeRadio.getData().data.name;
  916. var opinion = this.opinion.getValue();
  917. var medias = [];
  918. if (this.opinion.handwritingFile) medias.push(this.opinion.handwritingFile);
  919. var currentRouteId = this.routeRadio.getValue();
  920. var routeConfig = this.getRouteConfig(currentRouteId);
  921. if (!opinion && medias.length === 0) {
  922. if (routeConfig.opinionRequired === true) {
  923. this.opinion.setRequireStyle();
  924. this.flow.noticeError(
  925. MWF.xApplication.process.Work.LP.opinionRequired,
  926. this.opinion.opinionTextarea,
  927. null,
  928. {"x": "center", "y": "top"}
  929. );
  930. return false;
  931. }
  932. }
  933. var orgItems = this.currentOrgList ? this.currentOrgList.orgVisableItems : [];
  934. var appendTaskOrgItem = "";
  935. if (routeConfig.type === "appendTask" && routeConfig.appendTaskIdentityType === "select") {
  936. if (!orgItems || orgItems.length === 0) {
  937. this.flow.noticeError(
  938. MWF.xApplication.process.Work.LP.noAppendTaskIdentityConfig,
  939. this.node,
  940. null
  941. );
  942. return false;
  943. } else {
  944. appendTaskOrgItem = orgItems[0];
  945. }
  946. }
  947. this.currentOrgList.saveOrgsWithCheckEmpower(function () {
  948. var appandTaskIdentityList;
  949. if (appendTaskOrgItem) {
  950. appandTaskIdentityList = appendTaskOrgItem.getData();
  951. if (!appandTaskIdentityList || appandTaskIdentityList.length === 0) {
  952. this.flow.noticeError(
  953. MWF.xApplication.process.Work.LP.selectAppendTaskIdentityNotice,
  954. this.node
  955. );
  956. return;
  957. }
  958. }
  959. if (routeConfig.validationScriptText) {
  960. var validation = this.form.Macro.exec(routeConfig.validationScriptText, this);
  961. if (!validation || validation.toString() !== "true") {
  962. if (typeOf(validation) === "string") {
  963. this.flow.noticeError( validation, this.node );
  964. return false;
  965. } else {
  966. //"路由校验失败"
  967. this.flow.noticeError(
  968. MWF.xApplication.process.Work.LP.routeValidFailure,
  969. this.node
  970. );
  971. return false;
  972. }
  973. }
  974. }
  975. this.node.mask({
  976. "inject": {"where": "bottom", "target": this.node},
  977. "destroyOnHide": true,
  978. "style": {
  979. "background-color": "#999",
  980. "opacity": 0.3,
  981. "z-index": 600
  982. }
  983. });
  984. var array = [routeName, opinion, medias, appandTaskIdentityList, orgItems, function () {
  985. if (appendTaskOrgItem) appendTaskOrgItem.setData([]);
  986. }];
  987. this.fireEvent("submit", array);
  988. }.bind(this));
  989. },
  990. destroy: function () {
  991. Object.values( this.routeOrgMap ).each(function (orgList) {
  992. Object.values( orgList.orgMap ).each(function( org ){
  993. if(org.clearTooltip)org.clearTooltip();
  994. });
  995. });
  996. }
  997. });
  998. MWF.ProcessFlow.Processor.OrgListMobile = new Class({
  999. Extends: MWF.ProcessFlow.Processor.OrgList,
  1000. loadOrgs: function () {
  1001. var configVisable = this.getVisableOrgConfig(), len = configVisable.length, lineNode;
  1002. configVisable.each(function (config, i) {
  1003. var dom, cfgId = config.id, quickOrgData = this.getQuickOrgData( config );
  1004. //if( i % 2 === 0 )lineNode = new Element("div.o2flow-org-line").inject( this.node );
  1005. if( this.domMap[cfgId] ){
  1006. dom = this.domMap[cfgId].show().inject( this.node );
  1007. if( quickOrgData && this.orgMap[cfgId]){
  1008. var org = this.orgMap[cfgId];
  1009. org.container.empty();
  1010. org.setData( quickOrgData );
  1011. org.loadOrgWidget(quickOrgData, org.container);
  1012. //org.resetSelectorData();
  1013. }
  1014. this.orgVisableItems.push( this.orgMap[cfgId] );
  1015. }else{
  1016. dom = new Element("div.o2flow-org-node" ).inject( this.node );
  1017. this.domMap[cfgId] = dom;
  1018. this.loadOrg(dom, config, false, quickOrgData );
  1019. }
  1020. //lastDom = dom;
  1021. }.bind(this));
  1022. },
  1023. loadOrg: function (container, json, ignoreOldData, quickOrgData) {
  1024. var titleNode = new Element("div.o2flow-selector-title").inject(container);
  1025. new Element("div.o2flow-selector-titletext", { "text": json.title }).inject(titleNode);
  1026. var iconNode = new Element("div.o2flow-selector-icon").inject(titleNode);
  1027. new Element("i.o2icon-choose_people").inject(iconNode);
  1028. if( this.flow.options.mainColorEnable ){
  1029. iconNode.addClass("mainColor_color");
  1030. iconNode.addClass("mainColor_border");
  1031. }
  1032. var contentNode = new Element("div.o2flow-selector-content").inject(container);
  1033. var errorNode = new Element("div.o2flow-selector-errornode").inject(container);
  1034. var org = new MWF.ProcessFlow.Processor.OrgMobile(contentNode, this.form, json, this);
  1035. org.ignoreOldData = ignoreOldData;
  1036. org.errContainer = errorNode;
  1037. this.orgVisableItems.push(org);
  1038. this.orgMap[json.id] = org;
  1039. container.addEvent("click", function () {
  1040. org.load( quickOrgData );
  1041. });
  1042. var defaultValue = quickOrgData || org.getValue();
  1043. org.loadOrgWidget(defaultValue, contentNode);
  1044. },
  1045. getSelectedData: function (filedName) {
  1046. var data = [];
  1047. for (var i = 0; i < this.orgVisableItems.length; i++) {
  1048. var org = this.orgVisableItems[i];
  1049. if (org.json.name === filedName) {
  1050. data.push( org.getData() );
  1051. }
  1052. }
  1053. return data;
  1054. },
  1055. saveOrgsWithCheckEmpower: function (callback) {
  1056. var visableOrg = this.getVisableOrgConfig();
  1057. var needOrgLength = visableOrg.length;
  1058. var loadedOrgLength = 0;
  1059. if ( this.orgVisableItems && this.orgVisableItems.length)loadedOrgLength = this.orgVisableItems.length;
  1060. if( needOrgLength !== loadedOrgLength ){
  1061. this.flow.noticeError(
  1062. MWF.xApplication.process.Work.LP.loadedOrgCountUnexpected,
  1063. this.node
  1064. );
  1065. return false;
  1066. }
  1067. if (!this.orgVisableItems || !this.orgVisableItems.length) {
  1068. if (callback) callback();
  1069. return true;
  1070. }
  1071. if (!this.validationOrgs()) return false;
  1072. if (callback) callback();
  1073. }
  1074. });
  1075. MWF.ProcessFlow.Processor.OrgMobile = new Class({
  1076. Extends: MWF.ProcessFlow.Processor.Org,
  1077. load: function ( quickData ) {
  1078. var options = this.getOptions();
  1079. if (options) {
  1080. if( quickData )options.values = quickData;
  1081. setTimeout(function () {
  1082. this.selector = new MWF.O2Selector($(document.body), options);
  1083. }.bind(this), 100);
  1084. }
  1085. },
  1086. getDefaultOptions: function(){
  1087. return {
  1088. "style": "default",
  1089. "zIndex": 3000
  1090. };
  1091. },
  1092. getOptionEvents: function(){
  1093. return {
  1094. "onComplete": function (items) {
  1095. this.selectOnComplete(items);
  1096. }.bind(this),
  1097. "onCancel": this.selectOnCancel.bind(this),
  1098. "onClose": this.selectOnClose.bind(this)
  1099. };
  1100. },
  1101. selectOnComplete: function (items) { //移动端才执行
  1102. var array = [];
  1103. items.each(function (item) {
  1104. array.push(item.data);
  1105. }.bind(this));
  1106. var simple = this.json.storeRange === "simple";
  1107. this.checkEmpower(array, function (data) {
  1108. var values = [];
  1109. data.each(function (d) {
  1110. values.push(MWF.org.parseOrgData(d, true, simple));
  1111. }.bind(this));
  1112. this.setData(values);
  1113. this.container.empty();
  1114. this.loadOrgWidget(values, this.container);
  1115. this.selector = null;
  1116. this.fireEvent("select", [items, values]);
  1117. }.bind(this))
  1118. },
  1119. selectOnCancel: function () { //移动端才执行
  1120. //this.validation();
  1121. },
  1122. selectOnClose: function () {
  1123. var v = this._getBusinessData();
  1124. //if (!v || !v.length) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block");
  1125. },
  1126. getData: function () {
  1127. return this.getValue();
  1128. },
  1129. getSelectedData: function () {
  1130. return this.getValue();
  1131. },
  1132. getValue: function () {
  1133. var value = this._getBusinessData();
  1134. if (!value) value = this._computeValue();
  1135. return value || "";
  1136. },
  1137. loadOrgWidget: function (value, node) {
  1138. var height = node.getStyle("height").toInt();
  1139. if (node.getStyle("overflow") === "visible" && !height) node.setStyle("overflow", "hidden");
  1140. if (value && value.length) {
  1141. value.each(function (data) {
  1142. if( typeOf(data) === "string" ){
  1143. data = { distinguishedName : data, name : o2.name.cn(data) };
  1144. }
  1145. var flag = data.distinguishedName.substr(data.distinguishedName.length - 1, 1);
  1146. var copyData = Object.clone(data);
  1147. if (this.json.displayTextScript && this.json.displayTextScript.code) {
  1148. this.currentData = copyData;
  1149. var displayName = this.form.Macro.exec(this.json.displayTextScript.code, this);
  1150. if (displayName) {
  1151. copyData.displayName = displayName;
  1152. }
  1153. this.currentData = null;
  1154. }
  1155. var widget;
  1156. switch (flag.toLowerCase()) {
  1157. case "i":
  1158. widget = new MWF.ProcessFlow.widget.O2IdentityMobile(copyData, node, this.getOrgWidgetOption());
  1159. break;
  1160. case "p":
  1161. widget = new MWF.ProcessFlow.widget.O2PersonMobile(copyData, node, this.getOrgWidgetOption());
  1162. break;
  1163. case "u":
  1164. widget = new MWF.ProcessFlow.widget.O2UnitMobile(copyData, node, this.getOrgWidgetOption());
  1165. break;
  1166. case "g":
  1167. widget = new MWF.ProcessFlow.widget.O2GroupMobile(copyData, node, this.getOrgWidgetOption());
  1168. break;
  1169. default:
  1170. widget = new MWF.ProcessFlow.widget.O2OtherMobile(copyData, node, this.getOrgWidgetOption());
  1171. }
  1172. widget.field = this;
  1173. widget.load();
  1174. }.bind(this));
  1175. }
  1176. },
  1177. getOrgWidgetOption: function(){
  1178. return {
  1179. "mainColorEnable": this.processor.flow.options.mainColorEnable,
  1180. "removeByClick": true,
  1181. "style": "flowmobile",
  1182. "canRemove": false,
  1183. "lazy": true,
  1184. "disableInfor" : true,
  1185. "onRemove" : this.removeWidgetItem,
  1186. //"onPostLoad": this.loadWidgetItem,
  1187. "delay": true
  1188. };
  1189. },
  1190. // loadWidgetItem: function(){
  1191. // //this 是 MWF.widget.O2Identity 之类的对象
  1192. // var _self = this.field; //这个才是field
  1193. // var dn = this.data.distinguishedName;
  1194. // if( _self.processor.flow.options.mainColorEnable ){
  1195. // this.node.addClass("mainColor_bg");
  1196. // }
  1197. // },
  1198. removeWidgetItem : function( widget, ev ){
  1199. debugger;
  1200. //this 是 MWF.widget.O2Identity 之类的对象
  1201. var _self = this.field; //这个才是field
  1202. var dn = this.data.distinguishedName;
  1203. var data = _self._getBusinessData();
  1204. var index;
  1205. data.each( function ( d , i){
  1206. if( d.distinguishedName == dn ){
  1207. index = i
  1208. }
  1209. });
  1210. data.splice( index, 1 );
  1211. _self._setBusinessData( data );
  1212. this.node.destroy();
  1213. ev.stopPropagation();
  1214. },
  1215. });
  1216. MWF.ProcessFlow.widget.QuickSelectMobile = new Class({
  1217. Extends: MWF.ProcessFlow.widget.QuickSelect,
  1218. options: {
  1219. event : "click",
  1220. hasArrow : false,
  1221. hideByClickBody : true,
  1222. offset : {
  1223. x : 0,
  1224. y : 5
  1225. },
  1226. nodeStyles: {
  1227. "bottom": "0px",
  1228. "left": "0px",
  1229. "font-size" : "14px",
  1230. "position" : "absolute",
  1231. "max-width" : "100%",
  1232. "min-width" : "100%",
  1233. "height": "80%",
  1234. "z-index" : "1001",
  1235. "background-color" : "#fff",
  1236. "padding" : "0px",
  1237. "border-radius" : "15px 15px 0px 0px",
  1238. // "box-shadow": "0px 0px 8px 0px rgba(0,0,0,0.25)",
  1239. // "-webkit-user-select": "text",
  1240. // "-moz-user-select": "text"
  1241. }
  1242. },
  1243. _loadCustom : function( callback ){
  1244. this.node.loadCss( this.flow.path + this.flow.options.style + "/style.css" );
  1245. // var width = this.target.getSize().x ;
  1246. // this.node.setStyles({
  1247. // "max-width": width+"px",
  1248. // "min-width": width+"px"
  1249. // });
  1250. new Element("div.o2flow-quick-title", {
  1251. text: this.flow.lp.quickSelect
  1252. }).inject(this.contentNode);
  1253. var scrollNode = new Element("div.o2flow-quick-scroll").inject(this.contentNode);
  1254. this.quickNode = new Element("div.o2flow-quick-node").inject(scrollNode);
  1255. debugger;
  1256. var work = this.flow.form.businessData.work;
  1257. var d = {
  1258. process: work.process,
  1259. activity: work.activity,
  1260. activityAlias: work.activityAlias,
  1261. activityName: work.activityName
  1262. };
  1263. // if( work.activityAlias ){
  1264. // d.activityAlias = work.activityAlias
  1265. // }else{
  1266. // d.activityName = work.activityName;
  1267. // }
  1268. var p = o2.Actions.load("x_processplatform_assemble_surface").TaskProcessModeAction.listMode( d );
  1269. Promise.resolve(p).then(function (json) {
  1270. debugger;
  1271. var list = this.filterData(json.data);
  1272. var data = list.map(function (d) {
  1273. return {
  1274. type: d.action,
  1275. text: this.getText( d ),
  1276. data: d
  1277. }
  1278. }.bind(this));
  1279. if( !data || !data.length ){
  1280. new Element("div.o2flow-quick-select-item", {
  1281. text: this.flow.lp.noQuickSelectDataNote
  1282. }).inject( this.quickNode );
  1283. }else{
  1284. this.loadItems(data)
  1285. }
  1286. //setTimeout( function () {
  1287. if(callback)callback( data );
  1288. //}, 50);
  1289. }.bind(this));
  1290. },
  1291. loadItems: function(data){
  1292. var _self = this;
  1293. data.each( function (d) {
  1294. var item = new Element("div.o2flow-quick-select-item", {
  1295. events: {
  1296. mouseover: function () {
  1297. this.addClass("o2flow-quick-select-item-active");
  1298. this.getFirst().addClass("o2flow-quick-select-item-contnet-active");
  1299. if( _self.flow.options.mainColorEnable ){
  1300. this.addClass("mainColor_bg");
  1301. this.getFirst().addClass("mainColor_bg");
  1302. }
  1303. },
  1304. mouseout: function () {
  1305. this.removeClass("o2flow-quick-select-item-active");
  1306. this.getFirst().removeClass("o2flow-quick-select-item-contnet-active");
  1307. if( _self.flow.options.mainColorEnable ) {
  1308. this.removeClass("mainColor_bg");
  1309. this.getFirst().removeClass("mainColor_bg");
  1310. }
  1311. },
  1312. click: function () {
  1313. var d = Object.clone( item.retrieve("data"));
  1314. _self.flow.changeAction( d.type, d.data );
  1315. _self.hide();
  1316. }
  1317. }
  1318. }).inject( this.quickNode );
  1319. item.store( "data", d );
  1320. var title = new Element("div.o2flow-quick-select-itemtitle", {
  1321. text: this.flow.lp.flowActions[d.type]
  1322. }).inject( item );
  1323. title.addClass( "o2flow-"+d.type+"-color" );
  1324. var content = new Element("div.o2flow-quick-select-itemtext", {
  1325. text: ":"+ d.text
  1326. }).inject( item )
  1327. }.bind(this))
  1328. }
  1329. });
  1330. MWF.ProcessFlow.widget.OpinionMobile = new Class({
  1331. Extends: MWF.ProcessFlow.widget.Opinion,
  1332. Implements: [Options, Events],
  1333. handwriting: function(){
  1334. window.setTimeout(function () {
  1335. this._handwriting();
  1336. }.bind(this), 100)
  1337. },
  1338. _handwriting: function () {
  1339. if( !this.tablet )this.createHandwriting();
  1340. this.handwritingMask.show();
  1341. this.handwritingNode.show();
  1342. this.handwritingNode.setStyles({
  1343. "top": "0px",
  1344. "left": "0px"
  1345. });
  1346. },
  1347. createHandwriting: function () {
  1348. this.handwritingMask.inject( $(document.body) );
  1349. this.handwritingNode.show().inject(this.handwritingMask, "after");
  1350. //兼容以前的默认高宽
  1351. var bodySize = $(document.body).getSize();
  1352. var x = bodySize.x;
  1353. var y = bodySize.y;
  1354. this.options.tabletWidth = 0;
  1355. this.options.tabletHeight = 0;
  1356. var zidx = this.flow.node.getStyle("z-index");
  1357. this.handwritingNode.setStyles({
  1358. "height": "" + y + "px",
  1359. "width": "" + x + "px",
  1360. "z-index": zidx + 1
  1361. });
  1362. this.handwritingNode.addEvent('touchmove', function (e) {
  1363. e.preventDefault();
  1364. });
  1365. this.handwritingNode.setStyles({
  1366. "top": "0px",
  1367. "left": "0px"
  1368. });
  1369. this.handwritingAreaNode.setStyle("height", "" + y + "px");
  1370. MWF.require("MWF.widget.Tablet", function () {
  1371. var handWritingOptions = this.getHandWritingOptions();
  1372. handWritingOptions.tools = [
  1373. "undo",
  1374. "redo", "|",
  1375. "reset", "|",
  1376. "size",
  1377. "cancel"
  1378. ];
  1379. this.tablet = new MWF.widget.Tablet(this.handwritingAreaNode, handWritingOptions, null);
  1380. this.tablet.load();
  1381. }.bind(this));
  1382. }
  1383. });
  1384. MWF.ProcessFlow.widget.O2IdentityMobile = new Class({
  1385. Extends: o2.widget.O2Identity,
  1386. setText: function(){
  1387. var disply;
  1388. if( this.data.displayName ){
  1389. disply = this.data.displayName;
  1390. }else{
  1391. disply = this.data.name || o2.name.cn(this.data.distinguishedName)
  1392. // var name = this.data.name || o2.name.cn(this.data.distinguishedName);
  1393. // var unit;
  1394. // if(this.data.unitName){
  1395. // unit = this.data.unitName;
  1396. // }else if( this.data.unitLevelName ){
  1397. // var list = this.data.unitLevelName.split("/");
  1398. // unit = list[ list.length - 1 ];
  1399. // }
  1400. // disply = name + (unit ? "("+unit+")" : "")
  1401. }
  1402. this.textNode.set("text", disply );
  1403. },
  1404. load: function(){
  1405. this.fireEvent("queryLoad");
  1406. if (!this.options.lazy && !this.options.disableInfor) this.getPersonData();
  1407. this.node = new Element("div.o2flow-identity").inject(this.container);
  1408. this.iconNode = new Element("img.o2flow-identity-icon", {
  1409. src: o2.filterUrl(o2.Actions.get("x_organization_assemble_control").getPersonIcon(this.data.distinguishedName))
  1410. }).inject(this.node);
  1411. this.textNode = new Element("div.o2flow-identity-text").inject(this.node);
  1412. this.setText();
  1413. if( this.options.removeByClick ){
  1414. this.node.addEvent("click", function(e){
  1415. this.fireEvent("remove", [this, e]);
  1416. e.stopPropagation();
  1417. }.bind(this));
  1418. }
  1419. if (this.options.canRemove){
  1420. this.removeNode = new Element("div", {"styles": this.style.identityRemoveNode}).inject(this.node);
  1421. this.removeNode.addEvent("click", function(e){
  1422. this.fireEvent("remove", [this, e]);
  1423. e.stopPropagation();
  1424. }.bind(this));
  1425. }
  1426. this.setEvent();
  1427. this.fireEvent("postLoad");
  1428. },
  1429. });
  1430. MWF.ProcessFlow.widget.O2PersonMobile = new Class({
  1431. Extends: MWF.ProcessFlow.widget.O2IdentityMobile
  1432. })
  1433. MWF.ProcessFlow.widget.O2UnitMobile = new Class({
  1434. Extends: MWF.ProcessFlow.widget.O2IdentityMobile,
  1435. load: function(){
  1436. this.fireEvent("queryLoad");
  1437. this.getPersonData( function () {
  1438. this.node = new Element("div.o2flow-unit").inject(this.container);
  1439. this.iconNode = new Element("div.o2flow-unit-icon", {
  1440. text: this.data.name.substr(0,1)
  1441. }).inject(this.node);
  1442. if( this.options.mainColorEnable )this.iconNode.addClass("mainColor_bg");
  1443. this.textNode = new Element("div.o2flow-unit-text").inject(this.node);
  1444. this.nameNode = new Element("div.o2flow-unit-name").inject(this.textNode);
  1445. this.levelNameNode = new Element("div.o2flow-unit-levelname").inject(this.textNode);
  1446. this.setText();
  1447. if( this.options.removeByClick ){
  1448. this.node.addEvent("click", function(e){
  1449. this.fireEvent("remove", [this, e]);
  1450. e.stopPropagation();
  1451. }.bind(this));
  1452. }
  1453. if (this.options.canRemove){
  1454. this.removeNode = new Element("div", {"styles": this.style.identityRemoveNode}).inject(this.node);
  1455. this.removeNode.addEvent("click", function(e){
  1456. this.fireEvent("remove", [this, e]);
  1457. e.stopPropagation();
  1458. }.bind(this));
  1459. }
  1460. this.setEvent();
  1461. this.fireEvent("postLoad");
  1462. }.bind(this));
  1463. },
  1464. getPersonData: function( callback ){
  1465. if (!this.data.distinguishedName || !this.data.levelName){
  1466. this.action.actions = {"getUnit": {"uri": "/jaxrs/unit/{id}"}};
  1467. this.action.invoke({"name": "getUnit", "async": false, "parameter": {"id": (this.data.id || this.data.distinguishedName || this.data.name)}, "success": function(json){
  1468. this.data = json.data;
  1469. if(callback)callback();
  1470. }.bind(this)});
  1471. }else{
  1472. if(callback)callback();
  1473. }
  1474. },
  1475. setText: function(){
  1476. var disply;
  1477. if( this.data.displayName ){
  1478. disply = this.data.displayName;
  1479. }else{
  1480. disply = this.data.name || o2.name.cn(this.data.distinguishedName)
  1481. }
  1482. this.nameNode.set("text", disply );
  1483. this.levelNameNode.set("text", this.data.levelName);
  1484. },
  1485. })
  1486. MWF.ProcessFlow.widget.O2GroupMobile = new Class({
  1487. Extends: MWF.ProcessFlow.widget.O2UnitMobile,
  1488. load: function(){
  1489. this.fireEvent("queryLoad");
  1490. this.getPersonData( function () {
  1491. this.node = new Element("div.o2flow-unit").inject(this.container);
  1492. this.iconNode = new Element("div.o2flow-unit-icon", {
  1493. text: this.data.name.substr(0,1)
  1494. }).inject(this.node);
  1495. if( this.options.mainColorEnable )this.iconNode.addClass("mainColor_bg");
  1496. this.textNode = new Element("div.o2flow-group-text").inject(this.node);
  1497. this.nameNode = new Element("div.o2flow-unit-name").inject(this.textNode);
  1498. //this.levelNameNode = new Element("div.o2flow-unit-levelname").inject(this.textNode);
  1499. this.setText();
  1500. if( this.options.removeByClick ){
  1501. this.node.addEvent("click", function(e){
  1502. this.fireEvent("remove", [this, e]);
  1503. e.stopPropagation();
  1504. }.bind(this));
  1505. }
  1506. if (this.options.canRemove){
  1507. this.removeNode = new Element("div", {"styles": this.style.identityRemoveNode}).inject(this.node);
  1508. this.removeNode.addEvent("click", function(e){
  1509. this.fireEvent("remove", [this, e]);
  1510. e.stopPropagation();
  1511. }.bind(this));
  1512. }
  1513. this.setEvent();
  1514. this.fireEvent("postLoad");
  1515. }.bind(this));
  1516. },
  1517. getPersonData: function(callback){
  1518. if (!this.data.distinguishedName){
  1519. this.action.actions = {"getGroup": {"uri": "/jaxrs/group/{id}"}};
  1520. this.action.invoke({"name": "getGroup", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  1521. this.data = json.data;
  1522. if(callback)callback();
  1523. }.bind(this)});
  1524. }else{
  1525. if(callback)callback();
  1526. }
  1527. },
  1528. setText: function(){
  1529. var disply;
  1530. if( this.data.displayName ){
  1531. disply = this.data.displayName;
  1532. }else{
  1533. disply = this.data.name || o2.name.cn(this.data.distinguishedName)
  1534. }
  1535. this.nameNode.set("text", disply );
  1536. //this.levelNameNode.set("text", this.data.levelName);
  1537. },
  1538. })
  1539. MWF.ProcessFlow.widget.O2OtherMobile = new Class({
  1540. Extends: MWF.ProcessFlow.widget.O2GroupMobile,
  1541. getPersonData: function(){
  1542. return this.data;
  1543. }
  1544. });