Main.js 124 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104
  1. MWF.xApplication.process.Application.options.multitask = true;
  2. o2.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  4. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  5. MWF.xApplication.process.Application.Main = new Class({
  6. Extends: MWF.xApplication.Common.Main,
  7. Implements: [Options, Events],
  8. options: {
  9. "style1": "default",
  10. "style": "default",
  11. "name": "process.Application",
  12. "mvcStyle": "style.css",
  13. "icon": "icon.png",
  14. "application": "",
  15. "id": "",
  16. "navi" : "all",
  17. "title": MWF.xApplication.process.Application.LP.title
  18. },
  19. onQueryLoad: function(){
  20. this.lp = MWF.xApplication.process.Application.LP;
  21. this.action = o2.Actions.load("x_processplatform_assemble_surface");
  22. if (this.status) {
  23. if(this.status.id)this.options.id = this.status.id;
  24. if(this.status.navi){
  25. this.options.navi = this.status.navi;
  26. }
  27. }
  28. this._loadCss();
  29. },
  30. loadApplication: function(callback){
  31. this.initAcl(function (){
  32. this.loadProcessList(function (){
  33. this.action.ApplicationAction.get(this.options.id).then(function (json){
  34. if (json.data){
  35. this.setTitle(this.lp.title+"-"+json.data.name);
  36. this.application = json.data;
  37. var url = this.path+this.options.style+"/view/view.html";
  38. this.content.loadHtml(url, {"bind": {"acl":this.acl,"lp": this.lp,"data":{"application" : this.application}}, "module": this}, function(){
  39. this.setLayout();
  40. this.loadList(this.options.navi);
  41. if (callback) callback();
  42. }.bind(this));
  43. }
  44. }.bind(this));
  45. }.bind(this));
  46. }.bind(this));
  47. },
  48. loadApplicationIcon : function (e){
  49. var node = e.currentTarget;
  50. if (this.application.icon){
  51. node.setStyle("background-image", "url(data:image/png;base64,"+this.application.icon+")");
  52. }else{
  53. node.setStyle("background-image", "url("+"../x_component_process_Application/$Main/default/icon/application.png)");
  54. }
  55. },
  56. initAcl : function (callback){
  57. this.acl = {
  58. }
  59. this.action.ApplicationAction.isManager(this.options.id).then(function (json){
  60. this.acl.isAppManager = json.data.value;
  61. this.action.ProcessAction.listControllableWithApplication(this.options.id).then(function (json){
  62. var processList = json.data.valueList;
  63. if(processList.length>0){
  64. this.acl.isProcessManager = true;
  65. }else {
  66. this.acl.isProcessManager = false;
  67. }
  68. this.acl.processList = json.data.valueList;
  69. if(callback) callback();
  70. }.bind(this));
  71. }.bind(this));
  72. },
  73. loadProcessList : function (callback){
  74. this.action.ProcessAction.listWithPersonWithApplication(this.options.id).then(function (json){
  75. this.processList = json.data;
  76. if(callback) callback();
  77. }.bind(this));
  78. },
  79. createCountData: function(){
  80. var _self = this;
  81. if (!this.countData){
  82. this.countData = {"data": {}};
  83. var createDefineObject = function(p){
  84. return {
  85. "get": function(){return this.data[p]},
  86. "set": function(v){
  87. this.data[p] = v;
  88. _self[p+"CountNode"].set("text", v);
  89. }
  90. }
  91. };
  92. var o = {
  93. "task": createDefineObject("task"),
  94. "taskCompleted": createDefineObject("taskCompleted"),
  95. "read": createDefineObject("read"),
  96. "readCompleted": createDefineObject("readCompleted"),
  97. "draft": createDefineObject("draft"),
  98. };
  99. MWF.defineProperties(this.countData, o);
  100. }
  101. },
  102. loadCount: function(){
  103. this.createCountData();
  104. this.action.WorkAction.countWithPersonAndApplication(layout.session.user.id,this.application.id).then(function(json){
  105. this.countData.task = json.data.task;
  106. this.countData.taskCompleted = json.data.taskCompleted;
  107. this.countData.read = json.data.read;
  108. this.countData.readCompleted = json.data.readCompleted;
  109. }.bind(this));
  110. this.action.DraftAction.listMyPaging(1,1, {"applicationList":[this.application.id]}).then(function(json){
  111. this.countData.draft = json.count;
  112. }.bind(this));
  113. },
  114. loadList: function(type,ev,data){
  115. if (this.currentMenu) this.setMenuItemStyleDefault(this.currentMenu);
  116. this.setMenuItemStyleCurrent(this[type+"MenuNode"]);
  117. this.currentMenu = this[type+"MenuNode"];
  118. this._loadListContent(type);
  119. this.loadCount();
  120. },
  121. _loadListContent: function(type){
  122. this.mainNode.empty();
  123. list = new MWF.xApplication.process.Application[type.capitalize() +"List"](this.mainNode,this, {
  124. "onLoadData": function (){
  125. this.hideSkeleton();
  126. },
  127. "type" : type,
  128. "key" : this.options.key
  129. });
  130. this.currentList = list;
  131. },
  132. setLayout: function(){
  133. var items = this.content.getElements(".menuItem");
  134. items.addEvents({
  135. "mouseover": function(){this.addClass("menuItem_over")},
  136. "mouseout": function(){this.removeClass("menuItem_over")},
  137. "click": function(){}
  138. });
  139. },
  140. startProcess: function(){
  141. this.action.ProcessAction.listWithPersonWithApplication(this.application.id).then(function (json){
  142. var node = new Element("div");
  143. var url = this.path+this.options.style+"/view/dlg/processList.html";
  144. node.loadHtml(url, {"bind": {"lp": this.lp,"processList":json.data}, "module": this}, function(){
  145. this.startProcessDlg = o2.DL.open({
  146. "title": this.lp.startProcess,
  147. "width": "400px",
  148. "height": "260px",
  149. "mask": true,
  150. "content": node,
  151. "container": null,
  152. "positionNode": this.content,
  153. "onQueryClose": function () {
  154. node.destroy();
  155. }.bind(this),
  156. "buttonList": [
  157. ],
  158. "onPostShow": function () {
  159. this.startProcessDlg.reCenter();
  160. }.bind(this)
  161. });
  162. }.bind(this));
  163. }.bind(this));
  164. },
  165. startProcessItemOver: function(e){
  166. var node = e.target;
  167. while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
  168. if (node){
  169. node.addClass("menuItem_over");
  170. node.removeClass("mainColor_bg");
  171. }
  172. },
  173. startProcessItemOut: function(e){
  174. var node = e.target;
  175. while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
  176. if (node){
  177. node.removeClass("menuItem_over");
  178. node.removeClass("mainColor_bg");
  179. }
  180. },
  181. startProcessItemDown: function(e){
  182. var node = e.target;
  183. while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
  184. if (node){
  185. node.removeClass("menuItem_over");
  186. node.addClass("mainColor_bg");
  187. }
  188. },
  189. startProcessItemUp: function(e){
  190. var node = e.target;
  191. while (node && !node.hasClass("st_processItem")){ node = node.getParent();}
  192. if (node){
  193. node.addClass("menuItem_over");
  194. node.removeClass("mainColor_bg");
  195. }
  196. },
  197. startProcessItemClick: function(e, data){
  198. this.startProcessDlg.close();
  199. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  200. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(data, this, {
  201. "onStarted": function(workdata, title, processName){
  202. this.afterStartProcess(workdata, title, processName, data);
  203. }.bind(this)
  204. });
  205. starter.load();
  206. }.bind(this));
  207. },
  208. afterStartProcess: function(data, title, processName, processdata){
  209. if (data.work){
  210. this.startProcessDraft(data, title, processName);
  211. }else{
  212. this.startProcessInstance(data, title, processName);
  213. }
  214. },
  215. startProcessDraft: function(data, title, processName){
  216. var work = data.work;
  217. var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false,
  218. "onPostClose": function(){
  219. if (this.currentList.refresh) this.currentList.refresh();
  220. }.bind(this)
  221. };
  222. this.desktop.openApplication(null, "process.Work", options);
  223. },
  224. startProcessInstance: function(data, title, processName){
  225. var workInfors = [];
  226. var currentTask = [];
  227. data.each(function(work){
  228. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  229. workInfors.push(this.getStartWorkInforObj(work));
  230. }.bind(this));
  231. if (currentTask.length===1){
  232. var options = {"workId": currentTask[0], "appId": "process.Work"+currentTask[0],
  233. "onPostClose": function(){
  234. if (this.currentList.refresh) this.currentList.refresh();
  235. }.bind(this)
  236. };
  237. this.desktop.openApplication(null, "process.Work", options);
  238. if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, false);
  239. }else{
  240. if (layout.desktop.message) this.createStartWorkResault(workInfors, title, processName, true);
  241. }
  242. },
  243. getStartWorkInforObj: function(work){
  244. var users = [];
  245. var currentTask = "";
  246. work.taskList.each(function(task, idx){
  247. users.push(task.person+"("+task.department + ")");
  248. if (work.currentTaskIndex===idx) currentTask = task.id;
  249. }.bind(this));
  250. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask};
  251. },
  252. setMenuItemStyleDefault: function(node){
  253. node.removeClass("mainColor_bg_opacity");
  254. node.getFirst().removeClass("mainColor_color");
  255. node.getLast().removeClass("mainColor_color");
  256. },
  257. setMenuItemStyleCurrent: function(node){
  258. node.addClass("mainColor_bg_opacity");
  259. node.getFirst().addClass("mainColor_color");
  260. node.getLast().addClass("mainColor_color");
  261. },
  262. recordStatus: function(){
  263. return { "id": this.options.id};
  264. }
  265. });
  266. MWF.xApplication.process.Application.List = new Class({
  267. Implements: [Options, Events],
  268. options: {
  269. "type": "all",
  270. "itemHeight": 40,
  271. },
  272. initialize: function (node,app, options) {
  273. this.setOptions(options);
  274. this.app = app;
  275. this.container = node;
  276. this.lp = this.app.lp;
  277. this.css = this.app.css;
  278. this.action = app.action;
  279. this.type = this.options.type;
  280. this.application = app.application;
  281. var url = this.app.path+this.app.options.style+"/view/content.html";
  282. this.container.loadHtml(url, {"bind": {"lp": this.lp,"data":{"type":this.type}}, "module": this}, function(){
  283. this.content = this.listContentNode;
  284. this.bottomNode = this.listBottomNode;
  285. this.pageNode = this.pageNumberAreaNode;
  286. this.init();
  287. this.load();
  288. }.bind(this));
  289. },
  290. loadFilter: function () {
  291. var lp = this.lp;
  292. this.fileterNode = new Element("div.fileterNode", {
  293. "styles": this.css.fileterNode
  294. }).inject(this.searchNode);
  295. var html = "<table bordr='0' cellpadding='0' cellspacing='0' styles='filterTable'>" + //style='width: 900px;'
  296. "<tr>" +
  297. " <td styles='filterTableTitle' lable='title'></td>" +
  298. " <td styles='filterTableValue' item='title'></td>" +
  299. " <td styles='filterTableTitle' lable='activityName'></td>" +
  300. " <td styles='filterTableValue' item='activityName'></td>" +
  301. " <td styles='filterTableTitle' lable='creatorUnitList'></td>" +
  302. " <td styles='filterTableValue' item='creatorUnitList'></td>" +
  303. " <td styles='filterTableTitle' lable='credentialList'></td>" +
  304. " <td styles='filterTableValue' item='credentialList'></td>" +
  305. "</tr>" +
  306. "<tr style='height: 45px;'>" +
  307. " <td styles='filterTableTitle' lable='processName'></td>" +
  308. " <td styles='filterTableValue' item='processName'></td>" +
  309. " <td styles='filterTableTitle' lable='startTime'></td>" +
  310. " <td styles='filterTableValue' item='startTime'></td>" +
  311. " <td styles='filterTableTitle' lable='endTime'></td>" +
  312. " <td styles='filterTableValue' item='endTime'></td>" +
  313. " <td styles='filterTableValue' colspan='2'><div style='float:left' item='action'></div><div item='reset'></div></td>" +
  314. "</tr>" +
  315. "</table>";
  316. this.fileterNode.set("html", html);
  317. var selectValue = [""];
  318. var selectText = [""];
  319. this.app.processList.each(function(d){
  320. selectValue.push(d.id);
  321. selectText.push(d.name);
  322. })
  323. this.form = new MForm(this.fileterNode, {}, {
  324. style: "attendance",
  325. isEdited: true,
  326. itemTemplate: {
  327. title: {text: lp.subject, "type": "text", "style": {"min-width": "150px"}},
  328. activityName: {text: lp.activity, "type": "text", "style": {"min-width": "150px"}},
  329. processName: {
  330. "text": lp.process,
  331. "type": "select",
  332. "selectValue" :selectValue,
  333. "selectText" :selectText,
  334. "style": {"min-width": "150px"},
  335. },
  336. credentialList: {
  337. "text": lp.creator,
  338. "type": "org",
  339. "orgType": "identity",
  340. "orgOptions": {"resultType": "person"},
  341. "style": {"min-width": "150px"},
  342. "orgWidgetOptions": {"disableInfor": true}
  343. },
  344. creatorUnitList: {
  345. "text": lp.createunit,
  346. "type": "org",
  347. "orgType": "unit",
  348. "orgOptions": {"resultType": "person"},
  349. "style": {"min-width": "150px"},
  350. "orgWidgetOptions": {"disableInfor": true}
  351. },
  352. startTime: {
  353. text: lp.begin,
  354. "tType": "date",
  355. "style": {"min-width":"150px"}
  356. },
  357. endTime: {
  358. text: lp.end,
  359. "tType": "date",
  360. "style": {"min-width":"150px"}
  361. },
  362. action: {
  363. "value": this.lp.query, type: "button", className: "filterButton", event: {
  364. click: function () {
  365. var result = this.form.getResult(false, null, false, false, false);
  366. for (var key in result) {
  367. if (!result[key]) {
  368. delete result[key];
  369. } else if (key === "activityName" && result[key].length > 0) {
  370. //result[key] = result[key][0].split("@")[1];
  371. result["activityNameList"] = [result[key]];
  372. delete result[key];
  373. }else if (key === "processName" && result[key] !== "") {
  374. //result[key] = result[key][0].split("@")[1];
  375. result["processList"] = [result[key]];
  376. delete result[key];
  377. }else if (key === "endTime" && result[key] !== "") {
  378. result[key] = result[key] + " 23:59:59"
  379. }
  380. }
  381. result.applicationList = this.filterList.applicationList;
  382. if(result.credentialList) {
  383. result.creatorPersonList = result.credentialList;
  384. }
  385. this.filterList = result;
  386. this.refresh();
  387. }.bind(this)
  388. }
  389. },
  390. reset: {
  391. "value": this.lp.reset, type: "button", className: "filterButtonGrey", event: {
  392. click: function () {
  393. this.form.reset();
  394. this._initFilter();
  395. this.refresh();
  396. }.bind(this)
  397. }
  398. },
  399. }
  400. }, this.app, this.css);
  401. this.form.load();
  402. },
  403. showSkeleton: function(){
  404. if (this.skeletonNode) this.skeletonNode.inject(this.listContentNode);
  405. },
  406. hideSkeleton: function(){
  407. if (this.skeletonNode) this.skeletonNode.dispose();
  408. },
  409. loadListTitle : function (){
  410. this.listTitleNode.empty();
  411. this.listTitleNode.loadHtml(this.titleTempleteUrl, {"bind": {"lp": this.lp}, "module": this}, function(){
  412. this.currentSortNode = this.sortUpdateTimeNode;
  413. this.currentSortKey = "name";
  414. }.bind(this));
  415. },
  416. selectAll : function (e){
  417. if (e.currentTarget.get("disabled").toString()!="true"){
  418. var itemNode = e.currentTarget.getParent(".listItem");
  419. var iconNode = e.currentTarget.getElement(".selectFlagIcon");
  420. if (itemNode){
  421. if (itemNode.hasClass("mainColor_bg_opacity")){
  422. itemNode.removeClass("mainColor_bg_opacity");
  423. iconNode.removeClass("icon-xuanzhong");
  424. iconNode.removeClass("selectFlagIcon_select");
  425. iconNode.removeClass("mainColor_color");
  426. this.listContentNode.getElements("tr").each(function (tr){
  427. tr.removeClass("mainColor_bg_opacity");
  428. var ss = tr.getElement(".selectFlagIcon");
  429. tr.getElement(".selectFlag").hide();
  430. ss.removeClass("icon-xuanzhong");
  431. ss.removeClass("selectFlagIcon_select");
  432. ss.removeClass("mainColor_color");
  433. })
  434. this.selectedList = [];
  435. }else{
  436. itemNode.addClass("mainColor_bg_opacity");
  437. iconNode.addClass("icon-xuanzhong");
  438. iconNode.addClass("selectFlagIcon_select");
  439. iconNode.addClass("mainColor_color");
  440. this.listContentNode.getElements("tr").each(function (tr){
  441. tr.getElement(".selectFlag").show();
  442. tr.addClass("mainColor_bg_opacity");
  443. var ss = tr.getElement(".selectFlagIcon");
  444. ss.addClass("icon-xuanzhong");
  445. ss.addClass("selectFlagIcon_select");
  446. ss.addClass("mainColor_color");
  447. })
  448. this.selectedList.append(this.dataList);
  449. }
  450. }
  451. }
  452. this._setToolBar();
  453. },
  454. loadItems: function(data){
  455. this.dataList = data;
  456. this.content.loadHtml(this.listTempleteUrl, {"bind": {"lp": this.lp, "type": this.options.type, "data": data}, "module": this}, function(){
  457. this.node = this.content.getFirst();
  458. }.bind(this));
  459. },
  460. init: function(){
  461. this.listHeight = this.content.getSize().y - this.options.itemHeight - 60;
  462. this.size = (this.listHeight/this.options.itemHeight).toInt();
  463. this.size = 15;
  464. this.page = 1;
  465. this.loadFilter();
  466. this._initFilter();
  467. this.filterNameList = {};
  468. },
  469. _initFilter : function(){
  470. this.filterList = {
  471. applicationList : [this.application.id]
  472. };
  473. },
  474. _initTempate: function () {
  475. this.titleTempleteUrl = this.app.path + this.app.options.style + "/view/" + this.type + "/list_title.html";
  476. this.listTempleteUrl = this.app.path + this.app.options.style + "/view/" + this.type + "/list.html";
  477. },
  478. load: function(){
  479. var _self = this;
  480. this._initToolBar();
  481. this._initTempate();
  482. this.loadListTitle();
  483. if(this.toolbarItems.unSelect.length>0){
  484. this.loadToolBar(this.toolbarItems.unSelect);
  485. }else {
  486. this.loadToolBar(this.toolbarItems.default,true);
  487. }
  488. this.selectedList = [];
  489. this.loadData().then(function(data){
  490. _self.hide();
  491. _self.loadPage();
  492. _self.loadItems(data);
  493. });
  494. },
  495. _initToolBar : function (){
  496. this.toolbarItems = {
  497. "default":[
  498. ],
  499. "unSelect":[
  500. ],
  501. "selected":[
  502. ],
  503. "mulSelect":[
  504. ]
  505. }
  506. },
  507. loadToolBar : function (availableTool,disabled){
  508. this.toolBarNode.empty();
  509. this.toolbar = new MWF.xApplication.process.Application.Toolbar(this.toolBarNode, this, {
  510. viewType : this.options.defaultViewType,
  511. type : this.type,
  512. disabled : !!disabled,
  513. availableTool : availableTool
  514. });
  515. this.toolbar.load();
  516. if(availableTool.length===0){
  517. this.toolBarNode.hide();
  518. }else {
  519. this.toolBarNode.show();
  520. }
  521. },
  522. refresh: function(){
  523. this.hide();
  524. this.load();
  525. this.app.loadCount();
  526. },
  527. hide: function(){
  528. if (this.node) this.node.destroy();
  529. },
  530. loadPage: function(){
  531. var totalCount = this.total;
  532. var pages = totalCount/this.size;
  533. var pageCount = pages.toInt();
  534. if (pages !== pageCount) pageCount = pageCount+1;
  535. this.pageCount = pageCount;
  536. var size = this.bottomNode.getSize();
  537. var maxPageSize = 500;//size.x*0.8;
  538. maxPageSize = maxPageSize - 80*2-24*2-10*3;
  539. var maxPageCount = (maxPageSize/34).toInt();
  540. this.loadPageNode(pageCount, maxPageCount);
  541. },
  542. loadPageNode: function(pageCount, maxPageCount){
  543. var pageStart = 1;
  544. var pageEnd = pageCount;
  545. if (pageCount>maxPageCount){
  546. var halfCount = (maxPageCount/2).toInt();
  547. pageStart = Math.max(this.page-halfCount, 1);
  548. pageEnd = pageStart+maxPageCount-1;
  549. pageEnd = Math.min(pageEnd, pageCount);
  550. pageStart = pageEnd - maxPageCount+1;
  551. }
  552. this.pageNode.empty();
  553. var _self = this;
  554. for (var i=pageStart; i<=pageEnd; i++){
  555. var node = new Element("div.pageItem", {
  556. "text": i,
  557. "events": { "click": function(){_self.gotoPage(this.get("text"));} }
  558. }).inject(this.pageNode);
  559. if (i==this.page) node.addClass("mainColor_bg");
  560. }
  561. },
  562. nextPage: function(){
  563. this.page++;
  564. if (this.page>this.pageCount) this.page = this.pageCount;
  565. this.gotoPage(this.page);
  566. },
  567. prevPage: function(){
  568. this.page--;
  569. if (this.page<1) this.page = 1;
  570. this.gotoPage(this.page);
  571. },
  572. firstPage: function(){
  573. this.gotoPage(1);
  574. },
  575. lastPage: function(){
  576. this.gotoPage(this.pageCount);
  577. },
  578. gotoPage: function(page){
  579. this.page = page;
  580. this.hide();
  581. this.showSkeleton();
  582. this.load();
  583. },
  584. loadData: function(){
  585. },
  586. _fixData : function (dataList){
  587. dataList.each(function (data){
  588. data.creatorPersonName = data.creatorPerson.split("@")[0];
  589. data.creatorUnitName = data.creatorUnit.split("@")[0];
  590. data.title = data.title || this.lp.unnamed;
  591. }.bind(this));
  592. return dataList;
  593. },
  594. overTaskItem: function(e){
  595. e.currentTarget.addClass("listItem_over");
  596. var iconNode = e.currentTarget.getElement(".selectFlagIcon");
  597. if (iconNode.hasClass("selectFlagIcon_select")){
  598. }else{
  599. e.currentTarget.getElement(".selectFlag").show();
  600. }
  601. },
  602. outTaskItem: function(e){
  603. e.currentTarget.removeClass("listItem_over");
  604. var iconNode = e.currentTarget.getElement(".selectFlagIcon");
  605. if (iconNode.hasClass("selectFlagIcon_select")){
  606. }else{
  607. e.currentTarget.getElement(".selectFlag").hide();
  608. }
  609. },
  610. loadItemIcon: function(application, e){
  611. return
  612. this.app.loadItemIcon(application, e);
  613. },
  614. selectFile: function(id,e, dataList){
  615. var data ;
  616. for(var i = 0 ; i < this.dataList.length;i++){
  617. if(this.dataList[i].id === id){
  618. data = this.dataList[i];
  619. break ;
  620. }
  621. }
  622. if (e.currentTarget.get("disabled").toString()!="true"){
  623. var itemNode = e.currentTarget.getParent(".listItem");
  624. var iconNode = e.currentTarget.getElement(".selectFlagIcon");
  625. if (itemNode){
  626. if (itemNode.hasClass("mainColor_bg_opacity")){
  627. itemNode.removeClass("mainColor_bg_opacity");
  628. iconNode.removeClass("icon-xuanzhong");
  629. iconNode.removeClass("selectFlagIcon_select");
  630. iconNode.removeClass("mainColor_color");
  631. this.unselectedFile(data);
  632. }else{
  633. itemNode.addClass("mainColor_bg_opacity");
  634. iconNode.addClass("icon-xuanzhong");
  635. iconNode.addClass("selectFlagIcon_select");
  636. iconNode.addClass("mainColor_color");
  637. this.selectedFile(data);
  638. }
  639. }
  640. }
  641. this._setToolBar();
  642. },
  643. _setToolBar : function (){
  644. if(this.selectedList.length === 0 ){
  645. if(this.toolbarItems.unSelect.length>0){
  646. this.loadToolBar(this.toolbarItems.unSelect);
  647. }else {
  648. this.loadToolBar(this.toolbarItems.default,true);
  649. }
  650. } else if (this.selectedList.length === 1){
  651. this.loadToolBar(this.toolbarItems.selected);
  652. }else{
  653. this.loadToolBar(this.toolbarItems.mulSelect);
  654. }
  655. },
  656. selectedFile: function(data){
  657. if (!this.selectedList) this.selectedList = [];
  658. var idx = this.selectedList.findIndex(function(t){
  659. return t.id == data.id;
  660. });
  661. if (idx===-1) this.selectedList.push(data);
  662. },
  663. unselectedFile: function(data){
  664. // delete data._;
  665. if (!this.selectedList) this.selectedList = [];
  666. var idx = this.selectedList.findIndex(function(t){
  667. return t.id == data.id;
  668. });
  669. if (idx!==-1) this.selectedList.splice(idx, 1);
  670. },
  671. open : function (work,workCompleted,jobId){
  672. var options = {
  673. "workId": work,
  674. "workCompletedId": workCompleted,
  675. "appId": "process.Work" + work
  676. };
  677. if(o2.typeOf(jobId)=="string"){
  678. options.jobId = jobId;
  679. }
  680. layout.desktop.openApplication(null, "process.Work", options);
  681. }
  682. });
  683. MWF.xApplication.process.Application.AllList = new Class({
  684. Extends: MWF.xApplication.process.Application.List,
  685. loadData: function(){
  686. var _self = this;
  687. this.filterList.relateTask = true;
  688. return this.action.ReviewAction.V2ListPaging(this.page, this.size, this.filterList||{}).then(function(json){
  689. _self.fireEvent("loadData");
  690. _self.total = json.count;
  691. return _self._fixData(json.data);
  692. }.bind(this));
  693. },
  694. loadFilter: function () {
  695. var lp = this.lp;
  696. this.fileterNode = new Element("div.fileterNode", {
  697. "styles": this.css.fileterNode
  698. }).inject(this.searchNode);
  699. var html = "<table bordr='0' cellpadding='0' cellspacing='0' styles='filterTable'>" + //style='width: 900px;'
  700. "<tr>" +
  701. " <td styles='filterTableTitle' lable='title'></td>" +
  702. " <td styles='filterTableValue' item='title'></td>" +
  703. " <td styles='filterTableTitle' lable='creatorUnitList'></td>" +
  704. " <td styles='filterTableValue' item='creatorUnitList'></td>" +
  705. " <td styles='filterTableTitle' lable='credentialList'></td>" +
  706. " <td styles='filterTableValue' item='credentialList'></td>" +
  707. " <td styles='filterTableValue'></td>" +
  708. "</tr>" +
  709. "<tr style='height: 45px;'>" +
  710. " <td styles='filterTableTitle' lable='processName'></td>" +
  711. " <td styles='filterTableValue' item='processName'></td>" +
  712. " <td styles='filterTableTitle' lable='startTime'></td>" +
  713. " <td styles='filterTableValue' item='startTime'></td>" +
  714. " <td styles='filterTableTitle' lable='endTime'></td>" +
  715. " <td styles='filterTableValue' item='endTime'></td>" +
  716. " <td styles='filterTableValue' style='width: 180px'><div style='float:left' item='action'></div><div item='reset'></div></td>" +
  717. "</tr>" +
  718. "</table>";
  719. this.fileterNode.set("html", html);
  720. var selectValue = [""];
  721. var selectText = [""];
  722. this.app.processList.each(function(d){
  723. selectValue.push(d.id);
  724. selectText.push(d.name);
  725. })
  726. this.form = new MForm(this.fileterNode, {}, {
  727. style: "attendance",
  728. isEdited: true,
  729. itemTemplate: {
  730. title: {text: lp.subject, "type": "text", "style": {"min-width": "150px"}},
  731. processName: {
  732. "text": lp.process,
  733. "type": "select",
  734. "selectValue" :selectValue,
  735. "selectText" :selectText,
  736. "style": {"min-width": "150px"},
  737. },
  738. credentialList: {
  739. "text": lp.creator,
  740. "type": "org",
  741. "orgType": "identity",
  742. "orgOptions": {"resultType": "person"},
  743. "style": {"min-width": "150px"},
  744. "orgWidgetOptions": {"disableInfor": true}
  745. },
  746. creatorUnitList: {
  747. "text": lp.createunit,
  748. "type": "org",
  749. "orgType": "unit",
  750. "orgOptions": {"resultType": "person"},
  751. "style": {"min-width": "150px"},
  752. "orgWidgetOptions": {"disableInfor": true}
  753. },
  754. startTime: {
  755. text: lp.begin,
  756. "tType": "date",
  757. "style": {"min-width":"150px"}
  758. },
  759. endTime: {
  760. text: lp.end,
  761. "tType": "date",
  762. "style": {"min-width":"150px"}
  763. },
  764. action: {
  765. "value": this.lp.query, type: "button", className: "filterButton", event: {
  766. click: function () {
  767. var result = this.form.getResult(false, null, false, false, false);
  768. for (var key in result) {
  769. if (!result[key]) {
  770. delete result[key];
  771. } else if (key === "activityName" && result[key].length > 0) {
  772. //result[key] = result[key][0].split("@")[1];
  773. result["activityNameList"] = [result[key]];
  774. delete result[key];
  775. }else if (key === "processName" && result[key] !== "") {
  776. //result[key] = result[key][0].split("@")[1];
  777. result["processList"] = [result[key]];
  778. delete result[key];
  779. }else if (key === "endTime" && result[key] !== "") {
  780. result[key] = result[key] + " 23:59:59"
  781. }
  782. }
  783. result.applicationList = this.filterList.applicationList;
  784. if(result.credentialList) {
  785. result.creatorPersonList = result.credentialList;
  786. }
  787. this.filterList = result;
  788. this.refresh();
  789. }.bind(this)
  790. }
  791. },
  792. reset: {
  793. "value": this.lp.reset, type: "button", className: "filterButtonGrey", event: {
  794. click: function () {
  795. this.form.reset();
  796. this._initFilter();
  797. this.refresh();
  798. }.bind(this)
  799. }
  800. },
  801. }
  802. }, this.app, this.css);
  803. this.form.load();
  804. },
  805. _fixData : function (dataList){
  806. dataList.each(function (data){
  807. data.creatorPersonName = data.creatorPerson.split("@")[0];
  808. data.creatorUnitName = data.creatorUnit.split("@")[0];
  809. if(data.completed) {
  810. data.activityName = "结束";
  811. }else {
  812. if(data.taskList.length >0){
  813. data.activityName = data.taskList[0].activityName;
  814. }
  815. }
  816. data.title = data.title || this.lp.unnamed;
  817. }.bind(this));
  818. return dataList;
  819. },
  820. });
  821. MWF.xApplication.process.Application.TaskList = new Class({
  822. Extends: MWF.xApplication.process.Application.List,
  823. loadData: function(){
  824. var _self = this;
  825. return this.action.TaskAction.V2ListPaging(this.page, this.size, this.filterList||{}).then(function(json){
  826. _self.fireEvent("loadData");
  827. _self.total = json.count;
  828. return _self._fixData(json.data);
  829. }.bind(this));
  830. },
  831. });
  832. MWF.xApplication.process.Application.TaskDoneList = new Class({
  833. Extends: MWF.xApplication.process.Application.List,
  834. loadData: function(){
  835. var _self = this;
  836. this.filterList = this.filterList||{};
  837. this.filterList.latest = true;
  838. return this.action.TaskCompletedAction.V2ListPaging(this.page, this.size, this.filterList).then(function(json){
  839. _self.fireEvent("loadData");
  840. _self.total = json.count;
  841. return _self._fixData(json.data);
  842. }.bind(this));
  843. },
  844. });
  845. MWF.xApplication.process.Application.ReadList = new Class({
  846. Extends: MWF.xApplication.process.Application.List,
  847. loadData: function(){
  848. var _self = this;
  849. return this.action.ReadAction.V2ListPaging(this.page, this.size, this.filterList||{}).then(function(json){
  850. _self.fireEvent("loadData");
  851. _self.total = json.count;
  852. return _self._fixData(json.data);
  853. }.bind(this));
  854. },
  855. });
  856. MWF.xApplication.process.Application.ReadDoneList = new Class({
  857. Extends: MWF.xApplication.process.Application.List,
  858. loadData: function(){
  859. var _self = this;
  860. return this.action.ReadCompletedAction.V2ListPaging(this.page, this.size, this.filterList||{}).then(function(json){
  861. _self.fireEvent("loadData");
  862. _self.total = json.count;
  863. return _self._fixData(json.data);
  864. }.bind(this));
  865. },
  866. });
  867. MWF.xApplication.process.Application.DraftList = new Class({
  868. Extends: MWF.xApplication.process.Application.List,
  869. loadData: function(){
  870. var _self = this;
  871. return this.action.DraftAction.listMyPaging(this.page, this.size, this.filterList||{}).then(function(json){
  872. _self.fireEvent("loadData");
  873. _self.total = json.count;
  874. return _self._fixData(json.data);
  875. }.bind(this));
  876. },
  877. _fixData : function (dataList){
  878. dataList.each(function(d){
  879. if(d.title === "") d.title = this.lp.unnamed;
  880. }.bind(this));
  881. return dataList;
  882. },
  883. loadFilter: function () {
  884. var lp = this.lp;
  885. this.fileterNode = new Element("div.fileterNode", {
  886. "styles": this.css.fileterNode
  887. }).inject(this.searchNode);
  888. var html = "<table bordr='0' cellpadding='0' cellspacing='0' styles='filterTable'>" + //style='width: 900px;'
  889. "<tr style='height: 45px;'>" +
  890. " <td styles='filterTableTitle' lable='title'></td>" +
  891. " <td styles='filterTableValue' item='title'></td>" +
  892. " <td styles='filterTableTitle' lable='processName'></td>" +
  893. " <td styles='filterTableValue' item='processName'></td>" +
  894. " <td styles='filterTableTitle' lable='startTime'></td>" +
  895. " <td styles='filterTableValue' item='startTime'></td>" +
  896. " <td styles='filterTableTitle' lable='endTime'></td>" +
  897. " <td styles='filterTableValue' item='endTime'></td>" +
  898. " <td styles='filterTableValue' style='width: 200px'><div style='float:left' item='action'></div><div item='reset'></div></td>" +
  899. "</tr>" +
  900. "</table>";
  901. this.fileterNode.set("html", html);
  902. var selectValue = [""];
  903. var selectText = [""];
  904. this.app.processList.each(function(d){
  905. selectValue.push(d.id);
  906. selectText.push(d.name);
  907. })
  908. this.form = new MForm(this.fileterNode, {}, {
  909. style: "attendance",
  910. isEdited: true,
  911. itemTemplate: {
  912. title: {text: lp.subject, "type": "text", "style": {"min-width": "150px"}},
  913. processName: {
  914. "text": lp.process,
  915. "type": "select",
  916. "selectValue" :selectValue,
  917. "selectText" :selectText,
  918. "style": {"min-width": "150px"},
  919. },
  920. startTime: {
  921. text: lp.begin,
  922. "tType": "date",
  923. "style": {"min-width":"150px"}
  924. },
  925. endTime: {
  926. text: lp.end,
  927. "tType": "date",
  928. "style": {"min-width":"150px"}
  929. },
  930. action: {
  931. "value": lp.query, type: "button", className: "filterButton", event: {
  932. click: function () {
  933. var result = this.form.getResult(false, null, false, false, false);
  934. for (var key in result) {
  935. if (!result[key]) {
  936. delete result[key];
  937. } else if (key === "activityName" && result[key].length > 0) {
  938. //result[key] = result[key][0].split("@")[1];
  939. result["activityNameList"] = [result[key]];
  940. delete result[key];
  941. }else if (key === "processName" && result[key] !== "") {
  942. //result[key] = result[key][0].split("@")[1];
  943. result["processList"] = [result[key]];
  944. delete result[key];
  945. }else if (key === "endTime" && result[key] !== "") {
  946. result[key] = result[key] + " 23:59:59"
  947. }
  948. }
  949. this.filterList = result;
  950. this.refresh();
  951. }.bind(this)
  952. }
  953. },
  954. reset: {
  955. "value": lp.reset, type: "button", className: "filterButtonGrey", event: {
  956. click: function () {
  957. this.form.reset();
  958. this._initFilter();
  959. this.refresh();
  960. }.bind(this)
  961. }
  962. },
  963. }
  964. }, this.app, this.css);
  965. this.form.load();
  966. },
  967. open : function (id){
  968. var options = {
  969. "draftId": id,
  970. "appId": "process.Work" + id
  971. };
  972. layout.desktop.openApplication(null, "process.Work", options);
  973. }
  974. });
  975. MWF.xApplication.process.Application.WorkList = new Class({
  976. Extends: MWF.xApplication.process.Application.List,
  977. loadData: function(){
  978. var _self = this;
  979. this.filterList.relateEditionProcess = true;
  980. return this.action.WorkAction.manageListWithApplicationPaging(this.page, this.size, this.application.id,this.filterList||{}).then(function(json){
  981. _self.fireEvent("loadData");
  982. _self.total = json.count;
  983. return _self._fixData(json.data);
  984. }.bind(this));
  985. },
  986. _initToolBar : function (){
  987. this.toolbarItems = {
  988. "default":[
  989. ["delWork","jump","sendRead","rollback"],
  990. ["processing","endWork","addReview"],
  991. ["manage"]
  992. ],
  993. "unSelect":[
  994. ],
  995. "selected":[
  996. ["delWork","jump","sendRead","rollback"],
  997. ["processing","endWork","addReview"],
  998. ["manage"]
  999. ],
  1000. "mulSelect":[
  1001. ["delWork"],
  1002. ["processing","endWork","addReview"]
  1003. ]
  1004. }
  1005. },
  1006. open : function (id){
  1007. var options = {
  1008. "workId": id,
  1009. "appId": "process.Work" + id
  1010. };
  1011. layout.desktop.openApplication(null, "process.Work", options);
  1012. },
  1013. manage : function (id,ev,dataList){
  1014. var data ;
  1015. for(var i = 0 ; i < dataList.length;i++){
  1016. if(dataList[i].id === id){
  1017. data = dataList[i];
  1018. break ;
  1019. }
  1020. }
  1021. this._manage(data);
  1022. },
  1023. _manage : function (data){
  1024. var form;
  1025. form = new MWF.xApplication.process.Application.ManageWorkForm({app: this.app}, data );
  1026. form.open();
  1027. },
  1028. delete : function(id,e){
  1029. var _self = this;
  1030. this.app.confirm("warn", e,"删除确认!!", {
  1031. "html": "<br/>请选择删除方式? <br/><input type='radio' value='soft' name='delete_type'/>软删除(可恢复)" +
  1032. "<br/><input type='radio' value='delete' name='delete_type'/>硬删除(不能恢复)<div class='checkInfor'></div>"
  1033. }, 400, 200, function(){
  1034. var inputs = this.content.getElements("input");
  1035. var flag = "";
  1036. for (var i=0; i<inputs.length; i++){
  1037. if (inputs[i].checked){
  1038. flag = inputs[i].get("value");
  1039. break;
  1040. }
  1041. }
  1042. if (flag){
  1043. _self.action[flag === "soft"?"SnapAction":"WorkAction"][flag === "soft"?"typeAbandoned":"delete"]( id , function(){
  1044. _self.app.notice("成功删除工作。");
  1045. _self.refresh();
  1046. });
  1047. this.close();
  1048. }else{
  1049. this.content.getElement(".checkInfor").set("text", "请选择删除方式!").setStyle("color", "red");
  1050. }
  1051. }, function(){
  1052. this.close();
  1053. });
  1054. }
  1055. });
  1056. MWF.xApplication.process.Application.WorkCompletedList = new Class({
  1057. Extends: MWF.xApplication.process.Application.List,
  1058. loadData: function(){
  1059. var _self = this;
  1060. this.filterList.relateEditionProcess = true;
  1061. return this.action.WorkCompletedAction.manageListWithApplicationPaging(this.page, this.size,this.application.id, this.filterList||{}).then(function(json){
  1062. _self.fireEvent("loadData");
  1063. _self.total = json.count;
  1064. return _self._fixData(json.data);
  1065. }.bind(this));
  1066. },
  1067. _initToolBar : function (){
  1068. this.toolbarItems = {
  1069. "default":[
  1070. ["delCompletedWork"],
  1071. ["rollback","sendRead","addReview"],
  1072. ["manage"]
  1073. ],
  1074. "unSelect":[
  1075. ],
  1076. "selected":[
  1077. ["delCompletedWork"],
  1078. ["rollback","sendRead","addReview"],
  1079. ["manage"]
  1080. ],
  1081. "mulSelect":[
  1082. ["delCompletedWork"],
  1083. ["sendRead","addReview"]
  1084. ]
  1085. }
  1086. },
  1087. open : function (id){
  1088. debugger
  1089. var options = {
  1090. "workCompletedId": id,
  1091. "appId": "process.Work" + id
  1092. };
  1093. layout.desktop.openApplication(null, "process.Work", options);
  1094. },
  1095. manage : function (id,ev,dataList){
  1096. var data ;
  1097. for(var i = 0 ; i < dataList.length;i++){
  1098. if(dataList[i].id === id){
  1099. data = dataList[i];
  1100. break ;
  1101. }
  1102. }
  1103. this._manage(data);
  1104. },
  1105. _manage : function (data){
  1106. var form;
  1107. form = new MWF.xApplication.process.Application.ManageWorkCompletedForm({app: this.app}, data );
  1108. form.open();
  1109. },
  1110. delete : function(id,e){
  1111. var _self = this;
  1112. this.app.confirm("warn", e,"删除确认!!", {
  1113. "html": "<br/>请选择删除方式? <br/><input type='radio' value='soft' name='delete_type'/>软删除(可恢复)" +
  1114. "<br/><input type='radio' value='delete' name='delete_type'/>硬删除(不能恢复)<div class='checkInfor'></div>"
  1115. }, 400, 200, function(){
  1116. var inputs = this.content.getElements("input");
  1117. var flag = "";
  1118. for (var i=0; i<inputs.length; i++){
  1119. if (inputs[i].checked){
  1120. flag = inputs[i].get("value");
  1121. break;
  1122. }
  1123. }
  1124. if (flag){
  1125. _self.action[flag === "soft"?"SnapAction":"WorkCompletedAction"][flag === "soft"?"typeAbandonedWorkCompleted":"manageDelete"]( id , function(){
  1126. _self.app.notice("成功删除工作。");
  1127. _self.refresh();
  1128. });
  1129. this.close();
  1130. }else{
  1131. this.content.getElement(".checkInfor").set("text", "请选择删除方式!").setStyle("color", "red");
  1132. }
  1133. }, function(){
  1134. this.close();
  1135. });
  1136. }
  1137. });
  1138. MWF.xApplication.process.Application.SnapList = new Class({
  1139. Extends: MWF.xApplication.process.Application.List,
  1140. loadData: function(){
  1141. var _self = this;
  1142. return this.action.SnapAction.manageListWithApplicationPaging(this.page, this.size, this.application.id,this.filterList||{}).then(function(json){
  1143. _self.fireEvent("loadData");
  1144. _self.total = json.count;
  1145. return _self._fixData(json.data);
  1146. }.bind(this));
  1147. },
  1148. _initToolBar : function (){
  1149. this.toolbarItems = {
  1150. "default":[
  1151. ["delSnap"],
  1152. ["restore"]
  1153. ],
  1154. "unSelect":[
  1155. ],
  1156. "selected":[
  1157. ["delSnap"],
  1158. ["restore"]
  1159. ],
  1160. "mulSelect":[
  1161. ["delSnap"],
  1162. ["restore"]
  1163. ]
  1164. }
  1165. },
  1166. open : function (id){
  1167. debugger
  1168. var options = {
  1169. "workCompletedId": id,
  1170. "appId": "process.Work" + id
  1171. };
  1172. layout.desktop.openApplication(null, "process.Work", options);
  1173. },
  1174. delete : function(id,e){
  1175. var _self = this;
  1176. this.app.confirm("warn", e, "删除确认", "删除后不能恢复。", 350, 120, function () {
  1177. _self.action.SnapAction.delete( id , function(){
  1178. _self.app.notice("成功删除");
  1179. _self.refresh();
  1180. });
  1181. this.close();
  1182. }, function () {
  1183. this.close();
  1184. });
  1185. }
  1186. });
  1187. MWF.xApplication.process.Application.DictList = new Class({
  1188. Extends: MWF.xApplication.process.Application.List,
  1189. loadData: function(){
  1190. var _self = this;
  1191. return o2.Actions.load("x_processplatform_assemble_designer").ApplicationDictAction.listWithApplication(this.application.id).then(function(json){
  1192. _self.fireEvent("loadData");
  1193. _self.total = json.count;
  1194. return json.data;
  1195. }.bind(this));
  1196. },
  1197. open : function (id){
  1198. debugger
  1199. var options = {
  1200. "id": id,
  1201. "application" : this.app.application.id,
  1202. "appId": "process.DictionaryDesigner" + id
  1203. };
  1204. layout.desktop.openApplication(null, "process.DictionaryDesigner", options);
  1205. },
  1206. loadFilter: function () {
  1207. this.searchNode.setStyle("height","10px");
  1208. },
  1209. });
  1210. MWF.xApplication.process.Application.SerialList = new Class({
  1211. Extends: MWF.xApplication.process.Application.List,
  1212. loadData: function(){
  1213. var _self = this;
  1214. return this.action.SerialNumberAction.list(this.application.id).then(function(json){
  1215. _self.fireEvent("loadData");
  1216. _self.total = json.count;
  1217. return json.data;
  1218. }.bind(this));
  1219. },
  1220. loadFilter: function () {
  1221. this.searchNode.setStyle("height","10px");
  1222. },
  1223. _initToolBar : function (){
  1224. this.toolbarItems = {
  1225. "default":[
  1226. ],
  1227. "unSelect":[
  1228. ["addSerial"]
  1229. ],
  1230. "selected":[
  1231. ["delSerial"],
  1232. ["setSerial"],
  1233. ],
  1234. "mulSelect":[
  1235. ["delSerial"],
  1236. ]
  1237. }
  1238. },
  1239. });
  1240. MWF.xApplication.process.Application.Toolbar = new Class({
  1241. Extends: MWF.widget.Common,
  1242. Implements: [Options, Events],
  1243. options: {
  1244. "style": "default",
  1245. "viewType" : "list",
  1246. "type" : "all",
  1247. "disabled" : false
  1248. },
  1249. initialize : function( container, explorer, options ) {
  1250. this.container = container;
  1251. this.explorer = explorer;
  1252. this.app = explorer.app;
  1253. this.lp = explorer.app.lp;
  1254. this.css = this.app.css;
  1255. this.action = explorer.action;
  1256. this.setOptions(options);
  1257. this._initTools();
  1258. this.type = this.options.type;
  1259. this.availableTool = this.options.availableTool;
  1260. if(this.explorer.selectedList){
  1261. this.data = this.explorer.selectedList[0];
  1262. }
  1263. },
  1264. _initTools : function (){
  1265. this.tools = {
  1266. delWork :{
  1267. action : "delWork",
  1268. text : this.lp.actionList.delete,
  1269. icon : "icon-upload"
  1270. },
  1271. delCompletedWork : {
  1272. action : "delCompletedWork",
  1273. text : this.lp.actionList.delete,
  1274. icon : "icon-upload"
  1275. },
  1276. processing :{
  1277. action : "processing",
  1278. text : this.lp.actionList.processing,
  1279. icon : "icon-upload"
  1280. },
  1281. addReview :{
  1282. action : "addReview",
  1283. text : this.lp.actionList.addReview,
  1284. icon : "icon-upload"
  1285. },
  1286. endWork :{
  1287. action : "endWork",
  1288. text : this.lp.actionList.endWork,
  1289. icon : "icon-upload"
  1290. },
  1291. jump : {
  1292. action : "jump",
  1293. text : this.lp.actionList.jump,
  1294. icon : "icon-upload"
  1295. },
  1296. manage : {
  1297. action : "manage",
  1298. text : this.lp.actionList.manage,
  1299. icon : "icon-upload"
  1300. },
  1301. sendRead : {
  1302. action : "sendRead",
  1303. text : this.lp.actionList.sendRead,
  1304. icon : "icon-upload"
  1305. },
  1306. setSerial : {
  1307. action : "setSerial",
  1308. text : this.lp.actionList.setSerial,
  1309. icon : "icon-upload"
  1310. },
  1311. delSerial : {
  1312. action : "delSerial",
  1313. text : this.lp.actionList.delete,
  1314. icon : "icon-upload"
  1315. },
  1316. addSerial : {
  1317. action : "addSerial",
  1318. text : this.lp.actionList.add,
  1319. icon : "icon-upload"
  1320. },
  1321. rollback : {
  1322. action : "rollback",
  1323. text : this.lp.actionList.rollback,
  1324. icon : "icon-newfolder"
  1325. },
  1326. delSnap : {
  1327. action : "delSnap",
  1328. text : this.lp.actionList.delSnap,
  1329. icon : "icon-rename"
  1330. },
  1331. restore: {
  1332. action : "restore",
  1333. text : this.lp.actionList.restore,
  1334. icon : "icon-shareDownload"
  1335. }
  1336. }
  1337. },
  1338. load : function(){
  1339. this.node = new Element("div").inject( this.container );
  1340. this.availableTool.each( function( group ){
  1341. var toolgroupNode = new Element("div.toolgroupNode").inject( this.node );
  1342. var length = group.length;
  1343. group.each( function( t, i ){
  1344. var className;
  1345. if( length == 1 ){
  1346. className = "toolItemNode_single";
  1347. }else{
  1348. if( i == 0 ){
  1349. className = "toolItemNode_left";
  1350. }else if( i + 1 == length ){
  1351. className = "toolItemNode_right";
  1352. }else{
  1353. className = "toolItemNode_center";
  1354. }
  1355. }
  1356. var tool = this.tools[ t ];
  1357. var toolNode;
  1358. if(this.options.disabled){
  1359. toolNode = new Element( "div", {
  1360. class : className,
  1361. style : "height:30px;line-height:30px;padding-left:12px;padding-right:12px;background: rgb(123 177 240);font-size: 13px;color: #FFFFFF;font-weight: 400;",
  1362. }).inject( toolgroupNode );
  1363. }else {
  1364. toolNode = new Element( "div", {
  1365. class : className,
  1366. style : "cursor:pointer;height:30px;line-height:30px;padding-left:12px;padding-right:12px;background: #4A90E2;font-size: 13px;color: #FFFFFF;font-weight: 400;",
  1367. events : {
  1368. click : function( ev ){ this[tool.action]( ev ) }.bind(this)
  1369. }
  1370. }).inject( toolgroupNode );
  1371. }
  1372. //var iconNode = new Element("icon",{"class":"o2WorkApplication " + tool.icon,"style":"margin-right:6px"}).inject(toolNode);
  1373. var textNode = new Element("span").inject(toolNode);
  1374. textNode.set("text",tool.text);
  1375. }.bind(this))
  1376. }.bind(this));
  1377. this.loadRightNode()
  1378. },
  1379. addSerial: function(){
  1380. var _self = this;
  1381. var data = this.explorer.selectedList[0];
  1382. var form = new MWF.xApplication.process.Application.AddSerSialForm(this.explorer, data, {
  1383. }, {
  1384. app: this.app
  1385. });
  1386. form.edit()
  1387. },
  1388. setSerial : function(){
  1389. var _self = this;
  1390. if (this.explorer.selectedList && this.explorer.selectedList.length){
  1391. var data = this.explorer.selectedList[0];
  1392. var form = new MWF.xApplication.process.Application.SetSerSialForm(this.explorer, data, {
  1393. }, {
  1394. app: this.app
  1395. });
  1396. form.edit()
  1397. }else {
  1398. this.app.notice("请先选择文件","error");
  1399. return;
  1400. }
  1401. },
  1402. delWork : function (e){
  1403. var _self = this;
  1404. var dataList = this.explorer.selectedList;
  1405. this.app.confirm("warn", e,"删除确认!!", {
  1406. "html": "<br/>请选择删除方式? <br/><input type='radio' value='soft' name='delete_type'/>软删除(可恢复)" +
  1407. "<br/><input type='radio' value='delete' name='delete_type'/>硬删除(不能恢复)<div class='checkInfor'></div>"
  1408. }, 400, 200, function(){
  1409. var inputs = this.content.getElements("input");
  1410. var flag = "";
  1411. for (var i=0; i<inputs.length; i++){
  1412. if (inputs[i].checked){
  1413. flag = inputs[i].get("value");
  1414. break;
  1415. }
  1416. }
  1417. if (flag){
  1418. var count = 0;
  1419. dataList.each( function(data){
  1420. if(flag === "soft"){
  1421. _self.action.SnapAction.typeAbandoned( data.id , function(){
  1422. count++;
  1423. if( dataList.length == count ){
  1424. _self.app.notice("成功删除"+count+"个工作。");
  1425. _self.explorer.refresh();
  1426. }
  1427. });
  1428. }else {
  1429. _self.action.WorkAction.delete( data.id , function(){
  1430. count++;
  1431. if( dataList.length == count ){
  1432. _self.app.notice("成功删除"+count+"个工作。");
  1433. _self.explorer.refresh();
  1434. }
  1435. });
  1436. }
  1437. }.bind(this));
  1438. this.close();
  1439. }else{
  1440. this.content.getElement(".checkInfor").set("text", "请选择删除方式!").setStyle("color", "red");
  1441. }
  1442. }, function(){
  1443. this.close();
  1444. });
  1445. },
  1446. processing : function (e){
  1447. var _self = this;
  1448. var dataList = this.explorer.selectedList;
  1449. this.app.confirm("warn", e, "尝试流转确认", "是否尝试流转选中的"+dataList.length+"个文档?", 350, 120, function () {
  1450. var count = 0;
  1451. dataList.each( function(data){
  1452. _self.action.WorkAction.processing( data.id , {},function(){
  1453. count++;
  1454. if( dataList.length == count ){
  1455. _self.app.notice("成功处理"+count+"个文档。");
  1456. _self.explorer.refresh();
  1457. }
  1458. });
  1459. }.bind(this));
  1460. this.close();
  1461. }, function () {
  1462. this.close();
  1463. });
  1464. },
  1465. delCompletedWork : function (e){
  1466. var _self = this;
  1467. var dataList = this.explorer.selectedList;
  1468. this.app.confirm("warn", e,"删除确认!!", {
  1469. "html": "<br/>请选择删除方式? <br/><input type='radio' value='soft' name='delete_type'/>软删除(可恢复)" +
  1470. "<br/><input type='radio' value='delete' name='delete_type'/>硬删除(不能恢复)<div class='checkInfor'></div>"
  1471. }, 400, 280, function(){
  1472. var inputs = this.content.getElements("input");
  1473. var flag = "";
  1474. for (var i=0; i<inputs.length; i++){
  1475. if (inputs[i].checked){
  1476. flag = inputs[i].get("value");
  1477. break;
  1478. }
  1479. }
  1480. if (flag){
  1481. var count = 0;
  1482. dataList.each( function(data){
  1483. if(flag === "soft"){
  1484. _self.action.SnapAction.typeAbandonedWorkCompleted( data.id , function(){
  1485. count++;
  1486. if( dataList.length == count ){
  1487. _self.app.notice("成功删除"+count+"个工作。");
  1488. _self.explorer.refresh();
  1489. }
  1490. });
  1491. }else {
  1492. _self.action.WorkCompletedAction.manageDelete( data.id , function(){
  1493. count++;
  1494. if( dataList.length == count ){
  1495. _self.app.notice("成功删除"+count+"个工作。");
  1496. _self.explorer.refresh();
  1497. }
  1498. });
  1499. }
  1500. }.bind(this));
  1501. this.close();
  1502. }else{
  1503. this.content.getElement(".checkInfor").set("text", "请选择删除方式!").setStyle("color", "red");
  1504. }
  1505. }, function(){
  1506. this.close();
  1507. });
  1508. },
  1509. endWork : function (e){
  1510. var _self = this;
  1511. var dataList = this.explorer.selectedList;
  1512. this.app.confirm("warn", e, "结束确认", "是否结束选中的"+dataList.length+"个文档?", 350, 120, function () {
  1513. var count = 0;
  1514. dataList.each( function(data){
  1515. _self.action.ProcessAction.getComplex(data.process,function (json){
  1516. var endList = json.data.endList;
  1517. var endActivityId = endList[0].id;
  1518. var body = {
  1519. "activity": endActivityId,
  1520. "activityType": "end",
  1521. "mergeWork": true,
  1522. "manualForceTaskIdentityList": null
  1523. };
  1524. _self.action.WorkAction.V2Reroute(data.id, body, function (json) {
  1525. count++;
  1526. if( dataList.length == count ){
  1527. _self.app.notice("成功结束"+count+"个文档。");
  1528. _self.explorer.refresh();
  1529. }
  1530. });
  1531. });
  1532. }.bind(this));
  1533. this.close();
  1534. }, function () {
  1535. this.close();
  1536. });
  1537. },
  1538. delSnap : function (e){
  1539. var _self = this;
  1540. var dataList = this.explorer.selectedList;
  1541. this.app.confirm("warn", e, "删除确认", "是否删除选中的"+dataList.length+"个文档?删除后不能恢复。", 350, 120, function () {
  1542. var count = 0;
  1543. dataList.each( function(data){
  1544. _self.action.SnapAction.delete( data.id , function(){
  1545. count++;
  1546. if( dataList.length == count ){
  1547. _self.app.notice("成功删除"+count+"个文档。");
  1548. _self.explorer.refresh();
  1549. }
  1550. });
  1551. }.bind(this));
  1552. this.close();
  1553. }, function () {
  1554. this.close();
  1555. });
  1556. },
  1557. restore: function (e){
  1558. var _self = this;
  1559. var dataList = this.explorer.selectedList;
  1560. this.app.confirm("warn", e, "恢复确认", "是否恢复选中的"+dataList.length+"个文档?", 350, 120, function () {
  1561. var count = 0;
  1562. dataList.each( function(data){
  1563. _self.action.SnapAction.restore( data.id , function(){
  1564. count++;
  1565. if( dataList.length == count ){
  1566. _self.app.notice("成功恢复"+count+"个文档。");
  1567. _self.explorer.refresh();
  1568. }
  1569. });
  1570. }.bind(this));
  1571. this.close();
  1572. }, function () {
  1573. this.close();
  1574. });
  1575. },
  1576. delSerial : function (e){
  1577. var _self = this;
  1578. var dataList = this.explorer.selectedList;
  1579. this.app.confirm("warn", e, "删除确认", "是否删除选中的"+dataList.length+"个流水号?删除后不能恢复。", 350, 120, function () {
  1580. var count = 0;
  1581. dataList.each( function(data){
  1582. _self.action.SerialNumberAction.delete( data.id , function(){
  1583. count++;
  1584. if( dataList.length == count ){
  1585. _self.app.notice("成功删除"+count+"个流水号。");
  1586. _self.explorer.refresh();
  1587. }
  1588. });
  1589. }.bind(this));
  1590. this.close();
  1591. }, function () {
  1592. this.close();
  1593. });
  1594. },
  1595. sendRead : function (e){
  1596. var dataList = this.explorer.selectedList;
  1597. var ids = [];
  1598. dataList.each(function (data){
  1599. ids.push(data.id);
  1600. }.bind(this));
  1601. debugger
  1602. var _self = this;
  1603. var reviewNode = new Element("div",{"class":"control","style":"margin:10px"});
  1604. var personNode = new Element("textarea",{"class":"textarea","placeholder":"参阅人员选择"});
  1605. personNode.inject(reviewNode);
  1606. personNode.addEvent("click",function(){
  1607. var opt = {
  1608. "type": "identity",
  1609. "count": 0,
  1610. "values": personNode.retrieve("dataList") || [],
  1611. "onComplete": function (dataList) {
  1612. debugger
  1613. var arr = [];
  1614. var arr2 = [];
  1615. dataList.each(function (data) {
  1616. arr.push(data.data);
  1617. arr2.push(data.data.name);
  1618. });
  1619. personNode.set("value", arr2.join(","));
  1620. personNode.store("dataList", arr);
  1621. }.bind(this)
  1622. };
  1623. new MWF.O2Selector(_self.app.content, opt);
  1624. }.bind(this));
  1625. var reviewDlg = o2.DL.open({
  1626. "title": "增加参阅",
  1627. "width": "400px",
  1628. "height": "260px",
  1629. "mask": true,
  1630. "content": reviewNode,
  1631. "container": null,
  1632. "positionNode": _self.app.content,
  1633. "onQueryClose": function () {
  1634. reviewNode.destroy();
  1635. }.bind(this),
  1636. "buttonList": [
  1637. {
  1638. "text": "确认",
  1639. "action": function () {
  1640. var personList = personNode.retrieve("dataList") ;
  1641. var arr = [];
  1642. personList.each(function(person){
  1643. arr.push(person.distinguishedName);
  1644. });
  1645. ids.each(function(workId){
  1646. var data = {
  1647. "notify":true,
  1648. "identityList":arr
  1649. }
  1650. if(_self.type === "work"){
  1651. _self.app.action.ReadAction.createWithWork(workId,data,function (){},null,false);
  1652. }else{
  1653. _self.app.action.ReadAction.createWithWorkCompleted(workId,data,function (){},null,false);
  1654. }
  1655. });
  1656. _self.app.notice("增加成功。","success");
  1657. _self.explorer.refresh();
  1658. reviewDlg.close();
  1659. }.bind(this)
  1660. },
  1661. {
  1662. "text": "关闭",
  1663. "action": function () {
  1664. reviewDlg.close();
  1665. }.bind(this)
  1666. }
  1667. ],
  1668. "onPostShow": function () {
  1669. reviewDlg.reCenter();
  1670. }.bind(this)
  1671. });
  1672. },
  1673. addReview : function (e){
  1674. var dataList = this.explorer.selectedList;
  1675. var ids = [];
  1676. dataList.each(function (data){
  1677. ids.push(data.id);
  1678. }.bind(this));
  1679. debugger
  1680. var _self = this;
  1681. var reviewNode = new Element("div",{"class":"control","style":"margin:10px"});
  1682. var personNode = new Element("textarea",{"class":"textarea","placeholder":"参阅人员选择"});
  1683. personNode.inject(reviewNode);
  1684. personNode.addEvent("click",function(){
  1685. var opt = {
  1686. "type": "person",
  1687. "count": 0,
  1688. "values": personNode.retrieve("dataList") || [],
  1689. "onComplete": function (dataList) {
  1690. var arr = [];
  1691. var arr2 = [];
  1692. dataList.each(function (data) {
  1693. arr.push(data.data);
  1694. arr2.push(data.data.name);
  1695. });
  1696. personNode.set("value", arr2.join(","));
  1697. personNode.store("dataList", arr);
  1698. }.bind(this)
  1699. };
  1700. new MWF.O2Selector(_self.app.content, opt);
  1701. }.bind(this));
  1702. var reviewDlg = o2.DL.open({
  1703. "title": "增加参阅",
  1704. "width": "400px",
  1705. "height": "260px",
  1706. "mask": true,
  1707. "content": reviewNode,
  1708. "container": null,
  1709. "positionNode": _self.app.content,
  1710. "onQueryClose": function () {
  1711. reviewNode.destroy();
  1712. }.bind(this),
  1713. "buttonList": [
  1714. {
  1715. "text": "确认",
  1716. "action": function () {
  1717. var personList = personNode.retrieve("dataList") ;
  1718. var arr = [];
  1719. personList.each(function(person){
  1720. arr.push(person.distinguishedName);
  1721. });
  1722. ids.each(function(workId){
  1723. var data = {
  1724. "personList":arr
  1725. }
  1726. if(_self.type === "work"){
  1727. data.work = workId;
  1728. _self.app.action.ReviewAction.createWithWork(data,function (){},null,false);
  1729. }else{
  1730. data.workCompleted = workId;
  1731. _self.app.action.ReviewAction.createWithWorkCompleted(data,function (){},null,false);
  1732. }
  1733. });
  1734. _self.app.notice("增加成功。","success");
  1735. _self.explorer.refresh();
  1736. reviewDlg.close();
  1737. }.bind(this)
  1738. },
  1739. {
  1740. "text": "关闭",
  1741. "action": function () {
  1742. reviewDlg.close();
  1743. }.bind(this)
  1744. }
  1745. ],
  1746. "onPostShow": function () {
  1747. reviewDlg.reCenter();
  1748. }.bind(this)
  1749. });
  1750. },
  1751. manage : function (){
  1752. var form;
  1753. if(this.type === "workCompleted"){
  1754. form = new MWF.xApplication.process.Application.ManageWorkCompletedForm({app: this.app}, this.explorer.selectedList[0] );
  1755. }else{
  1756. form = new MWF.xApplication.process.Application.ManageWorkForm({app: this.app}, this.explorer.selectedList[0] );
  1757. }
  1758. form.open();
  1759. },
  1760. jump: function(){
  1761. var data = this.explorer.selectedList[0];
  1762. var lp = this.lp;
  1763. this.readyReroute = true;
  1764. var width = 560;
  1765. var height = 210;
  1766. var p = MWF.getCenterPosition(this.app.content, width, height);
  1767. var _self = this;
  1768. var dlg = new MWF.xDesktop.Dialog({
  1769. "title": "调度",
  1770. "style": "user",
  1771. "top": p.y-100,
  1772. "left": p.x,
  1773. "fromTop": p.y-100,
  1774. "fromLeft": p.x,
  1775. "width": width,
  1776. "height": height,
  1777. "url": this.app.path+"default/view/dlg/reroute.html",
  1778. "container": this.app.content,
  1779. "isClose": true,
  1780. "buttonList": [
  1781. {
  1782. "type": "ok",
  1783. "text": MWF.LP.process.button.ok,
  1784. "action": function (d, e) {
  1785. this.doRerouteWork(dlg);
  1786. }.bind(this)
  1787. },
  1788. {
  1789. "type": "cancel",
  1790. "text": MWF.LP.process.button.cancel,
  1791. "action": function () { dlg.close(); }
  1792. }
  1793. ],
  1794. "onPostShow": function(){
  1795. var select = $("rerouteWork_selectActivity");
  1796. _self.action.ProcessAction.getAllowRerouteTo(data.process, function(json){
  1797. if (json.data.agentList) json.data.agentList.each(function(activity){
  1798. new Element("option", {
  1799. "value": activity.id+"#agent",
  1800. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1801. }).inject(select);
  1802. }.bind(_self));
  1803. if (json.data.cancelList) json.data.cancelList.each(function(activity){
  1804. new Element("option", {
  1805. "value": activity.id+"#cancel",
  1806. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1807. }).inject(select);
  1808. }.bind(_self));
  1809. if (json.data.choiceList) json.data.choiceList.each(function(activity){
  1810. new Element("option", {
  1811. "value": activity.id+"#choice",
  1812. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1813. }).inject(select);
  1814. }.bind(_self));
  1815. if (json.data.conditionList) json.data.conditionList.each(function(activity){
  1816. new Element("option", {
  1817. "value": activity.id+"#condition",
  1818. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1819. }).inject(select);
  1820. }.bind(_self));
  1821. if (json.data.delayList) json.data.delayList.each(function(activity){
  1822. new Element("option", {
  1823. "value": activity.id+"#delay",
  1824. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1825. }).inject(select);
  1826. }.bind(_self));
  1827. if (json.data.embedList) json.data.embedList.each(function(activity){
  1828. new Element("option", {
  1829. "value": activity.id+"#embed",
  1830. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1831. }).inject(select);
  1832. }.bind(_self));
  1833. if (json.data.publishList) json.data.publishList.each(function(activity){
  1834. new Element("option", {
  1835. "value": activity.id+"#publish",
  1836. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1837. }).inject(select);
  1838. }.bind(_self));
  1839. if (json.data.endList) json.data.endList.each(function(activity){
  1840. new Element("option", {
  1841. "value": activity.id+"#end",
  1842. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1843. }).inject(select);
  1844. }.bind(_self));
  1845. if (json.data.invokeList) json.data.invokeList.each(function(activity){
  1846. new Element("option", {
  1847. "value": activity.id+"#invoke",
  1848. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1849. }).inject(select);
  1850. }.bind(_self));
  1851. if (json.data.manualList) json.data.manualList.each(function(activity){
  1852. new Element("option", {
  1853. "value": activity.id+"#manual",
  1854. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1855. }).inject(select);
  1856. }.bind(_self));
  1857. if (json.data.mergeList) json.data.mergeList.each(function(activity){
  1858. new Element("option", {
  1859. "value": activity.id+"#merge",
  1860. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1861. }).inject(select);
  1862. }.bind(_self));
  1863. if (json.data.messageList) json.data.messageList.each(function(activity){
  1864. new Element("option", {
  1865. "value": activity.id+"#message",
  1866. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1867. }).inject(select);
  1868. }.bind(_self));
  1869. if (json.data.parallelList) json.data.parallelList.each(function(activity){
  1870. new Element("option", {
  1871. "value": activity.id+"#parallel",
  1872. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1873. }).inject(select);
  1874. }.bind(_self));
  1875. if (json.data.serviceList) json.data.serviceList.each(function(activity){
  1876. new Element("option", {
  1877. "value": activity.id+"#service",
  1878. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1879. }).inject(select);
  1880. }.bind(_self));
  1881. if (json.data.splitList) json.data.splitList.each(function(activity){
  1882. new Element("option", {
  1883. "value": activity.id+"#split",
  1884. "text": activity.description===""?activity.name:activity.name+"(" + activity.description + ")"
  1885. }).inject(select);
  1886. }.bind(_self));
  1887. }.bind(_self));
  1888. var selPeopleButton = this.content.getElement(".rerouteWork_selPeopleButton");
  1889. selPeopleButton.addEvent("click", function () {
  1890. _self.selectReroutePeople(this);
  1891. }.bind(this));
  1892. }
  1893. });
  1894. dlg.show();
  1895. },
  1896. selectReroutePeople: function(dlg){
  1897. var names = dlg.identityList || [];
  1898. var areaNode = dlg.content.getElement(".rerouteWork_selPeopleArea");
  1899. var options = {
  1900. "values": names,
  1901. "type": "identity",
  1902. "count": 0,
  1903. "title": this.explorer.app.lp.reroute,
  1904. "onComplete": function (items) {
  1905. areaNode.empty();
  1906. var identityList = [];
  1907. items.each(function (item) {
  1908. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  1909. identityList.push(item.data.distinguishedName);
  1910. }.bind(this));
  1911. dlg.identityList = identityList;
  1912. }.bind(this)
  1913. };
  1914. MWF.xDesktop.requireApp("Selector", "package", function () {
  1915. var selector = new MWF.O2Selector(this.app.content, options);
  1916. }.bind(this));
  1917. },
  1918. doRerouteWork: function(dlg){
  1919. var _self = this;
  1920. var opinion = $("rerouteWork_opinion").get("value");
  1921. var select = $("rerouteWork_selectActivity");
  1922. var activity = select.options[select.selectedIndex].get("value");
  1923. var activityName = select.options[select.selectedIndex].get("text");
  1924. var tmp = activity.split("#");
  1925. activity = tmp[0];
  1926. var type = tmp[1];
  1927. var nameArr = [];
  1928. var names = dlg.identityList || [];
  1929. names.each(function (n) { nameArr.push(n); });
  1930. MWF.require("MWF.widget.Mask", function(){
  1931. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  1932. this.mask.loadNode(this.explorer.app.content);
  1933. this.rerouteWorkToActivity(activity, type, opinion, nameArr, function(){
  1934. // this.explorer.actions.getWork(this.data.id, function(workJson){
  1935. // this.data = workJson.data;
  1936. // this.workAreaNode.setStyles(this.css.workItemWorkNode);
  1937. // this.readyReroute = false;
  1938. // this.reload();
  1939. // }.bind(this));
  1940. _self.explorer.refresh();
  1941. dlg.close();
  1942. if (this.mask) {this.mask.hide(); this.mask = null;}
  1943. }.bind(this), function(xhr, text, error){
  1944. var errorText = error+":"+text;
  1945. if (xhr) errorText = xhr.responseText;
  1946. this.app.notice("request json error: "+errorText, "error", dlg.node);
  1947. if (this.mask) {this.mask.hide(); this.mask = null;}
  1948. }.bind(this));
  1949. }.bind(this));
  1950. },
  1951. rerouteWorkToActivity: function(activity, type, opinion, nameArr, success, failure){
  1952. var body = {
  1953. "activity": activity,
  1954. "activityType": type,
  1955. "mergeWork": false,
  1956. "manualForceTaskIdentityList": nameArr
  1957. };
  1958. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Reroute(this.data.id, body, function(){
  1959. if (success) success();
  1960. }.bind(this), function (xhr, text, error) {
  1961. if (failure) failure(xhr, text, error);
  1962. });
  1963. // this.explorer.actions.rerouteWork(this.data.id, activity, type, null, function(json){
  1964. // if (success) success();
  1965. // }.bind(this), function(xhr, text, error){
  1966. // if (failure) failure(xhr, text, error);
  1967. // });
  1968. },
  1969. rollback: function (){
  1970. debugger
  1971. var data = this.explorer.selectedList[0];
  1972. var node = new Element("div", { "styles": this.css.rollbackAreaNode });
  1973. var html = "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden;float:left;\">请选择文件要回溯到的位置:</div>";
  1974. html += "<div style=\"line-height: 30px; height: 30px; color: #333333; overflow: hidden;float:right;\"><input class='rollback_flowOption' checked type='checkbox' />并尝试继续流转</div>";
  1975. html += "<div style=\"clear:both; margin-bottom:10px; margin-top:10px; overflow-y:auto;\"></div>";
  1976. node.set("html", html);
  1977. var rollbackItemNode = node.getLast();
  1978. this.getRollbackLogs(rollbackItemNode,data.id);
  1979. //node.inject(this.app.content);
  1980. var dlg = o2.DL.open({
  1981. "title": MWF.xApplication.process.Work.LP.rollback,
  1982. "style": "user",
  1983. "isResize": false,
  1984. "content": node,
  1985. "width": 600,
  1986. "height" : 400,
  1987. "buttonList": [
  1988. {
  1989. "type": "ok",
  1990. "text": MWF.LP.process.button.ok,
  1991. "action": function (d, e) {
  1992. this.doRollback(node, e, dlg ,data.id);
  1993. }.bind(this)
  1994. },
  1995. {
  1996. "type": "cancel",
  1997. "text": MWF.LP.process.button.cancel,
  1998. "action": function () { dlg.close(); }
  1999. }
  2000. ]
  2001. });
  2002. },
  2003. doRollback: function (node, e, dlg ,workid) {
  2004. var lp = MWF.xApplication.process.Work.LP;
  2005. var rollbackItemNode = node.getLast();
  2006. var items = rollbackItemNode.getChildren();
  2007. var flowOption = (node.getElement(".rollback_flowOption").checked);
  2008. var _self = this;
  2009. for (var i = 0; i < items.length; i++) {
  2010. if (items[i].retrieve("isSelected")) {
  2011. var text = lp.rollbackConfirmContent;
  2012. var log = items[i].retrieve("log");
  2013. var checks = items[i].getElements("input:checked");
  2014. var idList = [];
  2015. checks.each(function (check) {
  2016. var id = check.get("value");
  2017. if (idList.indexOf(id) == -1) idList.push(id);
  2018. });
  2019. var opinion = MWF.xApplication.process.Xform.LP.rollbackTo+":"+log.fromActivityName;
  2020. text = text.replace("{log}", log.fromActivityName + "(" + log.arrivedTime + ")");
  2021. this.explorer.app.confirm("infor", e, lp.rollbackConfirmTitle, text, 450, 120, function () {
  2022. _self.app.action[_self.type === "workCompleted"?"WorkCompletedAction":"WorkAction"][_self.type === "workCompleted"?"rollback":"V2Rollback"](workid,{
  2023. "workLog": log.id,
  2024. "distinguishedNameList": idList,
  2025. "processing": !!flowOption,
  2026. "opinion": opinion
  2027. },function (json){
  2028. _self.app.notice(lp.rollbackSuccess);
  2029. _self.explorer.refresh();
  2030. },null,false);
  2031. dlg.close();
  2032. this.close();
  2033. }, function () {
  2034. this.close();
  2035. });
  2036. break;
  2037. }
  2038. }
  2039. },
  2040. getRollbackLogs: function (rollbackItemNode,id) {
  2041. var _self = this;
  2042. var data ;
  2043. this.app.action.WorkLogAction.listRollbackWithWorkOrWorkCompleted(id).then(function (json){
  2044. var dataList = json.data;
  2045. dataList.each(function (log) {
  2046. if (!log.splitting && log.connected) {
  2047. var node = new Element("div", { "styles": this.css.rollbackItemNode }).inject(rollbackItemNode);
  2048. node.store("log", log);
  2049. var iconNode = new Element("div", { "styles": this.css.rollbackItemIconNode }).inject(node);
  2050. var contentNode = new Element("div", { "styles": this.css.rollbackItemContentNode }).inject(node);
  2051. var div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
  2052. var activityNode = new Element("div", { "styles": this.css.rollbackItemActivityNode, "text": log.fromActivityName }).inject(div);
  2053. var timeNode = new Element("div", { "styles": this.css.rollbackItemTimeNode, "text": log.arrivedTime }).inject(div);
  2054. div = new Element("div", { "styles": { "overflow": "hidden" } }).inject(contentNode);
  2055. var taskTitleNode = new Element("div", { "styles": this.css.rollbackItemTaskTitleNode, "text": "办理人: " }).inject(div);
  2056. if (log.taskCompletedList.length) {
  2057. log.taskCompletedList.each(function (o) {
  2058. var text = o2.name.cn(o.person) + "(" + o.completedTime + ")";
  2059. var check = new Element("input", {
  2060. "value": o.identity,
  2061. "type": "checkbox",
  2062. "disabled": true,
  2063. "styles": this.css.rollbackItemTaskCheckNode
  2064. }).inject(div);
  2065. check.addEvent("click", function (e) {
  2066. e.stopPropagation();
  2067. });
  2068. var taskNode = new Element("div", { "styles": this.css.rollbackItemTaskNode, "text": text }).inject(div);
  2069. }.bind(this));
  2070. } else {
  2071. var text = "系统自动处理";
  2072. var taskNode = new Element("div", { "styles": this.css.rollbackItemTaskNode, "text": text }).inject(div);
  2073. }
  2074. node.addEvents({
  2075. "mouseover": function () {
  2076. var isSelected = this.retrieve("isSelected");
  2077. if (!isSelected) this.setStyles(_self.css.rollbackItemNode_over);
  2078. },
  2079. "mouseout": function () {
  2080. var isSelected = this.retrieve("isSelected");
  2081. if (!isSelected) this.setStyles(_self.css.rollbackItemNode)
  2082. },
  2083. "click": function () {
  2084. var isSelected = this.retrieve("isSelected");
  2085. if (isSelected) {
  2086. _self.setRollBackUnchecked(this);
  2087. } else {
  2088. var items = rollbackItemNode.getChildren();
  2089. items.each(function (item) {
  2090. _self.setRollBackUnchecked(item);
  2091. });
  2092. _self.setRollBackChecked(this);
  2093. }
  2094. }
  2095. });
  2096. }
  2097. }.bind(this));
  2098. }.bind(this));
  2099. },
  2100. setRollBackChecked: function (item) {
  2101. item.store("isSelected", true);
  2102. item.setStyles(this.css.rollbackItemNode_current);
  2103. item.getFirst().setStyles(this.css.rollbackItemIconNode_current);
  2104. var node = item.getLast().getFirst();
  2105. node.getFirst().setStyles(this.css.rollbackItemActivityNode_current);
  2106. node.getLast().setStyles(this.css.rollbackItemTimeNode_current);
  2107. node = item.getLast().getLast();
  2108. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode_current);
  2109. node.getLast().setStyles(this.css.rollbackItemTaskNode_current);
  2110. var checkeds = item.getElements("input");
  2111. if (checkeds){
  2112. checkeds.set("checked", true);
  2113. checkeds.set("disabled", false);
  2114. }
  2115. },
  2116. setRollBackUnchecked: function (item) {
  2117. item.store("isSelected", false);
  2118. item.setStyles(this.css.rollbackItemNode);
  2119. item.getFirst().setStyles(this.css.rollbackItemIconNode);
  2120. var node = item.getLast().getFirst();
  2121. node.getFirst().setStyles(this.css.rollbackItemActivityNode);
  2122. node.getLast().setStyles(this.css.rollbackItemTimeNode);
  2123. node = item.getLast().getLast();
  2124. node.getFirst().setStyles(this.css.rollbackItemTaskTitleNode);
  2125. node.getLast().setStyles(this.css.rollbackItemTaskNode);
  2126. var checkeds = item.getElements("input");
  2127. if (checkeds) {
  2128. checkeds.set("checked", false);
  2129. checkeds.set("disabled", true);
  2130. }
  2131. },
  2132. loadRightNode : function(){
  2133. this.toolabrRightNode = new Element("div.toolabrRightNode",{
  2134. "style": "float:right"
  2135. }).inject(this.node);
  2136. //this.loadSearch();
  2137. },
  2138. loadSearch : function (){
  2139. var searchNode = new Element("div.ft_titleSearchArea",{"style":"width:300px"}).inject(this.toolabrRightNode);
  2140. var searchIconNode = new Element("div.ft_filterIcon",{"html":'<icon class="o2icon-sousuo mainColor_color"></icon>'}).inject(searchNode);
  2141. var searchBtn = new Element("div",{"class":"ft_searchButton mainColor_bg","text":"搜索"}).inject(searchNode);
  2142. var searchInput = new Element("div.ft_titleInputArea").inject(searchNode);
  2143. new Element("input",{"placeholder" : "请输入关键字"}).inject(searchInput);
  2144. },
  2145. getListType : function(){
  2146. return this.viewType || this.options.viewType
  2147. },
  2148. loadListType : function(){
  2149. this.listViewTypeNode = new Element("div", {
  2150. "style" : "font-size:18px;float:left;margin-right:6px",
  2151. "class" : this.options.viewType == "list" ? "mainColor_color" : "",
  2152. events : {
  2153. click : function(){
  2154. this.viewType = "list";
  2155. this.explorer.options.defaultViewType = this.viewType;
  2156. this.explorer.refresh();
  2157. }.bind(this)
  2158. }
  2159. }).inject(this.toolabrRightNode);
  2160. new Element("icon",{"class":"o2Drive icon-list"}).inject(this.listViewTypeNode);
  2161. this.tileViewTypeNode = new Element("div", {
  2162. "style" : "font-size:18px;float:left",
  2163. "class" : this.options.viewType !== "list" ? "mainColor_color" : "",
  2164. events : {
  2165. click : function(){
  2166. this.viewType = "tile";
  2167. this.explorer.options.defaultViewType = this.viewType;
  2168. this.explorer.refresh();
  2169. }.bind(this)
  2170. }
  2171. }).inject(this.toolabrRightNode);
  2172. new Element("icon",{"class":"o2Drive icon-grid"}).inject(this.tileViewTypeNode);
  2173. }
  2174. });
  2175. MWF.xApplication.process.Application.AddSerSialForm = new Class({
  2176. Extends: MPopupForm,
  2177. Implements: [Options, Events],
  2178. options: {
  2179. "style": "attendanceV2",
  2180. "width": 500,
  2181. //"height": 300,
  2182. "height": "350",
  2183. "hasTop": true,
  2184. "hasIcon": false,
  2185. "draggable": true,
  2186. "title" : "新增流水号",
  2187. "id" : ""
  2188. },
  2189. _createTableContent: function () {
  2190. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  2191. "<tr><td styles='formTableTitleRight' lable='process'></td>" +
  2192. " <td styles='formTableValue1' item='process' colspan='2'></td>" +
  2193. "</tr>" +
  2194. "<tr><td styles='formTableTitleRight' lable='name'></td>" +
  2195. " <td styles='formTableValue1' item='name' colspan='2'></td>" +
  2196. "</tr>" +
  2197. "<tr><td styles='formTableTitleRight' lable='serial'></td>" +
  2198. " <td styles='formTableValue' item='serial' colspan='2'></td></tr>" +
  2199. "</table>";
  2200. this.formTableArea.set("html", html);
  2201. this.form = new MForm(this.formTableArea, this.data || {}, {
  2202. isEdited: true,
  2203. style : "attendance",
  2204. hasColon : true,
  2205. itemTemplate: {
  2206. name: { text : "关键字", notEmpty : true },
  2207. serial: { text : "流水号", notEmpty : true },
  2208. process: {
  2209. "text": "流程",
  2210. "type": "text",
  2211. "notEmpty" : true,
  2212. "defaultValue":this.data.processName,
  2213. "event": {
  2214. "click": function (item, ev){
  2215. var v = item.getValue();
  2216. o2.xDesktop.requireApp("Selector", "package", function(){
  2217. var options = {
  2218. "type": "Process",
  2219. "values": [],
  2220. "count": 1,
  2221. "applicationId" : this.app.application.id,
  2222. "onComplete": function (items) {
  2223. if(items.length>0){
  2224. var d = items[0].data;
  2225. this.data.processId = d.id;
  2226. item.setValue(d.name);
  2227. }
  2228. }.bind(this)
  2229. };
  2230. new o2.O2Selector(this.app.desktop.node, options);
  2231. }.bind(this),false);
  2232. }.bind(this)}
  2233. }
  2234. }
  2235. }, this.app);
  2236. this.form.load();
  2237. },
  2238. _createBottomContent: function () {
  2239. if (this.isNew || this.isEdited) {
  2240. this.okActionNode = new Element("button.inputOkButton", {
  2241. "styles": this.css.inputOkButton,
  2242. "text": "确定"
  2243. }).inject(this.formBottomNode);
  2244. this.okActionNode.addEvent("click", function (e) {
  2245. this.save(e);
  2246. }.bind(this));
  2247. }
  2248. this.cancelActionNode = new Element("button.inputCancelButton", {
  2249. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  2250. "text": "关闭"
  2251. }).inject(this.formBottomNode);
  2252. this.cancelActionNode.addEvent("click", function (e) {
  2253. this.close(e);
  2254. }.bind(this));
  2255. },
  2256. save: function(){
  2257. var data = this.form.getResult(true,null,true,false,true);
  2258. if( data ){
  2259. debugger
  2260. this.app.action.SerialNumberAction.create({
  2261. "application" : this.app.application.id,
  2262. "process" : data.processId,
  2263. "name" : data.name,
  2264. "serial" : data.serial
  2265. }).then(function (){
  2266. this.app.notice("添加成功");
  2267. this.explorer.refresh();
  2268. this.close();
  2269. }.bind(this));
  2270. }
  2271. }
  2272. });
  2273. MWF.xApplication.process.Application.SetSerSialForm = new Class({
  2274. Extends: MPopupForm,
  2275. Implements: [Options, Events],
  2276. options: {
  2277. "style": "attendanceV2",
  2278. "width": 500,
  2279. //"height": 300,
  2280. "height": "200",
  2281. "hasTop": true,
  2282. "hasIcon": false,
  2283. "draggable": true,
  2284. "title" : "设置流水号",
  2285. "id" : ""
  2286. },
  2287. _createTableContent: function () {
  2288. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  2289. "<tr><td styles='formTableTitle' lable='serial' width='25%'></td>" +
  2290. " <td styles='formTableValue14' item='serial' colspan='3'></td></tr>" +
  2291. "</table>";
  2292. this.formTableArea.set("html", html);
  2293. this.form = new MForm(this.formTableArea, this.data || {}, {
  2294. isEdited: true,
  2295. style : "minder",
  2296. hasColon : true,
  2297. itemTemplate: {
  2298. serial: { text : "流水号", notEmpty : true }
  2299. }
  2300. }, this.app);
  2301. this.form.load();
  2302. },
  2303. _createBottomContent: function () {
  2304. if (this.isNew || this.isEdited) {
  2305. this.okActionNode = new Element("button.inputOkButton", {
  2306. "styles": this.css.inputOkButton,
  2307. "text": "确定"
  2308. }).inject(this.formBottomNode);
  2309. this.okActionNode.addEvent("click", function (e) {
  2310. this.save(e);
  2311. }.bind(this));
  2312. }
  2313. this.cancelActionNode = new Element("button.inputCancelButton", {
  2314. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  2315. "text": "关闭"
  2316. }).inject(this.formBottomNode);
  2317. this.cancelActionNode.addEvent("click", function (e) {
  2318. this.close(e);
  2319. }.bind(this));
  2320. },
  2321. save: function(){
  2322. var data = this.form.getResult(true,null,true,false,true);
  2323. if( data ){
  2324. debugger
  2325. this.app.action.SerialNumberAction.update(data.id,{
  2326. "application" : data.application,
  2327. "process" : data.process,
  2328. "serial" : data.serial
  2329. }).then(function (){
  2330. this.app.notice("更新成功");
  2331. this.explorer.refresh();
  2332. this.close();
  2333. }.bind(this));
  2334. }
  2335. }
  2336. });
  2337. MWF.xApplication.process.Application.ManageWorkForm = new Class({
  2338. Extends: MPopupForm,
  2339. Implements: [Options, Events],
  2340. options: {
  2341. "style": "attendanceV2",
  2342. "width": "1000",
  2343. "height": "700",
  2344. "hasTop": true,
  2345. "hasIcon": false,
  2346. "hasTopIcon" : false,
  2347. "hasTopContent" : false,
  2348. "draggable": true,
  2349. "maxAction" : true,
  2350. "resizeable" : true,
  2351. "closeAction": true,
  2352. "title": MWF.xApplication.process.Application.LP.adminwork,
  2353. "hideBottomWhenReading": true,
  2354. "closeByClickMaskWhenReading": true,
  2355. },
  2356. _postLoad: function(){
  2357. if(this.data.completedTime){
  2358. this.isCompletedWork = true;
  2359. }
  2360. this._createTableContent_();
  2361. },
  2362. _createTableContent: function(){},
  2363. _createTableContent_: function () {
  2364. //this.formTableArea.set("html", this.getHtml());
  2365. this.formTableContainer.setStyle("width","95%");
  2366. this.formTableContainer.setStyle("margin","0px auto 10px");
  2367. this.loadTab();
  2368. },
  2369. loadTab : function (){
  2370. this.tabNode = new Element("div",{"styles" : this.css.tabNode }).inject(this.formTableArea);
  2371. this.taskArea = new Element("div",{"style" : "height:500px;overflow:auto" }).inject(this.tabNode);
  2372. this.taskDoneArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  2373. this.readArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  2374. this.readDoneArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  2375. this.reviewArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  2376. this.attachementArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  2377. this.recordArea = new Element("div",{"style" : "height:550px;overflow:auto" }).inject(this.tabNode);
  2378. this.businessDataArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  2379. this.dataRecordArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  2380. MWF.require("MWF.widget.Tab", function(){
  2381. this.tabs = new MWF.widget.Tab(this.tabNode, {"style": "attendance"});
  2382. this.tabs.load();
  2383. this.taskPage = this.tabs.addTab(this.taskArea, this.lp.task, false);
  2384. this.taskPage.addEvent("show",function(){
  2385. if(!this.initTask) this.loadTask();
  2386. }.bind(this));
  2387. this.taskDonePage = this.tabs.addTab(this.taskDoneArea, this.lp.taskDone, false);
  2388. this.taskDonePage.addEvent("show",function(){
  2389. if(!this.initTaskDone) this.loadTaskDone();
  2390. }.bind(this));
  2391. this.readPage = this.tabs.addTab(this.readArea, this.lp.read, false);
  2392. this.readPage.addEvent("show",function(){
  2393. if(!this.initRead) this.loadRead();
  2394. }.bind(this));
  2395. this.readDonePage = this.tabs.addTab(this.readDoneArea, this.lp.readDone, false);
  2396. this.readDonePage.addEvent("show",function(){
  2397. if(!this.initReadDone) this.loadReadDone();
  2398. }.bind(this));
  2399. this.recordPage = this.tabs.addTab(this.recordArea, this.lp.workLog, false);
  2400. this.recordPage.addEvent("show",function(){
  2401. if(!this.initRecord) this.loadRecord();
  2402. }.bind(this));
  2403. this.reviewPage = this.tabs.addTab(this.reviewArea, this.lp.review, false);
  2404. this.reviewPage.addEvent("show",function(){
  2405. if(!this.initReview) this.loadReview();
  2406. }.bind(this));
  2407. this.attachementPage = this.tabs.addTab(this.attachementArea, this.lp.attachment, false);
  2408. this.attachementPage.addEvent("show",function(){
  2409. if(!this.initAttachement) this.loadAttachement();
  2410. }.bind(this));
  2411. this.businessDataPage = this.tabs.addTab(this.businessDataArea,this.lp.businessData, false);
  2412. this.businessDataPage.addEvent("show",function(){
  2413. if(!this.initBusinessData) this.loadBusinessData();
  2414. }.bind(this));
  2415. this.dataRecordPage = this.tabs.addTab(this.dataRecordArea,this.lp.dataRecord, false);
  2416. this.dataRecordPage.addEvent("show",function(){
  2417. if(!this.initDataRecord) this.loadDataRecord();
  2418. }.bind(this));
  2419. this.tabs.pages[0].showTab();
  2420. }.bind(this));
  2421. },
  2422. loadTask : function () {
  2423. this.app.action.TaskAction.listWithWork(this.data.id,function (json){
  2424. this.taskList = json.data;
  2425. this._loadTask();
  2426. this.initTask = true;
  2427. }.bind(this),function (){
  2428. this.taskArea.empty();
  2429. this.initTask = true;
  2430. return true;
  2431. }.bind(this));
  2432. },
  2433. _loadTask : function (){
  2434. this.taskArea.empty();
  2435. this.taskContentNode = new Element("div").inject(this.taskArea);
  2436. var taskTableNode = new Element("table.table",{
  2437. "border" : 0,
  2438. "cellpadding" : 5,
  2439. "cellspacing" : 0
  2440. }).inject(this.taskContentNode);
  2441. var taskTableTheadNode = new Element("thead").inject(taskTableNode);
  2442. var taskTableTbodyNode = new Element("tbody").inject(taskTableNode);
  2443. var taskTableTheadTrNode = new Element("tr").inject(taskTableTheadNode);
  2444. Array.each([this.lp.currentPerson, this.lp.currentDept, this.lp.activity, this.lp.startTime, this.lp.action], function (text) {
  2445. new Element("th", {"text": text}).inject(taskTableTheadTrNode);
  2446. });
  2447. this.taskList.each(function (task) {
  2448. var trNode = new Element("tr").inject(taskTableTbodyNode);
  2449. trNode.store("data", task);
  2450. Array.each([task.person.split("@")[0], task.unit.split("@")[0], task.activityName, task.startTime], function (text) {
  2451. new Element("td", {
  2452. text: text
  2453. }).inject(trNode);
  2454. });
  2455. var tdOpNode = new Element("td").inject(trNode);
  2456. var restButton = new Element("button", {"text": this.lp.resetAction, "class": "button"}).inject(tdOpNode);
  2457. var deleteButton = new Element("button", {"text": this.lp.remove, "class": "button"}).inject(tdOpNode);
  2458. var addSignButton = new Element("button", {"text": this.lp.addSign, "class": "button"}).inject(tdOpNode);
  2459. var flowButton = new Element("button", {"text": this.lp.flow, "class": "button"}).inject(tdOpNode);
  2460. _self = this;
  2461. deleteButton.addEvent("click", function (e) {
  2462. _self.app.confirm("warn", e, _self.lp.tip, this.lp.tip_remove, 350, 120, function () {
  2463. _self.app.action.TaskAction.manageDelete(task.id,function (){},null,false);
  2464. _self.loadTask();
  2465. this.close();
  2466. }, function(){
  2467. this.close();
  2468. });
  2469. }.bind(this));
  2470. restButton.addEvent("click", function (ev) {
  2471. var opt = {
  2472. "type": "identity",
  2473. "count": 0,
  2474. "title": _self.lp.resetAction,
  2475. "onComplete": function (items) {
  2476. var _self = this;
  2477. var nameArr = [];
  2478. items.each(function(item){
  2479. nameArr.push(item.data.name)
  2480. });
  2481. this.explorer.app.confirm("warn", ev,_self.lp.tip_reset, {
  2482. "html": _self.lp.rest_content.replace("(name)",nameArr.join())
  2483. }, 400, 300, function(){
  2484. var inputs = this.content.getElements("input");
  2485. var opinion = this.content.getElement("textarea").get("value");
  2486. var flag = "";
  2487. for (var i=0; i<inputs.length; i++){
  2488. if (inputs[i].checked){
  2489. flag = inputs[i].get("value");
  2490. break;
  2491. }
  2492. }
  2493. inputs.addEvent("click",function (){
  2494. this.content.getElement("#reset_checkInfor").set("text","");
  2495. }.bind(this));
  2496. if (flag){
  2497. var keep = true;
  2498. if(flag==="no"){
  2499. keep = false;
  2500. }
  2501. var nameList = [];
  2502. items.each(function (identity) {
  2503. nameList.push(identity.data.distinguishedName);
  2504. });
  2505. var data = {
  2506. "routeName":_self.lp.resetAction,
  2507. "opinion":opinion,
  2508. "identityList":nameList,
  2509. "keep" : keep
  2510. }
  2511. _self.app.action.TaskAction.V2Reset(task.id,data,function(json){
  2512. },null,false);
  2513. _self.loadTask();
  2514. this.close();
  2515. }else{
  2516. this.content.getElement("#reset_checkInfor").set("text", _self.lp.tip_keetask).setStyle("color", "red");
  2517. }
  2518. }, function(){
  2519. this.close();
  2520. });
  2521. }.bind(this)
  2522. };
  2523. new MWF.O2Selector(this.app.content, opt);
  2524. }.bind(this));
  2525. addSignButton.addEvent("click", function (e) {
  2526. this._addSign(task);
  2527. }.bind(this));
  2528. flowButton.addEvent("click", function (e) {
  2529. this._flow(task,e);
  2530. }.bind(this));
  2531. }.bind(this));
  2532. },
  2533. _flow : function (taskData,ev){
  2534. var _self = this;
  2535. var processNode = new Element("div");
  2536. var dlg = o2.DL.open({
  2537. "title": _self.lp.flow,
  2538. "width": "600px",
  2539. "height": "420px",
  2540. "mask": true,
  2541. "content": processNode,
  2542. "container": null,
  2543. "positionNode": this.explorer.app.content,
  2544. "onQueryClose": function () {
  2545. processNode.destroy();
  2546. }.bind(this),
  2547. "onPostShow": function () {
  2548. dlg.reCenter();
  2549. o2.xDesktop.requireApp("process.Work", "Processor", function(){
  2550. new o2.xApplication.process.Work.Processor(processNode, taskData, {
  2551. "style": "task",
  2552. "isManagerProcess" : true,
  2553. "onCancel": function(){
  2554. dlg.close();
  2555. },
  2556. "onSubmit": function(routeName, opinion){
  2557. var taskId = taskData.id;
  2558. var data = {
  2559. "routeName": routeName,
  2560. "opinion": opinion
  2561. };
  2562. _self.app.action.TaskAction.processing(taskId,data,function(json){
  2563. dlg.close();
  2564. _self.loadTask();
  2565. },null,false);
  2566. }
  2567. });
  2568. }.bind(this));
  2569. }.bind(this)
  2570. });
  2571. },
  2572. _addSign : function(task){
  2573. var _self = this;
  2574. var opt = {};
  2575. o2.DL.open({
  2576. "title": o2.xApplication.process.Xform.LP.form.addTask,
  2577. "style": "user",
  2578. "width": (layout.mobile) ? "100%" : 680,
  2579. "height": (layout.mobile) ? "100%" : 380,
  2580. "url": this.app.path+"default/view/dlg/addSign.html",
  2581. "lp": o2.xApplication.process.Xform.LP.form,
  2582. "container": this.app.content,
  2583. "maskNode": this.app.content,
  2584. "offset": (layout.mobile) ? null : {y: -120},
  2585. "buttonList": [
  2586. {
  2587. "type": "ok",
  2588. "text": o2.LP.process.button.ok,
  2589. "action": function (d, e) {
  2590. if( !this.identityList || !this.identityList.length ){
  2591. _self.app.notice(o2.xApplication.process.Xform.LP.inputAddTaskPeople, "error", this.node);
  2592. }else{
  2593. _self.doAddTask(task,this);
  2594. }
  2595. }
  2596. },
  2597. {
  2598. "type": "cancel",
  2599. "text": MWF.LP.process.button.cancel,
  2600. "action": function () {
  2601. this.close();
  2602. }
  2603. }
  2604. ],
  2605. "onPostShow": function () {
  2606. var selPeopleButton = this.content.getElement(".addTask_selPeopleButton");
  2607. selPeopleButton.addEvent("click", function () {
  2608. _self.selectPeopleAll(this,0);
  2609. }.bind(this));
  2610. }
  2611. });
  2612. },
  2613. doAddTask: function(task,dlg){
  2614. MWF.require("MWF.widget.Mask", function () {
  2615. var position = this.getRadioValue(dlg.content, ".addTask_type") || "after";
  2616. var mode = this.getRadioValue(dlg.content, ".mode_type") || "single";
  2617. if (dlg.identityList && dlg.identityList.length){
  2618. this.mask = new MWF.widget.Mask({ "style": "desktop", "zIndex": 50000 });
  2619. if( layout.mobile ){
  2620. this.mask.load();
  2621. }else{
  2622. this.mask.loadNode(this.app.content);
  2623. }
  2624. var nameArr = dlg.identityList.map(function(id){
  2625. return o2.name.cn(id);
  2626. });
  2627. var opinion = dlg.content.getElement(".addTask_opinion").get("value");
  2628. this.doAddTaskToPeople(task,dlg.identityList, opinion, mode, position === "before", "", function (json) {
  2629. this.fireEvent("afterAddTask");
  2630. if (this.app && this.app.fireEvent) this.app.fireEvent("afterAddTask");
  2631. this.app.notice(MWF.xApplication.process.Xform.LP.addTaskOk + ": " + nameArr, "success");
  2632. dlg.close();
  2633. if (this.mask) this.mask.hide();
  2634. }.bind(this), function (xhr, text, error) {
  2635. var errorText = error + ":" + text;
  2636. if (xhr) errorText = xhr.responseText;
  2637. this.app.notice("request json error: " + errorText, "error", dlg ? dlg.node : null);
  2638. if (this.mask) this.mask.hide();
  2639. }.bind(this))
  2640. }else{
  2641. if (this.mask) this.mask.hide();
  2642. }
  2643. }.bind(this));
  2644. },
  2645. getRadioValue: function(node, selector){
  2646. var nodes = node.getElements(selector);
  2647. for (var i=0; i<nodes.length; i++){
  2648. if (nodes[i].checked){
  2649. return nodes[i].value;
  2650. }
  2651. }
  2652. return "";
  2653. },
  2654. doAddTaskToPeople: function (task,names, opinion, mode, before, routeName, success, failure) {
  2655. var lp = o2.xApplication.process.Xform.LP.form;
  2656. var leftText = (!!before ? lp.addTaskBefore : lp.addTaskAfter)+lp[mode];
  2657. var nameArr = names.map(function(id){
  2658. return o2.name.cn(id);
  2659. });
  2660. var n = nameArr.length > 3 ? (nameArr[0]+"、"+nameArr[1]+"、"+nameArr[2]+"...") : nameArr.join(", ");
  2661. var routeName = leftText+":"+n;
  2662. if (!opinion) opinion = leftText+":"+nameArr.join(", "); //o2.xApplication.process.Xform.LP.form.addTask+":"+nameArr.join(", ");
  2663. var data = {
  2664. "mode": mode,
  2665. "before": !!before,
  2666. "opinion": opinion,
  2667. "routeName": routeName,
  2668. "distinguishedNameList": names
  2669. };
  2670. o2.Actions.load("x_processplatform_assemble_surface").TaskAction.v3Add(
  2671. //this.workAction.resetWork(
  2672. function (json) {
  2673. if (success) success(json);
  2674. }.bind(this),
  2675. function (xhr, text, error) {
  2676. if (failure) failure(xhr, text, error);
  2677. },
  2678. task.id, data
  2679. );
  2680. },
  2681. selectPeopleAll: function (dlg, count) {
  2682. var names = dlg.identityList || [];
  2683. var areaNode = $("resetWork_selPeopleArea");
  2684. var options = {
  2685. "values": names,
  2686. "type": "identity",
  2687. "count": count,
  2688. "onComplete": function (items) {
  2689. areaNode.empty();
  2690. var identityList = [];
  2691. items.each(function (item) {
  2692. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  2693. identityList.push(item.data.distinguishedName);
  2694. }.bind(this));
  2695. dlg.identityList = identityList;
  2696. }.bind(this)
  2697. };
  2698. MWF.xDesktop.requireApp("Selector", "package", function () {
  2699. var selector = new MWF.O2Selector(this.app.content, options);
  2700. }.bind(this));
  2701. },
  2702. loadTaskDone : function () {
  2703. this.app.action.TaskCompletedAction.listWithJob(this.data.job, function (json) {
  2704. this.taskDoneList = json.data;
  2705. this._loadTaskDone();
  2706. this.initTaskDone = true;
  2707. }.bind(this));
  2708. },
  2709. _loadTaskDone : function (){
  2710. var lp = this.lp;
  2711. this.taskDoneArea.empty();
  2712. this.taskDoneContentNode = new Element("div").inject(this.taskDoneArea);
  2713. var taskDoneTableNode = new Element("table.table",{
  2714. "border" : 0,
  2715. "cellpadding" : 5,
  2716. "cellspacing" : 0
  2717. }).inject(this.taskDoneContentNode);
  2718. var taskDoneTableTheadNode = new Element("thead").inject(taskDoneTableNode);
  2719. var taskDoneTableTbodyNode = new Element("tbody").inject(taskDoneTableNode);
  2720. var taskDoneTableTheadTrNode = new Element("tr").inject(taskDoneTableTheadNode);
  2721. Array.each([lp.currentPerson, lp.currentDept, lp.activity, lp.startTime, lp.endTime, lp.routerName, lp.idea, lp.action], function (text) {
  2722. var tmpthNode = new Element("th", {"text": text}).inject(taskDoneTableTheadTrNode);
  2723. if(text===lp.idea){
  2724. tmpthNode.setStyle("width","150px");
  2725. }
  2726. });
  2727. this.taskDoneList.each(function (taskDone) {
  2728. var trNode = new Element("tr").inject(taskDoneTableTbodyNode);
  2729. trNode.store("data", taskDone);
  2730. Array.each([taskDone.person.split("@")[0], taskDone.unit.split("@")[0], taskDone.activityName, taskDone.startTime, taskDone.updateTime, taskDone.routeName, taskDone.opinion], function (text) {
  2731. new Element("td", {
  2732. text: text
  2733. }).inject(trNode);
  2734. });
  2735. var tdOpNode = new Element("td").inject(trNode);
  2736. var setOpinionButton = new Element("button", {"text": lp.idea, "class": "button"}).inject(tdOpNode);
  2737. var deleteButton = new Element("button", {"text": lp.remove, "class": "button"}).inject(tdOpNode);
  2738. deleteButton.addEvent("click", function (e) {
  2739. _self = this;
  2740. this.app.confirm("warn", e, lp.tip, lp.tip_remove, 350, 120, function () {
  2741. _self.app.action.TaskCompletedAction.manageDelete(taskDone.id,function (){},null,false);
  2742. _self.loadTaskDone();
  2743. this.close();
  2744. }, function(){
  2745. this.close();
  2746. });
  2747. }.bind(this));
  2748. setOpinionButton.addEvent("click", function () {
  2749. var ideaNode = new Element("div", {"class": "control", "style": "margin:10px"});
  2750. var textareaNode = new Element("textarea", {"style":"height:80px","class": "textarea", "text": taskDone.opinion});
  2751. textareaNode.inject(ideaNode);
  2752. var ideaDlg = o2.DL.open({
  2753. "title": lp.editIdea,
  2754. "width": "400px",
  2755. "height": "260px",
  2756. "mask": true,
  2757. "content": ideaNode,
  2758. "container": null,
  2759. "positionNode": this.app.content,
  2760. "onQueryClose": function () {
  2761. ideaNode.destroy();
  2762. }.bind(this),
  2763. "buttonList": [
  2764. {
  2765. "text": lp.ok,
  2766. "action": function () {
  2767. this.app.action.TaskCompletedAction.manageOpinion(taskDone.id,{"opinion":textareaNode.get("value")},function(json){
  2768. },null,false);
  2769. this.loadTaskDone();
  2770. ideaDlg.close();
  2771. }.bind(this)
  2772. },
  2773. {
  2774. "text": lp.close,
  2775. "action": function () {
  2776. ideaDlg.close();
  2777. }.bind(this)
  2778. }
  2779. ],
  2780. "onPostShow": function () {
  2781. ideaDlg.reCenter();
  2782. }.bind(this)
  2783. });
  2784. }.bind(this));
  2785. }.bind(this));
  2786. },
  2787. loadRead : function () {
  2788. this.app.action.ReadAction.listWithJob(this.data.job, function (json) {
  2789. this.readList = json.data;
  2790. this._loadRead();
  2791. this.initRead = true;
  2792. }.bind(this));
  2793. },
  2794. _loadRead : function (){
  2795. var lp = this.lp;
  2796. this.readArea.empty();
  2797. this.readContentNode = new Element("div").inject(this.readArea);
  2798. var readTableNode = new Element("table.table",{
  2799. "border" : 0,
  2800. "cellpadding" : 5,
  2801. "cellspacing" : 0
  2802. }).inject(this.readContentNode);
  2803. var readTableTheadNode = new Element("thead").inject(readTableNode);
  2804. var readTableTbodyNode = new Element("tbody").inject(readTableNode);
  2805. var readTableTheadTrNode = new Element("tr").inject(readTableTheadNode);
  2806. Array.each([lp.readPerson, lp.currentDept, lp.activity, lp.startTime, lp.action], function (text) {
  2807. new Element("th", {"text": text}).inject(readTableTheadTrNode);
  2808. });
  2809. this.readList.each(function (read) {
  2810. var trNode = new Element("tr").inject(readTableTbodyNode);
  2811. trNode.store("data", read);
  2812. Array.each([read.person.split("@")[0], read.unit.split("@")[0], read.activityName, read.startTime], function (text) {
  2813. new Element("td", {
  2814. text: text
  2815. }).inject(trNode);
  2816. });
  2817. var tdOpNode = new Element("td").inject(trNode);
  2818. var readButton = new Element("button", {"text": lp.readDone, "class": "button"}).inject(tdOpNode);
  2819. var restButton = new Element("button", {"text": lp.resetAction, "class": "button"}).inject(tdOpNode);
  2820. var deleteButton = new Element("button", {"text": lp.remove, "class": "button"}).inject(tdOpNode);
  2821. deleteButton.addEvent("click", function (e) {
  2822. var _self = this;
  2823. _self.app.confirm("warn", e, lp.tip, lp.tip_remove, 350, 120, function () {
  2824. _self.app.action.ReadAction.manageDelete(read.id,function (){},null,false);
  2825. _self.loadRead();
  2826. this.close();
  2827. }, function(){
  2828. this.close();
  2829. });
  2830. }.bind(this));
  2831. restButton.addEvent("click", function () {
  2832. var opt = {
  2833. "type": "identity",
  2834. "count": 0,
  2835. "title": lp.resetAction,
  2836. "onComplete": function (items) {
  2837. var nameList = [];
  2838. var nameDnList = [];
  2839. items.each(function (identity) {
  2840. nameList.push(identity.data.name);
  2841. nameDnList.push(identity.data.distinguishedName);
  2842. });
  2843. var data = {
  2844. "opinion":lp.resetActionFor + ": " + nameList.join(","),
  2845. "identityList":nameDnList
  2846. }
  2847. this.app.action.ReadAction.manageResetRead(read.id,data,function(json){
  2848. },null,false);
  2849. this.loadRead();
  2850. }.bind(this)
  2851. };
  2852. new MWF.O2Selector(this.app.content, opt);
  2853. }.bind(this));
  2854. readButton.addEvent("click", function () {
  2855. var ideaNode = new Element("div", { "style": "margin:10px"});
  2856. var textareaNode = new Element("textarea", {"class":"textarea","style": "min-width:100%;height: 100px", "text": read.opinion});
  2857. textareaNode.inject(ideaNode);
  2858. var ideaDlg = o2.DL.open({
  2859. "title": lp.readProcess,
  2860. "width": "400px",
  2861. "height": "260px",
  2862. "mask": true,
  2863. "content": ideaNode,
  2864. "container": null,
  2865. "positionNode": this.app.content,
  2866. "onQueryClose": function () {
  2867. ideaNode.destroy();
  2868. }.bind(this),
  2869. "buttonList": [
  2870. {
  2871. "text": lp.ok,
  2872. "action": function () {
  2873. this.app.action.ReadAction.manageProcessing(read.id,{"opinion":textareaNode.get("value")},function(json){
  2874. },null,false);
  2875. this.loadRead();
  2876. ideaDlg.close();
  2877. }.bind(this)
  2878. },
  2879. {
  2880. "text": lp.close,
  2881. "action": function () {
  2882. ideaDlg.close();
  2883. }.bind(this)
  2884. }
  2885. ],
  2886. "onPostShow": function () {
  2887. ideaDlg.reCenter();
  2888. }.bind(this)
  2889. });
  2890. }.bind(this));
  2891. }.bind(this));
  2892. },
  2893. loadReadDone : function () {
  2894. this.app.action.ReadCompletedAction.listWithJob(this.data.job, function (json) {
  2895. this.readDoneList = json.data;
  2896. this._loadReadDone();
  2897. this.initReadDone = true;
  2898. }.bind(this), null, false);
  2899. },
  2900. _loadReadDone : function (){
  2901. var lp = this.lp;
  2902. this.readDoneArea.empty();
  2903. this.readDoneContentNode = new Element("div").inject(this.readDoneArea);
  2904. var readDoneTableNode = new Element("table.table",{
  2905. "border" : 0,
  2906. "cellpadding" : 5,
  2907. "cellspacing" : 0
  2908. }).inject(this.readDoneContentNode);
  2909. var readDoneTableTheadNode = new Element("thead").inject(readDoneTableNode);
  2910. var readDoneTableTbodyNode = new Element("tbody").inject(readDoneTableNode);
  2911. var readDoneTableTheadTrNode = new Element("tr").inject(readDoneTableTheadNode);
  2912. Array.each([lp.currentPerson, lp.currentDept, lp.activity, lp.startTime, lp.endTime, lp.idea, lp.action], function (text) {
  2913. new Element("th", {"text": text}).inject(readDoneTableTheadTrNode);
  2914. });
  2915. this.readDoneList.each(function (readDone) {
  2916. var trNode = new Element("tr").inject(readDoneTableTbodyNode);
  2917. trNode.store("data", readDone);
  2918. Array.each([readDone.person.split("@")[0], readDone.unit.split("@")[0], readDone.activityName, readDone.startTime, readDone.updateTime, readDone.opinion], function (text) {
  2919. new Element("td", {
  2920. text: text
  2921. }).inject(trNode);
  2922. });
  2923. var tdOpNode = new Element("td").inject(trNode);
  2924. var setOpinionButton = new Element("button", {"text": lp.idea, "class": "button"}).inject(tdOpNode);
  2925. var deleteButton = new Element("button", {"text": lp.remove, "class": "button"}).inject(tdOpNode);
  2926. deleteButton.addEvent("click", function (e) {
  2927. _self = this;
  2928. this.app.confirm("warn", e, lp.tip, lp.tip_remove, 350, 120, function () {
  2929. _self.app.action.ReadCompletedAction.manageDelete(readDone.id,function (){},null,false);
  2930. _self.loadReadDone();
  2931. this.close();
  2932. }, function(){
  2933. this.close();
  2934. });
  2935. }.bind(this));
  2936. setOpinionButton.addEvent("click", function () {
  2937. var ideaNode = new Element("div", {"class": "control", "style": "margin:10px"});
  2938. var textareaNode = new Element("textarea", {"class": "textarea", "text": readDone.opinion});
  2939. textareaNode.inject(ideaNode);
  2940. var ideaDlg = o2.DL.open({
  2941. "title": lp.editIdea,
  2942. "width": "400px",
  2943. "height": "260px",
  2944. "mask": true,
  2945. "content": ideaNode,
  2946. "container": null,
  2947. "positionNode": this.app.content,
  2948. "onQueryClose": function () {
  2949. ideaNode.destroy();
  2950. }.bind(this),
  2951. "buttonList": [
  2952. {
  2953. "text": lp.ok,
  2954. "action": function () {
  2955. this.app.action.ReadCompletedAction.manageUpdate(readDone.id,{"opinion":textareaNode.get("value")},function(json){
  2956. },null,false);
  2957. this.loadReadDone();
  2958. ideaDlg.close();
  2959. }.bind(this)
  2960. },
  2961. {
  2962. "text": lp.close,
  2963. "action": function () {
  2964. ideaDlg.close();
  2965. }.bind(this)
  2966. }
  2967. ],
  2968. "onPostShow": function () {
  2969. ideaDlg.reCenter();
  2970. }.bind(this)
  2971. });
  2972. }.bind(this));
  2973. }.bind(this));
  2974. },
  2975. loadRecord : function (){
  2976. this.app.action.RecordAction.listWithJob(this.data.job, function (json) {
  2977. this.recordList = json.data;
  2978. this._loadRecord();
  2979. this.initRecord = true;
  2980. }.bind(this), null, false);
  2981. },
  2982. _loadRecord : function (){
  2983. var lp = this.lp;
  2984. this.recordArea.empty();
  2985. this.recordContentNode = new Element("div").inject(this.recordArea);
  2986. var recordTableNode = new Element("table.table",{
  2987. "border" : 0,
  2988. "cellpadding" : 5,
  2989. "cellspacing" : 0
  2990. }).inject(this.recordContentNode);
  2991. var recordTableTheadNode = new Element("thead").inject(recordTableNode);
  2992. var recordTableTbodyNode = new Element("tbody").inject(recordTableNode);
  2993. var recordTableTheadTrNode = new Element("tr").inject(recordTableTheadNode);
  2994. Array.each([lp.currentPerson, lp.currentDept, lp.activity, lp.startTime, lp.endTime, lp.routerName, lp.idea, lp.action], function (text) {
  2995. var tmpthNode = new Element("th", {"text": text}).inject(recordTableTheadTrNode);
  2996. if(text===lp.idea){
  2997. tmpthNode.setStyle("width","150px");
  2998. }
  2999. });
  3000. this.recordList.each(function (record) {
  3001. if(record.type!=="currentTask"){
  3002. var trNode = new Element("tr").inject(recordTableTbodyNode);
  3003. trNode.store("data", record);
  3004. console.log(record)
  3005. var routeName;
  3006. if(record.type === "reroute"){
  3007. routeName = lp.reroute;
  3008. }else if(record.type === "reset"){
  3009. routeName = lp.resetAction;
  3010. }else {
  3011. routeName = record.properties.routeName;
  3012. }
  3013. Array.each([record.person.split("@")[0], record.unit.split("@")[0], record.fromActivityName, record.properties.startTime, record.updateTime, routeName, record.properties.opinion], function (text) {
  3014. new Element("td", {
  3015. text: text
  3016. }).inject(trNode);
  3017. });
  3018. var tdOpNode = new Element("td").inject(trNode);
  3019. var setOpinionButton = new Element("button", {"text": lp.idea, "class": "button"}).inject(tdOpNode);
  3020. var modifyButton = new Element("button", {"text": lp.modify, "class": "button"}).inject(tdOpNode);
  3021. var copyButton = new Element("button", {"text": lp.copy, "class": "button"}).inject(tdOpNode);
  3022. var deleteButton = new Element("button", {"text": lp.remove, "class": "button"}).inject(tdOpNode);
  3023. deleteButton.addEvent("click", function (e) {
  3024. _self = this;
  3025. this.app.confirm("warn", e, lp.tip, lp.tip_remove, 350, 120, function () {
  3026. _self.app.action.RecordAction.manageDelete(record.id,function(json){
  3027. _self.loadRecord();
  3028. },null,false);
  3029. this.close();
  3030. }, function(){
  3031. this.close();
  3032. });
  3033. }.bind(this));
  3034. setOpinionButton.addEvent("click", function () {
  3035. _self = this;
  3036. var ideaNode = new Element("div", {"class": "control", "style": "margin:10px"});
  3037. var textareaNode = new Element("textarea", {"style":"height:80px","class": "textarea", "text": record.opinion});
  3038. textareaNode.inject(ideaNode);
  3039. var ideaDlg = o2.DL.open({
  3040. "title": lp.editIdea,
  3041. "width": "400px",
  3042. "height": "260px",
  3043. "mask": true,
  3044. "content": ideaNode,
  3045. "container": null,
  3046. "positionNode": this.app.content,
  3047. "onQueryClose": function () {
  3048. ideaNode.destroy();
  3049. }.bind(this),
  3050. "buttonList": [
  3051. {
  3052. "text": lp.ok,
  3053. "action": function () {
  3054. record.opinion = textareaNode.get("value");
  3055. _self.app.action.RecordAction.manageEdit(record.id,record,function(json){
  3056. _self.loadRecord();
  3057. },null,false);
  3058. ideaDlg.close();
  3059. }.bind(this)
  3060. },
  3061. {
  3062. "text": lp.close,
  3063. "action": function () {
  3064. ideaDlg.close();
  3065. }.bind(this)
  3066. }
  3067. ],
  3068. "onPostShow": function () {
  3069. ideaDlg.reCenter();
  3070. }.bind(this)
  3071. });
  3072. }.bind(this));
  3073. modifyButton.addEvent("click", function () {
  3074. var recordNode = new Element("div", {"class": "control", "style": "margin:10px"});
  3075. var textareaNode = new Element("textarea", {"style":"height:350px","class": "textarea", "text": JSON.stringify(record,null,"\t")});
  3076. textareaNode.inject(recordNode);
  3077. var recordDlg = o2.DL.open({
  3078. "title": lp.recordEdit,
  3079. "width": "800px",
  3080. "height": "500",
  3081. "mask": true,
  3082. "content": recordNode,
  3083. "container": null,
  3084. "positionNode": this.app.content,
  3085. "onQueryClose": function () {
  3086. recordNode.destroy();
  3087. }.bind(this),
  3088. "buttonList": [
  3089. {
  3090. "text": lp.ok,
  3091. "action": function () {
  3092. record = JSON.parse(textareaNode.get("value"));
  3093. this.app.action.RecordAction.manageEdit(record.id,record,function(json){
  3094. this.loadRecord();
  3095. }.bind(this),null,false);
  3096. recordDlg.close();
  3097. }.bind(this)
  3098. },
  3099. {
  3100. "text": lp.close,
  3101. "action": function () {
  3102. recordDlg.close();
  3103. }.bind(this)
  3104. }
  3105. ],
  3106. "onPostShow": function () {
  3107. recordDlg.reCenter();
  3108. }.bind(this)
  3109. });
  3110. }.bind(this));
  3111. copyButton.addEvent("click", function () {
  3112. var recordNode = new Element("div", {"class": "control", "style": "margin:10px"});
  3113. var textareaNode = new Element("textarea", {"style":"height:350px","class": "textarea", "text": JSON.stringify(record,null,"\t")});
  3114. textareaNode.inject(recordNode);
  3115. var recordDlg = o2.DL.open({
  3116. "title": lp.recordAdd,
  3117. "width": "800px",
  3118. "height": "500",
  3119. "mask": true,
  3120. "content": recordNode,
  3121. "container": null,
  3122. "positionNode": this.app.content,
  3123. "onQueryClose": function () {
  3124. recordNode.destroy();
  3125. }.bind(this),
  3126. "buttonList": [
  3127. {
  3128. "text": lp.ok,
  3129. "action": function () {
  3130. record = JSON.parse(textareaNode.get("value"));
  3131. this.app.action.RecordAction.manageCreateWithJob(record.job,record,function(json){
  3132. this.loadRecord();
  3133. }.bind(this),null,false);
  3134. recordDlg.close();
  3135. }.bind(this)
  3136. },
  3137. {
  3138. "text": lp.close,
  3139. "action": function () {
  3140. recordDlg.close();
  3141. }.bind(this)
  3142. }
  3143. ],
  3144. "onPostShow": function () {
  3145. recordDlg.reCenter();
  3146. }.bind(this)
  3147. });
  3148. }.bind(this));
  3149. }
  3150. }.bind(this));
  3151. },
  3152. loadReview : function (){
  3153. this.app.action.ReviewAction.listWithJob(this.data.job, function (json) {
  3154. this.reviewList = json.data;
  3155. this._loadReview();
  3156. this.initReview = true;
  3157. }.bind(this), null, false);
  3158. },
  3159. _loadReview : function (){
  3160. var lp = this.lp;
  3161. this.reviewArea.empty();
  3162. this.reviewContentNode = new Element("div").inject(this.reviewArea)
  3163. var reviewTableNode = new Element("table.table",{
  3164. "border" : 0,
  3165. "cellpadding" : 5,
  3166. "cellspacing" : 0
  3167. }).inject(this.reviewContentNode);
  3168. var reviewTableTheadNode = new Element("thead").inject(reviewTableNode);
  3169. var reviewTableTbodyNode = new Element("tbody").inject(reviewTableNode);
  3170. var reviewTableTheadTrNode = new Element("tr").inject(reviewTableTheadNode);
  3171. Array.each([lp.reviewitem, lp.action], function (text) {
  3172. new Element("th", {"text": text}).inject(reviewTableTheadTrNode);
  3173. });
  3174. this.reviewList.each(function (review) {
  3175. var trNode = new Element("tr").inject(reviewTableTbodyNode);
  3176. trNode.store("data", review);
  3177. Array.each([review.person], function (text) {
  3178. new Element("td", {
  3179. text: text
  3180. }).inject(trNode);
  3181. });
  3182. var tdOpNode = new Element("td").inject(trNode);
  3183. var deleteButton = new Element("button", {"text": lp.remove, "class": "button"}).inject(tdOpNode);
  3184. deleteButton.addEvent("click", function (e) {
  3185. _self = this;
  3186. this.app.confirm("warn", e, lp.tip, lp.tip_remove, 350, 120, function () {
  3187. _self.app.action.ReviewAction.manageDelete(review.id,review.application,function(json){
  3188. _self.loadReview();
  3189. },null,false);
  3190. this.close();
  3191. }, function(){
  3192. this.close();
  3193. });
  3194. }.bind(this));
  3195. }.bind(this));
  3196. },
  3197. loadDataRecord : function (){
  3198. this.app.action.DataRecordAction.listWithJob(this.data.job, function (json) {
  3199. this.dataRecordList = json.data;
  3200. this._loadDataRecord();
  3201. this.initAttachement = true;
  3202. }.bind(this), null, false);
  3203. },
  3204. _loadDataRecord : function (){
  3205. var lp = this.lp;
  3206. this.dataRecordArea.empty();
  3207. this.dataRecordContentNode = new Element("div").inject(this.dataRecordArea)
  3208. var dataRecordTableNode = new Element("table.table",{
  3209. "border" : 0,
  3210. "cellpadding" : 5,
  3211. "cellspacing" : 0
  3212. }).inject(this.dataRecordContentNode);
  3213. var dataRecordTableTheadNode = new Element("thead").inject(dataRecordTableNode);
  3214. var dataRecordTableTbodyNode = new Element("tbody").inject(dataRecordTableNode);
  3215. var dataRecordTableTheadTrNode = new Element("tr").inject(dataRecordTableTheadNode);
  3216. Array.each([this.lp.fieldName,lp.dataRecordView.person,lp.dataRecordView.time,lp.dataRecordView.active,lp.dataRecordView.old,lp.dataRecordView.new], function (text) {
  3217. new Element("th", {"text": text}).inject(dataRecordTableTheadTrNode);
  3218. });
  3219. this.dataRecordList.each(function (dataRecord) {
  3220. if(dataRecord.updateNum && dataRecord.updateNum>1){
  3221. var path = dataRecord.path;
  3222. var updateNum = dataRecord.updateNum;
  3223. this.app.action.DataRecordAction.getWithJobPath(this.data.job, dataRecord.path,function (json) {
  3224. var dataRecordList = json.data;
  3225. dataRecordList.dataRecordItemList.each(function (item,index) {
  3226. var trNode = new Element("tr").inject(dataRecordTableTbodyNode);
  3227. if(index === 0 ){
  3228. new Element("td", {
  3229. text: path,
  3230. rowspan : updateNum,
  3231. style : "border-right:1px solid #E6E6E6;background:#F7F7F7;font-weight:500"
  3232. }).inject(trNode);
  3233. }
  3234. item.personName = item.person.split("@")[0];
  3235. Array.each([item.personName,item.updateDate,item.activityName,item.oldData,item.newData], function (text) {
  3236. new Element("td", {
  3237. text: text
  3238. }).inject(trNode);
  3239. }.bind(this));
  3240. }.bind(this));
  3241. })
  3242. }
  3243. }.bind(this));
  3244. },
  3245. _loadDataRecordDetail : function (path){
  3246. _self = this;
  3247. var lp = this.lp;
  3248. var recordNode = new Element("div");
  3249. var dataRecordContentNode = new Element("div").inject(recordNode)
  3250. var dataRecordTableNode = new Element("table.table",{
  3251. "border" : 0,
  3252. "cellpadding" : 5,
  3253. "cellspacing" : 0
  3254. }).inject(dataRecordContentNode);
  3255. var dataRecordTableTheadNode = new Element("thead").inject(dataRecordTableNode);
  3256. var dataRecordTableTbodyNode = new Element("tbody").inject(dataRecordTableNode);
  3257. var dataRecordTableTheadTrNode = new Element("tr").inject(dataRecordTableTheadNode);
  3258. Array.each([lp.dataRecordView.person,lp.dataRecordView.time,lp.dataRecordView.active,lp.dataRecordView.old,lp.dataRecordView.new], function (text) {
  3259. new Element("th", {"text": text}).inject(dataRecordTableTheadTrNode);
  3260. });
  3261. this.app.action.DataRecordAction.getWithJobPath(this.data.job, path,function (json) {
  3262. var dataRecordList = json.data;
  3263. dataRecordList.dataRecordItemList.each(function (item) {
  3264. item.personName = item.person.split("@")[0];
  3265. var trNode = new Element("tr").inject(dataRecordTableTbodyNode);
  3266. Array.each([item.personName,item.updateDate,item.activityName,item.oldData,item.newData], function (text, index) {
  3267. new Element("td", {
  3268. text: text
  3269. }).inject(trNode);
  3270. }.bind(this));
  3271. }.bind(this));
  3272. var viewDlg = o2.DL.open({
  3273. "title": path + " : " + this.lp.dataRecordView.record,
  3274. "width": "800px",
  3275. "height": "500",
  3276. "mask": true,
  3277. "content": recordNode,
  3278. "container": this.app.content,
  3279. "positionNode": this.app.content,
  3280. "onQueryClose": function () {
  3281. recordNode.destroy();
  3282. }.bind(this),
  3283. "buttonList": [
  3284. {
  3285. "text": lp.close,
  3286. "action": function () {
  3287. viewDlg.close();
  3288. }.bind(this)
  3289. }
  3290. ],
  3291. "onPostShow": function () {
  3292. viewDlg.reCenter();
  3293. }.bind(this)
  3294. });
  3295. }.bind(this),null,false);
  3296. },
  3297. loadAttachement : function (){
  3298. this.app.action.AttachmentAction.listWithJob(this.data.job, function (json) {
  3299. this.attachmentList = json.data;
  3300. this._loadAttachement();
  3301. this.initAttachement = true;
  3302. }.bind(this), null, false);
  3303. },
  3304. _loadAttachement : function (){
  3305. this.attachementArea.empty();
  3306. this.attachmentContentNode = new Element("div").inject(this.attachementArea)
  3307. var attachmentTableNode = new Element("table.table",{
  3308. "border" : 0,
  3309. "cellpadding" : 5,
  3310. "cellspacing" : 0
  3311. }).inject(this.attachmentContentNode);
  3312. var attachmentTableTheadNode = new Element("thead").inject(attachmentTableNode);
  3313. var attachmentTableTbodyNode = new Element("tbody").inject(attachmentTableNode);
  3314. var attachmentTableTheadTrNode = new Element("tr").inject(attachmentTableTheadNode);
  3315. Array.each(["附件名称", "上传环节", "上传人", "上传时间", "标识","大小" ,"排序","操作"], function (text) {
  3316. new Element("th", {"text": text}).inject(attachmentTableTheadTrNode);
  3317. });
  3318. var siteArr = [];
  3319. this.attachmentList.each(function (attachment) {
  3320. if(!siteArr.contains(attachment.site)) siteArr.push(attachment.site);
  3321. var trNode = new Element("tr").inject(attachmentTableTbodyNode);
  3322. trNode.store("data", attachment);
  3323. Array.each([attachment.name, attachment.activityName, attachment.person.split("@")[0], attachment.createTime ,attachment.site,attachment["length"],attachment.orderNumber], function (text, index) {
  3324. new Element("td", {
  3325. text: index ===5 ? this.getFileSize(text) : text
  3326. }).inject(trNode);
  3327. }.bind(this));
  3328. var tdOpNode = new Element("td").inject(trNode);
  3329. var deleteButton = new Element("button", {"text": "删除", "class": "button"}).inject(tdOpNode);
  3330. deleteButton.addEvent("click", function (e) {
  3331. _self = this;
  3332. this.app.confirm("warn", e, "提示", "确认是否删除", 350, 120, function () {
  3333. _self.app.action.AttachmentAction.delete(attachment.id,function(json){
  3334. _self.loadAttachement();
  3335. },null,false);
  3336. this.close();
  3337. }, function(){
  3338. this.close();
  3339. });
  3340. }.bind(this));
  3341. var downButton = new Element("button", {"text": "下载", "class": "button"}).inject(tdOpNode);
  3342. downButton.addEvent("click", function () {
  3343. var locate = window.location;
  3344. var protocol = locate.protocol;
  3345. var addressObj = layout.serviceAddressList["x_processplatform_assemble_surface"];
  3346. var defaultPort = layout.config.app_protocol==='https' ? "443" : "80";
  3347. var appPort = addressObj.port || window.location.port;
  3348. var address = protocol+"//"+(addressObj.host || window.location.hostname)+((!appPort || appPort.toString()===defaultPort) ? "" : ":"+appPort)+addressObj.context;
  3349. window.open(o2.filterUrl(address) + "/jaxrs/attachment/download/"+ attachment.id +"/stream")
  3350. }.bind(this));
  3351. var sortButton = new Element("button", {"text": "排序", "class": "button"}).inject(tdOpNode);
  3352. sortButton.addEvent("click", function () {
  3353. var sortNode = new Element("div", {"class": "control", "style": "margin:10px"});
  3354. var inputNode = new Element("input", {"class": "input", "text": attachment.orderNumber});
  3355. inputNode.inject(sortNode);
  3356. var sortDlg = o2.DL.open({
  3357. "title": "排序号修改",
  3358. "width": "400px",
  3359. "height": "260px",
  3360. "mask": true,
  3361. "content": sortNode,
  3362. "container": null,
  3363. "positionNode": this.app.content,
  3364. "onQueryClose": function () {
  3365. sortNode.destroy();
  3366. }.bind(this),
  3367. "buttonList": [
  3368. {
  3369. "text": "确认",
  3370. "action": function () {
  3371. var orderNumber = inputNode.get("value");
  3372. debugger
  3373. this.app.action.AttachmentAction.changeOrderNumber(attachment.id,this.data.id,orderNumber,function( json ){
  3374. this.loadAttachement();
  3375. }.bind(this),null,false);
  3376. sortDlg.close();
  3377. }.bind(this)
  3378. },
  3379. {
  3380. "text": "关闭",
  3381. "action": function () {
  3382. sortDlg.close();
  3383. }.bind(this)
  3384. }
  3385. ],
  3386. "onPostShow": function () {
  3387. sortDlg.reCenter();
  3388. }.bind(this)
  3389. });
  3390. }.bind(this));
  3391. }.bind(this));
  3392. var attachmentUploadDiv = new Element("div").inject(this.attachmentContentNode);
  3393. var siteSelect = new Element("select",{"class":"select","style":"float:left"}).inject(attachmentUploadDiv);
  3394. new Element("option",{value:"",text:""}).inject(siteSelect);
  3395. siteArr.each(function(site){
  3396. new Element("option",{value:site,text:site}).inject(siteSelect);
  3397. });
  3398. siteSelect.addEvent("change",function(){
  3399. uploadSite.set("value",siteSelect.get("value"));
  3400. });
  3401. var uploadSite = new Element("input",{
  3402. "class":"input",
  3403. "placeholder":"对应上传的附件标识",
  3404. "style" :"width:200px;float:left"
  3405. }).inject(attachmentUploadDiv);
  3406. var uploadButton = new Element("button", {"text": "上传", "class": "button"}).inject(attachmentUploadDiv);
  3407. uploadButton.addEvent("click", function () {
  3408. if(uploadSite.get("value")==""){
  3409. this.app.notice("对应上传的附件标识不能为空","error");
  3410. return false;
  3411. }
  3412. var options = {
  3413. "title": "附件区域"
  3414. };
  3415. var site = uploadSite.get("value");
  3416. var uploadAction = this.isCompletedWork?"uploadAttachmentByWorkCompleted":"uploadAttachment";
  3417. o2.require("o2.widget.Upload", null, false);
  3418. var upload = new o2.widget.Upload(this.app.content, {
  3419. "action": o2.Actions.get("x_processplatform_assemble_surface").action,
  3420. "method": uploadAction,
  3421. "parameter": {
  3422. "id": this.data.id
  3423. },
  3424. "data":{
  3425. "site": site
  3426. },
  3427. "onCompleted": function(){
  3428. this.loadAttachement();
  3429. }.bind(this)
  3430. });
  3431. upload.load();
  3432. }.bind(this));
  3433. },
  3434. loadBusinessData : function (){
  3435. this.app.action.DataAction.getWithJob(this.data.job, function (json) {
  3436. this.workData = json.data;
  3437. this._loadBusinessData();
  3438. this.initBusinessData = true;
  3439. }.bind(this), null, false);
  3440. },
  3441. _loadBusinessData : function (){
  3442. var workData = this.workData;
  3443. var workDataContentNode = new Element("div",{"style":"margin:5px"}).inject(this.businessDataArea);
  3444. this.workDataContentNode = workDataContentNode;
  3445. var html = "<table bordr='0' cellpadding='0' cellspacing='0' styles='filterTable'>" +
  3446. "<tr>" +
  3447. " <td styles='filterTableTitle' lable='fieldList'></td>" +
  3448. " <td styles='filterTableTitle' item='fieldList'></td>" +
  3449. " <td styles='filterTableTitle' lable='fieldType'></td>" +
  3450. " <td styles='filterTableTitle' item='fieldType'></td>" +
  3451. " <td styles='filterTableTitle' lable='fieldName'></td>" +
  3452. " <td styles='filterTableTitle' item='fieldName'></td>" +
  3453. "</tr>" +
  3454. "<tr>" +
  3455. " <td styles='filterTableTitle' lable='fieldValue'></td>" +
  3456. " <td styles='filterTableValue' item='fieldValue' colspan=3></td>" +
  3457. " <td styles='filterTableValue' colspan=2><div item='action' ></div></td>" +
  3458. "</tr>" +
  3459. "</table><div item='workData'></div>"
  3460. workDataContentNode.set("html", html);
  3461. this.form = new MForm(workDataContentNode, {}, {
  3462. style: "attendance",
  3463. isEdited: true,
  3464. itemTemplate: {
  3465. fieldList: {
  3466. "text": "字段列表",
  3467. "type": "select",
  3468. "style": {"max-width": "150px"},
  3469. "selectValue": function () {
  3470. var arr = [""];
  3471. arr.append(Object.keys(workData));
  3472. return arr;
  3473. },
  3474. "event": {
  3475. "change": function (item, ev) {
  3476. var type = typeof(workData[item.getValue()]);
  3477. item.form.getItem("fieldType").setValue(type);
  3478. item.form.getItem("fieldName").setValue(item.getValue());
  3479. if(type === "object" || type === "array"){
  3480. item.form.getItem("fieldValue").setValue(JSON.stringify(workData[item.getValue()]));
  3481. }else {
  3482. item.form.getItem("fieldValue").setValue(workData[item.getValue()]);
  3483. }
  3484. }.bind(this)
  3485. }
  3486. },
  3487. fieldType: {
  3488. "text": "字段类型",
  3489. "type": "select",
  3490. "style": {"max-width": "150px"},
  3491. "selectValue": function () {
  3492. var array = ["","array","boolean","string","number","object"];
  3493. return array;
  3494. },
  3495. "event": {
  3496. "change": function (item, ev) {
  3497. }.bind(this)
  3498. }
  3499. },
  3500. fieldName: {text: "字段名", "type": "text", "style": {"min-width": "100px"}},
  3501. fieldValue: {text: "字段值", "type": "textarea", "style": {"width": "100%","margin-left": "10px"}},
  3502. action: {
  3503. "value": "修改", type: "button", className: "filterButton", event: {
  3504. click: function (e) {
  3505. var result = this.form.getResult(false, null, false, false, false);
  3506. var fieldName = result["fieldName"];
  3507. var fieldType = result["fieldType"];
  3508. var fieldValue = result["fieldValue"];
  3509. if (!fieldName) return false;
  3510. workData[fieldName] = (fieldType === "object" ? JSON.parse(fieldValue) : fieldValue);
  3511. _self = this;
  3512. this.app.confirm("warn", e.node, "提示", "确认是否修改", 350, 120, function () {
  3513. if(_self.isCompletedWork){
  3514. _self.app.action.DataAction.updateWithWorkCompleted(_self.data.id,workData,function (json){},null,false);
  3515. }else{
  3516. _self.app.action.DataAction.updateWithWork(_self.data.id,workData,function (json){},null,false);
  3517. }
  3518. _self.app.notice("success");
  3519. _self.loadScriptEditor();
  3520. this.close();
  3521. }, function(){
  3522. this.close();
  3523. });
  3524. }.bind(this)
  3525. }
  3526. }
  3527. }
  3528. }, this.app, this.css);
  3529. this.form.load();
  3530. this.loadScriptEditor();
  3531. },
  3532. loadScriptEditor:function(){
  3533. if( !this.workData )return;
  3534. MWF.require("MWF.widget.JavascriptEditor", null, false);
  3535. var workDataNode = this.formTableContainer.getElement('[item="workData"]');
  3536. this.scriptEditor = new MWF.widget.JavascriptEditor(workDataNode, {
  3537. "forceType": "ace",
  3538. "option": { "mode" : "json" }
  3539. });
  3540. this.scriptEditor.load(function(){
  3541. this.scriptEditor.setValue(JSON.stringify(this.workData, null, "\t"));
  3542. this.scriptEditor.editor.setReadOnly(true);
  3543. this.addEvent("afterResize", function () {
  3544. this.resizeScript();
  3545. }.bind(this))
  3546. this.addEvent("queryClose", function () {
  3547. }.bind(this))
  3548. this.resizeScript();
  3549. }.bind(this));
  3550. },
  3551. resizeScript: function () {
  3552. var size = this.formTableContainer.getSize();
  3553. var tableSize = this.formTableContainer.getElement('table').getSize();
  3554. this.formTableContainer.getElement('[item="workData"]').setStyle("height", size.y - 200);
  3555. if (this.scriptEditor && this.scriptEditor.editor) this.scriptEditor.editor.resize();
  3556. },
  3557. getFileSize: function (size) {
  3558. if (!size)
  3559. return "";
  3560. var num = 1024.00; //byte
  3561. if (size < num)
  3562. return size + "B";
  3563. if (size < Math.pow(num, 2))
  3564. return (size / num).toFixed(2) + "K"; //kb
  3565. if (size < Math.pow(num, 3))
  3566. return (size / Math.pow(num, 2)).toFixed(2) + "M"; //M
  3567. if (size < Math.pow(num, 4))
  3568. return (size / Math.pow(num, 3)).toFixed(2) + "G"; //G
  3569. },
  3570. });
  3571. MWF.xApplication.process.Application.ManageWorkCompletedForm = new Class({
  3572. Extends: MWF.xApplication.process.Application.ManageWorkForm,
  3573. loadTask : function () {
  3574. this.app.action.TaskAction.listWithJob(this.data.job).then(function(json){
  3575. this.taskList = json.data;
  3576. this._loadTask();
  3577. this.initTask = true;
  3578. }.bind(this));
  3579. },
  3580. loadTab : function (){
  3581. this.tabNode = new Element("div",{"styles" : this.css.tabNode }).inject(this.formTableArea);
  3582. this.taskDoneArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  3583. this.readArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  3584. this.readDoneArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  3585. this.reviewArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  3586. this.attachementArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  3587. this.recordArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  3588. this.businessDataArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  3589. this.dataRecordArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode);
  3590. MWF.require("MWF.widget.Tab", function(){
  3591. this.tabs = new MWF.widget.Tab(this.tabNode, {"style": "attendance"});
  3592. this.tabs.load();
  3593. this.taskDonePage = this.tabs.addTab(this.taskDoneArea, this.lp.taskDone, false);
  3594. this.taskDonePage.addEvent("show",function(){
  3595. if(!this.initTaskDone) this.loadTaskDone();
  3596. }.bind(this));
  3597. this.readPage = this.tabs.addTab(this.readArea, this.lp.read, false);
  3598. this.readPage.addEvent("show",function(){
  3599. if(!this.initRead) this.loadRead();
  3600. }.bind(this));
  3601. this.readDonePage = this.tabs.addTab(this.readDoneArea, this.lp.readDone, false);
  3602. this.readDonePage.addEvent("show",function(){
  3603. if(!this.initReadDone) this.loadReadDone();
  3604. }.bind(this));
  3605. this.recordPage = this.tabs.addTab(this.recordArea, this.lp.workLog, false);
  3606. this.recordPage.addEvent("show",function(){
  3607. if(!this.initRecord) this.loadRecord();
  3608. }.bind(this));
  3609. this.reviewPage = this.tabs.addTab(this.reviewArea, this.lp.review, false);
  3610. this.reviewPage.addEvent("show",function(){
  3611. if(!this.initReview) this.loadReview();
  3612. }.bind(this));
  3613. this.attachementPage = this.tabs.addTab(this.attachementArea, this.lp.attachment, false);
  3614. this.attachementPage.addEvent("show",function(){
  3615. if(!this.initAttachement) this.loadAttachement();
  3616. }.bind(this));
  3617. this.businessDataPage = this.tabs.addTab(this.businessDataArea, this.lp.businessData, false);
  3618. this.businessDataPage.addEvent("show",function(){
  3619. if(!this.initBusinessData) this.loadBusinessData();
  3620. }.bind(this));
  3621. this.dataRecordPage = this.tabs.addTab(this.dataRecordArea,this.lp.dataRecord, false);
  3622. this.dataRecordPage.addEvent("show",function(){
  3623. if(!this.initDataRecord) this.loadDataRecord();
  3624. }.bind(this));
  3625. this.tabs.pages[0].showTab();
  3626. }.bind(this));
  3627. }
  3628. });