Processor.js 129 KB

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