Processor.js 122 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953
  1. MWF.xApplication.process = MWF.xApplication.process || {};
  2. MWF.xApplication.process.Work = MWF.xApplication.process.Work || {};
  3. MWF.xDesktop.requireApp("process.Work", "lp." + MWF.language, null, false);
  4. MWF.xApplication.process.Work.Processor = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "mediaNode": null,
  10. "opinion": "",
  11. "tabletWidth": 0,
  12. "tabletHeight": 0,
  13. "orgHeight": 276,
  14. "maxOrgCountPerline": 2,
  15. "isManagerProcess": false //是否为管理员提交
  16. },
  17. initialize: function (node, task, options, form) {
  18. this.setOptions(options);
  19. this.path = "../x_component_process_Work/$Processor/";
  20. this.cssPath = "../x_component_process_Work/$Processor/" + this.options.style + "/css.wcss";
  21. this._loadCss();
  22. this.task = task;
  23. this.node = $(node);
  24. this.selectedRoute = null;
  25. this.form = form;
  26. this.load();
  27. },
  28. load: function () {
  29. if (layout.mobile) {
  30. this.content = new Element("div").inject(this.node);
  31. } else {
  32. this.content = this.node;
  33. }
  34. if (!this.form && this.options.isManagerProcess) {
  35. this.managerProcessNoticeNode = new Element("div", {
  36. "styles": this.css.managerProcessNoticeNode,
  37. "html": MWF.xApplication.process.Work.LP.managerProcessNotice
  38. }).inject(this.content);
  39. this.managerLoginNode = new Element("div", {
  40. "styles": this.css.managerLoginNode,
  41. "text": MWF.xApplication.process.Work.LP.managerLogin
  42. }).inject(this.content);
  43. this.managerLoginNode.addEvent("click", function (ev) {
  44. this.managerLogin(ev);
  45. }.bind(this));
  46. //var text = MWF.xApplication.process.Work.LP.managerLoginReturn.replace( "{user}", layout.session.user.name );
  47. //this.managerLoginReturnNode = new Element("div", {"styles": this.css.managerLoginNode, "text": text }).inject(this.content);
  48. //this.managerLoginReturnNode.hide();
  49. //this.managerPerson = layout.session.user.distinguishedName;
  50. //this.managerLoginReturnNode.addEvent("click", function(ev){
  51. // this.managerLoginReturn(ev);
  52. //}.bind(this))
  53. }
  54. this.routeOpinionTile = new Element("div", {
  55. "styles": this.css.routeOpinionTile,
  56. "text": MWF.xApplication.process.Work.LP.inputOpinion
  57. }).inject(this.content);
  58. this.routeOpinionArea = new Element("div", {"styles": this.css.routeOpinionArea}).inject(this.content);
  59. this.setOpinion();
  60. if (this.form) {
  61. if (layout.mobile) {
  62. this.orgsArea = new Element("div", {"styles": this.css.orgsArea}).inject(this.content);
  63. this.orgsTile = new Element("div", {
  64. "styles": this.css.orgsTitle,
  65. "text": MWF.xApplication.process.Work.LP.selectPerson
  66. }).inject(this.orgsArea);
  67. this.orgsArea.hide();
  68. } else {
  69. this.orgsArea = new Element("div", {"styles": this.css.orgsArea}).inject(this.content);
  70. this.orgsTile = new Element("div", {
  71. "styles": this.css.orgsTitle,
  72. "text": MWF.xApplication.process.Work.LP.selectPerson
  73. }).inject(this.orgsArea);
  74. }
  75. }
  76. if (layout.mobile) {
  77. this.buttonsArea = new Element("div", {"styles": this.css.buttonsArea}).inject(this.node);
  78. } else {
  79. this.buttonsArea = new Element("div", {"styles": this.css.buttonsArea}).inject(this.content);
  80. }
  81. this.setButtons();
  82. if (this.form) {
  83. if (layout.mobile) {
  84. this.getRouteGroupList();
  85. if (this.hasDecisionOpinion) {
  86. this.routeContainer = new Element("div", {
  87. "styles": this.css.routeContainer
  88. }).inject(this.routeOpinionTile, "before");
  89. this.routeGroupTitle = new Element("div", {
  90. "styles": this.css.routeSelectorTile,
  91. "text": MWF.xApplication.process.Work.LP.selectRouteGroup
  92. }).inject(this.routeContainer);
  93. this.routeGroupArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeContainer);
  94. this.routeSelectorTile = new Element("div", {
  95. "styles": this.css.routeSelectorTile,
  96. "text": MWF.xApplication.process.Work.LP.selectRoute
  97. }).inject(this.routeContainer);
  98. this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeContainer);
  99. this.setRouteGroupList();
  100. } else {
  101. this.routeSelectorTile = new Element("div", {
  102. "styles": this.css.routeSelectorTile,
  103. "text": MWF.xApplication.process.Work.LP.selectRoute
  104. }).inject(this.routeOpinionTile, "before");
  105. this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeSelectorTile, "after");
  106. this.setRouteList();
  107. }
  108. } else {
  109. this.getRouteGroupList();
  110. if (this.hasDecisionOpinion) {
  111. //if( this.getMaxOrgLength() > 1 ){
  112. this.routeContainer = new Element("div", {
  113. "styles": this.css.routeContainer
  114. }).inject(this.routeOpinionTile, "before");
  115. this.routeLeftWarper = new Element("div", {
  116. "styles":
  117. this.getMaxOrgLength() > 1 ? this.css.routeLeftWarper : this.css.routeLeftWarper_single
  118. }).inject(this.routeContainer);
  119. this.routeGroupTitle = new Element("div", {
  120. "styles": this.css.routeSelectorTile,
  121. "text": MWF.xApplication.process.Work.LP.selectRouteGroup
  122. }).inject(this.routeLeftWarper);
  123. this.routeGroupArea = new Element("div", {"styles": this.css.routeSelectorArea_hasGroup}).inject(this.routeLeftWarper);
  124. this.routeRightWarper = new Element("div", {
  125. "styles":
  126. this.getMaxOrgLength() > 1 ? this.css.routeRightWarper : this.css.routeRightWarper_single
  127. }).inject(this.routeContainer);
  128. this.routeSelectorTile = new Element("div", {
  129. "styles": this.css.routeSelectorTile,
  130. "text": MWF.xApplication.process.Work.LP.selectRoute
  131. }).inject(this.routeRightWarper);
  132. this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea_hasGroup}).inject(this.routeRightWarper);
  133. this.setRouteGroupList();
  134. //}else{
  135. // this.routeGroupTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute }).inject(this.routeOpinionTile, "before");
  136. // this.routeGroupArea = new Element("div", {"styles": this.css.routeSelectorArea_hasGroup_wide }).inject(this.routeGroupTile, "after");
  137. // this.setRouteGroupList();
  138. //}
  139. } else {
  140. this.routeSelectorTile = new Element("div", {
  141. "styles": this.css.routeSelectorTile,
  142. "text": MWF.xApplication.process.Work.LP.selectRoute
  143. }).inject(this.routeOpinionTile, "before");
  144. this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeSelectorTile, "after");
  145. this.setRouteList();
  146. }
  147. }
  148. } else { //快速处理
  149. this.routeSelectorTile = new Element("div", {
  150. "styles": this.css.routeSelectorTile,
  151. "text": MWF.xApplication.process.Work.LP.selectRoute
  152. }).inject(this.routeOpinionTile, "before");
  153. this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeSelectorTile, "after");
  154. this.setRouteList_noform();
  155. this.setSize_noform();
  156. }
  157. this.fireEvent("postLoad");
  158. },
  159. getRouteGroupList: function () {
  160. if (this.routeGroupObject) return this.routeGroupObject;
  161. this.routeGroupObject = {};
  162. this.routeGroupNameList = [];
  163. this.hasDecisionOpinion = false;
  164. var routeList = this.getRouteDataList();
  165. routeList.each(function (route, i) {
  166. if (route.hiddenScriptText && this.form && this.form.Macro) { //如果隐藏路由,返回
  167. if (this.form.Macro.exec(route.hiddenScriptText, this).toString() === "true") return;
  168. }
  169. if (route.displayNameScriptText && this.form && this.form.Macro) { //如果有显示名称公式
  170. route.displayName = this.form.Macro.exec(route.displayNameScriptText, this);
  171. } else {
  172. route.displayName = route.name;
  173. }
  174. if (route.decisionOpinion) {
  175. this.hasDecisionOpinion = true;
  176. var decisionOpinionList = route.decisionOpinion.split("#");
  177. decisionOpinionList.each(function (decisionOption) {
  178. this.routeGroupNameList.combine([decisionOption]);
  179. var d = this.splitByStartNumber(decisionOption);
  180. if (!this.routeGroupObject[d.name]) this.routeGroupObject[d.name] = [];
  181. this.routeGroupObject[d.name].push(route);
  182. }.bind(this))
  183. } else {
  184. var defaultName = MWF.xApplication.process.Work.LP.defaultDecisionOpinionName;
  185. this.routeGroupNameList.combine([defaultName]);
  186. if (!this.routeGroupObject[defaultName]) this.routeGroupObject[defaultName] = [];
  187. this.routeGroupObject[defaultName].push(route);
  188. }
  189. }.bind(this));
  190. return this.routeGroupObject;
  191. },
  192. splitByStartNumber: function (str) {
  193. var obj = {
  194. name: "",
  195. order: ""
  196. };
  197. for (var i = 0; i < str.length; i++) {
  198. if (parseInt(str.substr(i, 1)).toString() !== "NaN") {
  199. obj.order = obj.order + str.substr(i, 1);
  200. } else {
  201. obj.name = str.substr(i, str.length);
  202. break;
  203. }
  204. }
  205. return obj;
  206. },
  207. setRouteGroupList: function () {
  208. var _self = this;
  209. //var keys = Object.keys( this.routeGroupObject );
  210. //var length = keys.length;
  211. //var sortArray = MWF.xApplication.process.Work.LP.routeGroupOrderList;
  212. //keys.sort( function( a, b ){
  213. // var aIdx = sortArray.indexOf(a);
  214. // var bIdx = sortArray.indexOf(b);
  215. // if( aIdx === -1 )aIdx = sortArray.length;
  216. // if( bIdx === -1 )aIdx = sortArray.length;
  217. // return aIdx - bIdx;
  218. //});
  219. var keys = this.routeGroupNameList;
  220. keys.sort(function (a, b) {
  221. var aIdx = parseInt(this.splitByStartNumber(a).order || "9999999");
  222. var bIdx = parseInt(this.splitByStartNumber(b).order || "9999999");
  223. return aIdx - bIdx;
  224. }.bind(this));
  225. var list = [];
  226. keys.each(function (k) {
  227. list.push(this.splitByStartNumber(k).name)
  228. }.bind(this));
  229. var flag = false;
  230. list.each(function (routeGroupName) {
  231. var routeList = this.routeGroupObject[routeGroupName];
  232. var routeGroupNode = new Element("div", {
  233. "styles": this.css.routeGroupNode,
  234. "text": routeGroupName
  235. }).inject(this.routeGroupArea);
  236. routeGroupNode.store("routeList", routeList);
  237. routeGroupNode.store("routeGroupName", routeGroupName);
  238. routeGroupNode.addEvents({
  239. "mouseover": function (e) {
  240. _self.overRouteGroup(this);
  241. },
  242. "mouseout": function (e) {
  243. _self.outRouteGroup(this);
  244. },
  245. "click": function (e) {
  246. _self.selectRouteGroup(this);
  247. }
  248. });
  249. if (keys.length === 1) {
  250. this.selectRouteGroup(routeGroupNode);
  251. flag = false;
  252. } else {
  253. flag = true;
  254. }
  255. }.bind(this))
  256. if (flag) {
  257. this.setSize(0);
  258. }
  259. },
  260. overRouteGroup: function (node) {
  261. if (this.selectedRouteGroup) {
  262. if (this.selectedRouteGroup.get("text") != node.get("text")) {
  263. node.setStyles(this.css.routeGroupNode_over);
  264. }
  265. } else {
  266. node.setStyles(this.css.routeGroupNode_over);
  267. }
  268. },
  269. outRouteGroup: function (node) {
  270. if (this.selectedRouteGroup) {
  271. if (this.selectedRouteGroup.get("text") != node.get("text")) {
  272. node.setStyles(this.css.routeGroupNode);
  273. }
  274. } else {
  275. node.setStyles(this.css.routeGroupNode);
  276. }
  277. },
  278. selectRouteGroup: function (node) {
  279. if (this.selectedRouteGroup) {
  280. if (this.selectedRouteGroup.get("text") != node.get("text")) {
  281. this.selectedRouteGroup.setStyles(this.css.routeGroupNode);
  282. //this.selectedRouteGroup.removeClass("mainColor_bg");
  283. this.selectedRouteGroup = node;
  284. this.selectedRouteGroup.setStyles(this.css.routeGroupNode_selected);
  285. //this.selectedRouteGroup.addClass("mainColor_bg");
  286. var routeList = this.selectedRouteGroup.retrieve("routeList");
  287. this.setRouteList(routeList);
  288. } else {
  289. //this.selectedRouteGroup.setStyles(this.css.routeNode);
  290. //this.selectedRouteGroup.getFirst().setStyles(this.css.routeIconNode);
  291. //this.selectedRouteGroup.getLast().setStyles(this.css.routeTextNode);
  292. //
  293. //this.selectedRouteGroup = null;
  294. }
  295. } else {
  296. this.selectedRouteGroup = node;
  297. node.setStyles(this.css.routeGroupNode_selected);
  298. //this.selectedRouteGroup.addClass("mainColor_bg");
  299. var routeList = this.selectedRouteGroup.retrieve("routeList");
  300. this.setRouteList(routeList);
  301. }
  302. this.routeGroupArea.setStyle("background-color", "#FFF");
  303. },
  304. setRouteList_noform: function (routeList) {
  305. var _self = this;
  306. this.routeSelectorArea.empty();
  307. this.selectedRoute = null;
  308. //this.task.routeNameList = ["送审核", "送办理", "送公司领导阅"];
  309. if (!routeList) routeList = this.getRouteDataList();
  310. routeList.each(function (route, i) {
  311. var routeName = route.name;
  312. var routeNode = new Element("div", {
  313. "styles": this.css.routeNode,
  314. "text": routeName
  315. }).inject(this.routeSelectorArea);
  316. routeNode.store("route", route.id);
  317. routeNode.store("routeName", route.name);
  318. routeNode.addEvents({
  319. "mouseover": function (e) {
  320. _self.overRoute(this);
  321. },
  322. "mouseout": function (e) {
  323. _self.outRoute(this);
  324. },
  325. "click": function (e) {
  326. _self.selectRoute_noform(this);
  327. }
  328. });
  329. if (routeList.length == 1 || route.sole) {
  330. this.selectRoute_noform(routeNode);
  331. }
  332. }.bind(this));
  333. },
  334. setRouteList: function (routeList) {
  335. var _self = this;
  336. //if( this.hasDecisionOpinion && this.getMaxOrgLength() === 1 ){
  337. // if( this.routeSelectorArea )this.routeSelectorArea.destroy();
  338. // this.routeSelectorArea = new Element("div", { styles : this.css.routeSelectorArea_hasGroup_single }).inject( this.selectedRouteGroup, "after" );
  339. //}else{
  340. this.routeSelectorArea.empty();
  341. //}
  342. this.selectedRoute = null;
  343. //this.task.routeNameList = ["送审核", "送办理", "送公司领导阅"];
  344. if (!routeList) routeList = this.getRouteDataList();
  345. //this.task.routeNameList.each(function(route, i){
  346. var isSelected = false;
  347. routeList.each(function (route, i) {
  348. if (route.hiddenScriptText && this.form && this.form.Macro) {
  349. if (this.form.Macro.exec(route.hiddenScriptText, this).toString() === "true") return;
  350. }
  351. var routeName = route.name;
  352. if (route.displayNameScriptText && this.form && this.form.Macro) {
  353. routeName = this.form.Macro.exec(route.displayNameScriptText, this);
  354. }
  355. var routeNode = new Element("div", {
  356. "styles": this.css.routeNode,
  357. "text": routeName
  358. }).inject(this.routeSelectorArea);
  359. //var routeIconNode = new Element("div", {"styles": this.css.routeIconNode}).inject(routeNode);
  360. //var routeTextNode = new Element("div", {"styles": this.css.routeTextNode, "text": routeName}).inject(routeNode);
  361. routeNode.store("route", route.id);
  362. routeNode.store("routeName", route.name);
  363. routeNode.addEvents({
  364. "mouseover": function (e) {
  365. _self.overRoute(this);
  366. },
  367. "mouseout": function (e) {
  368. _self.outRoute(this);
  369. },
  370. "click": function (e) {
  371. _self.selectRoute(this);
  372. }
  373. });
  374. if (routeList.length == 1 || route.sole) { //sole表示优先路由
  375. this.selectRoute(routeNode);
  376. isSelected = true;
  377. }
  378. }.bind(this));
  379. if (!isSelected) {
  380. this.setSize(0);
  381. }
  382. },
  383. overRoute: function (node) {
  384. if (this.selectedRoute) {
  385. if (this.selectedRoute.get("text") != node.get("text")) {
  386. node.setStyles(this.css.routeNode_over);
  387. node.addClass("lightColor_bg");
  388. //node.setStyle("background-color", "#f7e1d0");
  389. }
  390. } else {
  391. node.setStyles(this.css.routeNode_over);
  392. node.addClass("lightColor_bg");
  393. }
  394. },
  395. outRoute: function (node) {
  396. if (this.selectedRoute) {
  397. if (this.selectedRoute.get("text") != node.get("text")) {
  398. node.setStyles(this.css.routeNode);
  399. node.removeClass("lightColor_bg");
  400. }
  401. } else {
  402. node.setStyles(this.css.routeNode);
  403. node.removeClass("lightColor_bg");
  404. }
  405. },
  406. selectRoute_noform: function (node) {
  407. if (this.selectedRoute) {
  408. if (this.selectedRoute.get("text") != node.get("text")) {
  409. this.selectedRoute.setStyles(this.css.routeNode);
  410. this.selectedRoute.removeClass("mainColor_bg");
  411. this.selectedRoute = node;
  412. node.setStyles(this.css.routeNode_selected);
  413. node.addClass("mainColor_bg");
  414. node.removeClass("lightColor_bg");
  415. } else {
  416. this.selectedRoute.setStyles(this.css.routeNode);
  417. this.selectedRoute.addClass("lightColor_bg");
  418. this.selectedRoute.removeClass("mainColor_bg");
  419. this.selectedRoute = null;
  420. }
  421. } else {
  422. this.selectedRoute = node;
  423. node.setStyles(this.css.routeNode_selected);
  424. node.addClass("mainColor_bg");
  425. node.removeClass("lightColor_bg");
  426. }
  427. this.routeSelectorArea.setStyle("background-color", "#FFF");
  428. },
  429. selectRoute: function (node) {
  430. if (this.selectedRoute) {
  431. if (this.selectedRoute.get("text") != node.get("text")) {
  432. this.selectedRoute.setStyles(this.css.routeNode);
  433. this.selectedRoute.removeClass("mainColor_bg");
  434. //this.selectedRoute.getFirst().setStyles(this.css.routeIconNode);
  435. //this.selectedRoute.getLast().setStyles(this.css.routeTextNode);
  436. this.selectedRoute = node;
  437. node.setStyles(this.css.routeNode_selected);
  438. node.addClass("mainColor_bg");
  439. node.removeClass("lightColor_bg");
  440. //node.setStyle("background-color", "#da7429");
  441. //node.getFirst().setStyle("background-image", "url("+"../x_component_process_Work/$Processor/default/checked.png)");
  442. //node.getLast().setStyle("color", "#FFF");
  443. } else {
  444. this.selectedRoute.setStyles(this.css.routeNode);
  445. this.selectedRoute.addClass("lightColor_bg");
  446. this.selectedRoute.removeClass("mainColor_bg");
  447. //this.selectedRoute.getFirst().setStyles(this.css.routeIconNode);
  448. //this.selectedRoute.getLast().setStyles(this.css.routeTextNode);
  449. this.selectedRoute = null;
  450. }
  451. } else {
  452. this.selectedRoute = node;
  453. node.setStyles(this.css.routeNode_selected);
  454. node.addClass("mainColor_bg");
  455. node.removeClass("lightColor_bg");
  456. //node.setStyle("background-color", "#da7429");
  457. //node.getFirst().setStyle("background-image", "url("+"../x_component_process_Work/$Processor/default/checked.png)");
  458. //node.getLast().setStyle("color", "#FFF");
  459. }
  460. this.routeSelectorArea.setStyle("background-color", "#FFF");
  461. if (layout.mobile) {
  462. this.loadOrgs_mobile(this.selectedRoute ? this.selectedRoute.retrieve("route") : "");
  463. } else {
  464. this.loadOrgs(this.selectedRoute ? this.selectedRoute.retrieve("route") : "");
  465. }
  466. //临时添加
  467. if (this.form.data.json.events && this.form.data.json.events.afterSelectRoute) {
  468. this.form.Macro.exec(this.form.data.json.events.afterSelectRoute.code, node);
  469. }
  470. },
  471. setOpinion: function () {
  472. this.selectIdeaNode = new Element("div", {"styles": this.css.selectIdeaNode}).inject(this.routeOpinionArea);
  473. this.selectIdeaScrollNode = new Element("div", {"styles": this.css.selectIdeaScrollNode}).inject(this.selectIdeaNode);
  474. this.selectIdeaAreaNode = new Element("div", {
  475. "styles": {
  476. "overflow": "hidden"
  477. }
  478. }).inject(this.selectIdeaScrollNode);
  479. this.inputOpinionNode = new Element("div", {"styles": this.css.inputOpinionNode}).inject(this.routeOpinionArea);
  480. this.inputTextarea = new Element("textarea", {
  481. "styles": this.css.inputTextarea,
  482. "value": this.options.opinion || MWF.xApplication.process.Work.LP.inputText
  483. }).inject(this.inputOpinionNode);
  484. this.inputTextarea.addEvents({
  485. "focus": function () {
  486. if (this.get("value") == MWF.xApplication.process.Work.LP.inputText) this.set("value", "");
  487. },
  488. "blur": function () {
  489. if (!this.get("value")) this.set("value", MWF.xApplication.process.Work.LP.inputText);
  490. },
  491. "keydown": function () {
  492. this.inputTextarea.setStyles(this.inputTextareaStyle || this.css.inputTextarea);
  493. }.bind(this)
  494. });
  495. this.mediaActionArea = new Element("div", {"styles": this.css.inputOpinionMediaActionArea}).inject(this.inputOpinionNode);
  496. this.handwritingAction = new Element("div", {
  497. "styles": this.css.inputOpinionHandwritingAction,
  498. "text": MWF.xApplication.process.Work.LP.handwriting
  499. }).inject(this.mediaActionArea);
  500. this.handwritingAction.addEvent("click", function () {
  501. if (layout.mobile) {
  502. window.setTimeout(function () {
  503. this.handwriting();
  504. }.bind(this), 100)
  505. } else {
  506. this.handwriting();
  507. }
  508. }.bind(this));
  509. // if (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia){
  510. // this.audioRecordAction = new Element("div", {"styles": this.css.inputOpinionAudioRecordAction, "text": MWF.xApplication.process.Work.LP.audioRecord}).inject(this.mediaActionArea);
  511. // this.audioRecordAction.addEvent("click", function(){
  512. // this.audioRecord();
  513. // }.bind(this));
  514. // }
  515. if (layout.mobile) {
  516. this.selectIdeaNode.inject(this.routeOpinionArea, "after");
  517. }
  518. MWF.require("MWF.widget.ScrollBar", function () {
  519. new MWF.widget.ScrollBar(this.selectIdeaScrollNode, {
  520. "style": "small",
  521. "where": "before",
  522. "distance": 30,
  523. "friction": 4,
  524. "indent": false,
  525. "axis": {"x": false, "y": true}
  526. });
  527. }.bind(this));
  528. MWF.require("MWF.widget.UUID", function () {
  529. MWF.UD.getDataJson("idea", function (json) {
  530. if (json) {
  531. if (json.ideas) {
  532. this.setIdeaList(json.ideas);
  533. }
  534. } else {
  535. MWF.UD.getPublicData("idea", function (pjson) {
  536. if (pjson) {
  537. if (pjson.ideas) {
  538. this.setIdeaList(pjson.ideas);
  539. }
  540. }
  541. }.bind(this));
  542. }
  543. }.bind(this));
  544. }.bind(this));
  545. },
  546. audioRecord: function () {
  547. if (!this.audioRecordNode) this.createAudioRecord();
  548. this.audioRecordNode.show();
  549. this.audioRecordNode.position({
  550. "relativeTo": this.options.mediaNode || this.node,
  551. "position": "center",
  552. "edge": "center"
  553. });
  554. MWF.require("MWF.widget.AudioRecorder", function () {
  555. this.audioRecorder = new MWF.widget.AudioRecorder(this.audioRecordNode, {
  556. "onSave": function (blobFile) {
  557. this.soundFile = blobFile;
  558. this.audioRecordNode.hide();
  559. // this.page.get("div_image").node.set("src",base64Image);
  560. }.bind(this),
  561. "onCancel": function () {
  562. this.soundFile = null;
  563. this.audioRecordNode.hide();
  564. }.bind(this)
  565. }, null);
  566. }.bind(this));
  567. },
  568. createAudioRecord: function () {
  569. this.audioRecordNode = new Element("div", {"styles": this.css.handwritingNode}).inject(this.node, "after");
  570. var size = (this.options.mediaNode || this.node).getSize();
  571. // var y = Math.max(size.y, 320);
  572. // var x = Math.max(size.x, 400);
  573. // for (k in this.node.style){
  574. // if (this.node.style[k]) this.audioRecordNode.style[k] = this.node.style[k];
  575. // }
  576. var zidx = this.node.getStyle("z-index");
  577. this.audioRecordNode.setStyles({
  578. "height": "" + size.y + "px",
  579. "width": "" + size.x + "px",
  580. "z-index": zidx + 1
  581. });
  582. },
  583. handwriting: function () {
  584. if (!this.handwritingNode) this.createHandwriting();
  585. if (this.handwritingNodeMask) this.handwritingNodeMask.show();
  586. this.handwritingNode.show();
  587. if (layout.mobile) {
  588. this.handwritingNode.setStyles({
  589. "top": "0px",
  590. "left": "0px"
  591. });
  592. } else {
  593. this.handwritingNode.position({
  594. "relativeTo": this.options.mediaNode || this.node,
  595. "position": "center",
  596. "edge": "center"
  597. });
  598. }
  599. },
  600. createHandwriting: function () {
  601. this.handwritingNodeMask = new Element("div.handwritingMask", {"styles": this.css.handwritingMask}).inject(this.node);
  602. this.handwritingNode = new Element("div.handwritingNode", {"styles": this.css.handwritingNode}).inject(this.node, "after");
  603. //var size = (this.options.mediaNode || this.node).getSize();
  604. //var y = size.y;
  605. //var x = size.x;
  606. //兼容以前的默认高宽
  607. var x = 600;
  608. var y = 320;
  609. if (!layout.mobile) {
  610. x = Math.max(this.options.tabletWidth || x, 500);
  611. y = Math.max(this.options.tabletHeight ? (parseInt(this.options.tabletHeight) + 110) : y, 320);
  612. //y = Math.max(size.y, 320);
  613. //x = Math.max(size.x, 480);
  614. } else {
  615. var bodySize = $(document.body).getSize();
  616. x = bodySize.x;
  617. y = bodySize.y;
  618. this.options.tabletWidth = 0;
  619. this.options.tabletHeight = 0;
  620. }
  621. // for (k in this.node.style){
  622. // if (this.node.style[k]) this.handwritingNode.style[k] = this.node.style[k];
  623. // }
  624. var zidx = this.node.getStyle("z-index");
  625. this.handwritingNode.setStyles({
  626. "height": "" + y + "px",
  627. "width": "" + x + "px",
  628. "z-index": zidx + 1
  629. });
  630. if (layout.mobile) {
  631. debugger;
  632. this.handwritingNode.addEvent('touchmove', function (e) {
  633. e.preventDefault();
  634. });
  635. this.handwritingNode.setStyles({
  636. "top": "0px",
  637. "left": "0px"
  638. });
  639. //this.handwritingNode.position({
  640. // "relativeTo": this.node,
  641. // "position": "center",
  642. // "edge": "center"
  643. //});
  644. } else {
  645. this.handwritingNode.position({
  646. "relativeTo": this.options.mediaNode || this.node,
  647. "position": "center",
  648. "edge": "center"
  649. });
  650. }
  651. this.handwritingAreaNode = new Element("div", {"styles": this.css.handwritingAreaNode}).inject(this.handwritingNode);
  652. this.handwritingActionNode = new Element("div", {
  653. "styles": this.css.handwritingActionNode,
  654. "text": MWF.xApplication.process.Work.LP.saveWrite
  655. }).inject(this.handwritingNode);
  656. var h = this.handwritingActionNode.getSize().y + this.handwritingActionNode.getStyle("margin-top").toInt() + this.handwritingActionNode.getStyle("margin-bottom").toInt();
  657. h = y - h;
  658. this.handwritingAreaNode.setStyle("height", "" + h + "px");
  659. MWF.require("MWF.widget.Tablet", function () {
  660. var handWritingOptions = {
  661. "style": "default",
  662. "contentWidth": this.options.tabletWidth || 0,
  663. "contentHeight": this.options.tabletHeight || 0,
  664. "onSave": function (base64code, base64Image, imageFile) {
  665. this.handwritingFile = imageFile;
  666. this.handwritingNode.hide();
  667. this.handwritingNodeMask.hide();
  668. // this.page.get("div_image").node.set("src",base64Image);
  669. }.bind(this),
  670. "onCancel": function () {
  671. this.handwritingFile = null;
  672. this.handwritingNode.hide();
  673. this.handwritingNodeMask.hide();
  674. }.bind(this)
  675. };
  676. if (layout.mobile) {
  677. handWritingOptions.tools = [
  678. "undo",
  679. "redo", "|",
  680. "reset", "|",
  681. "size",
  682. "cancel"
  683. ]
  684. }
  685. this.tablet = new MWF.widget.Tablet(this.handwritingAreaNode, handWritingOptions, null);
  686. this.tablet.load();
  687. }.bind(this));
  688. this.handwritingActionNode.addEvent("click", function () {
  689. //this.handwritingNode.hide();
  690. if (this.tablet) this.tablet.save();
  691. }.bind(this));
  692. },
  693. setIdeaList: function (ideas) {
  694. var _self = this;
  695. ideas.each(function (idea) {
  696. if (!idea) return;
  697. new Element("div", {
  698. "styles": this.css.selectIdeaItemNode,
  699. "text": idea,
  700. "events": {
  701. "click": function () {
  702. if (_self.inputTextarea.get("value") == MWF.xApplication.process.Work.LP.inputText) {
  703. _self.inputTextarea.set("value", this.get("text"));
  704. } else {
  705. _self.inputTextarea.set("value", _self.inputTextarea.get("value") + ", " + this.get("text"));
  706. }
  707. },
  708. "dblclick": function () {
  709. if (_self.inputTextarea.get("value") == MWF.xApplication.process.Work.LP.inputText) {
  710. _self.inputTextarea.set("value", this.get("text"));
  711. } else {
  712. _self.inputTextarea.set("value", _self.inputTextarea.get("value") + ", " + this.get("text"));
  713. }
  714. },
  715. "mouseover": function () {
  716. this.setStyles(_self.css.selectIdeaItemNode_over);
  717. },
  718. "mouseout": function () {
  719. this.setStyles(_self.css.selectIdeaItemNode);
  720. }
  721. }
  722. }).inject(this.selectIdeaAreaNode);
  723. }.bind(this));
  724. },
  725. setButtons: function () {
  726. this.cancelButton = new Element("div", {"styles": this.css.cancelButton}).inject(this.buttonsArea);
  727. var iconNode = new Element("div", {"styles": this.css.cancelIconNode}).inject(this.cancelButton);
  728. var textNode = new Element("div", {
  729. "styles": this.css.cancelTextNode,
  730. "text": MWF.xApplication.process.Work.LP.cancel
  731. }).inject(this.cancelButton);
  732. this.okButton = new Element("div", {"styles": this.css.okButton}).inject(this.buttonsArea);
  733. var iconNode = new Element("div", {"styles": this.css.okIconNode}).inject(this.okButton);
  734. var textNode = new Element("div", {
  735. "styles": this.css.okTextNode,
  736. "text": MWF.xApplication.process.Work.LP.ok
  737. }).inject(this.okButton);
  738. this.cancelButton.addEvent("click", function () {
  739. this.destroy();
  740. this.fireEvent("cancel");
  741. }.bind(this));
  742. this.okButton.addEvent("click", function (ev) {
  743. if (layout.mobile) {
  744. this.submit_mobile(ev)
  745. } else {
  746. this.submit_pc(ev)
  747. }
  748. }.bind(this));
  749. },
  750. submit_mobile: function (ev) {
  751. if (this.hasDecisionOpinion && !this.selectedRouteGroup) {
  752. this.routeGroupArea.setStyle("background-color", "#ffe9e9");
  753. MWF.xDesktop.notice(
  754. "error",
  755. {"x": "center", "y": "top"},
  756. MWF.xApplication.process.Work.LP.mustSelectRouteGroup,
  757. this.routeGroupArea,
  758. null, //{"x": 0, "y": 30}
  759. {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
  760. );
  761. return false;
  762. }
  763. if (!this.selectedRoute) {
  764. this.routeSelectorArea.setStyle("background-color", "#ffe9e9");
  765. new mBox.Notice({
  766. type: "error",
  767. position: {"x": "center", "y": "top"},
  768. move: false,
  769. target: this.routeSelectorArea,
  770. delayClose: 6000,
  771. content: MWF.xApplication.process.Work.LP.mustSelectRoute
  772. });
  773. return false;
  774. }
  775. var routeName = this.selectedRoute.retrieve("routeName") || this.selectedRoute.get("text");
  776. var opinion = this.inputTextarea.get("value");
  777. if (opinion === MWF.xApplication.process.Work.LP.inputText) opinion = "";
  778. var medias = [];
  779. if (this.handwritingFile) medias.push(this.handwritingFile);
  780. if (this.soundFile) medias.push(this.soundFile);
  781. if (this.videoFile) medias.push(this.videoFile);
  782. var currentRouteId = this.selectedRoute.retrieve("route");
  783. var routeData = this.getRouteData(currentRouteId);
  784. if (!opinion && medias.length === 0) {
  785. if (routeData.opinionRequired == true) {
  786. this.inputTextarea.setStyle("background-color", "#ffe9e9");
  787. new mBox.Notice({
  788. type: "error",
  789. position: {"x": "center", "y": "top"},
  790. move: false,
  791. target: this.inputTextarea,
  792. delayClose: 6000,
  793. content: MWF.xApplication.process.Work.LP.opinionRequired
  794. });
  795. return false;
  796. }
  797. }
  798. if (routeData.validationScriptText) {
  799. var validation = this.form.Macro.exec(routeData.validationScriptText, this);
  800. if (!validation || validation.toString() !== "true") {
  801. if (typeOf(validation) === "string") {
  802. new mBox.Notice({
  803. type: "error",
  804. position: {"x": "center", "y": "top"},
  805. move: false,
  806. target: this.node,
  807. delayClose: 6000,
  808. content: validation
  809. });
  810. return false;
  811. } else {
  812. //"路由校验失败"
  813. new mBox.Notice({
  814. type: "error",
  815. position: {"x": "center", "y": "top"},
  816. move: false,
  817. target: this.node,
  818. delayClose: 6000,
  819. content: MWF.xApplication.process.Work.LP.routeValidFailure
  820. });
  821. return false;
  822. }
  823. }
  824. }
  825. //var array = [routeName, opinion, medias];
  826. //this.node.mask({
  827. // "inject": {"where": "bottom", "target": this.node},
  828. // "destroyOnHide": true,
  829. // "style": {
  830. // "background-color": "#999",
  831. // "opacity": 0.3,
  832. // "z-index":600
  833. // }
  834. //});
  835. //this.fireEvent("submit", array );
  836. var appendTaskOrgItem;
  837. if (routeData.type === "appendTask" && routeData.appendTaskIdentityType === "select") {
  838. if (!this.orgItems || this.orgItems.length === 0) {
  839. new mBox.Notice({
  840. type: "error",
  841. position: {"x": "center", "y": "top"},
  842. move: false,
  843. target: this.orgsArea,
  844. delayClose: 6000,
  845. content: MWF.xApplication.process.Work.LP.noAppendTaskIdentityConfig //"没有配置转交人,请联系管理员"
  846. });
  847. return false;
  848. } else {
  849. appendTaskOrgItem = this.orgItems[0]
  850. }
  851. }
  852. if (!this.saveOrgs()) return false;
  853. //this.saveOrgsWithCheckEmpower( function(){
  854. var appandTaskIdentityList;
  855. if (appendTaskOrgItem) {
  856. appandTaskIdentityList = appendTaskOrgItem.getData();
  857. if (!appandTaskIdentityList || appandTaskIdentityList.length === 0) {
  858. new mBox.Notice({
  859. type: "error",
  860. position: {"x": "center", "y": "top"},
  861. move: false,
  862. target: this.orgsArea,
  863. delayClose: 6000,
  864. content: MWF.xApplication.process.Work.LP.selectAppendTaskIdentityNotice //"请选择转交人"
  865. });
  866. return;
  867. }
  868. }
  869. if (routeData.validationScriptText) {
  870. var validation = this.form.Macro.exec(routeData.validationScriptText, this);
  871. if (!validation || validation.toString() !== "true") {
  872. if (typeOf(validation) === "string") {
  873. MWF.xDesktop.notice(
  874. "error",
  875. {"x": "center", "y": "center"},
  876. validation,
  877. this.node,
  878. {"x": 0, "y": 30},
  879. {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
  880. );
  881. return false;
  882. } else {
  883. //"路由校验失败"
  884. MWF.xDesktop.notice(
  885. "error",
  886. {"x": "center", "y": "center"},
  887. MWF.xApplication.process.Work.LP.routeValidFailure,
  888. this.node,
  889. {"x": 0, "y": 30},
  890. {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
  891. );
  892. return false;
  893. }
  894. }
  895. }
  896. this.node.mask({
  897. "inject": {"where": "bottom", "target": this.node},
  898. "destroyOnHide": true,
  899. "style": {
  900. "background-color": "#999",
  901. "opacity": 0.3,
  902. "z-index": 600
  903. }
  904. });
  905. var array = [routeName, opinion, medias, appandTaskIdentityList, this.orgItems, function () {
  906. if (appendTaskOrgItem) appendTaskOrgItem.setData([]);
  907. }];
  908. this.fireEvent("submit", array);
  909. //}.bind(this))
  910. },
  911. submit_pc: function (ev) {
  912. if (this.hasDecisionOpinion && !this.selectedRouteGroup) {
  913. this.routeGroupArea.setStyle("background-color", "#ffe9e9");
  914. MWF.xDesktop.notice(
  915. "error",
  916. {"x": "center", "y": "top"},
  917. MWF.xApplication.process.Work.LP.mustSelectRouteGroup,
  918. this.routeGroupArea,
  919. null, //{"x": 0, "y": 30}
  920. {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
  921. );
  922. return false;
  923. }
  924. if (!this.selectedRoute) {
  925. this.routeSelectorArea.setStyle("background-color", "#ffe9e9");
  926. //new mBox.Notice({
  927. // type: "error",
  928. // position: {"x": "center", "y": "top"},
  929. // move: false,
  930. // target: this.routeSelectorArea,
  931. // delayClose: 6000,
  932. // content: MWF.xApplication.process.Work.LP.mustSelectRoute
  933. //});
  934. MWF.xDesktop.notice(
  935. "error",
  936. {"x": "center", "y": "top"},
  937. MWF.xApplication.process.Work.LP.mustSelectRoute,
  938. this.routeSelectorArea,
  939. null, //{"x": 0, "y": 30}
  940. {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
  941. );
  942. return false;
  943. }
  944. var routeName = this.selectedRoute.retrieve("routeName") || this.selectedRoute.get("text");
  945. var opinion = this.inputTextarea.get("value");
  946. if (opinion === MWF.xApplication.process.Work.LP.inputText) opinion = "";
  947. var medias = [];
  948. if (this.handwritingFile) medias.push(this.handwritingFile);
  949. if (this.soundFile) medias.push(this.soundFile);
  950. if (this.videoFile) medias.push(this.videoFile);
  951. var currentRouteId = this.selectedRoute.retrieve("route");
  952. var routeData = this.getRouteData(currentRouteId);
  953. if (!opinion && medias.length === 0) {
  954. if (routeData.opinionRequired == true) {
  955. this.inputTextarea.setStyle("background-color", "#ffe9e9");
  956. //new mBox.Notice({
  957. // type: "error",
  958. // position: {"x": "center", "y": "top"},
  959. // move: false,
  960. // target: this.inputTextarea,
  961. // delayClose: 6000,
  962. // content: MWF.xApplication.process.Work.LP.opinionRequired
  963. //});
  964. MWF.xDesktop.notice(
  965. "error",
  966. {"x": "center", "y": "top"},
  967. MWF.xApplication.process.Work.LP.opinionRequired,
  968. this.inputTextarea,
  969. null, //{"x": 0, "y": 30}
  970. {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
  971. );
  972. return false;
  973. }
  974. }
  975. var appendTaskOrgItem = "";
  976. if (routeData.type === "appendTask" && routeData.appendTaskIdentityType === "select") {
  977. if (!this.orgItems || this.orgItems.length === 0) {
  978. //new mBox.Notice({
  979. // type: "error",
  980. // position: {"x": "center", "y": "top"},
  981. // move: false,
  982. // target: this.orgsArea,
  983. // delayClose: 6000,
  984. // content: MWF.xApplication.process.Work.LP.noAppendTaskIdentityConfig //"没有配置转交人,请联系管理员"
  985. //});
  986. MWF.xDesktop.notice(
  987. "error",
  988. {"x": "center", "y": "center"},
  989. MWF.xApplication.process.Work.LP.noAppendTaskIdentityConfig,
  990. this.node,
  991. null, //{"x": 0, "y": 30}
  992. {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
  993. );
  994. return false;
  995. } else {
  996. appendTaskOrgItem = this.orgItems[0]
  997. }
  998. }
  999. this.saveOrgsWithCheckEmpower(function () {
  1000. var appandTaskIdentityList;
  1001. if (appendTaskOrgItem) {
  1002. appandTaskIdentityList = appendTaskOrgItem.getData();
  1003. if (!appandTaskIdentityList || appandTaskIdentityList.length === 0) {
  1004. //new mBox.Notice({
  1005. // type: "error",
  1006. // position: {"x": "center", "y": "top"},
  1007. // move: false,
  1008. // target: this.orgsArea,
  1009. // delayClose: 6000,
  1010. // content: MWF.xApplication.process.Work.LP.selectAppendTaskIdentityNotice //"请选择转交人"
  1011. //});
  1012. MWF.xDesktop.notice(
  1013. "error",
  1014. {"x": "center", "y": "center"},
  1015. MWF.xApplication.process.Work.LP.selectAppendTaskIdentityNotice,
  1016. this.node,
  1017. {"x": 0, "y": 30},
  1018. {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
  1019. );
  1020. return;
  1021. }
  1022. }
  1023. if (routeData.validationScriptText) {
  1024. var validation = this.form.Macro.exec(routeData.validationScriptText, this);
  1025. if (!validation || validation.toString() !== "true") {
  1026. if (typeOf(validation) === "string") {
  1027. MWF.xDesktop.notice(
  1028. "error",
  1029. {"x": "center", "y": "center"},
  1030. validation,
  1031. this.node,
  1032. {"x": 0, "y": 30},
  1033. {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
  1034. );
  1035. return false;
  1036. } else {
  1037. //"路由校验失败"
  1038. MWF.xDesktop.notice(
  1039. "error",
  1040. {"x": "center", "y": "center"},
  1041. MWF.xApplication.process.Work.LP.routeValidFailure,
  1042. this.node,
  1043. {"x": 0, "y": 30},
  1044. {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
  1045. );
  1046. return false;
  1047. }
  1048. }
  1049. }
  1050. this.node.mask({
  1051. "inject": {"where": "bottom", "target": this.node},
  1052. "destroyOnHide": true,
  1053. "style": {
  1054. "background-color": "#999",
  1055. "opacity": 0.3,
  1056. "z-index": 600
  1057. }
  1058. });
  1059. var array = [routeName, opinion, medias, appandTaskIdentityList, this.orgItems, function () {
  1060. if (appendTaskOrgItem) appendTaskOrgItem.setData([]);
  1061. }];
  1062. this.fireEvent("submit", array);
  1063. }.bind(this))
  1064. },
  1065. destroy: function () {
  1066. this.node.empty();
  1067. delete this.task;
  1068. delete this.node;
  1069. delete this.routeSelectorTile;
  1070. delete this.routeSelectorArea;
  1071. delete this.routeOpinionTile;
  1072. delete this.routeOpinionArea;
  1073. delete this.buttonsArea;
  1074. delete this.inputOpinionNode;
  1075. delete this.inputTextarea;
  1076. delete this.cancelButton;
  1077. delete this.okButton;
  1078. },
  1079. getRouteDataList: function () {
  1080. if (!this.routeDataList) {
  1081. o2.Actions.get("x_processplatform_assemble_surface").listRoute({"valueList": this.task.routeList}, function (json) {
  1082. json.data.each(function (d) {
  1083. d.selectConfigList = JSON.parse(d.selectConfig || "[]");
  1084. }.bind(this));
  1085. this.routeDataList = json.data;
  1086. }.bind(this), null, false);
  1087. }
  1088. return this.routeDataList;
  1089. },
  1090. getRouteData: function (routeId) {
  1091. var routeList = this.getRouteDataList();
  1092. for (var i = 0; i < routeList.length; i++) {
  1093. if (routeList[i].id === routeId) {
  1094. return routeList[i];
  1095. }
  1096. }
  1097. },
  1098. getMaxOrgLength: function () {
  1099. var routeList = this.getRouteDataList();
  1100. var length = 0;
  1101. routeList.each(function (route) {
  1102. if (route.hiddenScriptText) { //如果隐藏路由,返回
  1103. if (this.form.Macro.exec(route.hiddenScriptText, this).toString() === "true") return;
  1104. }
  1105. length = Math.max(length, route.selectConfigList.length);
  1106. }.bind(this));
  1107. return length;
  1108. },
  1109. getOrgData: function (routeId) {
  1110. var routeList = this.getRouteDataList();
  1111. for (var i = 0; i < routeList.length; i++) {
  1112. if (routeList[i].id === routeId) {
  1113. return routeList[i].selectConfigList;
  1114. }
  1115. }
  1116. },
  1117. getVisableOrgData: function (routeId) {
  1118. var selectConfigList = this.getOrgData(routeId);
  1119. var list = [];
  1120. (selectConfigList || []).each(function (config) {
  1121. if (!this.isOrgHidden(config)) {
  1122. list.push(config);
  1123. }
  1124. }.bind(this));
  1125. return list;
  1126. },
  1127. isOrgHidden: function (d) {
  1128. if (d.hiddenScript && d.hiddenScript.code) { //如果隐藏路由,返回
  1129. var hidden = this.form.Macro.exec(d.hiddenScript.code, this);
  1130. if (hidden && hidden.toString() === "true") return true;
  1131. }
  1132. return false;
  1133. },
  1134. loadOrgs_mobile: function (route) {
  1135. if (!this.form || !route) {
  1136. this.orgsArea.hide();
  1137. this.setSize(0);
  1138. return;
  1139. } else {
  1140. this.orgsArea.show();
  1141. }
  1142. if (!this.orgTableObject) this.orgTableObject = {};
  1143. if (!this.orgItemsObject) this.orgItemsObject = {};
  1144. if (!this.orgItemsMap) this.orgItemsMap = {};
  1145. var isLoaded = false;
  1146. for (var key in this.orgTableObject) {
  1147. if (route === key) {
  1148. isLoaded = true;
  1149. } else {
  1150. this.orgTableObject[key].hide();
  1151. }
  1152. }
  1153. if (isLoaded) {
  1154. this.showOrgs_mobile(route);
  1155. } else {
  1156. this.createOrgs_mobile(route)
  1157. }
  1158. },
  1159. showOrgs_mobile: function (route) {
  1160. this.orgItemMap = this.orgItemsMap[route] || {};
  1161. var dataVisable = this.getVisableOrgData(route);
  1162. if (dataVisable.length) {
  1163. if (this.isSameArray(Object.keys(this.orgItemMap), dataVisable.map(function (d) {
  1164. return d.name
  1165. }))) {
  1166. this.orgTableObject[route].show();
  1167. this.orgItems = this.orgItemsObject[route] || [];
  1168. this.setSize(dataVisable.length);
  1169. } else {
  1170. this.loadOrgTable_mobile(route);
  1171. }
  1172. } else {
  1173. this.orgsArea.hide();
  1174. this.orgItemMap = {};
  1175. this.orgItems = [];
  1176. this.setSize(0);
  1177. }
  1178. },
  1179. createOrgs_mobile: function (route) {
  1180. var dataVisable = this.getVisableOrgData(route);
  1181. if (dataVisable.length) {
  1182. this.loadOrgTable_mobile(route);
  1183. } else {
  1184. this.setSize(dataVisable.length);
  1185. this.orgItemMap = {};
  1186. this.orgItems = [];
  1187. this.orgsArea.hide();
  1188. }
  1189. },
  1190. loadOrgTable_mobile: function (route) {
  1191. var dataVisable = this.getVisableOrgData(route);
  1192. this.setSize(dataVisable.length);
  1193. this.orgsArea.show();
  1194. var table_old = this.orgTableObject[route];
  1195. var divsMap_old = {};
  1196. if (divsMap_old) {
  1197. var divs = table_old.getChildren("div");
  1198. divs.each(function (div) {
  1199. divsMap_old[div.retrieve("orgName")] = div;
  1200. });
  1201. }
  1202. var orgItems_old = this.orgItemsObject[route] || [];
  1203. var orgItemMap_old = this.orgItemsMap[route] || {};
  1204. this.orgItemsObject[route] = [];
  1205. this.orgItemsMap[route] = {};
  1206. this.orgItems = this.orgItemsObject[route];
  1207. this.orgItemMap = this.orgItemsMap[route];
  1208. var routeOrgTable = new Element("div", {
  1209. "styles": this.css.routeOrgTable
  1210. }).inject(this.orgsArea);
  1211. this.orgTableObject[route] = routeOrgTable;
  1212. dataVisable.each(function (config, i) {
  1213. var sNode = new Element("div", {
  1214. "styles": this.css.routeOrgTr
  1215. }).inject(routeOrgTable);
  1216. sNode.store("orgName", config.name);
  1217. if (orgItemMap_old[config.name]) {
  1218. var org = orgItemMap_old[config.name];
  1219. this.orgItems.push(org);
  1220. this.orgItemMap[config.name] = org;
  1221. var div = divsMap_old[config.name];
  1222. div.getChildren().inject(sNode);
  1223. } else {
  1224. this.loadOrg_mobile(sNode, config, ignoreFirstOrgOldData && i == 0)
  1225. }
  1226. }.bind(this));
  1227. if (table_old) table_old.destroy();
  1228. },
  1229. // loadOrgs_mobile: function (route) {
  1230. // if (!this.form || !route) {
  1231. // this.orgsArea.hide();
  1232. // return;
  1233. // } else {
  1234. // this.orgsArea.show();
  1235. // }
  1236. // if (!this.orgTableObject) this.orgTableObject = {};
  1237. // if (!this.orgItemsObject) this.orgItemsObject = {};
  1238. // if (!this.orgItemsMap) this.orgItemsMap = {};
  1239. //
  1240. // var isLoaded = false;
  1241. // for (var key in this.orgTableObject) {
  1242. // if (route === key) {
  1243. // this.orgTableObject[key].show();
  1244. // this.orgItems = this.orgItemsObject[key] || [];
  1245. // var data = this.getOrgData(route);
  1246. // isLoaded = true;
  1247. // } else {
  1248. // this.orgTableObject[key].hide();
  1249. // }
  1250. // }
  1251. // if (isLoaded) return;
  1252. //
  1253. // this.orgItems = [];
  1254. // this.orgItemsObject[route] = this.orgItems;
  1255. //
  1256. // var data = this.getOrgData(route);
  1257. // var routeConfig = this.getRouteData(route);
  1258. // var ignoreFirstOrgOldData = false; //(routeConfig.type === "appendTask" && routeConfig.appendTaskIdentityType === "select");
  1259. // this.setSize(data.length);
  1260. // if (data.length) {
  1261. // this.orgsArea.show();
  1262. //
  1263. // var routeOrgTable = new Element("div", {
  1264. // "styles": this.css.routeOrgTable
  1265. // }).inject(this.orgsArea);
  1266. // this.orgTableObject[route] = routeOrgTable;
  1267. //
  1268. // data.each(function (config, i) {
  1269. // var sNode = new Element("div", {
  1270. // "styles": this.css.routeOrgTr
  1271. // }).inject(routeOrgTable);
  1272. // this.loadOrg_mobile(sNode, config, ignoreFirstOrgOldData && i == 0)
  1273. // }.bind(this))
  1274. // } else {
  1275. // this.orgsArea.hide();
  1276. // }
  1277. // },
  1278. loadOrg_mobile: function (container, json, ignoreOldData) {
  1279. var titleNode = new Element("div.selectorTitle", {
  1280. "styles": this.css.selectorTitle
  1281. }).inject(container);
  1282. var titleTextNode = new Element("div.selectorTitleText", {
  1283. "text": json.title,
  1284. "styles": this.css.selectorTitleText
  1285. }).inject(titleNode);
  1286. var contentNode = new Element("div.selectorContent", {
  1287. "styles": this.css.selectorContent
  1288. }).inject(container);
  1289. var errorNode = new Element("div.selectorErrorNode", {
  1290. "styles": this.css.selectorErrorNode
  1291. }).inject(container);
  1292. var org = new MWF.xApplication.process.Work.Processor.Org(contentNode, this.form, json, this, {
  1293. onSelect: function (items, data) {
  1294. if (!data || !data.length) {
  1295. contentNode.setStyles(this.css.selectorContent_noItem);
  1296. } else {
  1297. contentNode.setStyles(this.css.selectorContent);
  1298. }
  1299. }.bind(this)
  1300. });
  1301. org.ignoreOldData = ignoreOldData;
  1302. org.errContainer = errorNode;
  1303. org.summitDlalog = this;
  1304. this.orgItems.push(org);
  1305. this.orgItemMap[json.name] = org;
  1306. titleNode.addEvent("click", function () {
  1307. this.load();
  1308. }.bind(org));
  1309. contentNode.addEvent("click", function () {
  1310. this.load();
  1311. }.bind(org));
  1312. var defaultValue = org.getValue();
  1313. org.loadOrgWidget(defaultValue, contentNode);
  1314. if (!defaultValue || defaultValue.length == 0) {
  1315. contentNode.setStyles(this.css.selectorContent_noItem);
  1316. }
  1317. },
  1318. isSameArray: function (arr1, arr2) {
  1319. if (arr1.length !== arr2.length) return false;
  1320. for (var i = 0; i < arr1.length; i++) {
  1321. if (arr1[i] !== arr2[i]) return false;
  1322. }
  1323. return true;
  1324. },
  1325. loadOrgs: function (route) {
  1326. if (!this.form || !route) {
  1327. this.orgsArea.hide();
  1328. this.setSize(0);
  1329. return;
  1330. } else {
  1331. this.orgsArea.show();
  1332. }
  1333. if (!this.orgTableObject) this.orgTableObject = {};
  1334. if (!this.orgItemsObject) this.orgItemsObject = {};
  1335. if (!this.orgItemsMap) this.orgItemsMap = {};
  1336. var isLoaded = false;
  1337. for (var key in this.orgTableObject) {
  1338. if (route === key) {
  1339. isLoaded = true;
  1340. } else {
  1341. this.orgTableObject[key].hide();
  1342. }
  1343. }
  1344. if (isLoaded) {
  1345. this.showOrgs(route);
  1346. } else {
  1347. this.createOrgs(route)
  1348. }
  1349. },
  1350. showOrgs: function (route) {
  1351. this.orgItemMap = this.orgItemsMap[route] || {};
  1352. var dataVisable = this.getVisableOrgData(route);
  1353. if (dataVisable.length) {
  1354. if (this.isSameArray(Object.keys(this.orgItemMap), dataVisable.map(function (d) {
  1355. return d.name
  1356. }))) {
  1357. this.orgTableObject[route].show();
  1358. this.orgItems = this.orgItemsObject[route] || [];
  1359. this.setSize(dataVisable.length);
  1360. } else {
  1361. this.loadOrgTable(route);
  1362. }
  1363. } else {
  1364. this.orgsArea.hide();
  1365. this.orgItemMap = {};
  1366. this.orgItems = [];
  1367. this.setSize(0);
  1368. }
  1369. },
  1370. createOrgs: function (route) {
  1371. var dataVisable = this.getVisableOrgData(route);
  1372. if (dataVisable.length) {
  1373. this.loadOrgTable(route);
  1374. } else {
  1375. this.setSize(dataVisable.length);
  1376. this.orgItemMap = {};
  1377. this.orgItems = [];
  1378. this.orgsArea.hide();
  1379. }
  1380. },
  1381. loadOrgTable: function (route) {
  1382. var data = this.getOrgData(route);
  1383. var dataVisable = this.getVisableOrgData(route);
  1384. this.setSize(dataVisable.length);
  1385. this.orgsArea.show();
  1386. var table_old = this.orgTableObject[route];
  1387. var tdsMap_old = {};
  1388. if (table_old) {
  1389. var tds = table_old.getElements("td");
  1390. tds.each(function (td) {
  1391. tdsMap_old[td.retrieve("orgName")] = td;
  1392. });
  1393. }
  1394. debugger;
  1395. var orgItems_old = this.orgItemsObject[route] || [];
  1396. var orgItemMap_old = this.orgItemsMap[route] || {};
  1397. this.orgItemsObject[route] = [];
  1398. this.orgItemsMap[route] = {};
  1399. this.orgItems = this.orgItemsObject[route];
  1400. this.orgItemMap = this.orgItemsMap[route];
  1401. var len = dataVisable.length;
  1402. var routeOrgTable = new Element("table", {
  1403. "cellspacing": 0, "cellpadding": 0, "border": 0, "width": "100%",
  1404. "styles": this.css.routeOrgTable
  1405. }).inject(this.orgsArea);
  1406. this.orgTableObject[route] = routeOrgTable;
  1407. var lines = ((len + 1) / 2).toInt();
  1408. for (var n = 0; n < lines; n++) {
  1409. var tr = new Element("tr").inject(routeOrgTable);
  1410. new Element("td", {"width": "50%", "valign": "bottom", "styles": this.css.routeOrgOddTd}).inject(tr);
  1411. new Element("td", {"width": "50%", "valign": "bottom", "styles": this.css.routeOrgEvenTd}).inject(tr);
  1412. }
  1413. var trs = routeOrgTable.getElements("tr");
  1414. // var routeConfig = this.getRouteData( route );
  1415. var ignoreFirstOrgOldData = false; //(routeConfig.type === "appendTask" && routeConfig.appendTaskIdentityType === "select");
  1416. dataVisable.each(function (config, i) {
  1417. var sNode;
  1418. var width;
  1419. if (i + 1 == len && (len % 2 === 1)) {
  1420. sNode = trs[trs.length - 1].getFirst("td");
  1421. sNode.set("colspan", 2);
  1422. trs[trs.length - 1].getLast("td").destroy();
  1423. sNode.setStyle("border", "0px");
  1424. sNode.set("width", "100%");
  1425. sNode.store("orgName", config.name);
  1426. if (orgItemMap_old[config.name]) {
  1427. var org = orgItemMap_old[config.name];
  1428. this.orgItems.push(org);
  1429. this.orgItemMap[config.name] = org;
  1430. var td = tdsMap_old[config.name];
  1431. td.getChildren().inject(sNode);
  1432. } else {
  1433. this.loadOrg(sNode, config, "all", ignoreFirstOrgOldData && i == 0)
  1434. }
  1435. } else {
  1436. var row = ((i + 2) / 2).toInt();
  1437. var tr = trs[row - 1];
  1438. sNode = (i % 2 === 0) ? tr.getFirst("td") : tr.getLast("td");
  1439. sNode.store("orgName", config.name);
  1440. if (orgItemMap_old[config.name]) {
  1441. var org = orgItemMap_old[config.name];
  1442. this.orgItems.push(org);
  1443. this.orgItemMap[config.name] = org;
  1444. var td = tdsMap_old[config.name];
  1445. td.getChildren().inject(sNode);
  1446. } else {
  1447. this.loadOrg(sNode, config, (i % 2 === 0) ? "left" : "right", ignoreFirstOrgOldData && i == 0)
  1448. }
  1449. }
  1450. }.bind(this));
  1451. if (table_old) table_old.destroy();
  1452. },
  1453. loadOrg: function (container, json, position, ignoreOldData) {
  1454. var titleNode = new Element("div.selectorTitle", {
  1455. "styles": this.css.selectorTitle
  1456. }).inject(container);
  1457. var titleTextNode = new Element("div.selectorTitleText", {
  1458. "text": json.title,
  1459. "styles": this.css.selectorTitleText
  1460. }).inject(titleNode);
  1461. var errorNode = new Element("div.selectorErrorNode", {
  1462. "styles": this.css.selectorErrorNode
  1463. }).inject(titleNode);
  1464. var contentNode = new Element("div.selectorContent", {
  1465. "styles": this.css.selectorContent
  1466. }).inject(container);
  1467. var org = new MWF.xApplication.process.Work.Processor.Org(contentNode, this.form, json, this);
  1468. org.ignoreOldData = ignoreOldData;
  1469. org.errContainer = errorNode;
  1470. org.summitDlalog = this;
  1471. org.load();
  1472. this.orgItems.push(org);
  1473. this.orgItemMap[json.name] = org;
  1474. },
  1475. showOrgsByRoute: function (route) {
  1476. //debugger;
  1477. this.loadOrgs(route);
  1478. },
  1479. clearAllOrgs: function () {
  1480. //清空组织所选人
  1481. for (var key in this.orgItemsObject) {
  1482. var orgItems = this.orgItemsObject[key] || [];
  1483. orgItems.each(function (org) {
  1484. org.setDataToOriginal();
  1485. })
  1486. }
  1487. //
  1488. this.orgTableObject = {};
  1489. this.orgItemsObject = {};
  1490. this.orgsArea.empty();
  1491. },
  1492. getCurrentRouteSelectorList: function () {
  1493. var selectorList = [];
  1494. var currentRoute = this.selectedRoute ? this.selectedRoute.retrieve("route") : "";
  1495. var orgList = this.orgItemsObject[currentRoute];
  1496. if (!orgList) return [];
  1497. orgList.each(function (org) {
  1498. if (org.selector && org.selector.selector) {
  1499. selectorList.push(org.selector.selector);
  1500. }
  1501. }.bind(this))
  1502. return selectorList;
  1503. },
  1504. getCurrentRouteOrgList: function () {
  1505. var currentRoute = this.selectedRoute ? this.selectedRoute.retrieve("route") : "";
  1506. var orgList = this.orgItemsObject[currentRoute];
  1507. return orgList || [];
  1508. },
  1509. getSelectorSelectedData: function (filedName) {
  1510. var data = [];
  1511. var orgList = this.getCurrentRouteOrgList();
  1512. for (var i = 0; i < orgList.length; i++) {
  1513. var org = orgList[i];
  1514. if (org.json.name === filedName) {
  1515. var selector = org.selector.selector;
  1516. selector.selectedItems.each(function (item) {
  1517. data.push(item.data)
  1518. })
  1519. }
  1520. }
  1521. return data;
  1522. },
  1523. getOffsetY: function (node) {
  1524. return (node.getStyle("margin-top").toInt() || 0) +
  1525. (node.getStyle("margin-bottom").toInt() || 0) +
  1526. (node.getStyle("padding-top").toInt() || 0) +
  1527. (node.getStyle("padding-bottom").toInt() || 0) +
  1528. (node.getStyle("border-top-width").toInt() || 0) +
  1529. (node.getStyle("border-bottom-width").toInt() || 0);
  1530. },
  1531. setSize_noform: function () {
  1532. var height = 0;
  1533. if (this.managerProcessNoticeNode) height = height + this.getOffsetY(this.managerProcessNoticeNode) + this.managerProcessNoticeNode.getStyle("height").toInt();
  1534. if (this.managerLoginNode) height = height + this.getOffsetY(this.managerLoginNode) + this.managerLoginNode.getStyle("height").toInt();
  1535. if (this.routeSelectorTile) height = height + this.getOffsetY(this.routeSelectorTile) + this.routeSelectorTile.getStyle("height").toInt();
  1536. if (this.routeSelectorArea) height = height + this.getOffsetY(this.routeSelectorArea) + this.routeSelectorArea.getStyle("height").toInt();
  1537. if (this.routeOpinionTile) height = height + this.getOffsetY(this.routeOpinionTile) + this.routeOpinionTile.getStyle("height").toInt();
  1538. if (this.routeOpinionArea) height = height + this.getOffsetY(this.routeOpinionArea) + this.routeOpinionArea.getStyle("height").toInt();
  1539. this.node.setStyle("height", height);
  1540. this.fireEvent("resize");
  1541. },
  1542. setSize: function (currentOrgLength, flag) {
  1543. if (layout.mobile) {
  1544. this.setSize_mobile();
  1545. } else {
  1546. this.setSize_pc(currentOrgLength, flag);
  1547. }
  1548. //this.node.store("width", this.node.getStyle("width").toInt() + ( flag ? 20 : 0 ));
  1549. if (!flag) this.fireEvent("resize");
  1550. },
  1551. setSize_mobile: function () {
  1552. if (this.buttonsArea) {
  1553. debugger;
  1554. var bodySize = $(document.body).getSize();
  1555. var nodeHeight = bodySize.y - this.getOffsetY(this.node);
  1556. this.node.setStyles({
  1557. "overflow-y": "hidden",
  1558. "height": nodeHeight
  1559. });
  1560. var buttonsAreaSize = this.buttonsArea.getSize();
  1561. this.content.setStyles({
  1562. "height": nodeHeight - buttonsAreaSize.y - this.getOffsetY(this.buttonsArea) - this.getOffsetY(this.content),
  1563. "overflow-y": "auto"
  1564. })
  1565. }
  1566. },
  1567. setSize_pc: function (currentOrgLength, flag) {
  1568. var lines = ((currentOrgLength + 1) / 2).toInt();
  1569. var height = 0;
  1570. if (this.routeSelectorTile) height = height + this.getOffsetY(this.routeSelectorTile) + this.routeSelectorTile.getStyle("height").toInt();
  1571. if (this.routeSelectorArea) height = height + this.getOffsetY(this.routeSelectorArea) + this.routeSelectorArea.getStyle("height").toInt();
  1572. if (this.routeOpinionTile) height = height + this.getOffsetY(this.routeOpinionTile) + this.routeOpinionTile.getStyle("height").toInt();
  1573. if (this.routeOpinionArea) height = height + this.getOffsetY(this.routeOpinionArea) + this.routeOpinionArea.getStyle("height").toInt();
  1574. //if( this.buttonsArea )height = height + this.getOffsetY(this.buttonsArea) + this.buttonsArea.getStyle("height").toInt();
  1575. if (lines > 0) {
  1576. if (this.orgsArea) this.orgsArea.show();
  1577. if (flag) {
  1578. // if( this.orgsTile )height = height + this.getOffsetY(this.orgsTile) + this.orgsTile.getStyle("height").toInt();
  1579. this.orgsArea.getChildren().each(function (el) {
  1580. height += el.getSize().y + this.getOffsetY(el);
  1581. }.bind(this))
  1582. this.node.setStyle("height", height);
  1583. } else {
  1584. if (this.orgsTile) height = height + this.getOffsetY(this.orgsTile) + this.orgsTile.getStyle("height").toInt();
  1585. height = height + lines * this.options.orgHeight + this.getOffsetY(this.orgsArea);
  1586. this.node.setStyle("height", height);
  1587. }
  1588. } else {
  1589. if (this.orgsArea) this.orgsArea.hide();
  1590. this.node.setStyle("height", height);
  1591. //this.node.store("height", 401 );
  1592. }
  1593. debugger;
  1594. if (this.getMaxOrgLength() > 1) {
  1595. this.node.setStyles(this.css.node_wide);
  1596. this.inputOpinionNode.setStyles(this.css.inputOpinionNode_wide);
  1597. this.inputTextarea.setStyles(this.css.inputTextarea_wide);
  1598. this.inputTextareaStyle = this.css.inputTextarea_wide;
  1599. this.selectIdeaNode.setStyles(this.css.selectIdeaNode_wide);
  1600. } else {
  1601. this.node.setStyles(this.css.node);
  1602. this.inputOpinionNode.setStyles(this.css.inputOpinionNode);
  1603. this.inputTextarea.setStyles(this.css.inputTextarea);
  1604. this.inputTextareaStyle = this.css.inputTextarea;
  1605. this.selectIdeaNode.setStyles(this.css.selectIdeaNode);
  1606. }
  1607. },
  1608. isErrorHeightOverflow: function () {
  1609. var hasOverflow = false;
  1610. (this.orgItems || []).each(function (item) {
  1611. if (item.errorHeightOverflow) {
  1612. hasOverflow = true;
  1613. }
  1614. }.bind(this));
  1615. return hasOverflow;
  1616. },
  1617. checkErrorHeightOverflow: function (force) {
  1618. if (force || this.isErrorHeightOverflow()) {
  1619. this.setSize(this.orgItems.length, true);
  1620. }
  1621. },
  1622. errorHeightChange: function () {
  1623. debugger;
  1624. this.checkErrorHeightOverflow(true)
  1625. },
  1626. validationOrgs: function () {
  1627. if (!this.orgItems || !this.orgItems.length) return true;
  1628. var flag = true;
  1629. this.orgItems.each(function (item) {
  1630. if (!item.validation()) flag = false;
  1631. }.bind(this));
  1632. this.checkErrorHeightOverflow();
  1633. return flag;
  1634. },
  1635. isOrgsHasEmpower: function () {
  1636. if (!this.orgItems || !this.orgItems.length) return true;
  1637. var flag = false;
  1638. this.needCheckEmpowerOrg = [];
  1639. this.orgItems.each(function (item) {
  1640. if (item.hasEmpowerIdentity()) {
  1641. this.needCheckEmpowerOrg.push(item);
  1642. flag = true;
  1643. }
  1644. }.bind(this));
  1645. return flag;
  1646. },
  1647. saveOrgs: function (keepSilent) {
  1648. if (!this.orgItems || !this.orgItems.length) return true;
  1649. var flag = true;
  1650. this.orgItems.each(function (item) {
  1651. if (!item.save(!keepSilent)) flag = false;
  1652. }.bind(this));
  1653. return flag;
  1654. },
  1655. saveOrgsWithCheckEmpower: function (callback) {
  1656. debugger;
  1657. if (!this.orgItems || !this.orgItems.length) {
  1658. if (callback) callback();
  1659. return true;
  1660. }
  1661. if (!this.validationOrgs()) return false;
  1662. if (layout.mobile) {
  1663. if (callback) callback();
  1664. return true;
  1665. } else {
  1666. if (!this.isOrgsHasEmpower()) {
  1667. if (callback) callback();
  1668. return true;
  1669. }
  1670. //this.checkEmpowerMode = true;
  1671. this.showEmpowerDlg(callback);
  1672. }
  1673. },
  1674. showEmpowerDlg: function (callback) {
  1675. //this.empowerMask = new Element("div", {"styles": this.css.handwritingMask}).inject(this.node);
  1676. //this.needCheckEmpowerOrg.each( function(org){
  1677. // org.saveCheckedEmpowerData();
  1678. //}.bind(this));
  1679. var empowerNode = new Element("div.empowerNode", {"styles": this.css.empowerNode});
  1680. var empowerTitleNode = new Element("div", {
  1681. text: MWF.xApplication.process.Xform.LP.empowerDlgText,
  1682. styles: this.css.empowerTitleNode
  1683. }).inject(empowerNode);
  1684. var orgs = this.needCheckEmpowerOrg;
  1685. var len = orgs.length;
  1686. var lines = ((len + 1) / 2).toInt();
  1687. var empowerTable = new Element("table", {
  1688. "cellspacing": 0, "cellpadding": 0, "border": 0, "width": "100%",
  1689. "styles": this.css.empowerTable
  1690. }).inject(empowerNode);
  1691. for (var n = 0; n < lines; n++) {
  1692. var tr = new Element("tr").inject(empowerTable);
  1693. new Element("td", {"width": "50%", "styles": this.css.empowerOddTd}).inject(tr);
  1694. new Element("td", {"width": "50%", "styles": this.css.empowerEvenTd}).inject(tr);
  1695. }
  1696. var trs = empowerTable.getElements("tr");
  1697. orgs.each(function (org, i) {
  1698. var sNode;
  1699. var width;
  1700. if (i + 1 == len && (len % 2 === 1)) {
  1701. sNode = trs[trs.length - 1].getFirst("td");
  1702. sNode.set("colspan", 2);
  1703. trs[trs.length - 1].getLast("td").destroy();
  1704. width = "50%";
  1705. } else {
  1706. var row = ((i + 2) / 2).toInt();
  1707. var tr = trs[row - 1];
  1708. sNode = (i % 2 === 0) ? tr.getFirst("td") : tr.getLast("td");
  1709. }
  1710. var titleNode = new Element("div.empowerAreaTitle", {
  1711. "styles": this.css.empowerAreaTitle
  1712. }).inject(sNode);
  1713. var titleTextNode = new Element("div.empowerAreaTitleText", {
  1714. "text": org.json.title,
  1715. "styles": this.css.empowerAreaTitleText
  1716. }).inject(titleNode);
  1717. var selectAllNode = new Element("div", {
  1718. styles: {
  1719. float: "right"
  1720. }
  1721. }).inject(titleNode);
  1722. var contentNode = new Element("div.empowerAreaContent", {
  1723. "styles": this.css.empowerAreaContent
  1724. }).inject(sNode);
  1725. org.loadCheckEmpower(null, contentNode, selectAllNode);
  1726. }.bind(this));
  1727. empowerNode.setStyle("height", lines * this.options.orgHeight + 20);
  1728. //var dlgHeight = Math.min( Math.floor( this.form.app.content.getSize().y * 0.9) , lines*this.options.orgHeight + 151 );
  1729. //var width = this.node.retrieve("width");
  1730. //empowerNode.setStyle( "width", width );
  1731. var width = 840;
  1732. //if( len > 1 ){
  1733. // width = "840"
  1734. //}else{
  1735. // width = "420"
  1736. //}
  1737. empowerNode.setStyle("width", width + "px");
  1738. this.node.getParent().mask({
  1739. "style": this.css.mask
  1740. });
  1741. this.empowerDlg = o2.DL.open({
  1742. "title": MWF.xApplication.process.Xform.LP.selectEmpower,
  1743. "style": this.form.json.dialogStyle || "user",
  1744. "isResize": false,
  1745. "content": empowerNode,
  1746. //"container" : this.node,
  1747. "width": width + 40, //600,
  1748. "height": "auto", //dlgHeight,
  1749. "mark": false,
  1750. "onPostLoad": function () {
  1751. if (this.nodeWidth) {
  1752. this.node.setStyle("width", this.nodeWidth + "px");
  1753. }
  1754. if (this.nodeHeight) {
  1755. this.node.setStyle("height", this.nodeHeight + "px");
  1756. }
  1757. },
  1758. "buttonList": [
  1759. {
  1760. "type": "ok",
  1761. "text": MWF.LP.process.button.ok,
  1762. "action": function (d, e) {
  1763. //if (this.empowerDlg) this.empowerDlg.okButton.click();
  1764. orgs.each(function (org, i) {
  1765. org.saveCheckedEmpowerData(function () {
  1766. if (i === orgs.length - 1) {
  1767. if (callback) callback();
  1768. this.node.getParent().unmask();
  1769. this.empowerDlg.close();
  1770. }
  1771. }.bind(this))
  1772. }.bind(this))
  1773. }.bind(this)
  1774. },
  1775. {
  1776. "type": "cancel",
  1777. "text": MWF.LP.process.button.cancel,
  1778. "action": function () {
  1779. this.node.getParent().unmask();
  1780. this.empowerDlg.close();
  1781. }.bind(this)
  1782. }
  1783. ]
  1784. });
  1785. },
  1786. managerLogin: function (e) {
  1787. debugger;
  1788. var _self = this;
  1789. var user = (this.task.identityDn || this.task.identity).split("@")[0];
  1790. var text = MWF.xApplication.process.Work.LP.managerLoginConfirmContent.replace("{user}", user);
  1791. MWF.xDesktop.confirm("infor", e, MWF.xApplication.process.Work.LP.managerLoginConfirmTitle, text, 450, 120, function () {
  1792. o2.Actions.load("x_organization_assemble_authentication").AuthenticationAction.switchUser({"credential": (_self.task.personDn || _self.task.person)}, function () {
  1793. var text = MWF.xApplication.process.Work.LP.managerLoginSuccess.replace("{user}", user);
  1794. MWF.xDesktop.notice("success", {x: "right", y: "top"}, text);
  1795. window.open(o2.filterUrl("../x_desktop/work.html?workid=" + _self.task.work));
  1796. }.bind(this));
  1797. this.close();
  1798. }, function () {
  1799. this.close();
  1800. }, null, null);
  1801. }
  1802. });
  1803. //兼容快速流转,所以需要判断
  1804. if (MWF.xApplication.process.Xform && MWF.xApplication.process.Xform.Form) {
  1805. MWF.xDesktop.requireApp("process.Xform", "Org", null, false);
  1806. MWF.xApplication.process.Work.Processor.Org = new Class({
  1807. Implements: [Options, Events],
  1808. options: {
  1809. moduleEvents: ["queryLoadSelector", "postLoadSelector", "postLoadContent", "queryLoadCategory", "postLoadCategory",
  1810. "selectCategory", "unselectCategory", "queryLoadItem", "postLoadItem", "selectItem", "unselectItem", "change"]
  1811. },
  1812. initialize: function (container, form, json, processor, options) {
  1813. this.form = form;
  1814. this.json = json;
  1815. this.processor = processor;
  1816. this.container = $(container);
  1817. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  1818. this.setOptions(options);
  1819. },
  1820. load: function () {
  1821. if (layout.mobile) {
  1822. setTimeout(function () { //如果有输入法界面,这个时候页面的计算不对,所以等100毫秒
  1823. var options = this.getOptions();
  1824. if (options) {
  1825. //this.selector = new MWF.O2Selector(this.container, options);
  1826. this.selector = new MWF.O2Selector($(document.body), options);
  1827. }
  1828. }.bind(this), 100)
  1829. } else {
  1830. var options = this.getOptions();
  1831. if (options) {
  1832. this.selector = new MWF.O2Selector(this.container, options);
  1833. }
  1834. }
  1835. },
  1836. _getOrgOptions: function () {
  1837. this.selectTypeList = typeOf(this.json.selectType) == "array" ? this.json.selectType : [this.json.selectType];
  1838. if (this.selectTypeList.contains("identity")) {
  1839. this.identityOptions = new MWF.xApplication.process.Work.Processor.IdentityOptions(this.form, this.json);
  1840. }
  1841. if (this.selectTypeList.contains("unit")) {
  1842. this.unitOptions = new MWF.xApplication.process.Work.Processor.UnitOptions(this.form, this.json);
  1843. }
  1844. //if( this.selectTypeList.contains( "group" ) ){
  1845. // this.groupOptions = new MWF.APPOrg.GroupOptions( this.form, this.json );
  1846. //}
  1847. },
  1848. getOptions: function () {
  1849. var _self = this;
  1850. this._getOrgOptions();
  1851. if (this.selectTypeList.length === 0) return false;
  1852. var exclude = [];
  1853. if (this.json.exclude) {
  1854. var v = this.form.Macro.exec(this.json.exclude.code, this);
  1855. exclude = typeOf(v) === "array" ? v : [v];
  1856. }
  1857. var identityOpt;
  1858. if (this.identityOptions) {
  1859. identityOpt = this.identityOptions.getOptions();
  1860. if (this.json.identityRange !== "all") {
  1861. if (!identityOpt.noUnit && (!identityOpt.units || !identityOpt.units.length)) {
  1862. this.form.notice(MWF.xApplication.process.Xform.LP.noIdentitySelectRange, "error", this.node);
  1863. identityOpt.disabled = true;
  1864. // return false;
  1865. }
  1866. }
  1867. if (!identityOpt.noUnit && this.json.dutyRange && this.json.dutyRange !== "all") {
  1868. if (!identityOpt.dutys || !identityOpt.dutys.length) {
  1869. this.form.notice(MWF.xApplication.process.Xform.LP.noIdentityDutySelectRange, "error", this.node);
  1870. identityOpt.disabled = true;
  1871. // return false;
  1872. }
  1873. }
  1874. if (this.ignoreOldData) {
  1875. identityOpt.values = this._computeValue() || [];
  1876. } else {
  1877. identityOpt.values = this.getValue();
  1878. }
  1879. identityOpt.exclude = exclude;
  1880. }
  1881. var unitOpt;
  1882. if (this.unitOptions) {
  1883. unitOpt = this.unitOptions.getOptions();
  1884. if (this.json.unitRange !== "all") {
  1885. if (!unitOpt.units || !unitOpt.units.length) {
  1886. this.form.notice(MWF.xApplication.process.Xform.LP.noUnitSelectRange, "error", this.node);
  1887. unitOpt.disabled = true;
  1888. // return false;
  1889. }
  1890. }
  1891. if (this.ignoreOldData) {
  1892. unitOpt.values = this._computeValue() || [];
  1893. } else {
  1894. unitOpt.values = this.getValue();
  1895. }
  1896. unitOpt.exclude = exclude;
  1897. }
  1898. //var groupOpt;
  1899. //if( this.groupOptions ){
  1900. // groupOpt = this.groupOptions.getOptions();
  1901. // groupOpt.values = (this.json.isInput) ? [] : values;
  1902. // groupOpt.exclude = exclude;
  1903. //}
  1904. var defaultOpt;
  1905. if (layout.mobile) {
  1906. defaultOpt = {
  1907. "style": "default",
  1908. "zIndex": 3000
  1909. };
  1910. } else {
  1911. defaultOpt = {
  1912. "style": "process",
  1913. "width": "auto",
  1914. "height": "240",
  1915. "embedded": true,
  1916. "hasLetter": false, //字母
  1917. "hasTop": true //可选、已选的标题
  1918. };
  1919. }
  1920. if (this.json.events && typeOf(this.json.events) === "object") {
  1921. Object.each(this.json.events, function (e, key) {
  1922. if (e.code) {
  1923. if (this.options.moduleEvents.indexOf(key) !== -1) {
  1924. //this.addEvent(key, function(event){
  1925. // return this.form.Macro.fire(e.code, this, event);
  1926. //}.bind(this));
  1927. if (key === "postLoadSelector") {
  1928. this.addEvent("loadSelector", function (selector) {
  1929. return this.form.Macro.fire(e.code, selector);
  1930. }.bind(this))
  1931. } else if (key === "queryLoadSelector") {
  1932. defaultOpt["onQueryLoad"] = function (target) {
  1933. return this.form.Macro.fire(e.code, target);
  1934. }.bind(this)
  1935. } else {
  1936. defaultOpt["on" + key.capitalize()] = function (target) {
  1937. return this.form.Macro.fire(e.code, target);
  1938. }.bind(this)
  1939. }
  1940. }
  1941. }
  1942. }.bind(this));
  1943. }
  1944. if (this.needValid()) {
  1945. defaultOpt["onValid"] = function (selector) {
  1946. this.validOnSelect();
  1947. }.bind(this);
  1948. }
  1949. if (this.form.json.selectorStyle) {
  1950. defaultOpt = Object.merge(Object.clone(this.form.json.selectorStyle), defaultOpt);
  1951. if (this.form.json.selectorStyle.style) defaultOpt.style = this.form.json.selectorStyle.style;
  1952. }
  1953. var mobileEvents = {
  1954. "onComplete": function (items) {
  1955. this.selectOnComplete(items);
  1956. }.bind(this),
  1957. "onCancel": this.selectOnCancel.bind(this),
  1958. "onClose": this.selectOnClose.bind(this)
  1959. };
  1960. if (this.selectTypeList.length === 1) {
  1961. return Object.merge(
  1962. defaultOpt,
  1963. {
  1964. "type": this.selectTypeList[0],
  1965. "onLoad": function () {
  1966. //this 为 selector
  1967. _self.selectOnLoad(this, this.selector)
  1968. }
  1969. //"onComplete": function(items){
  1970. // this.selectOnComplete(items);
  1971. //}.bind(this),
  1972. //"onCancel": this.selectOnCancel.bind(this),
  1973. //"onClose": this.selectOnClose.bind(this)
  1974. },
  1975. layout.mobile ? mobileEvents : {},
  1976. identityOpt || unitOpt
  1977. )
  1978. } else if (this.selectTypeList.length > 1) {
  1979. var options = {
  1980. "type": "",
  1981. "types": this.selectTypeList,
  1982. "onLoad": function () {
  1983. //this 为 selector
  1984. _self.selectOnLoad(this)
  1985. }
  1986. //"onComplete": function(items){
  1987. // this.selectOnComplete(items);
  1988. //}.bind(this),
  1989. //"onCancel": this.selectOnCancel.bind(this),
  1990. //"onClose": this.selectOnClose.bind(this)
  1991. };
  1992. if (identityOpt) {
  1993. options.identityOptions = Object.merge(
  1994. defaultOpt,
  1995. layout.mobile ? mobileEvents : {},
  1996. identityOpt
  1997. );
  1998. }
  1999. if (unitOpt) {
  2000. options.unitOptions = Object.merge(
  2001. defaultOpt,
  2002. layout.mobile ? mobileEvents : {},
  2003. unitOpt
  2004. );
  2005. }
  2006. //if( groupOpt )options.groupOptions = groupOpt;
  2007. return options;
  2008. }
  2009. },
  2010. selectOnComplete: function (items) { //移动端才执行
  2011. var array = [];
  2012. items.each(function (item) {
  2013. array.push(item.data);
  2014. }.bind(this));
  2015. var simple = this.json.storeRange === "simple";
  2016. this.checkEmpower(array, function (data) {
  2017. var values = [];
  2018. data.each(function (d) {
  2019. values.push(MWF.org.parseOrgData(d, true, simple));
  2020. }.bind(this));
  2021. this.setData(values);
  2022. //this.validationMode();
  2023. //this.validation();
  2024. this.container.empty();
  2025. this.loadOrgWidget(values, this.container);
  2026. this.selector = null;
  2027. this.fireEvent("select", [items, values]);
  2028. }.bind(this))
  2029. },
  2030. selectOnCancel: function () { //移动端才执行
  2031. //this.validation();
  2032. },
  2033. selectOnLoad: function (selector) {
  2034. //if (this.descriptionNode) this.descriptionNode.setStyle("display", "none");
  2035. this.fireEvent("loadSelector", [selector])
  2036. },
  2037. selectOnClose: function () {
  2038. var v = this._getBusinessData();
  2039. //if (!v || !v.length) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block");
  2040. },
  2041. loadOrgWidget: function (value, node) {
  2042. var height = node.getStyle("height").toInt();
  2043. if (node.getStyle("overflow") === "visible" && !height) node.setStyle("overflow", "hidden");
  2044. if (value && value.length) {
  2045. value.each(function (data) {
  2046. var flag = data.distinguishedName.substr(data.distinguishedName.length - 1, 1);
  2047. var copyData = Object.clone(data);
  2048. if (this.json.displayTextScript && this.json.displayTextScript.code) {
  2049. this.currentData = copyData;
  2050. var displayName = this.form.Macro.exec(this.json.displayTextScript.code, this);
  2051. if (displayName) {
  2052. copyData.displayName = displayName;
  2053. }
  2054. this.currentData = null;
  2055. }
  2056. var widget;
  2057. switch (flag.toLowerCase()) {
  2058. case "i":
  2059. widget = new MWF.widget.O2Identity(copyData, node, {"style": "xform", "lazy": true});
  2060. break;
  2061. case "p":
  2062. widget = new MWF.widget.O2Person(copyData, node, {"style": "xform", "lazy": true});
  2063. break;
  2064. case "u":
  2065. widget = new MWF.widget.O2Unit(copyData, node, {"style": "xform", "lazy": true});
  2066. break;
  2067. case "g":
  2068. widget = new MWF.widget.O2Group(copyData, node, {"style": "xform", "lazy": true});
  2069. break;
  2070. default:
  2071. widget = new MWF.widget.O2Other(copyData, node, {"style": "xform", "lazy": true});
  2072. }
  2073. widget.field = this;
  2074. if (layout.mobile) {
  2075. //widget.node.setStyles({
  2076. // "float" : "none"
  2077. //})
  2078. }
  2079. }.bind(this));
  2080. }
  2081. },
  2082. hasEmpowerIdentity: function () {
  2083. var data = this.getData();
  2084. if (!this.empowerChecker) this.empowerChecker = new MWF.xApplication.process.Work.Processor.EmpowerChecker(this.form, this.json, this.processor);
  2085. return this.empowerChecker.hasEmpowerIdentity(data);
  2086. },
  2087. checkEmpower: function (data, callback, container, selectAllNode) {
  2088. if (typeOf(data) === "array" && this.identityOptions && this.json.isCheckEmpower && this.json.identityResultType === "identity") {
  2089. if (!this.empowerChecker) this.empowerChecker = new MWF.xApplication.process.Work.Processor.EmpowerChecker(this.form, this.json, this.processor);
  2090. this.empowerChecker.selectAllNode = selectAllNode;
  2091. this.empowerChecker.load(data, callback, container);
  2092. } else {
  2093. if (callback) callback(data);
  2094. }
  2095. },
  2096. loadCheckEmpower: function (callback, container, selectAllNode) {
  2097. this.checkEmpower(this.getData(), callback, container, selectAllNode)
  2098. },
  2099. saveCheckedEmpowerData: function (callback) {
  2100. var data = this.getData();
  2101. var simple = this.json.storeRange === "simple";
  2102. //this.empowerChecker.replaceEmpowerIdentity(data, function( newData ){
  2103. this.empowerChecker.setIgnoreEmpowerFlag(data, function (newData) {
  2104. var values = [];
  2105. newData.each(function (d) {
  2106. values.push(MWF.org.parseOrgData(d, true, simple));
  2107. }.bind(this));
  2108. this.setData(values);
  2109. if (callback) callback(values)
  2110. }.bind(this))
  2111. },
  2112. //saveWithCheckEmpower: function( isValid, callback ){
  2113. // var checkEmpowerData = function(){
  2114. // var array = this.getData();
  2115. // this.checkEmpower( array, function( data ){
  2116. // var values = [];
  2117. // data.each(function(d){
  2118. // values.push(MWF.org.parseOrgData(d, true));
  2119. // }.bind(this));
  2120. // this.setData( values );
  2121. // if( callback )callback(values)
  2122. // }.bind(this), container, selectAllNode)
  2123. // }.bind(this)
  2124. // if( isValid ){
  2125. // if( this.validation() ){
  2126. // checkEmpowerData( function(){
  2127. // if(callback)callback();
  2128. // }.bind(this));
  2129. // return true;
  2130. // }else{
  2131. // return false;
  2132. // }
  2133. // }else{
  2134. // //this.setData( this.getData() );
  2135. // checkEmpowerData( function(){
  2136. // if(callback)callback();
  2137. // }.bind(this));
  2138. // return true;
  2139. // }
  2140. //},
  2141. save: function (isValid) {
  2142. if (isValid) {
  2143. if (this.validation()) {
  2144. return true;
  2145. } else {
  2146. this.processor.checkErrorHeightOverflow();
  2147. return false;
  2148. }
  2149. } else {
  2150. this.setData(this.getData());
  2151. return true;
  2152. }
  2153. },
  2154. resetSelectorData: function () {
  2155. if (this.selector && this.selector.selector) {
  2156. this.selector.selector.emptySelectedItems();
  2157. this.selector.selector.options.values = this.getValue();
  2158. this.selector.selector.setSelectedItem();
  2159. }
  2160. },
  2161. setDataToOriginal: function () {
  2162. var v = this._computeValue();
  2163. this.setData(v || "");
  2164. },
  2165. resetData: function () {
  2166. var v = this.getValue();
  2167. //this.setData((v) ? v.join(", ") : "");
  2168. this.setData(v);
  2169. },
  2170. getData: function () {
  2171. if (this.selector && !layout.mobile) {
  2172. return this.getSelectedData();
  2173. } else {
  2174. return this.getValue();
  2175. }
  2176. },
  2177. getSelectedData: function () {
  2178. if (layout.mobile) {
  2179. return this.getValue();
  2180. } else {
  2181. var simple = this.json.storeRange === "simple";
  2182. var data = [];
  2183. if (this.selector && this.selector.selector) {
  2184. this.selector.selector.selectedItems.each(function (item) {
  2185. data.push(MWF.org.parseOrgData(item.data, true, simple));
  2186. })
  2187. }
  2188. return data;
  2189. }
  2190. },
  2191. getValue: function () {
  2192. var value = this._getBusinessData();
  2193. if (!value) value = this._computeValue();
  2194. return value || "";
  2195. },
  2196. _computeValue: function () {
  2197. var values = [];
  2198. if (this.json.identityValue) {
  2199. this.json.identityValue.each(function (v) {
  2200. if (v) values.push(v)
  2201. });
  2202. }
  2203. if (this.json.unitValue) {
  2204. this.json.unitValue.each(function (v) {
  2205. if (v) values.push(v)
  2206. });
  2207. }
  2208. if (this.json.dutyValue) {
  2209. var dutys = JSON.decode(this.json.dutyValue);
  2210. var par;
  2211. if (dutys.length) {
  2212. dutys.each(function (duty) {
  2213. if (duty.code) par = this.form.Macro.exec(duty.code, this);
  2214. var code = "return this.org.getDuty(\"" + duty.name + "\", \"" + par + "\")";
  2215. var d = this.form.Macro.exec(code, this);
  2216. if (typeOf(d) !== "array") d = (d) ? [d.toString()] : [];
  2217. d.each(function (dd) {
  2218. if (dd) values.push(dd);
  2219. });
  2220. }.bind(this));
  2221. }
  2222. }
  2223. if (this.json.defaultValue && this.json.defaultValue.code) {
  2224. var fd = this.form.Macro.exec(this.json.defaultValue.code, this);
  2225. if (typeOf(fd) !== "array") fd = (fd) ? [fd] : [];
  2226. fd.each(function (fdd) {
  2227. if (fdd) {
  2228. if (typeOf(fdd) === "string") {
  2229. var data;
  2230. this.getOrgAction()[this.getValueMethod(fdd)](function (json) {
  2231. data = json.data
  2232. }.bind(this), null, fdd, false);
  2233. values.push(data);
  2234. } else {
  2235. values.push(fdd);
  2236. }
  2237. }
  2238. }.bind(this));
  2239. }
  2240. if (this.json.count > 0) {
  2241. return values.slice(0, this.json.count);
  2242. }
  2243. return values;
  2244. //return (this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || "");
  2245. },
  2246. getOrgAction: function () {
  2247. if (!this.orgAction) this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  2248. //if (!this.orgAction) this.orgAction = new MWF.xApplication.Selector.Actions.RestActions();
  2249. return this.orgAction;
  2250. },
  2251. setData: function (value) {
  2252. if (!value) return false;
  2253. var oldValues = this.getValue();
  2254. var values = [];
  2255. var simple = this.json.storeRange === "simple";
  2256. var type = typeOf(value);
  2257. if (type === "array") {
  2258. value.each(function (v) {
  2259. var vtype = typeOf(v);
  2260. var data = null;
  2261. if (vtype === "string") {
  2262. this.getOrgAction()[this.getValueMethod(v)](function (json) {
  2263. data = MWF.org.parseOrgData(json.data, true, simple);
  2264. }.bind(this), error, v, false);
  2265. }
  2266. if (vtype === "object") {
  2267. data = MWF.org.parseOrgData(v, true, simple);
  2268. if (data.woPerson) delete data.woPerson;
  2269. }
  2270. if (data) values.push(data);
  2271. }.bind(this));
  2272. }
  2273. if (type === "string") {
  2274. var vData;
  2275. this.getOrgAction()[this.getValueMethod(value)](function (json) {
  2276. vData = MWF.org.parseOrgData(json.data, true, simple);
  2277. }.bind(this), error, value, false);
  2278. if (vData) values.push(vData);
  2279. }
  2280. if (type === "object") {
  2281. var vData = MWF.org.parseOrgData(value, true, simple);
  2282. if (vData.woPerson) delete vData.woPerson;
  2283. values.push(vData);
  2284. }
  2285. var change = false;
  2286. if (oldValues.length && values.length) {
  2287. if (oldValues.length === values.length) {
  2288. for (var i = 0; i < oldValues.length; i++) {
  2289. if ((oldValues[i].distinguishedName !== values[i].distinguishedName) || (oldValues[i].name !== values[i].name) || (oldValues[i].unique !== values[i].unique)) {
  2290. change = true;
  2291. break;
  2292. }
  2293. }
  2294. } else {
  2295. change = true;
  2296. }
  2297. } else if (values.length || oldValues.length) {
  2298. change = true;
  2299. }
  2300. this._setBusinessData(values);
  2301. if (change) this.fireEvent("change");
  2302. },
  2303. getValueMethod: function (value) {
  2304. if (value) {
  2305. var flag = value.substr(value.length - 1, 1);
  2306. switch (flag.toLowerCase()) {
  2307. case "i":
  2308. return "getIdentity";
  2309. case "p":
  2310. return "getPerson";
  2311. case "u":
  2312. return "getUnit";
  2313. case "g":
  2314. return "getGroup";
  2315. default:
  2316. return (this.json.selectType === "unit") ? "getUnit" : "getIdentity";
  2317. }
  2318. }
  2319. return (this.json.selectType === "unit") ? "getUnit" : "getIdentity";
  2320. },
  2321. _getBusinessData: function () {
  2322. if (this.json.section == "yes") {
  2323. return this._getBusinessSectionData();
  2324. } else {
  2325. if (this.json.type === "Opinion") {
  2326. return this._getBusinessSectionDataByPerson();
  2327. } else {
  2328. return this.form.businessData.data[this.json.name] || "";
  2329. }
  2330. }
  2331. },
  2332. _getBusinessSectionData: function () {
  2333. switch (this.json.sectionBy) {
  2334. case "person":
  2335. return this._getBusinessSectionDataByPerson();
  2336. case "unit":
  2337. return this._getBusinessSectionDataByUnit();
  2338. case "activity":
  2339. return this._getBusinessSectionDataByActivity();
  2340. case "splitValue":
  2341. return this._getBusinessSectionDataBySplitValue();
  2342. case "script":
  2343. return this._getBusinessSectionDataByScript(this.json.sectionByScript.code);
  2344. default:
  2345. return this.form.businessData.data[this.json.name] || "";
  2346. }
  2347. },
  2348. _getBusinessSectionDataByPerson: function () {
  2349. this.form.sectionListObj[this.json.name] = layout.desktop.session.user.id;
  2350. var dataObj = this.form.businessData.data[this.json.name];
  2351. return (dataObj) ? (dataObj[layout.desktop.session.user.id] || "") : "";
  2352. },
  2353. _getBusinessSectionDataByUnit: function () {
  2354. this.form.sectionListObj[this.json.name] = "";
  2355. var key = (this.form.businessData.task) ? this.form.businessData.task.unit : "";
  2356. if (key) this.form.sectionListObj[this.json.name] = key;
  2357. var dataObj = this.form.businessData.data[this.json.name];
  2358. if (!dataObj) return "";
  2359. return (key) ? (dataObj[key] || "") : "";
  2360. },
  2361. _getBusinessSectionDataByActivity: function () {
  2362. this.form.sectionListObj[this.json.name] = "";
  2363. var key = (this.form.businessData.work) ? this.form.businessData.work.activity : "";
  2364. if (key) this.form.sectionListObj[this.json.name] = key;
  2365. var dataObj = this.form.businessData.data[this.json.name];
  2366. if (!dataObj) return "";
  2367. return (key) ? (dataObj[key] || "") : "";
  2368. },
  2369. _getBusinessSectionDataBySplitValue: function () {
  2370. this.form.sectionListObj[this.json.name] = "";
  2371. var key = (this.form.businessData.work) ? this.form.businessData.work.splitValue : "";
  2372. if (key) this.form.sectionListObj[this.json.name] = key;
  2373. var dataObj = this.form.businessData.data[this.json.name];
  2374. if (!dataObj) return "";
  2375. return (key) ? (dataObj[key] || "") : "";
  2376. },
  2377. _getBusinessSectionDataByScript: function (code) {
  2378. this.form.sectionListObj[this.json.name] = "";
  2379. var dataObj = this.form.businessData.data[this.json.name];
  2380. if (!dataObj) return "";
  2381. var key = this.form.Macro.exec(code, this);
  2382. if (key) this.form.sectionListObj[this.json.name] = key;
  2383. return (key) ? (dataObj[key] || "") : "";
  2384. },
  2385. loadPathData: function (path) {
  2386. var data = null;
  2387. this.form.workAction.getJobDataByPath(this.form.businessData.work.job, path, function (json) {
  2388. data = json.data || null;
  2389. }, null, false);
  2390. return data;
  2391. },
  2392. _setBusinessData: function (v) {
  2393. if (this.json.section == "yes") {
  2394. // var d = this.loadPathData(this.json.name);
  2395. // if (d) this.form.businessData.data[this.json.name] = d;
  2396. this._setBusinessSectionData(v);
  2397. } else {
  2398. if (this.json.type === "Opinion") {
  2399. // var d = this.loadPathData(this.json.name);
  2400. // if (d) this.form.businessData.data[this.json.name] = d;
  2401. this._setBusinessSectionDataByPerson(v);
  2402. } else {
  2403. if (this.form.businessData.data[this.json.name]) {
  2404. this.form.businessData.data[this.json.name] = v;
  2405. } else {
  2406. this.form.businessData.data[this.json.name] = v;
  2407. this.form.Macro.environment.setData(this.form.businessData.data);
  2408. }
  2409. if (this.json.isTitle) this.form.businessData.work.title = v;
  2410. }
  2411. }
  2412. },
  2413. _setBusinessSectionData: function (v) {
  2414. switch (this.json.sectionBy) {
  2415. case "person":
  2416. this._setBusinessSectionDataByPerson(v);
  2417. break;
  2418. case "unit":
  2419. this._setBusinessSectionDataByUnit(v);
  2420. break;
  2421. case "activity":
  2422. this._setBusinessSectionDataByActivity(v);
  2423. break;
  2424. case "splitValue":
  2425. this._setBusinessSectionDataBySplitValue(v);
  2426. break;
  2427. case "script":
  2428. this._setBusinessSectionDataByScript(this.json.sectionByScript.code, v);
  2429. break;
  2430. default:
  2431. if (this.form.businessData.data[this.json.name]) {
  2432. this.form.businessData.data[this.json.name] = v;
  2433. } else {
  2434. this.form.businessData.data[this.json.name] = v;
  2435. this.form.Macro.environment.setData(this.form.businessData.data);
  2436. }
  2437. }
  2438. },
  2439. _setBusinessSectionDataByPerson: function (v) {
  2440. var resetData = false;
  2441. var key = layout.desktop.session.user.id;
  2442. this.form.sectionListObj[this.json.name] = key;
  2443. var dataObj = this.form.businessData.data[this.json.name];
  2444. if (!dataObj) {
  2445. dataObj = {};
  2446. this.form.businessData.data[this.json.name] = dataObj;
  2447. resetData = true;
  2448. }
  2449. if (!dataObj[key]) resetData = true;
  2450. dataObj[key] = v;
  2451. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2452. },
  2453. _setBusinessSectionDataByUnit: function (v) {
  2454. var resetData = false;
  2455. var key = (this.form.businessData.task) ? this.form.businessData.task.unit : "";
  2456. if (key) {
  2457. this.form.sectionListObj[this.json.name] = key;
  2458. var dataObj = this.form.businessData.data[this.json.name];
  2459. if (!dataObj) {
  2460. dataObj = {};
  2461. this.form.businessData.data[this.json.name] = dataObj;
  2462. resetData = true;
  2463. }
  2464. if (!dataObj[key]) resetData = true;
  2465. dataObj[key] = v;
  2466. }
  2467. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2468. },
  2469. _setBusinessSectionDataByActivity: function (v) {
  2470. var resetData = false;
  2471. var key = (this.form.businessData.work) ? this.form.businessData.work.activity : "";
  2472. if (key) {
  2473. this.form.sectionListObj[this.json.name] = key;
  2474. var dataObj = this.form.businessData.data[this.json.name];
  2475. if (!dataObj) {
  2476. dataObj = {};
  2477. this.form.businessData.data[this.json.name] = dataObj;
  2478. resetData = true;
  2479. }
  2480. if (!dataObj[key]) resetData = true;
  2481. dataObj[key] = v;
  2482. }
  2483. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2484. },
  2485. _setBusinessSectionDataBySplitValue: function (v) {
  2486. var resetData = false;
  2487. var key = (this.form.businessData.work) ? this.form.businessData.work.splitValue : "";
  2488. if (key) {
  2489. this.form.sectionListObj[this.json.name] = key;
  2490. var dataObj = this.form.businessData.data[this.json.name];
  2491. if (!dataObj) {
  2492. dataObj = {};
  2493. this.form.businessData.data[this.json.name] = dataObj;
  2494. resetData = true;
  2495. }
  2496. if (!dataObj[key]) resetData = true;
  2497. dataObj[key] = v;
  2498. }
  2499. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2500. },
  2501. _setBusinessSectionDataByScript: function (code, v) {
  2502. var resetData = false;
  2503. var key = this.form.Macro.exec(code, this);
  2504. if (key) {
  2505. this.form.sectionListObj[this.json.name] = key;
  2506. var dataObj = this.form.businessData.data[this.json.name];
  2507. if (!dataObj) {
  2508. dataObj = {};
  2509. this.form.businessData.data[this.json.name] = dataObj;
  2510. resetData = true;
  2511. }
  2512. if (!dataObj[key]) resetData = true;
  2513. dataObj[key] = v;
  2514. }
  2515. if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
  2516. },
  2517. createErrorNode: function (text) {
  2518. var _self = this;
  2519. var node;
  2520. if (this.processor.css.errorContentNode) {
  2521. node = new Element("div", {
  2522. "styles": this.processor.css.errorContentNode,
  2523. "text": text
  2524. });
  2525. if (this.processor.css.errorCloseNode) {
  2526. var closeNode = new Element("div", {
  2527. "styles": this.processor.css.errorCloseNode,
  2528. "events": {
  2529. "click": function () {
  2530. this.destroy();
  2531. if (_self.errorHeightOverflow) {
  2532. _self.errorHeightOverflow = false;
  2533. _self.processor.errorHeightChange();
  2534. }
  2535. }.bind(node)
  2536. }
  2537. }).inject(node);
  2538. }
  2539. } else {
  2540. node = new Element("div");
  2541. var iconNode = new Element("div", {
  2542. "styles": {
  2543. "width": "20px",
  2544. "height": "20px",
  2545. "float": "left",
  2546. "background": "url(" + "../x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
  2547. }
  2548. }).inject(node);
  2549. var textNode = new Element("div", {
  2550. "styles": {
  2551. "height": "auto",
  2552. "min-height": "20px",
  2553. "line-height": "20px",
  2554. "margin-left": "20px",
  2555. "color": "red",
  2556. "word-break": "break-all"
  2557. },
  2558. "text": text
  2559. }).inject(node);
  2560. }
  2561. return node;
  2562. },
  2563. notValidationMode: function (text) {
  2564. if (!this.isNotValidationMode) {
  2565. //this.isNotValidationMode = true;
  2566. //this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
  2567. //this.node.setStyle("border-color", "red");
  2568. this.errNode = this.createErrorNode(text);
  2569. if (this.errContainer) {
  2570. this.errContainer.empty();
  2571. this.errNode.inject(this.errContainer);
  2572. } else {
  2573. this.errNode.inject(this.container, "after");
  2574. }
  2575. var errorSize = this.errNode.getSize();
  2576. debugger;
  2577. if (!layout.mobile && errorSize.y > 26) {
  2578. this.errorHeightOverflow = true;
  2579. }
  2580. //this.showNotValidationMode(this.node);
  2581. //if (!this.node.isIntoView()) this.node.scrollIntoView();
  2582. }
  2583. },
  2584. needValid: function () {
  2585. return ((this.json.validationCount && typeOf(this.json.validationCount.toInt()) === "number") ||
  2586. (this.json.validation && this.json.validation.code));
  2587. },
  2588. validOnSelect: function () {
  2589. if (!this.errNode) return true;
  2590. var flag = true;
  2591. if (this.json.validationCount && typeOf(this.json.validationCount.toInt()) === "number") {
  2592. if (this.selector.selector.selectedItems.length < this.json.validationCount.toInt()) {
  2593. flag = "请至少选择" + this.json.validationCount + "项"
  2594. }
  2595. }
  2596. if (flag === true) {
  2597. if (this.json.validation && this.json.validation.code) {
  2598. var data = this.getData();
  2599. this.setData(data);
  2600. flag = this.form.Macro.exec(this.json.validation.code, this);
  2601. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  2602. }
  2603. }
  2604. if (flag.toString() != "true") {
  2605. this.notValidationMode(flag);
  2606. this.processor.errorHeightChange();
  2607. return false;
  2608. } else if (this.errNode) {
  2609. this.errNode.destroy();
  2610. this.errNode = null;
  2611. if (this.errorHeightOverflow) {
  2612. this.errorHeightOverflow = false;
  2613. this.processor.errorHeightChange();
  2614. }
  2615. }
  2616. return true;
  2617. },
  2618. validation: function () {
  2619. var data = this.getData();
  2620. this.setData(data);
  2621. var flag = true;
  2622. if (this.json.validationCount && typeOf(this.json.validationCount.toInt()) === "number") {
  2623. if (data.length < this.json.validationCount.toInt()) {
  2624. flag = "请至少选择" + this.json.validationCount + "项"
  2625. }
  2626. }
  2627. if (flag === true) {
  2628. if (this.json.validation && this.json.validation.code) {
  2629. flag = this.form.Macro.exec(this.json.validation.code, this);
  2630. if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
  2631. }
  2632. }
  2633. if (flag.toString() != "true") {
  2634. this.notValidationMode(flag);
  2635. return false;
  2636. } else if (this.errNode) {
  2637. this.errNode.destroy();
  2638. this.errNode = null;
  2639. }
  2640. return true;
  2641. }
  2642. });
  2643. MWF.xApplication.process.Work.Processor.EmpowerChecker = new Class({
  2644. Extends: MWF.APPOrg.EmpowerChecker,
  2645. initialize: function (form, json, processor) {
  2646. this.form = form;
  2647. this.json = json;
  2648. this.processor = processor;
  2649. this.css = this.processor.css;
  2650. this.checkedAllItems = true;
  2651. },
  2652. load: function (data, callback, container) {
  2653. if (typeOf(data) === "array" && this.json.isCheckEmpower && this.json.identityResultType === "identity") {
  2654. var array = [];
  2655. data.each(function (d) {
  2656. if (d.distinguishedName) {
  2657. var flag = d.distinguishedName.substr(d.distinguishedName.length - 1, 1).toLowerCase();
  2658. if (flag === "i") {
  2659. array.push(d.distinguishedName)
  2660. }
  2661. }
  2662. }.bind(this));
  2663. if (array.length > 0) {
  2664. o2.Actions.get("x_organization_assemble_express").listEmpowerWithIdentity({
  2665. "application": (this.form.businessData.work || this.form.businessData.workCompleted).application,
  2666. "process": (this.form.businessData.work || this.form.businessData.workCompleted).process,
  2667. "work": (this.form.businessData.work || this.form.businessData.workCompleted).id,
  2668. "identityList": array
  2669. }, function (json) {
  2670. var arr = [];
  2671. json.data.each(function (d) {
  2672. if (d.fromIdentity !== d.toIdentity) arr.push(d);
  2673. });
  2674. if (arr.length > 0) {
  2675. if (layout.mobile) {
  2676. this.openSelectEmpowerDlg(arr, data, callback, container);
  2677. } else {
  2678. this.openSelectEmpowerDlg_embedded(arr, data, callback, container);
  2679. }
  2680. } else {
  2681. if (callback) callback(data);
  2682. }
  2683. }.bind(this), function () {
  2684. if (callback) callback(data);
  2685. }.bind(this))
  2686. } else {
  2687. if (callback) callback(data);
  2688. }
  2689. } else {
  2690. if (callback) callback(data);
  2691. }
  2692. },
  2693. hasEmpowerIdentity: function (data) {
  2694. var flag = false;
  2695. if (typeOf(data) === "array" && this.json.isCheckEmpower && this.json.identityResultType === "identity") {
  2696. var array = [];
  2697. data.each(function (d) {
  2698. if (d.distinguishedName) {
  2699. var flag = d.distinguishedName.substr(d.distinguishedName.length - 1, 1).toLowerCase();
  2700. if (flag === "i") array.push(d.distinguishedName)
  2701. }
  2702. }.bind(this));
  2703. if (array.length > 0) {
  2704. o2.Actions.get("x_organization_assemble_express").listEmpowerWithIdentity({
  2705. "application": (this.form.businessData.work || this.form.businessData.workCompleted).application,
  2706. "process": (this.form.businessData.work || this.form.businessData.workCompleted).process,
  2707. "work": (this.form.businessData.work || this.form.businessData.workCompleted).id,
  2708. "identityList": array
  2709. }, function (json) {
  2710. var arr = [];
  2711. json.data.each(function (d) {
  2712. if (d.fromIdentity !== d.toIdentity)
  2713. arr.push(d);
  2714. });
  2715. if (arr.length > 0) {
  2716. flag = true;
  2717. }
  2718. }.bind(this), null, false)
  2719. }
  2720. }
  2721. return flag;
  2722. },
  2723. openSelectEmpowerDlg_embedded: function (data, orgData, callback, container) {
  2724. var node = new Element("div", {"styles": this.css.empowerAreaNode});
  2725. //var html = "<div style=\"line-height: 30px; color: #333333; overflow: hidden\">"+MWF.xApplication.process.Xform.LP.empowerDlgText+"</div>";
  2726. var html = "<div style=\"margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  2727. node.set("html", html);
  2728. var itemNode = node.getLast();
  2729. this.getEmpowerItems(itemNode, data);
  2730. node.inject(container || this.form.app.content);
  2731. if (this.selectAllNode) {
  2732. var selectNode = this.createSelectAllEmpowerNode();
  2733. selectNode.inject(this.selectAllNode);
  2734. if (this.checkedAllItems) {
  2735. selectNode.store("isSelected", true);
  2736. selectNode.setStyles(this.css.empowerSelectAllItemNode_selected);
  2737. }
  2738. }
  2739. },
  2740. getSelectedData: function (callback) {
  2741. var json = {};
  2742. this.empowerSelectNodes.each(function (node) {
  2743. if (node.retrieve("isSelected")) {
  2744. var d = node.retrieve("data");
  2745. json[d.fromIdentity] = d;
  2746. }
  2747. }.bind(this));
  2748. if (callback) callback(json);
  2749. }
  2750. });
  2751. MWF.xApplication.process.Work.Processor.UnitOptions = new Class({
  2752. Extends: MWF.APPOrg.UnitOptions
  2753. });
  2754. MWF.xApplication.process.Work.Processor.IdentityOptions = new Class({
  2755. Extends: MWF.APPOrg.IdentityOptions
  2756. });
  2757. }