Processor.js 122 KB

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