Common.js 111 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766
  1. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  2. MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  3. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  4. MWF.require("MWF.widget.O2Identity", null, false);
  5. MWF.xDesktop.requireApp("Selector", "package", null, false);
  6. MWF.xDesktop.requireApp("Report", "Attachment", null, false);
  7. MWF.xApplication.Report = MWF.xApplication.Report || {};
  8. MWF.xApplication.Report.Common = new Class({
  9. initialize: function ( app ) {
  10. this.app = app;
  11. },
  12. //getIdentityString : function( username, callback ){
  13. // var ids = [];
  14. // this.getIdentity( username, function( identityList ){
  15. // for( var i=0; i<identityList.length; i++ ){
  16. // ids.push( identityList[i].distinguishedName )
  17. // }
  18. // if(callback)callback( ids );
  19. // }.bind(this))
  20. //},
  21. getIdentity : function( username, callback ){
  22. if(!username) username = ( layout.desktop.session.user || layout.user ).distinguishedName;
  23. if(!this.identityList)this.identityList={};
  24. if( this.identityList[username] ){
  25. if(callback)callback(this.identityList[username]);
  26. }else{
  27. MWF.Actions.get("x_organization_assemble_express").listIdentityWithPersonValue( {"personList":[ username ]} , function( json ){
  28. this.identityList[username] = json.data.identityList;
  29. if(callback)callback(this.identityList[username]);
  30. }.bind(this))
  31. }
  32. },
  33. openReport: function( reportData, view ){
  34. if( reportData.reportStatus == "已完成" || reportData.reportStatus == "结束" || reportData.reportStatus == "董事长审阅" ){
  35. MWF.Actions.get("x_processplatform_assemble_surface").listWorkByJob( reportData.wf_JobId, function( json ){
  36. var workCompletedList = json.data.workCompletedList;
  37. if( workCompletedList.length > 0 ){
  38. var options = {
  39. "workCompletedId": workCompletedList[0].id,
  40. "appId": workCompletedList[0].id,
  41. "onQueryClose" : function(){
  42. }.bind(this)
  43. };
  44. this.app.desktop.openApplication(null, "process.Work", options);
  45. }
  46. }.bind(this))
  47. }else{
  48. var options = {
  49. "workId": reportData.wf_WorkId,
  50. "appId": reportData.wf_WorkId,
  51. "onQueryClose" : function(){
  52. this.obj.app.restActions.getReport( reportData.id, function( json ){
  53. if( this.reportData.activityName != json.data.activityName ){
  54. try{ view.reload(); }catch(e){}
  55. }
  56. }.bind(this))
  57. }.bind({ obj : this, reportData : reportData })
  58. };
  59. this.app.desktop.openApplication(null, "process.Work", options);
  60. }
  61. },
  62. addWork : function( reportData, keyworkData, view, orderNumber ){
  63. var form = new MWF.xApplication.Report.WorkForm( this.app, { "reportId" : reportData.id, "targetPerson" : reportData.targetPerson }, {
  64. orderNumber : orderNumber
  65. }, {
  66. app : this.app
  67. } );
  68. form.view = view;
  69. form.reportData = reportData;
  70. form.keyworkData = keyworkData;
  71. form.create();
  72. },
  73. editWork : function( data, reportData,view ){
  74. var form = new MWF.xApplication.Report.WorkForm( this.app, data, {}, {
  75. app : this.app
  76. } );
  77. form.reportData = reportData;
  78. form.view = view;
  79. form.edit();
  80. },
  81. openWork : function( data, reportData,keyworkData, view, editedAble ){
  82. var form = new MWF.xApplication.Report.WorkForm( this.app, data, {
  83. editedAble : editedAble
  84. }, {
  85. app : this.app
  86. } );
  87. form.reportData = reportData;
  88. form.keyworkData = keyworkData;
  89. form.view = view;
  90. form.open();
  91. },
  92. deleteWork: function( data, e, callback ){
  93. var _self = this;
  94. var text = this.app.lp.delete_work.replace(/{name}/g, data.progressContent );
  95. this.app.confirm("infor", e, this.app.lp.delete_work_title, text, 380, 150, function(){
  96. _self._deleteWork( data, callback, e );
  97. this.close();
  98. }, function(){
  99. this.close();
  100. });
  101. },
  102. _deleteWork: function(data, callback, ev){
  103. this.app.restActions.deleteWork( data.id, function(){
  104. if( callback )callback();
  105. this.app.notice( this.app.lp.deleteDocumentOK, "success", ev.target )
  106. }.bind(this))
  107. },
  108. addCustomWork : function( reportData, keyworkData, view, orderNumber ){
  109. var form = new MWF.xApplication.Report.CustomWorkForm( this.app, { "reportId" : reportData.id, "targetPerson" : reportData.targetPerson }, {
  110. orderNumber : orderNumber
  111. }, {
  112. app : this.app
  113. } );
  114. form.view = view;
  115. form.reportData = reportData;
  116. form.keyworkData = keyworkData;
  117. form.create();
  118. },
  119. editCustomWork : function( data, reportData,view ){
  120. var form = new MWF.xApplication.Report.CustomWorkForm( this.app, data, {}, {
  121. app : this.app
  122. } );
  123. form.reportData = reportData;
  124. form.view = view;
  125. form.edit();
  126. },
  127. openCustomWork : function( data, reportData,keyworkData, view, editedAble ){
  128. var form = new MWF.xApplication.Report.CustomWorkForm( this.app, data, {
  129. editedAble : editedAble
  130. }, {
  131. app : this.app
  132. } );
  133. form.reportData = reportData;
  134. form.keyworkData = keyworkData;
  135. form.view = view;
  136. form.open();
  137. },
  138. deleteCustomWork: function( data, e, callback ){
  139. var _self = this;
  140. var text = this.app.lp.delete_work.replace(/{name}/g, data.workTitle );
  141. this.app.confirm("infor", e, this.app.lp.delete_work_title, text, 380, 150, function(){
  142. _self._deleteCustomWork( data, callback , e);
  143. this.close();
  144. }, function(){
  145. this.close();
  146. });
  147. },
  148. _deleteCustomWork: function(data, callback, ev){
  149. this.app.restActions.deleteWork( data.id, function(){
  150. if( callback )callback();
  151. this.app.notice( this.app.lp.deleteDocumentOK, "success", ev.target )
  152. }.bind(this))
  153. },
  154. addExtWork : function( reportData, keyworkData, view, orderNumber, category ){
  155. var form = new MWF.xApplication.Report.ExtWorkForm( this.app, { "reportId" : reportData.id, "targetPerson" : reportData.targetPerson }, {
  156. category : category,
  157. orderNumber : orderNumber
  158. }, {
  159. app : this.app
  160. } );
  161. form.view = view;
  162. form.reportData = reportData;
  163. form.keyworkData = keyworkData;
  164. form.create();
  165. },
  166. editExtWork : function( data, reportData, parentData, view, category ){
  167. var form = new MWF.xApplication.Report.ExtWorkForm( this.app, data, {category : category}, {
  168. app : this.app
  169. } );
  170. form.reportData = reportData;
  171. form.keyworkData = parentData;
  172. form.view = view;
  173. form.edit();
  174. },
  175. openExtWork : function( data, reportData,keyworkData, view, editedAble, category ){
  176. var form = new MWF.xApplication.Report.ExtWorkForm( this.app, data, {
  177. editedAble : editedAble,
  178. category : category
  179. }, {
  180. app : this.app
  181. } );
  182. form.reportData = reportData;
  183. form.keyworkData = keyworkData;
  184. form.view = view;
  185. form.open();
  186. },
  187. deleteExtWork: function( data, e, callback, category ){
  188. var _self = this;
  189. var text = "确定要删除该工作?";
  190. this.app.confirm("infor", e, this.app.lp.delete_work_title, text, 380, 150, function(){
  191. _self._deleteExtWork( data, callback , e, category);
  192. this.close();
  193. }, function(){
  194. this.close();
  195. });
  196. },
  197. _deleteExtWork: function(data, callback, ev, category){
  198. this.app.restActions[ "delete"+category ]( data.id, function(){
  199. if( callback )callback();
  200. this.app.notice( this.app.lp.deleteDocumentOK, "success", ev.target )
  201. }.bind(this))
  202. },
  203. addPlan : function(reportData, keyworkData, view, isPlanNext, orderNumber){
  204. var form = new MWF.xApplication.Report.PlanForm( this.app,
  205. { "reportId" : reportData.id, "targetPerson" : reportData.targetPerson },
  206. { "isPlanNext" : isPlanNext , orderNumber : orderNumber },
  207. { app : this.app }
  208. );
  209. form.reportData = reportData;
  210. form.keyworkData = keyworkData;
  211. form.view = view;
  212. form.create();
  213. },
  214. editPlan : function( data , reportData, keyworkData, view, isPlanNext){
  215. var form = new MWF.xApplication.Report.PlanForm( this.app, data, {"isPlanNext" : isPlanNext}, {
  216. app : this.app
  217. } );
  218. form.reportData = reportData;
  219. form.keyworkData = keyworkData;
  220. form.view = view;
  221. form.edit();
  222. },
  223. openPlan : function( data , reportData, keyworkData, view, isPlanNext, editedAble){
  224. var form = new MWF.xApplication.Report.PlanForm( this.app, data, {
  225. "isPlanNext" : isPlanNext,
  226. "editedAble" : editedAble
  227. }, {
  228. app : this.app
  229. } );
  230. form.reportData = reportData;
  231. form.keyworkData = keyworkData;
  232. form.view = view;
  233. form.open();
  234. },
  235. deletePlan: function( data, e , callback){
  236. var _self = this;
  237. var text = this.app.lp.delete_plan.replace(/{name}/g, data.planContent );
  238. this.app.confirm("infor", e, this.app.lp.delete_plan_title, text, 380, 150, function(){
  239. _self._deletePlan( data, callback, e );
  240. this.close();
  241. }, function(){
  242. this.close();
  243. });
  244. },
  245. _deletePlan: function( data, callback, ev ){
  246. this.app.restActions.deletePlan( data.id, function(){
  247. if( callback )callback();
  248. this.app.notice( this.app.lp.deleteDocumentOK, "success", ev.target )
  249. }.bind(this))
  250. },
  251. deletePlanNext: function( data, e , callback){
  252. var _self = this;
  253. var text = this.app.lp.delete_plan.replace(/{name}/g, data.planContent );
  254. this.app.confirm("infor", e, this.app.lp.delete_plan_title, text, 380, 150, function(){
  255. _self._deletePlanNext( data, callback, e );
  256. this.close();
  257. }, function(){
  258. this.close();
  259. });
  260. },
  261. _deletePlanNext: function( data, callback , ev ){
  262. this.app.restActions.deletePlanNext( data.id, function(){
  263. if( callback )callback();
  264. this.app.notice( this.app.lp.deleteDocumentOK, "success", ev.target )
  265. }.bind(this))
  266. },
  267. getUnitWithExportPermission : function( callback ){
  268. this.getIdentity( null, function( identityList ){
  269. this.unitList = [];
  270. identityList.each( function( identity ){
  271. MWF.Actions.get("x_organization_assemble_express").listUnitWithDuty( {"name":"部门战略管理员","identity":identity}, function( json ){
  272. for( var i=0; i<json.data.length; i++){
  273. this.unitList.push( json.data[i].distinguishedName );
  274. }
  275. }.bind(this), null, false );
  276. MWF.Actions.get("x_organization_assemble_express").listUnitWithDuty( {"name":"部主管","identity":identity}, function( json ){
  277. for( var i=0; i<json.data.length; i++){
  278. this.unitList.push( json.data[i].distinguishedName );
  279. }
  280. }.bind(this), null, false );
  281. }.bind(this));
  282. if( callback )callback(this.unitList);
  283. }.bind(this))
  284. },
  285. hasExportAllUnitPermission: function(){
  286. if( typeOf( this.exportFlag ) == "boolean" ){
  287. return this.exportFlag;
  288. }
  289. this.exportFlag = false;
  290. if( this.isAdmin() ){
  291. this.exportFlag = true;
  292. return this.exportFlag;
  293. }
  294. var username = ( layout.desktop.session.user || layout.user ).distinguishedName;
  295. MWF.Actions.get("x_organization_assemble_express").listPersonWithGroup( {"groupList":["ReportExporter"]}, function( json ){
  296. for( var i=0; i<json.data.length; i++){
  297. if( json.data[i].distinguishedName == username ){
  298. this.exportFlag = true;
  299. break;
  300. }
  301. }
  302. }.bind(this), null, false );
  303. return this.exportFlag;
  304. },
  305. isAdmin : function(){
  306. //return MWF.AC.isAdministrator();
  307. if( typeOf( this.adminFlag ) == "boolean" ){
  308. return this.adminFlag;
  309. }else{
  310. this.app.restActions.isAdmin( function( json ){
  311. this.adminFlag = json.data.value
  312. }.bind(this), null, false);
  313. return this.adminFlag;
  314. }
  315. },
  316. addZero : function( str, length ){
  317. var zero = "";
  318. str = str.toString();
  319. for( var i=0; i<length; i++ ){
  320. zero = zero + "0";
  321. }
  322. var s = zero + str;
  323. return s.substr(s.length - length, length );
  324. },
  325. listSetting : function( callback ){
  326. if( this.setting ){
  327. if( callback )callback( this.setting );
  328. }else{
  329. this.setting = {};
  330. this.app.restActions.listSetting( function( json ){
  331. json.data.each( function(d){
  332. var value = d.configValue;
  333. if( typeOf(value) == "string"){
  334. if( value == "NONE" )value = ""
  335. }else if( typeOf(value) == "array" ){
  336. for( var i=0; i<value.length-1; i++ ){
  337. if( value[i] == "NONE" )value[i] = ""
  338. }
  339. }
  340. this.setting[d.configCode] = value;
  341. }.bind(this));
  342. if( callback )callback( this.setting );
  343. }.bind(this))
  344. }
  345. },
  346. replaceWithBr : function( str ){
  347. if( typeOf(str) != "string" )return "";
  348. var reg=new RegExp("\n","g");
  349. return str.replace(reg,"<br/>");
  350. },
  351. splitWithLength : function( str, length ){
  352. var result = [];
  353. var arr = str.split("\n");
  354. arr.each( function( s ){
  355. do {
  356. result.push( s.substr( 0, Math.min( s.length, length ) ) );
  357. s = ( s.length > length ) ? s.substr( length , s.length ) : "";
  358. }while ( s );
  359. });
  360. return result.join("\n");
  361. }
  362. });
  363. MWF.xApplication.Report.ReportFileter = new Class({
  364. Implements: [Options, Events],
  365. options : {
  366. items : ["reportType","title","year","month","reportDate","targetList","activityList","currentPersonList","reportStatus"],
  367. defaultResult : {}
  368. },
  369. initialize: function ( container, app, options ) {
  370. this.setOptions( options );
  371. this.container = container;
  372. this.app = app;
  373. this.lp = app.lp;
  374. this.css = app.css;
  375. this.load();
  376. },
  377. load: function(){
  378. this.searchBarAreaNode = new Element("div", {
  379. "styles": this.css.searchBarAreaNode
  380. }).inject(this.container);
  381. this.searchBarNode = new Element("div", {
  382. "styles": this.css.searchBarNode
  383. }).inject(this.searchBarAreaNode);
  384. this.searchBarInputBoxNode = new Element("div", {
  385. "styles": this.css.searchBarInputBoxNode
  386. }).inject(this.searchBarNode);
  387. this.searchBarInputNode = new Element("input", {
  388. "type": "text",
  389. "value": this.lp.searchKey,
  390. "styles": this.css.searchBarInputNode
  391. }).inject(this.searchBarInputBoxNode);
  392. this.searchBarResetActionNode = new Element("div", {
  393. "styles": this.css.searchBarResetActionNode
  394. }).inject(this.searchBarInputBoxNode);
  395. this.searchBarResetActionNode.setStyle("display","none");
  396. this.searchBarActionNode = new Element("div", {
  397. "styles": this.css.searchBarActionNode
  398. }).inject(this.searchBarNode);
  399. this.searchBarMoreActionNode = new Element("div", {
  400. "styles": this.css.searchMoreActionNode,
  401. "title" : "高级搜索"
  402. }).inject(this.searchBarNode);
  403. var _self = this;
  404. this.searchBarActionNode.addEvent("click", function(){
  405. this.search();
  406. }.bind(this));
  407. this.searchBarResetActionNode.addEvent("click", function(){
  408. this.reset();
  409. }.bind(this));
  410. this.searchBarInputNode.addEvents({
  411. "focus": function(){
  412. if (this.value==_self.lp.searchKey) this.set("value", "");
  413. },
  414. "blur": function(){if (!this.value) this.set("value", _self.lp.searchKey);},
  415. "keydown": function(e){
  416. if (e.code==13){
  417. this.search();
  418. e.preventDefault();
  419. }
  420. }.bind(this)
  421. });
  422. this.loadMore();
  423. },
  424. destroy : function(){
  425. this.tootip.destroy();
  426. this.container.empty();
  427. },
  428. reload: function( opt ){
  429. this.removeEvent( "search" );
  430. this.setOptions( opt );
  431. this.tootip.reload( opt );
  432. },
  433. getResult : function(){
  434. var value = this.searchBarInputNode.get("value");
  435. var result = { title: value == this.lp.searchKey ? "" : value };
  436. if( !result.title )result = {};
  437. if( this.options.defaultResult ){
  438. result = Object.merge(result, this.options.defaultResult);
  439. }
  440. return result;
  441. },
  442. search : function( result ){
  443. this.searchBarResetActionNode.setStyle("display","");
  444. this.fireEvent("search" , result || this.getResult())
  445. },
  446. reset : function( result ){
  447. this.searchBarResetActionNode.setStyle("display","none");
  448. this.searchBarInputNode.set("value",this.lp.searchKey );
  449. this.fireEvent("search", result || this.options.defaultResult );
  450. },
  451. loadMore : function(){
  452. this.tootip = new MWF.xApplication.Report.FileterTooltip(this.app.content, this.searchBarMoreActionNode, this.app, {}, this.options);
  453. this.tootip.parent = this;
  454. }
  455. });
  456. MWF.xApplication.Report.FileterTooltip = new Class({
  457. Extends: MTooltips,
  458. options : {
  459. event : "click", //事件类型, mouseenter对应mouseleave,click 对应 container 的 click
  460. position : "right",
  461. nodeStyles : {
  462. "font-size" : "12px",
  463. "position" : "absolute",
  464. "max-width" : "500px",
  465. "min-width" : "360px",
  466. "z-index" : "11",
  467. "background-color" : "#fff",
  468. "padding" : "20px",
  469. "border-radius" : "8px",
  470. "box-shadow": "0 0 18px 0 #999",
  471. "-webkit-user-select": "text",
  472. "-moz-user-select": "text"
  473. },
  474. items : ["reportType","title","year","month","reportDate","targetList","activityList","currentPersonList","reportStatus","reportObjType"],
  475. defaultResult : {}
  476. },
  477. destroy: function(){
  478. if(this.node)this.node.destroy();
  479. if(this.markNode)this.markNode.destroy();
  480. this.node = null;
  481. this.markNode = null;
  482. },
  483. reload: function( options ){
  484. if(this.node)this.node.destroy();
  485. if(this.markNode)this.markNode.destroy();
  486. this.node = null;
  487. this.markNode = null;
  488. this.setOptions(options);
  489. },
  490. _customNode : function( node ){
  491. },
  492. _loadCustom: function (callback) {
  493. this.getReportType( function(){
  494. this.loadHTML();
  495. this.loadForm();
  496. if (callback)callback();
  497. }.bind(this))
  498. },
  499. _getHtml: function () {
  500. },
  501. getReportType : function( callback ){
  502. this.app.common.listSetting( function( s ){
  503. this.setting = s;
  504. this.reportType = { value : [""], text : ["全部"] };
  505. if( s.MONTHREPORT_ENABLE == "true" ){
  506. this.reportType.value.push("MONTH");
  507. this.reportType.text.push("月报");
  508. }
  509. if( s.WEEKREPORT_ENABLE == "true" ){
  510. this.reportType.value.push("WEEK");
  511. this.reportType.text.push("周报");
  512. }
  513. if( s.DAYREPORT_ENABLE == "true" ){
  514. this.reportType.value.push("DAILY");
  515. this.reportType.text.push("日报");
  516. }
  517. if(callback)callback();
  518. }.bind(this))
  519. },
  520. getItemTemplate: function(){
  521. var template = {
  522. title : { text: "标题", type : "text" },
  523. year : { text: "年度", type : "select", defaultValue : new Date().getFullYear(),
  524. selectValue : ["",2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037]
  525. },
  526. month : { text: "月份", type : "select", selectValue : ["","01","02","03","04","05","06","07","08","09","10","11","12"] },
  527. //reportDate : {text: "日期", tType: "date"},
  528. targetList : { text:"汇报者", type: "org", orgType : "person" },
  529. activityList : {"text":"审核环节"},
  530. currentPersonList : { text:"当前处理人", type: "org", orgType : "person" },
  531. reportObjType : {"text":"汇报类型", type : "select", selectValue : ["","PERSON","UNIT"], selectText : ["","个人汇报","组织汇报"]},
  532. reportStatus: {"text":"汇报状态", type : "select", selectValue : ["","汇报者填写","审核中","已完成"]}
  533. };
  534. if( this.reportType.value.length > 2 ){
  535. template.reportType = { text : "类别", type : "select", selectValue : this.reportType.value, selectText : this.reportType.text }
  536. }
  537. for( var key in template ) {
  538. if (!this.options.items.contains(key)) {
  539. delete template[key];
  540. }
  541. }
  542. template.filterAction = {"text":"搜索", "value":"搜索", type : "button", className : "inputSeachButton", event : {
  543. click : function(){
  544. this.parent.search( this.getResult() );
  545. }.bind(this)
  546. }};
  547. template.resetAction = {"text":"重置", "value":"重置", type : "button", className : "inputResetButton", event : {
  548. click : function(){
  549. this.parent.reset( this.reset() );
  550. }.bind(this)
  551. }};
  552. return template;
  553. },
  554. loadHTML : function(){
  555. this.formNode = new Element("div").inject(this.node);
  556. var htmlList = {
  557. title : "<tr><td styles='formTableTitle14' lable='title' width='30%'></td><td item='title' styles='formTableValue14' width='70%'></td></tr>",
  558. year : "<tr><td styles='formTableTitle14' lable='year'></td><td item='year' styles='formTableValue14'></td></tr>",
  559. month : "<tr><td styles='formTableTitle14' lable='month'></td><td item='month' styles='formTableValue14'></td></tr>",
  560. targetList : "<tr><td styles='formTableTitle14' lable='targetList'></td><td item='targetList' styles='formTableValue14'></td></tr>",
  561. currentPersonList : "<tr><td styles='formTableTitle14' lable='currentPersonList'></td><td item='currentPersonList' styles='formTableValue14'></td></tr>",
  562. activityList : "<tr><td styles='formTableTitle14' lable='activityList'></td><td item='activityList' styles='formTableValue14'></td></tr>" //,
  563. //reportStatus : "<tr><td styles='formTableTitle14' lable='reportStatus'></td><td item='reportStatus' styles='formTableValue14'></td></tr>",
  564. //reportObjType : "<tr><td styles='formTableTitle14' lable='reportObjType'></td><td item='reportObjType' styles='formTableValue14'></td></tr>"
  565. };
  566. if( this.reportType.value.length > 2 ){
  567. htmlList.reportType = "<tr><td styles='formTableTitle14' lable='reportType'></td><td item='reportType' styles='formTableValue14'></td></tr>"
  568. }
  569. for( var key in htmlList ) {
  570. if (!this.options.items.contains(key)){
  571. delete htmlList[key];
  572. }
  573. }
  574. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>";
  575. for( var key in htmlList ){
  576. html += htmlList[key];
  577. }
  578. html += "<tr><td></td><td styles='formTableValue14'><span item='filterAction'></span><span item='resetAction'></span></td></tr>";
  579. html += "</table>";
  580. this.formNode.set("html",html);
  581. },
  582. loadForm : function(){
  583. this.form = new MForm(this.formNode, {}, {
  584. usesNewVersion : true,
  585. isEdited: true,
  586. style : "report",
  587. hasColon : true,
  588. itemTemplate: this.getItemTemplate()
  589. }, this.app);
  590. this.form.load();
  591. },
  592. reset: function(){
  593. this.form.reset();
  594. return this.options.defaultResult;
  595. },
  596. getResult : function(){
  597. var result = this.form.getResult(false, null, false, false, false);
  598. for( var key in result ){
  599. var v = result[key];
  600. if( typeOf( v ) == "array" && v.length == 0 ){
  601. delete result[key];
  602. }else if( !v ){
  603. delete result[key];
  604. }
  605. }
  606. delete result.filterAction;
  607. if( this.options.defaultResult ){
  608. result = Object.merge(result, this.options.defaultResult);
  609. }
  610. if( result.activityList )result.activityList = [result.activityList];
  611. //if( result.targetList ){
  612. // var targetCNList = [];
  613. // result.targetList.each( function( id ){
  614. // targetCNList.push(id.split("@")[0])
  615. // }.bind(this));
  616. // result.targetList = targetCNList.unique();
  617. //}
  618. return result;
  619. }
  620. });
  621. MWF.xApplication.Report.PlanForm = new Class({
  622. Extends: MPopupForm,
  623. Implements: [Options, Events],
  624. options: {
  625. "style": "report",
  626. "width": 800,
  627. "height": 400,
  628. "minWidth" : 700,
  629. "minHeight" : 320,
  630. "hasTop": true,
  631. "hasIcon": false,
  632. "hasTopIcon" : false,
  633. "hasTopContent" : false,
  634. "maxAction" : true,
  635. "hasBottom": true,
  636. "draggable": true,
  637. "resizeable": true,
  638. "editedAble" : true,
  639. "closeAction": true,
  640. "isPlanNext" : true
  641. },
  642. _createTableContent: function () {
  643. if( this.data.planContent && this.data.planContent=="暂无内容" )this.data.planContent="";
  644. this.formTopTextNode.set( "text", this.options.isPlanNext ? "下月计划" : "本月计划" );
  645. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  646. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  647. "<tr><td styles='formTableTitle' lable='workTitle' width='20%'></td>" +
  648. " <td styles='formTableValue14' colspan='3'>"+
  649. " <div item='workTitle' style='"+ "" +"'></div>" +
  650. "</td></tr>" +
  651. //"<tr><td styles='formTableTitle' lable='workContent'></td>" +
  652. //" <td styles='formTableValue14' item='workContent' colspan='3'></td></tr>" +
  653. //"<tr style='display: none;' item='measureTr'><td styles='formTableTitle' lable='measure'></td>" +
  654. //" <td styles='formTableValue14' colspan='3' item='measure'></td></tr>" +
  655. //"<tr><td styles='formTableTitle' lable='title'></td>" +
  656. //" <td styles='formTableValue' item='title' colspan='3'></td></tr>" +
  657. //"<tr><td styles='formTableTitle' lable='startTime' width='20%'></td>" +
  658. //" <td styles='formTableValue14' item='startTime'></td>" +
  659. //" <td styles='formTableTitleRight' lable='endTime' width='20%'></td>" +
  660. //" <td styles='formTableValue14' item='endTime'></td></tr>" +
  661. "<tr><td styles='formTableTitle' lable='planContent'></td>" +
  662. " <td styles='formTableValue14' item='planContent' colspan='3'></td></tr>" +
  663. //"<tr><td styles='formTableValue14' item='attachmentArea' colspan='4'></td></tr>" +
  664. "</table>";
  665. this.formTableArea.set("html", html);
  666. this.loadForm()
  667. },
  668. loadForm : function(){
  669. if(this.data)this.data.workTitle = this.keyworkData.workTitle;
  670. MWF.xDesktop.requireApp("Template", "MForm", function () {
  671. this.form = new MForm(this.formTableArea, this.data, {
  672. usesNewVersion : true,
  673. isEdited: this.isEdited || this.isNew,
  674. style : "report",
  675. hasColon : true,
  676. itemTemplate: {
  677. //title: { text : this.lp.planName, notEmpty : true },
  678. workTitle: { type : "innertext", text : this.lp.keyWork, isEdited : false },
  679. workContent: { text : this.lp.workContent, type : "innertext", defaultValue : this.keyworkData.workDescribe || " " }, 
  680. //measure : { disable : !measureIdList.length , isEdited : false, type:"checkbox" ,text : this.lp.measureText, notEmpty : true, selectValue : measureIdList, selectText: measureTitleList, value : measureIdList },
  681. //startTime: { text : this.lp.startTime, tType : "date", notEmpty : true },
  682. //endTime: { text : this.lp.endTime, tType : "date", notEmpty : true },
  683. planContent: { text : this.lp.planContent, type : "textarea", notEmpty : true, style : { height : "150px" } }
  684. }
  685. }, this.app);
  686. this.form.load();
  687. }.bind(this), true);
  688. },
  689. _createBottomContent: function () {
  690. if (this.isNew || this.isEdited) {
  691. this.okActionNode = new Element("button.inputOkButton", {
  692. "styles": this.css.inputOkButton,
  693. "text": this.lp.save
  694. }).inject(this.formBottomNode);
  695. this.okActionNode.addEvent("click", function (e) {
  696. this.save(e);
  697. }.bind(this));
  698. }
  699. if( this.isEdited ){
  700. this.removeAction = new Element("button.inputCancelButton", {
  701. "styles": this.css.inputCancelButton,
  702. "text": this.lp.remove
  703. }).inject(this.formBottomNode);
  704. this.removeAction.addEvent("click", function (e) {
  705. this.remove(e);
  706. }.bind(this));
  707. }
  708. //var identityList = layout.desktop.session.user.identity
  709. if( !this.isEdited && !this.isNew && this.getEditPermission()){
  710. this.editAction = new Element("button.inputOkButton", {
  711. "styles": this.css.inputOkButton,
  712. "text": this.lp.edit
  713. }).inject(this.formBottomNode);
  714. this.editAction.addEvent("click", function (e) {
  715. this.editWork(e);
  716. }.bind(this));
  717. }
  718. this.cancelActionNode = new Element("button.inputCancelButton", {
  719. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  720. "text": this.lp.close
  721. }).inject(this.formBottomNode);
  722. this.cancelActionNode.addEvent("click", function (e) {
  723. this.close(e);
  724. }.bind(this));
  725. },
  726. editWork : function(){
  727. this.formTopNode = null;
  728. if(this.setFormNodeSizeFun && this.app ){
  729. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  730. }
  731. if( this.formMaskNode )this.formMaskNode.destroy();
  732. this.formAreaNode.destroy();
  733. this.edit();
  734. },
  735. save: function(){
  736. var data = this.form.getResult(true,null,true,false,true);
  737. if( data ){
  738. //data.workTitle = this.form.getItem("workId").getText();
  739. if( !data.flag ){
  740. data.reportId = this.reportData.id;
  741. data.workInfoId = this.keyworkData.id;
  742. data.keyWorkId = this.keyworkData.keyWorkId;
  743. data.flag = this.reportData.flag;
  744. data.year = this.reportData.year;
  745. data.month = this.reportData.month;
  746. data.week = this.reportData.week;
  747. data.date = this.reportData.date;
  748. data.targetPerson = ( layout.desktop.session.user || layout.user ).distinguishedName;
  749. data.orderNumber = this.options.orderNumber || 1;
  750. }
  751. data.workDescribe = data.workContent;
  752. data.title = data.workTitle;
  753. var act = this.options.isPlanNext ? "savePlanNext" : "savePlan";
  754. this.actions[act]( data, function(json){
  755. this.app.notice(this.lp.save_success, "success", this.formNode );
  756. var view = this.view;
  757. this.close();
  758. this.view.reload();
  759. }.bind(this));
  760. }
  761. },
  762. remove: function( ev ){
  763. var view = this.view;
  764. this.app.common[ this.options.isPlanNext ? "deletePlanNext" : "deletePlan" ]( this.data, ev, function(){
  765. view.reload();
  766. this.close();
  767. }.bind(this));
  768. },
  769. loadAttachment: function( area ){
  770. this.attachment = new MWF.xApplication.Report.Attachment( area, this.app, this.app.restActions, this.lp, {
  771. documentId : this.advanceId || this.data.id,
  772. isNew : this.isNew,
  773. isEdited : this.isEdited,
  774. "size" : "min",
  775. onQueryUploadAttachment : function(){
  776. this.attachment.isQueryUploadSuccess = true;
  777. }.bind(this),
  778. onDelete : function( data ){
  779. }.bind(this)
  780. });
  781. this.attachment.load();
  782. },
  783. getEditPermission : function(){
  784. if( !this.options.editedAble )return false;
  785. //if( !this.options.isPlanNext )return false;
  786. var username = ( layout.desktop.session.user || layout.user ).distinguishedName;
  787. var reportTarget = this.view && this.view.report && this.view.report.data && this.view.report.data.targetPerson;
  788. if( username != this.data.targetPerson && !this.app.common.isAdmin() && username != reportTarget ){
  789. return false;
  790. }
  791. return true;
  792. //this.reportData.reportStatus
  793. }
  794. });
  795. MWF.xApplication.Report.WorkForm = new Class({
  796. Extends: MPopupForm,
  797. Implements: [Options, Events],
  798. options: {
  799. "style": "report",
  800. "width": 800,
  801. "height": 450,
  802. "minWidth" : 700,
  803. "minHeight" : 320,
  804. "hasTop": true,
  805. "hasIcon": false,
  806. "hasTopIcon" : false,
  807. "hasTopContent" : false,
  808. "maxAction" : true,
  809. "hasBottom": true,
  810. "draggable": true,
  811. "resizeable": true,
  812. "editedAble" : true,
  813. "closeAction": true
  814. },
  815. _createTableContent: function () {
  816. if( this.data.progressContent && this.data.progressContent=="暂无内容" )this.data.progressContent="";
  817. this.formTopTextNode.set( "text", this.lp.work );
  818. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  819. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  820. "<tr><td styles='formTableTitle' lable='workTitle' width='20%'></td>" +
  821. " <td styles='formTableValue14' colspan='3'>"+
  822. " <div item='workTitle' style='"+ "" +"'></div>" +
  823. "</td></tr>" +
  824. //"<tr><td styles='formTableTitle' lable='workContent'></td>" +
  825. //" <td styles='formTableValue14' item='workContent' colspan='3'></td></tr>" +
  826. //"<tr style='display: none;' item='measureTr'><td styles='formTableTitle' lable='measure'></td>" +
  827. //" <td styles='formTableValue14' colspan='3' item='measure'></td></tr>" +
  828. //"<tr><td styles='formTableTitle' lable='title'></td>" +
  829. //" <td styles='formTableValue' item='title' colspan='3'></td></tr>" +
  830. "<tr><td styles='formTableTitle' lable='progressContent'></td>" +
  831. " <td styles='formTableValue14' item='progressContent' colspan='3'></td></tr>" +
  832. "</table>";
  833. this.formTableArea.set("html", html);
  834. //this.listMeasure( function( measureList ){
  835. this.loadForm();
  836. //}.bind(this))
  837. },
  838. //listMeasure: function( callback ){
  839. // var measureList = [];
  840. // this.selectableMeasureObject = {};
  841. // this.keyworkData.selectableMeasures.each( function( m ){
  842. // if( m ){
  843. // this.selectableMeasureObject[ m.id ]=m;
  844. // }
  845. // }.bind(this));
  846. // this.keyworkData.measuresList.each( function( id, i ){
  847. // if( id && this.selectableMeasureObject[ id ] ){
  848. // var data = this.selectableMeasureObject[ id ];
  849. // measureList.push( data );
  850. // }
  851. // }.bind(this));
  852. // if(callback)callback( measureList );
  853. //},
  854. loadForm : function( measureList ){
  855. //var measureIdList = [];
  856. //var measureTitleList = [];
  857. //if( measureList ){
  858. // measureList.each( function( d ){
  859. // measureIdList.push( d.id );
  860. // measureTitleList.push( d.measuresinfotitle )
  861. // });
  862. //}
  863. //if( measureIdList.length ){
  864. // this.formTableArea.getElement("[item='measureTr']").setStyle("display","");
  865. //}
  866. MWF.xDesktop.requireApp("Template", "MForm", function () {
  867. this.form = new MForm(this.formTableArea, this.data, {
  868. usesNewVersion : true,
  869. isEdited: this.isEdited || this.isNew,
  870. style : "report",
  871. hasColon : true,
  872. itemTemplate: {
  873. //title: { text : this.lp.workName, notEmpty : true },
  874. workTitle: { type : "innertext", text : this.lp.keyWork, defaultValue : this.keyworkData.workTitle , isEdited : false },
  875. workContent: { text : this.lp.workContent, type : "innertext", defaultValue : this.keyworkData.workDescribe || " "},
  876. //measure : { disable : !measureIdList.length , isEdited : false, type:"checkbox" ,text : this.lp.measureText, notEmpty : true, selectValue : measureIdList, selectText: measureTitleList, value : measureIdList },
  877. progressContent: { text : this.lp.completion, type : "textarea", notEmpty : true, style : { height : "150px" } }
  878. }
  879. }, this.app);
  880. this.form.load();
  881. }.bind(this), true);
  882. },
  883. _createBottomContent: function () {
  884. if (this.isNew || this.isEdited) {
  885. this.okActionNode = new Element("button.inputOkButton", {
  886. "styles": this.css.inputOkButton,
  887. "text": this.lp.save
  888. }).inject(this.formBottomNode);
  889. this.okActionNode.addEvent("click", function (e) {
  890. this.save(e);
  891. }.bind(this));
  892. }
  893. if( this.isEdited ){
  894. this.removeAction = new Element("button.inputCancelButton", {
  895. "styles": this.css.inputCancelButton,
  896. "text": this.lp.remove
  897. }).inject(this.formBottomNode);
  898. this.removeAction.addEvent("click", function (e) {
  899. this.remove(e);
  900. }.bind(this));
  901. }
  902. //var identityList = layout.desktop.session.user.identity
  903. if( !this.isEdited && !this.isNew && this.getEditPermission()){
  904. this.editAction = new Element("button.inputOkButton", {
  905. "styles": this.css.inputOkButton,
  906. "text": this.lp.edit
  907. }).inject(this.formBottomNode);
  908. this.editAction.addEvent("click", function (e) {
  909. this.editWork(e);
  910. }.bind(this));
  911. }
  912. this.cancelActionNode = new Element("button.inputCancelButton", {
  913. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  914. "text": this.lp.close
  915. }).inject(this.formBottomNode);
  916. this.cancelActionNode.addEvent("click", function (e) {
  917. this.close(e);
  918. }.bind(this));
  919. },
  920. editWork : function(){
  921. this.formTopNode = null;
  922. if(this.setFormNodeSizeFun && this.app ){
  923. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  924. }
  925. if( this.formMaskNode )this.formMaskNode.destroy();
  926. this.formAreaNode.destroy();
  927. this.edit();
  928. },
  929. save: function(){
  930. var data = this.form.getResult(true,null,true,false,true);
  931. if( data ){
  932. if( !data.flag ){
  933. data.reportId = this.reportData.id;
  934. data.workInfoId = this.keyworkData.id;
  935. data.keyWorkId = this.keyworkData.keyWorkId;
  936. data.flag = this.reportData.flag;
  937. data.year = this.reportData.year;
  938. data.month = this.reportData.month;
  939. data.week = this.reportData.week;
  940. data.date = this.reportData.date;
  941. data.targetPerson = ( layout.desktop.session.user || layout.user ).distinguishedName;
  942. data.orderNumber = this.options.orderNumber || 1;
  943. }
  944. data.workDescribe = data.workContent;
  945. data.title = data.workTitle;
  946. this.actions.saveWork( data, function(json){
  947. this.app.notice(this.lp.save_success, "success", this.formNode );
  948. var view = this.view;
  949. this.close();
  950. this.view.reload();
  951. }.bind(this));
  952. }
  953. },
  954. remove: function( ev ){
  955. var view = this.view;
  956. this.app.common.deleteWork( this.data, ev, function(){
  957. view.reload();
  958. this.close();
  959. }.bind(this));
  960. },
  961. loadAttachment: function( area ){
  962. this.attachment = new MWF.xApplication.Report.Attachment( area, this.app, this.app.restActions, this.lp, {
  963. documentId : this.advanceId || this.data.id,
  964. isNew : this.isNew,
  965. isEdited : this.isEdited,
  966. "size" : "min",
  967. onQueryUploadAttachment : function(){
  968. this.attachment.isQueryUploadSuccess = true;
  969. }.bind(this),
  970. onDelete : function( data ){
  971. }.bind(this)
  972. });
  973. this.attachment.load();
  974. },
  975. getEditPermission : function(){
  976. if( !this.options.editedAble )return false;
  977. var username = ( layout.desktop.session.user || layout.user ).distinguishedName;
  978. var reportTarget = this.view && this.view.report && this.view.report.data && this.view.report.data.targetPerson;
  979. if( username != this.data.targetPerson && !this.app.common.isAdmin() && username != reportTarget ){
  980. return false;
  981. }
  982. return true;
  983. }
  984. });
  985. MWF.xApplication.Report.CustomWorkForm = new Class({
  986. Extends: MPopupForm,
  987. Implements: [Options, Events],
  988. options: {
  989. "style": "report",
  990. "width": 800,
  991. "height": 550,
  992. "hasTop": true,
  993. "hasIcon": false,
  994. "maxAction" : true,
  995. "draggable": true,
  996. "resizeable": true,
  997. "editedAble" : true
  998. },
  999. _createTableContent: function () {
  1000. if( this.data.progressContent && this.data.progressContent=="暂无内容" )this.data.progressContent="";
  1001. this.formTopTextNode.set( "text", this.lp.work );
  1002. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  1003. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  1004. "<tr><td styles='formTableTitle' lable='workTitle' width='20%'></td>" +
  1005. " <td styles='formTableValue14' colspan='3' item='workTitle'></td></tr>" +
  1006. "<tr><td styles='formTableTitle' lable='workDescribe'></td>" +
  1007. " <td styles='formTableValue14' item='workDescribe' colspan='3'></td></tr>" +
  1008. "<tr><td styles='formTableTitle' lable='workTag'></td>" +
  1009. " <td styles='formTableValue14' item='workTag' colspan='3'></td></tr>" +
  1010. "<tr><td styles='formTableTitle' lable='progressContent'></td>" +
  1011. " <td styles='formTableValue14' item='progressContent' colspan='3'></td></tr>" +
  1012. //"<tr><td styles='formTableValue14' item='attachmentArea' colspan='4'></td></tr>" +
  1013. "</table>";
  1014. this.formTableArea.set("html", html);
  1015. this.loadForm()
  1016. },
  1017. loadForm : function( ){
  1018. var _self = this;
  1019. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1020. this.form = new MForm(this.formTableArea, this.data, {
  1021. usesNewVersion : true,
  1022. isEdited: this.isEdited || this.isNew,
  1023. style : "report",
  1024. hasColon : true,
  1025. itemTemplate: {
  1026. workTitle: { type : "text", text : "工作标题", notEmpty : true },
  1027. workDescribe: { type : "textarea", text : this.lp.workContent, notEmpty : true },
  1028. workTag : { type:"mselector" ,text : "工作标签", notEmpty : true, mSelectorOptions : {
  1029. "defaultOptionLp" : "选择或填写标签",
  1030. "inputEnable" : true,
  1031. "valueField" : "tagName",
  1032. "width" : "500px",
  1033. "onLoadData" : function( callback ){
  1034. _self.actions.listWorkTagWithUnit( _self.reportData.targetUnit, function( json ){
  1035. var arr = [];
  1036. (json.data || []).each( function(d){
  1037. if(d.tagName != "部门重点工作" )arr.push(d)
  1038. });
  1039. callback( arr );
  1040. }.bind(this))
  1041. }
  1042. }},
  1043. progressContent: { text : this.lp.completion, type : "textarea", notEmpty : true, style : { height : "150px" } }
  1044. }
  1045. }, this.app);
  1046. this.form.load();
  1047. }.bind(this), true);
  1048. },
  1049. _createBottomContent: function () {
  1050. if (this.isNew || this.isEdited) {
  1051. this.okActionNode = new Element("button.inputOkButton", {
  1052. "styles": this.css.inputOkButton,
  1053. "text": this.lp.save
  1054. }).inject(this.formBottomNode);
  1055. this.okActionNode.addEvent("click", function (e) {
  1056. this.save(e);
  1057. }.bind(this));
  1058. }
  1059. if( this.isEdited ){
  1060. this.removeAction = new Element("button.inputCancelButton", {
  1061. "styles": this.css.inputCancelButton,
  1062. "text": this.lp.remove
  1063. }).inject(this.formBottomNode);
  1064. this.removeAction.addEvent("click", function (e) {
  1065. this.remove(e);
  1066. }.bind(this));
  1067. }
  1068. //var identityList = layout.desktop.session.user.identity
  1069. if( !this.isEdited && !this.isNew && this.getEditPermission()){
  1070. this.editAction = new Element("button.inputOkButton", {
  1071. "styles": this.css.inputOkButton,
  1072. "text": this.lp.edit
  1073. }).inject(this.formBottomNode);
  1074. this.editAction.addEvent("click", function (e) {
  1075. this.editWork(e);
  1076. }.bind(this));
  1077. }
  1078. this.cancelActionNode = new Element("button.inputCancelButton", {
  1079. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  1080. "text": this.lp.close
  1081. }).inject(this.formBottomNode);
  1082. this.cancelActionNode.addEvent("click", function (e) {
  1083. this.close(e);
  1084. }.bind(this));
  1085. },
  1086. editWork : function(){
  1087. this.formTopNode = null;
  1088. if(this.setFormNodeSizeFun && this.app ){
  1089. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1090. }
  1091. if( this.formMaskNode )this.formMaskNode.destroy();
  1092. this.formAreaNode.destroy();
  1093. this.edit();
  1094. },
  1095. save: function(){
  1096. var data = this.form.getResult(true,null,true,false,true);
  1097. if( data ){
  1098. if( data.workTag == "选择或填写标签" || data.workTag == ""){
  1099. this.app.notice("请选择或填写工作标签","error", this.formTableArea);
  1100. return false;
  1101. }
  1102. //data.workTitle = this.form.getItem("workId").getText();
  1103. if( !data.flag ){
  1104. data.reportId = this.reportData.id;
  1105. //data.workInfoId = this.keyworkData.id;
  1106. //data.keyWorkId = this.keyworkData.workId;
  1107. data.flag = this.reportData.flag;
  1108. data.year = this.reportData.year;
  1109. data.month = this.reportData.month;
  1110. data.week = this.reportData.week;
  1111. data.date = this.reportData.date;
  1112. data.targetPerson = ( layout.desktop.session.user || layout.user ).distinguishedName;
  1113. data.orderNumber = this.options.orderNumber || 1;
  1114. }
  1115. if( data.keyWorkObject ){
  1116. delete data.keyWorkObject;
  1117. }
  1118. this.actions.saveWork( data, function(json){
  1119. this.app.notice(this.lp.save_success, "success", this.formNode );
  1120. var view = this.view;
  1121. this.close();
  1122. this.view.reload();
  1123. }.bind(this));
  1124. }
  1125. },
  1126. remove: function( ev ){
  1127. var view = this.view;
  1128. this.app.common.deleteCustomWork( this.data, ev, function(){
  1129. view.reload();
  1130. this.close();
  1131. }.bind(this));
  1132. },
  1133. loadAttachment: function( area ){
  1134. this.attachment = new MWF.xApplication.Report.Attachment( area, this.app, this.app.restActions, this.lp, {
  1135. documentId : this.advanceId || this.data.id,
  1136. isNew : this.isNew,
  1137. isEdited : this.isEdited,
  1138. "size" : "min",
  1139. onQueryUploadAttachment : function(){
  1140. this.attachment.isQueryUploadSuccess = true;
  1141. }.bind(this),
  1142. onDelete : function( data ){
  1143. }.bind(this)
  1144. });
  1145. this.attachment.load();
  1146. },
  1147. getEditPermission : function(){
  1148. if( !this.options.editedAble )return false;
  1149. var username = ( layout.desktop.session.user || layout.user ).distinguishedName;
  1150. var reportTarget = this.view && this.view.report && this.view.report.data && this.view.report.data.targetPerson;
  1151. if( username != this.data.targetPerson && !this.app.common.isAdmin() && username != reportTarget ){
  1152. return false;
  1153. }
  1154. return true;
  1155. }
  1156. });
  1157. MWF.xApplication.Report.ExtWorkForm = new Class({
  1158. Extends: MPopupForm,
  1159. Implements: [Options, Events],
  1160. options: {
  1161. "style": "report",
  1162. "width": 800,
  1163. "height": 450,
  1164. "hasTop": true,
  1165. "hasIcon": false,
  1166. "maxAction" : true,
  1167. "draggable": true,
  1168. "resizeable": true,
  1169. "editedAble" : true,
  1170. "category" : ""
  1171. },
  1172. _createTableContent: function () {
  1173. this.formTopTextNode.set( "text", this.lp[ this.options.category ] );
  1174. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  1175. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
  1176. "<tr><td styles='formTableTitle' lable='title' width='20%'></td>" +
  1177. " <td styles='formTableValue14' colspan='3' item='title'></td></tr>" +
  1178. "<tr><td styles='formTableTitle' lable='content'></td>" +
  1179. " <td styles='formTableValue14' item='content' colspan='3'></td></tr>" +
  1180. //"<tr><td styles='formTableValue14' item='attachmentArea' colspan='4'></td></tr>" +
  1181. "</table>";
  1182. this.formTableArea.set("html", html);
  1183. this.loadForm()
  1184. },
  1185. loadForm : function( ){
  1186. var _self = this;
  1187. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1188. this.form = new MForm(this.formTableArea, this.data, {
  1189. usesNewVersion : true,
  1190. isEdited: this.isEdited || this.isNew,
  1191. style : "report",
  1192. hasColon : true,
  1193. itemTemplate: {
  1194. title: { type : "innerText", text : "类别", notEmpty : true, defaultValue : this.lp[ this.options.category ] },
  1195. content: { text : "内容", type : "textarea", notEmpty : true, style : { height : "150px" } }
  1196. }
  1197. }, this.app);
  1198. this.form.load();
  1199. }.bind(this), true);
  1200. },
  1201. _createBottomContent: function () {
  1202. if (this.isNew || this.isEdited) {
  1203. this.okActionNode = new Element("button.inputOkButton", {
  1204. "styles": this.css.inputOkButton,
  1205. "text": this.lp.save
  1206. }).inject(this.formBottomNode);
  1207. this.okActionNode.addEvent("click", function (e) {
  1208. this.save(e);
  1209. }.bind(this));
  1210. }
  1211. if( this.isEdited ){
  1212. this.removeAction = new Element("button.inputCancelButton", {
  1213. "styles": this.css.inputCancelButton,
  1214. "text": this.lp.remove
  1215. }).inject(this.formBottomNode);
  1216. this.removeAction.addEvent("click", function (e) {
  1217. this.remove(e);
  1218. }.bind(this));
  1219. }
  1220. //var identityList = layout.desktop.session.user.identity
  1221. if( !this.isEdited && !this.isNew && this.getEditPermission()){
  1222. this.editAction = new Element("button.inputOkButton", {
  1223. "styles": this.css.inputOkButton,
  1224. "text": this.lp.edit
  1225. }).inject(this.formBottomNode);
  1226. this.editAction.addEvent("click", function (e) {
  1227. this.editWork(e);
  1228. }.bind(this));
  1229. }
  1230. this.cancelActionNode = new Element("button.inputCancelButton", {
  1231. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  1232. "text": this.lp.close
  1233. }).inject(this.formBottomNode);
  1234. this.cancelActionNode.addEvent("click", function (e) {
  1235. this.close(e);
  1236. }.bind(this));
  1237. },
  1238. editWork : function(){
  1239. this.formTopNode = null;
  1240. if(this.setFormNodeSizeFun && this.app ){
  1241. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1242. }
  1243. if( this.formMaskNode )this.formMaskNode.destroy();
  1244. this.formAreaNode.destroy();
  1245. this.edit();
  1246. },
  1247. save: function(){
  1248. var data = this.form.getResult(true,null,true,false,true);
  1249. if( data ){
  1250. if( !data.id ){
  1251. data.reportId = this.reportData.id;
  1252. //data.workInfoId = this.keyworkData.id;
  1253. //data.keyWorkId = this.keyworkData.workId;
  1254. //data.flag = this.reportData.flag;
  1255. //data.year = this.reportData.year;
  1256. //data.month = this.reportData.month;
  1257. //data.week = this.reportData.week;
  1258. //data.date = this.reportData.date;
  1259. data.category = this.keyworkData.id;
  1260. data.targetPerson = ( layout.desktop.session.user || layout.user ).distinguishedName;
  1261. data.orderNumber = this.options.orderNumber || 1;
  1262. }
  1263. this.actions["save"+this.options.category]( data, function(json){
  1264. this.app.notice(this.lp.save_success, "success", this.formNode );
  1265. var view = this.view;
  1266. this.close();
  1267. this.view.reload();
  1268. }.bind(this));
  1269. }
  1270. },
  1271. remove: function( ev ){
  1272. var view = this.view;
  1273. this.app.common.deleteExtWork( this.data, ev, function(){
  1274. view.reload();
  1275. this.close();
  1276. }.bind(this), this.options.category);
  1277. },
  1278. loadAttachment: function( area ){
  1279. this.attachment = new MWF.xApplication.Report.Attachment( area, this.app, this.app.restActions, this.lp, {
  1280. documentId : this.advanceId || this.data.id,
  1281. isNew : this.isNew,
  1282. isEdited : this.isEdited,
  1283. "size" : "min",
  1284. onQueryUploadAttachment : function(){
  1285. this.attachment.isQueryUploadSuccess = true;
  1286. }.bind(this),
  1287. onDelete : function( data ){
  1288. }.bind(this)
  1289. });
  1290. this.attachment.load();
  1291. },
  1292. getEditPermission : function(){
  1293. if( !this.options.editedAble )return false;
  1294. var username = ( layout.desktop.session.user || layout.user ).distinguishedName;
  1295. //var usernameCN = username.split("@")[0];
  1296. var reportTarget = this.view && this.view.report && this.view.report.data && this.view.report.data.targetPerson;
  1297. if( username != this.data.targetPerson && !this.app.common.isAdmin() && username != reportTarget ){ //&& usernameCN != this.data.targetPerson
  1298. return false;
  1299. }
  1300. return true;
  1301. }
  1302. });
  1303. MWF.xApplication.Report.ReportTooltip = new Class({
  1304. Extends: MTooltips,
  1305. _loadCustom : function( callback ){
  1306. if(callback)callback();
  1307. },
  1308. _getHtml : function(){
  1309. debugger;
  1310. var d = this.data;
  1311. var lp = this.lp;
  1312. var titleStyle = "font-size:14px;color:#333";
  1313. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1314. var html =
  1315. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1316. " <div style='font-size: 16px;color:#333;float: left'>"+ lp[d.reportObjType] + lp[d.reportType] +"</div>"+
  1317. "</div>"+
  1318. "<div style='font-size: 16px;color:#333;padding:0px 10px 15px 20px;'>"+ d.title +"</div>"+
  1319. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1320. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1321. "<tr><td style='"+titleStyle+"' width='100'>管理员:</td>" +
  1322. " <td style='"+valueStyle+"'>"+ ( d.targetPerson ? d.targetPerson.split("@")[0] : "" ) +"</td></tr>" +
  1323. "<tr><td style='"+titleStyle+"'>" + lp.targetUnit +":</td>" +
  1324. " <td style='"+valueStyle+"'>" + ( d.targetUnit ? d.targetUnit.split("@")[0] : "" )+ "</td></tr>" +
  1325. "<tr><td style='"+titleStyle+"'>"+ lp.createDate +":</td>" +
  1326. " <td style='"+valueStyle+"'>"+ d.createDateString+"</td></tr>" +
  1327. "<tr><td style='"+titleStyle+"'>"+ lp.activityName +":</td>" +
  1328. " <td style='"+valueStyle+"'>"+ d.activityName+"</td></tr>" +
  1329. "<tr><td style='"+titleStyle+"'>"+ lp.currentPersonName+":</td>" +
  1330. " <td style='"+valueStyle+"'>"+ ( d.currentPersonName ? d.currentPersonName.split("@")[0] : "" ) +"</td></tr>" +
  1331. "</table>";
  1332. return html;
  1333. }
  1334. });
  1335. MWF.xApplication.Report.SideBar = new Class({
  1336. Extends: MWF.widget.Common,
  1337. Implements: [Options, Events],
  1338. options: {
  1339. "style": "default"
  1340. },
  1341. initialize : function( container, app, options){
  1342. this.setOptions( options );
  1343. this.container = container;
  1344. this.app = app;
  1345. //this.css = this.app.css;
  1346. this.lp = this.app.lp;
  1347. this.isHidden = false;
  1348. this.cssPath = "/x_component_Report/$Common/"+this.options.style+"/sidebar/css.wcss";
  1349. this._loadCss();
  1350. this.load();
  1351. },
  1352. load : function(){
  1353. this.node = new Element("div.sideBar", {
  1354. "styles": this.css.node,
  1355. events : {
  1356. mousedown : function( ev ){
  1357. ev.stopPropagation();
  1358. }
  1359. }
  1360. }).inject(this.container);
  1361. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  1362. this.loadStatusArea();
  1363. new Element("div.contentLine", {
  1364. "styles" : this.css.contentLine
  1365. }).inject( this.contentNode );
  1366. this.loadWaitDoNode();
  1367. this.trapezoid = new Element("div.trapezoid",{
  1368. "styles":this.css.trapezoid_toRight,
  1369. events : {
  1370. click : function(){
  1371. this.trigger();
  1372. }.bind(this)
  1373. }
  1374. }).inject(this.node);
  1375. this.listData( function(){
  1376. this.loadWaitDo( function(){
  1377. var x = this.node.getSize().x - 8;
  1378. this.node.setStyle( "right", "-"+x+"px" );
  1379. this.resetNodeSize();
  1380. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  1381. this.app.addEvent("resize", this.resetNodeSizeFun );
  1382. this.hideFun = this.hide.bind(this);
  1383. this.app.node.addEvent("mousedown", this.hideFun);
  1384. }.bind(this));
  1385. }.bind(this) )
  1386. },
  1387. loadStatusArea : function(){
  1388. var area = new Element("div", {
  1389. "styles" : this.css.statusArea
  1390. }).inject( this.contentNode );
  1391. var lp = this.lp.config;
  1392. var html = "<div class='titleDiv'>"+lp.reportStatus+"</div>" +
  1393. "<div class = 'statusStyle'>"+
  1394. " <div class='statusIconStyle' style='background-color:"+ lp.waitColor +"'></div>" +
  1395. " <div class = 'statusTextStyle'>"+lp.wait+"</div></div>" +
  1396. "</div>"+
  1397. "<div class = 'statusStyle'>"+
  1398. " <div class='statusIconStyle' style='background-color:"+ lp.auditColor +"'></div>" +
  1399. " <div class = 'statusTextStyle'>"+lp.audit+"</div></div>" +
  1400. "</div>"+
  1401. "<div class = 'statusStyle'>"+
  1402. " <div class='statusIconStyle' style='background-color:"+ lp.progressColor +"'></div>" +
  1403. " <div class = 'statusTextStyle'>"+lp.progress+"</div></div>" +
  1404. "</div>"+
  1405. "<div class = 'statusStyle'>"+
  1406. " <div class='statusIconStyle' style='background-color:"+ lp.completedColor +"'></div>" +
  1407. " <div class = 'statusTextStyle'>"+lp.completed+"</div></div>" +
  1408. "</div>";
  1409. area.set("html", html);
  1410. area.getElements("div.titleDiv").setStyles( this.css.titleDiv );
  1411. area.getElements("div.statusStyle").setStyles( this.css.statusStyle );
  1412. area.getElements("div.statusIconStyle").setStyles( this.css.statusIconStyle );
  1413. area.getElements("div.statusIconStyle2").setStyles( this.css.statusIconStyle2 );
  1414. area.getElements("div.statusTextStyle").setStyles( this.css.statusTextStyle );
  1415. },
  1416. loadWaitDoNode: function(){
  1417. var area = new Element("div.reportArea", {
  1418. "styles" : this.css.reportArea
  1419. }).inject( this.contentNode );
  1420. new Element("div.titleDiv", {
  1421. "styles" : this.css.titleDiv,
  1422. "text" : this.lp.reportNotice
  1423. }).inject( area );
  1424. this.reportNode = Element("div", {
  1425. "styles" : this.css.reportNode
  1426. }).inject( area );
  1427. },
  1428. loadWaitDo : function( callback ){
  1429. var today = new Date();
  1430. var user = ( layout.desktop.session.user || layout.user );
  1431. var dn = user.distinguishedName;
  1432. var data = this.data;
  1433. if( user.distinguishedName ){
  1434. var userName = user.distinguishedName.split("@")[0]
  1435. }else{
  1436. var userName = user.name
  1437. }
  1438. var lp = data.length ? this.lp.reportTopInfor : this.lp.noReportTopInfor ;
  1439. this.reportTopNode = new Element("div", {
  1440. "styles" : this.css.reportTopNode,
  1441. "html" : lp.replace("{userName}",userName).replace("{count}",data.length )
  1442. }).inject( this.reportNode );
  1443. this.scrollNode = new Element("div.scrollNode", {
  1444. "styles" : this.css.scrollNode
  1445. }).inject( this.reportNode );
  1446. this.reportItemContainer = new Element("div.reportItemContainer", {
  1447. "styles" : this.css.reportItemContainer
  1448. }).inject( this.scrollNode );
  1449. data.each( function( d, i ){
  1450. var itemNode = new Element("div.reportItemNode", {
  1451. "styles" : this.css.reportItemNode,
  1452. "events" : {
  1453. click : function(){
  1454. this.obj.app.common.openReport( this.data );
  1455. }.bind({ obj : this, data : d })
  1456. }
  1457. }).inject( this.reportItemContainer );
  1458. this.tooltipList = this.tooltipList || [];
  1459. this.tooltipList.push( new MWF.xApplication.Report.ReportTooltip(this.app.content, itemNode, this.app, d, {
  1460. axis : "x",
  1461. hiddenDelay : 300,
  1462. displayDelay : 300
  1463. })
  1464. );
  1465. var colorNode = new Element("div.reportItemColorNode", {
  1466. "styles" : this.css.reportItemColorNode,
  1467. "text" : i+1
  1468. }).inject( itemNode );
  1469. var textNode = new Element("div.reportItemTextNode", {
  1470. "styles" : this.css.reportItemTextNode,
  1471. "text" : d.title
  1472. }).inject( itemNode );
  1473. var lp = this.lp.config;
  1474. var status;
  1475. if( d.reportStatus == "审核中" && user.distinguishedName == d.currentPersonName ){
  1476. status = "需要我审核"
  1477. }else{
  1478. status = d.reportStatus;
  1479. }
  1480. switch (status){
  1481. case "汇报者填写":
  1482. colorNode.setStyles({ "background-color": lp.waitColor });
  1483. break;
  1484. case "审核中":
  1485. colorNode.setStyles({ "background-color": lp.progressColor });
  1486. break;
  1487. case "需要我审核":
  1488. colorNode.setStyles({ "background-color": lp.auditColor });
  1489. break;
  1490. case "已完成":
  1491. colorNode.setStyles({ "background-color": lp.completedColor });
  1492. break;
  1493. }
  1494. var y = itemNode.getSize().y ;
  1495. colorNode.setStyle("margin-top", ( y - 20)/2 );
  1496. }.bind(this));
  1497. this.setScrollBar( this.scrollNode );
  1498. if( callback )callback();
  1499. },
  1500. listData : function( callback ){
  1501. this.app.restActions.listReportNextWithFilter((0), 100, {
  1502. targetList : [this.app.userName],
  1503. reportStatus : "汇报者填写"
  1504. }, function(json){
  1505. if( !json.data )json.data = [];
  1506. this.data = json.data;
  1507. this.app.restActions.listReportNextWithFilter((0), 100, {
  1508. currentPersonList : [this.app.userName],
  1509. reportStatus : "审核中"
  1510. }, function(j){
  1511. if( !j.data )j.data = [];
  1512. j.data.each( function( j ){
  1513. this.data.push( j );
  1514. }.bind(this));
  1515. if (callback)callback();
  1516. }.bind(this));
  1517. }.bind(this));
  1518. },
  1519. trigger : function(){
  1520. this.isHidden ? this.show( true ) : this.hide( true )
  1521. },
  1522. hide: function( isFireEvent ){
  1523. var x = this.node.getSize().x - 9;
  1524. var fx = new Fx.Morph(this.node, {
  1525. "duration": "300",
  1526. "transition": Fx.Transitions.Expo.easeOut
  1527. });
  1528. fx.start({
  1529. //"opacity": 0
  1530. }).chain(function(){
  1531. this.isHidden = true;
  1532. //this.node.setStyle("display", "none");
  1533. this.node.setStyles({
  1534. "right": "-"+x+"px"
  1535. });
  1536. this.trapezoid.setStyles( this.css.trapezoid_toLeft );
  1537. //if(isFireEvent)this.app.fireEvent("resize");
  1538. }.bind(this));
  1539. },
  1540. show: function( isFireEvent ){
  1541. this.node.setStyles(this.css.node);
  1542. this.trapezoid.setStyles( this.css.trapezoid_toRight );
  1543. //var x = this.node.getSize().x - 8;
  1544. //this.node.setStyles( "right", "-"+x+"px" );
  1545. var fx = new Fx.Morph(this.node, {
  1546. "duration": "500",
  1547. "transition": Fx.Transitions.Expo.easeOut
  1548. });
  1549. this.app.fireAppEvent("resize");
  1550. fx.start({
  1551. "opacity": 1
  1552. }).chain(function(){
  1553. this.node.setStyles({
  1554. //"position": "static",
  1555. //"width": "auto"
  1556. "right": "0px"
  1557. });
  1558. this.isHidden = false;
  1559. //if(isFireEvent)this.app.fireEvent("resize");
  1560. }.bind(this))
  1561. },
  1562. //show: function(){
  1563. // this.node.setStyles(this.css.configNode);
  1564. // var fx = new Fx.Morph(this.node, {
  1565. // "duration": "500",
  1566. // "transition": Fx.Transitions.Expo.easeOut
  1567. // });
  1568. // fx.start({
  1569. // "opacity": 1
  1570. // }).chain(function(){
  1571. // this.hideFun = this.hide.bind(this);
  1572. // this.app.content.addEvent("mousedown", this.hideFun);
  1573. // }.bind(this));
  1574. //},
  1575. //hide: function(){
  1576. // this.node.destroy();
  1577. // this.app.content.removeEvent("mousedown", this.hideFun);
  1578. // MWF.release(this);
  1579. //},
  1580. resetNodeSize: function(){
  1581. var size = this.container.getSize();
  1582. this.node.setStyle("height", size.y - 50 );
  1583. this.trapezoid.setStyle("top", ( (size.y - 50)/2 - this.trapezoid.getSize().y/2 ));
  1584. var y = size.y - 395;
  1585. var meetContainerY = this.reportItemContainer.getSize().y + 12;
  1586. this.scrollNode.setStyle("height", Math.min( y, meetContainerY ) );
  1587. },
  1588. getSize : function(){
  1589. //var size = this.node.getSize();
  1590. //return {
  1591. // x : this.isHidden ? 9 : size.x,
  1592. // y : size.y
  1593. //}
  1594. return { x : 9, y : 0 }
  1595. },
  1596. showByType : function( type ){
  1597. },
  1598. reload : function(){
  1599. this.destory();
  1600. this.app.reload();
  1601. },
  1602. openReport : function( data ){
  1603. var form = new MWF.xApplication.Report.ReportForm(this, data, {}, {app:this.app});
  1604. form.view = this.app;
  1605. form.open();
  1606. },
  1607. destory : function(){
  1608. this.tooltipList.each( function( t ){
  1609. t.destory();
  1610. });
  1611. this.app.removeEvent("resize", this.resetNodeSizeFun );
  1612. this.app.node.removeEvent("mousedown", this.hideFun);
  1613. this.node.destory();
  1614. }
  1615. });
  1616. MWF.xApplication.Report.ReportArea = new Class({
  1617. initialize: function(container, view, data){
  1618. this.container = container;
  1619. this.view = view;
  1620. this.css = this.view.css;
  1621. this.app = this.view.app;
  1622. this.data = data;
  1623. this.beginDate = Date.parse(this.data.startTime);
  1624. this.endDate = Date.parse(this.data.completedTime);
  1625. this.userName = ( layout.desktop.session.user || layout.user ).distinguishedName;
  1626. this.userId = ( layout.desktop.session.user || layout.user ).id;
  1627. this.path = "/x_component_Report/$Common/default/reportarea/";
  1628. this.cssPath = "/x_component_Report/$Common/default/reportarea/css.wcss";
  1629. this._loadCss();
  1630. this.load();
  1631. },
  1632. load: function(){
  1633. var d = this.data;
  1634. this.node = new Element("div", {"styles": this.css.reportNode}).inject( this.container );
  1635. this.node.addEvents({
  1636. mouseenter : function(){
  1637. this.node.setStyles( this.css.reportNode_over );
  1638. this.subjectNode.setStyles( this.css.reportSubjectNode_over );
  1639. }.bind(this),
  1640. mouseleave : function(){
  1641. this.node.setStyles( this.css.reportNode );
  1642. this.subjectNode.setStyles( this.css.reportSubjectNode );
  1643. }.bind(this),
  1644. click : function(){
  1645. this.openReport()
  1646. }.bind(this)
  1647. });
  1648. this.colorNode = new Element("div", {"styles": this.css.reportColorNode}).inject(this.node);
  1649. this.contentNode = new Element("div", {"styles": this.css.reportContentNode}).inject(this.node);
  1650. //var beginTime = (this.beginDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.beginDate.getHours() ) + ":" + this.getString( this.beginDate.getMinutes() );
  1651. //var endTime = (this.endDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.endDate.getHours() ) + ":" + this.getString( this.endDate.getMinutes() );
  1652. //this.timeNode = new Element("div", {
  1653. // "styles": this.css.reportTimeNode,
  1654. // "text" : beginTime + "-" + endTime
  1655. //}).inject(this.contentNode);
  1656. this.subjectNode = new Element("div", {
  1657. "styles": this.css.reportSubjectNode,
  1658. "text": this.data.title
  1659. }).inject(this.contentNode);
  1660. this.descriptionNode = new Element("div", {
  1661. "styles": this.css.reportDescriptionNode,
  1662. "text" : this.app.lp[d.reportObjType] + this.app.lp[d.reportType] + " " +
  1663. ( d.currentPersonName ? d.currentPersonName.split("@")[0] + " " : "" ) + d.activityName 
  1664. }).inject(this.contentNode);
  1665. var status;
  1666. var lp = this.app.lp.config;
  1667. if( d.reportStatus == "审核中" && this.app.userName == d.currentPersonName ){
  1668. status = "需要我审核"
  1669. }else{
  1670. status = d.reportStatus;
  1671. }
  1672. switch (status){
  1673. case "汇报者填写":
  1674. this.colorNode.setStyles({ "background-color": lp.waitColor });
  1675. break;
  1676. case "审核中":
  1677. this.colorNode.setStyles({ "background-color": lp.progressColor });
  1678. break;
  1679. case "需要我审核":
  1680. this.colorNode.setStyles({ "background-color": lp.auditColor });
  1681. break;
  1682. case "已完成":
  1683. this.colorNode.setStyles({ "background-color": lp.completedColor });
  1684. break;
  1685. }
  1686. this.resetNodeSize();
  1687. this.loadTooltip();
  1688. },
  1689. getString : function( str ){
  1690. var s = "00" + str;
  1691. return s.substr(s.length - 2, 2 );
  1692. },
  1693. _loadCss: function(){
  1694. var key = encodeURIComponent(this.cssPath);
  1695. if (MWF.widget.css[key]){
  1696. this.css = MWF.widget.css[key];
  1697. }else{
  1698. var r = new Request.JSON({
  1699. url: this.cssPath,
  1700. secure: false,
  1701. async: false,
  1702. method: "get",
  1703. noCache: false,
  1704. onSuccess: function(responseJSON, responseText){
  1705. this.css = responseJSON;
  1706. MWF.widget.css[key] = responseJSON;
  1707. }.bind(this),
  1708. onError: function(text, error){
  1709. alert(error + text);
  1710. }
  1711. });
  1712. r.send();
  1713. }
  1714. },
  1715. loadTooltip : function( isHideAttachment ){
  1716. this.tooltip = new MWF.xApplication.Report.ReportTooltip(this.app.content, this.node, this.app, this.data, {
  1717. axis : "x",
  1718. hiddenDelay : 300,
  1719. displayDelay : 300,
  1720. isHideAttachment : isHideAttachment
  1721. });
  1722. },
  1723. openReport : function(){
  1724. this.app.common.openReport( this.data, this.view )
  1725. },
  1726. resetNodeSize: function(){
  1727. var contentSize = this.contentNode.getSize();
  1728. this.colorNode.setStyle("height", contentSize.y );
  1729. },
  1730. destroy: function(){
  1731. if(this.tooltip)this.tooltip.destroy();
  1732. this.node.destroy();
  1733. MWF.release(this);
  1734. }
  1735. });
  1736. MWF.xApplication.Report.KeyWorkTooltip = new Class({
  1737. Extends: MTooltips,
  1738. _loadCustom : function( callback ){
  1739. if(callback)callback();
  1740. },
  1741. _getHtml : function(){
  1742. var d = this.data;
  1743. var lp = this.lp.keyWorkList.popupForm;
  1744. var titleStyle = "font-size:14px;color:#333;";
  1745. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1746. var department = [];
  1747. if( d.deptlist ){
  1748. d.deptlist.each( function( dept ){
  1749. department.push( dept.split("@")[0] )
  1750. })
  1751. }
  1752. var html =
  1753. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1754. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.keyWorkList.name +"</div>"+
  1755. "</div>"+
  1756. "<div style='font-size: 16px;color:#333;padding:0px 10px 15px 20px;'>"+ d.strategydeploytitle +"</div>"+
  1757. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1758. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1759. "<tr><td style='"+titleStyle+"' width='80'>"+ lp.sequencenumber+":</td>" +
  1760. " <td style='"+valueStyle+"'>"+ d.sequencenumber +"</td></tr>" +
  1761. "<tr><td style='"+titleStyle+"'>"+ lp.year +":</td>" +
  1762. " <td style='"+valueStyle+"'>"+ d.strategydeployyear+"</td></tr>" +
  1763. "<tr style='display: "+ (department.length ? "" : "none") +"'><td style='"+titleStyle+"'>"+ lp.department +":</td>" +
  1764. " <td style='"+valueStyle+"'>"+ department.join(" ") +"</td></tr>" +
  1765. "<tr><td style='"+titleStyle+"'>"+ lp.description+":</td>" +
  1766. " <td style='"+valueStyle+"'>"+ d.strategydeploydescribe +"</td></tr>" +
  1767. "</table>";
  1768. return html;
  1769. }
  1770. });
  1771. MWF.xApplication.Report.MeasureTooltip = new Class({
  1772. Extends: MTooltips,
  1773. _loadCustom : function( callback ){
  1774. //if( this.options.measureId ){
  1775. // this.app.restActions.getMeasureById( this.options.measureId, function( json ){
  1776. // this.measureData = json.data;
  1777. // this.setContent();
  1778. // if(callback)callback();
  1779. // }.bind(this))
  1780. //}else{
  1781. // if(callback)callback();
  1782. //}
  1783. //this.measureData = this.data;
  1784. //if(callback)callback();
  1785. var d = this.data;
  1786. var lp = this.lp.measure.popupForm;
  1787. var department = [];
  1788. d.deptlist.each( function( dept ){
  1789. department.push( dept.split("@")[0] )
  1790. });
  1791. var table = new Element( "table", {
  1792. "width":"100%",
  1793. "border":"0",
  1794. "cellpadding":"5",
  1795. "cellspacing":"0",
  1796. "styles" : this.css.formTable
  1797. }).inject( this.contentNode );
  1798. var tr = new Element("tr").inject( table );
  1799. new Element("td", {
  1800. "text" : "举措",
  1801. "width" : "70",
  1802. "styles": this.css.formTableTitle
  1803. }).inject( tr );
  1804. var td =new Element("td", {
  1805. "styles": this.css.formTableValue,
  1806. "text" : d.measuresinfotitle
  1807. }).inject( tr );
  1808. tr = new Element("tr").inject( table );
  1809. new Element("td", {
  1810. "text" : lp.sequencenumber,
  1811. "width" : "70",
  1812. "styles": this.css.formTableTitle
  1813. }).inject( tr );
  1814. var td =new Element("td", {
  1815. "styles": this.css.formTableValue,
  1816. "text" : d.sequencenumber
  1817. }).inject( tr );
  1818. tr = new Element("tr").inject( table );
  1819. new Element("td", {
  1820. "text" : lp.year,
  1821. "width" : "70",
  1822. "styles": this.css.formTableTitle
  1823. }).inject( tr );
  1824. var td =new Element("td", {
  1825. "styles": this.css.formTableValue,
  1826. "text" : d.measuresinfoyear
  1827. }).inject( tr );
  1828. tr = new Element("tr").inject( table );
  1829. new Element("td", {
  1830. "text" : lp.department,
  1831. "width" : "70",
  1832. "styles": this.css.formTableTitle
  1833. }).inject( tr );
  1834. var td =new Element("td", {
  1835. "styles": this.css.formTableValue,
  1836. "text" : department.join(" ")
  1837. }).inject( tr );
  1838. tr = new Element("tr").inject( table );
  1839. new Element("td", {
  1840. "text" : lp.description,
  1841. "width" : "70",
  1842. "styles": this.css.formTableTitle
  1843. }).inject( tr );
  1844. var td =new Element("td", {
  1845. "styles": this.css.formTableValue,
  1846. "text" : d.measuresinfodescribe
  1847. }).inject( tr );
  1848. if(callback)callback();
  1849. },
  1850. setContent : function(){
  1851. //this.contentNode.set( "html", this._getHtml() );
  1852. },
  1853. _getHtml : function(){
  1854. //if( !this.data )return;
  1855. //var d = this.measureData || this.data;
  1856. //var lp = this.lp.measure.popupForm;
  1857. //
  1858. //var titleStyle = "font-size:14px;color:#333";
  1859. //var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1860. //
  1861. //var department = [];
  1862. //d.deptlist.each( function( dept ){
  1863. // department.push( dept.split("@")[0] )
  1864. //});
  1865. //
  1866. //var html =
  1867. // "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1868. // " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.measure.name +"</div>"+
  1869. // "</div>"+
  1870. // "<div style='font-size: 16px;color:#333;padding:0px 10px 15px 20px;'>"+ d.measuresinfotitle +"</div>"+
  1871. // "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1872. // "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1873. // "<tr><td style='"+titleStyle+"' width='80'>"+ lp.sequencenumber+":</td>" +
  1874. // " <td style='"+valueStyle+"'>"+ d.sequencenumber +"</td></tr>" +
  1875. // "<tr><td style='"+titleStyle+"'>"+ lp.year +":</td>" +
  1876. // " <td style='"+valueStyle+"'>"+ d.measuresinfoyear+"</td></tr>" +
  1877. // "<tr><td style='"+titleStyle+"'>"+ lp.department +":</td>" +
  1878. // " <td style='"+valueStyle+"'>"+ department.join(" ") +"</td></tr>" +
  1879. // "<tr><td style='"+titleStyle+"'>"+ lp.description+":</td>" +
  1880. // " <td style='"+valueStyle+"'>"+ d.measuresinfodescribe +"</td></tr>" +
  1881. // "</table>";
  1882. //return html;
  1883. }
  1884. });
  1885. MWF.xApplication.Report.PriorityTooltip = new Class({
  1886. Extends: MTooltips,
  1887. _loadCustom : function( callback ){
  1888. if( this.data.keyWorkId ){
  1889. this.app.strategyActions.getPriorityById( this.data.keyWorkId, function( json ){
  1890. this.priorityData = json.data;
  1891. this.setContent();
  1892. if(callback)callback();
  1893. }.bind(this))
  1894. }else{
  1895. if(callback)callback();
  1896. }
  1897. },
  1898. setContent : function(){
  1899. this.contentNode.set( "html", this._getHtml() );
  1900. },
  1901. _getHtml : function(){
  1902. if( !this.priorityData && this.data.keyWorkId )return;
  1903. var d = this.priorityData || this.data;
  1904. var lp = this.lp.priority.popupForm;
  1905. var titleStyle = "font-size:14px;color:#333";
  1906. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1907. var html =
  1908. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1909. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.priority.name +"</div>"+
  1910. "</div>"+
  1911. "<div style='font-size: 16px;color:#333;padding:0px 10px 15px 20px;'>"+ d.keyworktitle +"</div>"+
  1912. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1913. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1914. "<tr><td style='"+titleStyle+"' width='80'>"+ lp.sequencenumber+":</td>" +
  1915. " <td style='"+valueStyle+"'>"+ d.sequencenumber +"</td></tr>" +
  1916. "<tr><td style='"+titleStyle+"'>"+ lp.year +":</td>" +
  1917. " <td style='"+valueStyle+"'>"+ d.keyworkyear+"</td></tr>" +
  1918. "<tr><td style='"+titleStyle+"'>"+ lp.validDate +":</td>" +
  1919. " <td style='"+valueStyle+"'>"+ d.keyworkbegindate + " "+ lp.validDateConnect + " "+ d.keyworkenddate +"</td></tr>" +
  1920. "<tr><td style='"+titleStyle+"'>"+ lp.department +":</td>" +
  1921. " <td style='"+valueStyle+"'>"+ (d.keyworkunit ? d.keyworkunit.split("@")[0] : "") +"</td></tr>" +
  1922. "<tr><td style='"+titleStyle+"'>"+ lp.description+":</td>" +
  1923. " <td style='"+valueStyle+"'>"+ d.keyworkdescribe +"</td></tr>" +
  1924. "</table>";
  1925. return html;
  1926. }
  1927. });
  1928. MWF.xApplication.Report.ShowMeasureTooltip = new Class({
  1929. Extends: MTooltips,
  1930. options : {
  1931. overflow : "scroll"
  1932. },
  1933. _loadCustom : function( callback ){
  1934. var data = this.data;
  1935. var measureNode = new Element("div", {
  1936. //styles : this.css.measureDeployNode
  1937. }).inject( this.contentNode );
  1938. var measureObject = {};
  1939. data.selectableMeasures.each( function( measure ){
  1940. measureObject[ measure.id ] = measure;
  1941. }.bind(this));
  1942. this.measuresList.each( function( id ){
  1943. var measure = measureObject[id];
  1944. if( measure ){
  1945. var table = new Element( "table", {
  1946. "width":"100%",
  1947. "border":"0",
  1948. "cellpadding":"5",
  1949. "cellspacing":"0",
  1950. "styles" : this.css.formTable
  1951. }).inject( measureNode );
  1952. var tr = new Element("tr").inject( table );
  1953. new Element("td", {
  1954. "text" : "举措",
  1955. "width" : "70",
  1956. "styles": this.css.formTableTitle
  1957. }).inject( tr );
  1958. new Element("td", {
  1959. "text": measure.measuresinfotitle,
  1960. "styles": this.css.formTableValue
  1961. }).inject( tr );
  1962. tr = new Element("tr").inject( table );
  1963. new Element("td", {
  1964. "text" : "内容",
  1965. "styles": this.css.formTableTitle
  1966. }).inject( tr );
  1967. new Element("td", {
  1968. "text": measure.measuresinfodescribe,
  1969. "styles": this.css.formTableValue
  1970. }).inject( tr );
  1971. }
  1972. }.bind(this));
  1973. if(callback)callback();
  1974. }
  1975. });
  1976. MWF.xApplication.Report.SelectMeasureTooltips = new Class({
  1977. Extends: MTooltips,
  1978. options : {
  1979. overflow : "scroll"
  1980. },
  1981. _loadCustom : function( callback ){
  1982. var data = this.data;
  1983. var measureNode = new Element("div", {
  1984. //styles : this.css.measureDeployNode
  1985. }).inject( this.contentNode );
  1986. measureNode.setStyle("padding-bottom", "10px");
  1987. //var measureObject = {};
  1988. data.selectableMeasures.each( function( measure ){
  1989. //measureObject[ measure.id ] = measure;
  1990. var table = new Element( "table", {
  1991. "width":"100%",
  1992. "border":"0",
  1993. "cellpadding":"5",
  1994. "cellspacing":"0",
  1995. "styles" : this.css.formTable
  1996. }).inject( measureNode );
  1997. var tr = new Element("tr").inject( table );
  1998. tr = new Element("tr").inject( table );
  1999. new Element("td", {
  2000. "text" : "举措",
  2001. "width" : "70",
  2002. "styles": this.css.formTableTitle
  2003. }).inject( tr );
  2004. var td =new Element("td", {
  2005. "styles": this.css.formTableValue
  2006. }).inject( tr );
  2007. var table_select = new Element( "table", {
  2008. "width":"100%",
  2009. "border":"0",
  2010. "cellpadding":"0",
  2011. "cellspacing":"0"
  2012. }).inject( td );
  2013. var tr_select = new Element("tr").inject( table_select );
  2014. var td_select =new Element("td", { width : "30" }).inject( tr_select );
  2015. var checkbox = new Element( "input", {
  2016. type : "checkbox",
  2017. "data-id" : measure.id,
  2018. checked : this.measuresList.contains( measure.id )
  2019. }).inject( td_select );
  2020. checkbox.addEvent("click", function(){
  2021. var value = [];
  2022. this.contentNode.getElements("input[type='checkbox']").each( function( checkbox ){
  2023. if( checkbox.get("checked") ){
  2024. value.push( checkbox.get("data-id") );
  2025. }
  2026. }.bind(this));
  2027. var list = [];
  2028. this.data.selectableMeasures.each( function( measure ){
  2029. if( value.contains( measure.id ) ){
  2030. list.push( measure )
  2031. }
  2032. }.bind(this));
  2033. this.fireEvent("select", [list, value]);
  2034. }.bind(this));
  2035. var td_select =new Element("td").inject( tr_select );
  2036. new Element("div", { "text": measure.measuresinfotitle }).inject( td_select );
  2037. tr = new Element("tr").inject( table );
  2038. new Element("td", {
  2039. "text" : "内容",
  2040. "styles": this.css.formTableTitle
  2041. }).inject( tr );
  2042. new Element("td", {
  2043. "text": measure.measuresinfodescribe,
  2044. "styles": this.css.formTableValue
  2045. }).inject( tr );
  2046. }.bind(this));
  2047. if(callback)callback();
  2048. }
  2049. });
  2050. MWF.xApplication.Report.SelectMeasureForm = new Class({
  2051. Extends: MPopupForm,
  2052. Implements: [Options, Events],
  2053. options: {
  2054. "style": "report",
  2055. "width": 800,
  2056. "height": 450,
  2057. "minWidth" : 700,
  2058. "minHeight" : 300,
  2059. "hasTop": true,
  2060. "hasIcon": false,
  2061. "hasTopIcon" : false,
  2062. "hasTopContent" : false,
  2063. "maxAction" : true,
  2064. "hasBottom": true,
  2065. "draggable": true,
  2066. "resizeable": true,
  2067. "editedAble" : true,
  2068. "closeAction": true
  2069. },
  2070. _createTableContent: function () {
  2071. var data = this.data;
  2072. this.formTopTextNode.set( "text", "选择举措" );
  2073. var node = new Element("div", {
  2074. styles : { "overflow": "hidden", "padding":"10px", "margin" : "20px 20px" }
  2075. }).inject( this.formTableArea );
  2076. //this.loadTooltip( keyworkNode, data, "keywork" );
  2077. var measureNode = new Element("div", {
  2078. styles : this.css.measureDeployNode
  2079. }).inject( node );
  2080. var measureIdList = [];
  2081. var measureTitleList = [];
  2082. var measureObject = {};
  2083. data.selectableMeasures.each( function( measure ){
  2084. measureIdList.push( measure.id );
  2085. measureTitleList.push( measure.measuresinfotitle );
  2086. measureObject[ measure.id ] = measure;
  2087. }.bind(this));
  2088. this.item = new MDomItem( measureNode, {
  2089. name : "measures", type : "checkbox", selectValue: measureIdList, selectText : measureTitleList, value : data.measuresList, style : { "overflow" : "hidden" },
  2090. onPostLoad : function( item ){
  2091. item.items.each( function( it ){
  2092. var iconNode = new Element("span", {
  2093. styles : this.css.measureIconNode
  2094. }).inject( it, "top" );
  2095. var id = it.getElement("input[type='checkbox']").get("value");
  2096. this.loadMeasureTooltip(iconNode, id);
  2097. var d = measureObject[id];
  2098. var descriptionNode = new Element("div",{
  2099. styles : this.css.measuresDescribeNode,
  2100. text : "工作内容:" + d.measuresinfodescribe
  2101. }).inject( it, "after" )
  2102. }.bind(this))
  2103. }.bind(this)
  2104. } , null, this.app, this.css);
  2105. this.item.load();
  2106. },
  2107. _createBottomContent: function () {
  2108. if (this.isNew || this.isEdited) {
  2109. this.okActionNode = new Element("button.inputOkButton", {
  2110. "styles": this.css.inputOkButton,
  2111. "text": "确定"
  2112. }).inject(this.formBottomNode);
  2113. this.okActionNode.addEvent("click", function (e) {
  2114. this.save(e);
  2115. }.bind(this));
  2116. }
  2117. this.cancelActionNode = new Element("button.inputCancelButton", {
  2118. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  2119. "text": this.lp.close
  2120. }).inject(this.formBottomNode);
  2121. this.cancelActionNode.addEvent("click", function (e) {
  2122. this.close(e);
  2123. }.bind(this));
  2124. },
  2125. loadMeasureTooltip: function( node, measureId ){
  2126. new MWF.xApplication.Report.MeasureTooltip( this.app.content, node, this.app, null, {
  2127. position : { x : "right", y : "auto" },
  2128. measureId : measureId,
  2129. displayDelay : 300
  2130. })
  2131. },
  2132. save: function(){
  2133. var list = [];
  2134. var value = this.item.getValue();
  2135. this.data.selectableMeasures.each( function( measure ){
  2136. if( value.contains( measure.id ) ){
  2137. list.push( measure )
  2138. }
  2139. }.bind(this));
  2140. this.fireEvent("postOk", [list, value]);
  2141. this.close()
  2142. }
  2143. });
  2144. MWF.xApplication.Report.StatisticsForm = new Class({
  2145. Extends: MPopupForm,
  2146. Implements: [Options, Events],
  2147. options: {
  2148. "style": "report",
  2149. "width": 800,
  2150. "height": 450,
  2151. "hasTop": true,
  2152. "hasIcon": false,
  2153. "maxAction" : true,
  2154. "draggable": true,
  2155. "resizeable": true,
  2156. "editedAble" : true,
  2157. "category" : ""
  2158. },
  2159. _createTableContent: function () {
  2160. this.lp = {
  2161. ok : "导出",
  2162. close : "取消"
  2163. };
  2164. this.formTopTextNode.set( "text", "导出" );
  2165. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  2166. this.formTableArea.setStyle("margin-top","20px");
  2167. var selectAll = "";
  2168. if( this.app.common.isAdmin() || this.app.exportAllFlag ){
  2169. selectAll = "<tr><td styles='formTableTitleP14' lable='allUnit'></td>" +
  2170. " <td styles='formTableValueP14' item='allUnit' ></td></tr>"
  2171. }
  2172. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  2173. "<tr><td styles='formTableTitleP14' lable='year' width='20%'></td>" +
  2174. " <td styles='formTableValueP14' item='year'></td></tr>" +
  2175. "<tr><td styles='formTableTitleP14' lable='month'></td>" +
  2176. " <td styles='formTableValueP14' item='month' ></td></tr>" +
  2177. "<tr><td styles='formTableTitleP14' lable='wfProcessStatus'></td>" +
  2178. " <td styles='formTableValueP14' item='wfProcessStatus' ></td></tr>" +
  2179. "<tr><td styles='formTableTitleP14' lable='unitList'></td>" +
  2180. " <td styles='formTableValueP14' item='unitList' ></td></tr>" +
  2181. selectAll +
  2182. "</table>";
  2183. this.formTableArea.set("html", html);
  2184. this.loadForm()
  2185. },
  2186. loadForm : function( ){
  2187. var _self = this;
  2188. MWF.xDesktop.requireApp("Template", "MForm", function () {
  2189. this.form = new MForm(this.formTableArea, this.data, {
  2190. usesNewVersion : true,
  2191. isEdited: this.isEdited || this.isNew,
  2192. style : "report",
  2193. hasColon : true,
  2194. itemTemplate: {
  2195. year: { type : "select", notEmpty : true, text : "年度",
  2196. selectText : function(){
  2197. var arr = [];
  2198. var data = new Date();
  2199. data.decrement("year",5);
  2200. for( var i=0; i<11; i++ ){
  2201. data.increment("year",1);
  2202. arr.push(data.getFullYear()+ "年")
  2203. }
  2204. return arr
  2205. },
  2206. selectValue : function(){
  2207. var arr = [];
  2208. var data = new Date();
  2209. data.decrement("year",5);
  2210. for( var i=0; i<11; i++ ){
  2211. data.increment("year",1);
  2212. arr.push(data.getFullYear().toString())
  2213. }
  2214. return arr
  2215. },
  2216. defaultValue : (new Date()).getFullYear().toString(),
  2217. event : {
  2218. change : function(){
  2219. this.listUnitNamesForReport();
  2220. }.bind(this)
  2221. }
  2222. },
  2223. month: { type : "select", notEmpty : true, text : "月份",
  2224. selectText : ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"] ,
  2225. selectValue : ["01","02","03","04","05","06","07","08","09","10","11","12"],
  2226. defaultValue : (new Date().format("%m")).toString(),
  2227. event : {
  2228. change : function(){
  2229. this.listUnitNamesForReport();
  2230. }.bind(this)
  2231. }
  2232. },
  2233. unitList : { type : "checkbox", notEmpty : true, text : "部门" },
  2234. wfProcessStatus: { type : "select", text : "审批状态",
  2235. selectText : ["全部","已完成","流转中"] ,
  2236. selectValue : ["","已完成","流转中"],
  2237. event : {
  2238. change : function(){
  2239. this.listUnitNamesForReport();
  2240. }.bind(this)
  2241. }
  2242. },
  2243. allUnit : { type : "checkbox", text : "所有部门", selectValue : ["yes"], selectText : ["是"], event : {
  2244. change : function(item, ev){
  2245. if(item.getValue().join() == "yes"){
  2246. this.form.getItem("unitList").setValue( this.allUnitList );
  2247. }else{
  2248. this.form.getItem("unitList").setValue("");
  2249. }
  2250. }.bind(this)
  2251. }}
  2252. }
  2253. }, this.app);
  2254. this.form.load();
  2255. this.listUnitNamesForReport( (new Date()).getFullYear().toString(), (new Date().format("%m")).toString() )
  2256. }.bind(this), true);
  2257. },
  2258. listUnitNamesForReport : function(year, month, wfProcessStatus){
  2259. var unitListItem = this.formTableArea.getElement("[item='unitList']");
  2260. if(this.nounitListNode)this.nounitListNode.destroy();
  2261. if( !year )year = this.form.getItem("year").getValue();
  2262. if( !month )month = this.form.getItem("month").getValue();
  2263. if( !wfProcessStatus )wfProcessStatus = this.form.getItem("wfProcessStatus").getValue();
  2264. this.app.restActions.listUnitNamesForReport({
  2265. year : year,
  2266. month : month,
  2267. wfProcessStatus : wfProcessStatus ? [wfProcessStatus] : null
  2268. }, function( json ){
  2269. var value = this.allUnitList = [];
  2270. var text = [];
  2271. var data = json.data || [];
  2272. if( this.app.exportAllFlag ){
  2273. data.each( function( d ){
  2274. value.push(d.value );
  2275. text.push(d.value.split("@")[0] );
  2276. });
  2277. }else{
  2278. data.each(function(d){
  2279. if( this.app.unitWithExport.contains(d.value ) ){
  2280. value.push(d.value );
  2281. text.push(d.value.split("@")[0] );
  2282. }
  2283. }.bind(this));
  2284. }
  2285. if( value.length == 0 ){
  2286. this.form.getItem("unitList").disable();
  2287. this.nounitListNode = new Element("div", {
  2288. text : "系统未找"+year+"年"+ month +"月"+this.form.getItem("wfProcessStatus").getValue()+"的工作汇报"
  2289. }).inject( unitListItem );
  2290. var allUnit = this.form.getItem("allUnit");
  2291. if( allUnit ){
  2292. allUnit.setValue( "" );
  2293. }
  2294. }else{
  2295. if( this.nounitListNode )this.nounitListNode.destroy();
  2296. var unitList = this.form.getItem("unitList");
  2297. unitList.resetItemOptions( value, text, true );
  2298. unitList.setValue( this.allUnitList );
  2299. var allUnit = this.form.getItem("allUnit");
  2300. if( allUnit ){
  2301. allUnit.setValue( "yes" );
  2302. }
  2303. }
  2304. }.bind(this), null, false)
  2305. },
  2306. _createBottomContent: function () {
  2307. if (this.isNew || this.isEdited) {
  2308. this.okActionNode = new Element("button.inputOkButton", {
  2309. "styles": this.css.inputOkButton,
  2310. "text": this.lp.ok
  2311. }).inject(this.formBottomNode);
  2312. this.okActionNode.addEvent("click", function (e) {
  2313. this.export(e);
  2314. }.bind(this));
  2315. }
  2316. this.cancelActionNode = new Element("button.inputCancelButton", {
  2317. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  2318. "text": this.lp.close
  2319. }).inject(this.formBottomNode);
  2320. this.cancelActionNode.addEvent("click", function (e) {
  2321. this.close(e);
  2322. }.bind(this));
  2323. },
  2324. export: function(){
  2325. var data = this.form.getResult(true,null,true,false,true);
  2326. if( data ){
  2327. data.wfProcessStatus = data.wfProcessStatus ? [data.wfProcessStatus] : null;
  2328. data.unitList = data.unitList || null;
  2329. this.app.restActions.statByUnit( data , function( json ){
  2330. if( json.data && json.data.id ){
  2331. this.app.restActions.getExportFileStream( json.data.id );
  2332. }else{
  2333. this.app.notice("系统中未找到指定条件的数据","error");
  2334. }
  2335. }.bind(this));
  2336. }
  2337. }
  2338. });
  2339. MWF.xApplication.Report.SummarizationForm = new Class({
  2340. Extends: MPopupForm,
  2341. Implements: [Options, Events],
  2342. options: {
  2343. "style": "report",
  2344. "width": "80%",
  2345. "height": "90%",
  2346. "hasTop": true,
  2347. "hasBottom": false,
  2348. "hasIcon": false,
  2349. "maxAction" : true,
  2350. "draggable": true,
  2351. "resizeable": true,
  2352. "editedAble" : true,
  2353. "category" : ""
  2354. },
  2355. createContent: function () {
  2356. this.tableContainer = new Element("div.formTabContainer",{
  2357. styles : {
  2358. "padding-top" : "10px",
  2359. "margin": "0px auto 20px",
  2360. "width": "90%"
  2361. }
  2362. }).inject(this.formNode);
  2363. this.formContentNode = new Element("div.formContentNode", {
  2364. "styles": this.css.formContentNode
  2365. }).inject(this.formNode);
  2366. this.formTableContainer = new Element("div.formTableContainer", {
  2367. "styles": this.css.formTableContainer
  2368. }).inject(this.formContentNode);
  2369. this.formTableArea = new Element("div.formTableArea", {
  2370. "styles": this.css.formTableArea
  2371. }).inject(this.formTableContainer);
  2372. this._createTableContent();
  2373. },
  2374. _createTableContent: function () {
  2375. this.lp = {
  2376. ok : "查询",
  2377. close : "取消"
  2378. };
  2379. this.formTopTextNode.set( "text", "部门五项重点工作统览" );
  2380. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  2381. this.formTableArea.setStyle("margin-top","20px");
  2382. this.formTableContainer.setStyle("width","90%");
  2383. var selectAll = "";
  2384. var html = "<table width='96%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  2385. "<tr><td styles='formTableTitleP14' lable='year'></td>" +
  2386. " <td styles='formTableValueP14' item='year'></td>" +
  2387. " <td styles='formTableTitleP14' lable='month'></td>" +
  2388. " <td styles='formTableValueP14' item='month' ></td>" +
  2389. " <td styles='formTableTitleP14' lable='wfProcessStatus'></td>" +
  2390. " <td styles='formTableValueP14' item='wfProcessStatus' ></td>" +
  2391. " <td styles='formTableValueP14' item='ok' style='width: 80px;'></td></tr>" +
  2392. "</table>";
  2393. this.tableContainer.set("html", html);
  2394. this.loadForm()
  2395. },
  2396. loadForm : function( ){
  2397. var _self = this;
  2398. MWF.xDesktop.requireApp("Template", "MForm", function () {
  2399. this.form = new MForm(this.tableContainer, this.data, {
  2400. usesNewVersion : true,
  2401. isEdited: this.isEdited || this.isNew,
  2402. style : "report",
  2403. hasColon : true,
  2404. itemTemplate: {
  2405. year: { type : "select", notEmpty : true, text : "年度",
  2406. selectText : function(){
  2407. var arr = [];
  2408. var data = new Date();
  2409. data.decrement("year",5);
  2410. for( var i=0; i<11; i++ ){
  2411. data.increment("year",1);
  2412. arr.push(data.getFullYear()+ "年")
  2413. }
  2414. return arr
  2415. },
  2416. selectValue : function(){
  2417. var arr = [];
  2418. var data = new Date();
  2419. data.decrement("year",5);
  2420. for( var i=0; i<11; i++ ){
  2421. data.increment("year",1);
  2422. arr.push(data.getFullYear().toString())
  2423. }
  2424. return arr
  2425. },
  2426. defaultValue : (new Date()).getFullYear().toString()
  2427. },
  2428. month: { type : "select", text : "月份",
  2429. selectText : ["全年","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"] ,
  2430. selectValue : ["","01","02","03","04","05","06","07","08","09","10","11","12"]
  2431. },
  2432. unitList : { type : "checkbox", text : "部门" },
  2433. ok : { type : "button", text : "查询", value : "查询", event : {
  2434. click : function(){ this.ok()}.bind(this)
  2435. } },
  2436. wfProcessStatus: { type : "select", text : "审批状态",
  2437. selectText : ["全部","已完成","流转中"] ,
  2438. selectValue : ["","已完成","流转中"]
  2439. }
  2440. }
  2441. }, this.app);
  2442. this.form.load();
  2443. this.ok();
  2444. }.bind(this), true);
  2445. },
  2446. ok: function(){
  2447. var data = this.form.getResult(true,null,true,false,true);
  2448. data.wfProcessStatus = data.wfProcessStatus ? [data.wfProcessStatus] : null;
  2449. if( !this.app.exportAllFlag )data.unitList = this.app.unitWithExport;
  2450. this.formTableArea.empty();
  2451. this.app.restActions.listWorkInfoByYear( data.year, data, function( json ){
  2452. var table = new Element( "table", {
  2453. "width":"96%",
  2454. "border":"0",
  2455. "cellpadding":"5",
  2456. "cellspacing":"0",
  2457. "styles" : this.form.css.formTable
  2458. }).inject( this.formTableArea );
  2459. var tr = new Element("tr").inject( table );
  2460. var td = new Element("th", {
  2461. "styles": this.form.css.formTableTitleP14,
  2462. "text" : "部门"
  2463. }).inject( tr );
  2464. var td = new Element("th", {
  2465. "styles": this.form.css.formTableTitleP14,
  2466. "text" : "月份"
  2467. }).inject( tr );
  2468. var td = new Element("th", {
  2469. "styles": this.form.css.formTableTitleP14,
  2470. "text" : "重点工作"
  2471. }).inject( tr );
  2472. json.data.each( function( data, i ){
  2473. tr = new Element("tr").inject( table );
  2474. var count = 0;
  2475. var firstTd = td = new Element("td", {
  2476. "styles": this.form.css.formTableValueP14,
  2477. "text" : data.unitName.split("@")[0] + "(" + data.workTotal + ")"
  2478. }).inject( tr );
  2479. td.setStyle("text-align","center");
  2480. if( data.workMonths ){
  2481. var flag = false;
  2482. data.workMonths.each( function( monthData, j ){
  2483. if( monthData.workInfoList ){
  2484. //if( j != 0 )tr = new Element("tr").inject( table );
  2485. if( flag ){
  2486. tr = new Element("tr").inject( table );
  2487. }else{
  2488. flag = true;
  2489. }
  2490. var count2 = 0;
  2491. var secondTd = td = new Element("td", {
  2492. "styles": this.form.css.formTableValueP14,
  2493. "text" : parseInt( monthData.month ) + "月"
  2494. }).inject( tr );
  2495. td.setStyle("text-align","center");
  2496. monthData.workInfoList.each( function( workInfo, k ){
  2497. count = count + 1;
  2498. count2 = count2 + 1;
  2499. if( k != 0 )tr = new Element("tr").inject( table );
  2500. var td = new Element("td", {
  2501. "styles": this.form.css.formTableValueP14,
  2502. "text" : workInfo.workName || "未设置"
  2503. }).inject( tr );
  2504. }.bind(this));
  2505. secondTd.set("rowspan",count2);
  2506. }
  2507. }.bind(this))
  2508. }
  2509. firstTd.set("rowspan",count);
  2510. }.bind(this))
  2511. }.bind(this))
  2512. },
  2513. setFormNodeSize: function (width, height, top, left) {
  2514. if (!width)width = this.options.width ? this.options.width : "50%";
  2515. if (!height)height = this.options.height ? this.options.height : "50%";
  2516. if (!top) top = this.options.top ? this.options.top : 0;
  2517. if (!left) left = this.options.left ? this.options.left : 0;
  2518. var containerSize = this.container.getSize();
  2519. if( containerSize.x < width )width = containerSize.x;
  2520. if( containerSize.y < height )height = containerSize.y;
  2521. var allSize = this.app.content.getSize();
  2522. var limitWidth = allSize.x; //window.screen.width
  2523. var limitHeight = allSize.y; //window.screen.height
  2524. "string" == typeof width && (1 < width.length && "%" == width.substr(width.length - 1, 1)) && (width = parseInt(limitWidth * parseInt(width, 10) / 100, 10));
  2525. "string" == typeof height && (1 < height.length && "%" == height.substr(height.length - 1, 1)) && (height = parseInt(limitHeight * parseInt(height, 10) / 100, 10));
  2526. 300 > width && (width = 300);
  2527. 220 > height && (height = 220);
  2528. top = top || parseInt((limitHeight - height) / 2, 10); //+appTitleSize.y);
  2529. left = left || parseInt((limitWidth - width) / 2, 10);
  2530. this.formAreaNode.setStyles({
  2531. "width": "" + width + "px",
  2532. "height": "" + height + "px",
  2533. "top": "" + top + "px",
  2534. "left": "" + left + "px"
  2535. });
  2536. this.formNode.setStyles({
  2537. "width": "" + width + "px",
  2538. "height": "" + height + "px"
  2539. });
  2540. var iconSize = this.formIconNode ? this.formIconNode.getSize() : {x: 0, y: 0};
  2541. var topSize = this.formTopNode ? this.formTopNode.getSize() : {x: 0, y: 0};
  2542. var bottomSize = this.formBottomNode ? this.formBottomNode.getSize() : {x: 0, y: 0};
  2543. var tabSize = this.tableContainer ? this.tableContainer.getSize() : {x: 0, y: 0};
  2544. var contentHeight = height - iconSize.y - topSize.y - bottomSize.y - tabSize.y - 30;
  2545. //var formMargin = formHeight -iconSize.y;
  2546. this.formContentNode.setStyles({
  2547. "height": "" + contentHeight + "px"
  2548. });
  2549. this.formTableContainer.setStyles({
  2550. "height": "" + contentHeight + "px"
  2551. });
  2552. }
  2553. });