Common.js 112 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768
  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. var d = this.data;
  1310. var lp = this.lp;
  1311. var titleStyle = "font-size:14px;color:#333";
  1312. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1313. var html =
  1314. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1315. " <div style='font-size: 16px;color:#333;float: left'>"+ lp[d.reportObjType] + lp[d.reportType] +"</div>"+
  1316. "</div>"+
  1317. "<div style='font-size: 16px;color:#333;padding:0px 10px 15px 20px;'>"+ d.title +"</div>"+
  1318. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1319. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1320. "<tr><td style='"+titleStyle+"' width='100'>管理员:</td>" +
  1321. " <td style='"+valueStyle+"'>"+ ( d.targetPerson ? d.targetPerson.split("@")[0] : "" ) +"</td></tr>" +
  1322. "<tr><td style='"+titleStyle+"'>" + lp.targetUnit +":</td>" +
  1323. " <td style='"+valueStyle+"'>" + ( d.targetUnit ? d.targetUnit.split("@")[0] : "" )+ "</td></tr>" +
  1324. "<tr><td style='"+titleStyle+"'>"+ lp.createDate +":</td>" +
  1325. " <td style='"+valueStyle+"'>"+ d.createDateString+"</td></tr>" +
  1326. "<tr><td style='"+titleStyle+"'>"+ lp.activityName +":</td>" +
  1327. " <td style='"+valueStyle+"'>"+ d.activityName+"</td></tr>" +
  1328. "<tr><td style='"+titleStyle+"'>"+ lp.currentPersonName+":</td>" +
  1329. " <td style='"+valueStyle+"'>"+ ( d.currentPersonName ? d.currentPersonName.split("@")[0] : "" ) +"</td></tr>" +
  1330. "</table>";
  1331. return html;
  1332. }
  1333. });
  1334. MWF.xApplication.Report.SideBar = new Class({
  1335. Extends: MWF.widget.Common,
  1336. Implements: [Options, Events],
  1337. options: {
  1338. "style": "default"
  1339. },
  1340. initialize : function( container, app, options){
  1341. this.setOptions( options );
  1342. this.container = container;
  1343. this.app = app;
  1344. //this.css = this.app.css;
  1345. this.lp = this.app.lp;
  1346. this.isHidden = false;
  1347. this.cssPath = "../x_component_Report/$Common/"+this.options.style+"/sidebar/css.wcss";
  1348. this._loadCss();
  1349. this.load();
  1350. },
  1351. load : function(){
  1352. this.node = new Element("div.sideBar", {
  1353. "styles": this.css.node,
  1354. events : {
  1355. mousedown : function( ev ){
  1356. ev.stopPropagation();
  1357. }
  1358. }
  1359. }).inject(this.container);
  1360. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  1361. this.loadStatusArea();
  1362. new Element("div.contentLine", {
  1363. "styles" : this.css.contentLine
  1364. }).inject( this.contentNode );
  1365. this.loadWaitDoNode();
  1366. this.trapezoid = new Element("div.trapezoid",{
  1367. "styles":this.css.trapezoid_toRight,
  1368. events : {
  1369. click : function(){
  1370. this.trigger();
  1371. }.bind(this)
  1372. }
  1373. }).inject(this.node);
  1374. this.listData( function(){
  1375. this.loadWaitDo( function(){
  1376. var x = this.node.getSize().x - 8;
  1377. this.node.setStyle( "right", "-"+x+"px" );
  1378. this.resetNodeSize();
  1379. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  1380. this.app.addEvent("resize", this.resetNodeSizeFun );
  1381. this.hideFun = this.hide.bind(this);
  1382. this.app.node.addEvent("mousedown", this.hideFun);
  1383. }.bind(this));
  1384. }.bind(this) )
  1385. },
  1386. loadStatusArea : function(){
  1387. var area = new Element("div", {
  1388. "styles" : this.css.statusArea
  1389. }).inject( this.contentNode );
  1390. var lp = this.lp.config;
  1391. var html = "<div class='titleDiv'>"+lp.reportStatus+"</div>" +
  1392. "<div class = 'statusStyle'>"+
  1393. " <div class='statusIconStyle' style='background-color:"+ lp.waitColor +"'></div>" +
  1394. " <div class = 'statusTextStyle'>"+lp.wait+"</div></div>" +
  1395. "</div>"+
  1396. "<div class = 'statusStyle'>"+
  1397. " <div class='statusIconStyle' style='background-color:"+ lp.auditColor +"'></div>" +
  1398. " <div class = 'statusTextStyle'>"+lp.audit+"</div></div>" +
  1399. "</div>"+
  1400. "<div class = 'statusStyle'>"+
  1401. " <div class='statusIconStyle' style='background-color:"+ lp.progressColor +"'></div>" +
  1402. " <div class = 'statusTextStyle'>"+lp.progress+"</div></div>" +
  1403. "</div>"+
  1404. "<div class = 'statusStyle'>"+
  1405. " <div class='statusIconStyle' style='background-color:"+ lp.completedColor +"'></div>" +
  1406. " <div class = 'statusTextStyle'>"+lp.completed+"</div></div>" +
  1407. "</div>";
  1408. area.set("html", html);
  1409. area.getElements("div.titleDiv").setStyles( this.css.titleDiv );
  1410. area.getElements("div.statusStyle").setStyles( this.css.statusStyle );
  1411. area.getElements("div.statusIconStyle").setStyles( this.css.statusIconStyle );
  1412. area.getElements("div.statusIconStyle2").setStyles( this.css.statusIconStyle2 );
  1413. area.getElements("div.statusTextStyle").setStyles( this.css.statusTextStyle );
  1414. },
  1415. loadWaitDoNode: function(){
  1416. var area = new Element("div.reportArea", {
  1417. "styles" : this.css.reportArea
  1418. }).inject( this.contentNode );
  1419. new Element("div.titleDiv", {
  1420. "styles" : this.css.titleDiv,
  1421. "text" : this.lp.reportNotice
  1422. }).inject( area );
  1423. this.reportNode = Element("div", {
  1424. "styles" : this.css.reportNode
  1425. }).inject( area );
  1426. },
  1427. loadWaitDo : function( callback ){
  1428. var today = new Date();
  1429. var user = ( layout.desktop.session.user || layout.user );
  1430. var dn = user.distinguishedName;
  1431. var data = this.data;
  1432. if( user.distinguishedName ){
  1433. var userName = user.distinguishedName.split("@")[0]
  1434. }else{
  1435. var userName = user.name
  1436. }
  1437. var lp = data.length ? this.lp.reportTopInfor : this.lp.noReportTopInfor ;
  1438. this.reportTopNode = new Element("div", {
  1439. "styles" : this.css.reportTopNode,
  1440. "html" : lp.replace("{userName}",userName).replace("{count}",data.length )
  1441. }).inject( this.reportNode );
  1442. this.scrollNode = new Element("div.scrollNode", {
  1443. "styles" : this.css.scrollNode
  1444. }).inject( this.reportNode );
  1445. this.reportItemContainer = new Element("div.reportItemContainer", {
  1446. "styles" : this.css.reportItemContainer
  1447. }).inject( this.scrollNode );
  1448. data.each( function( d, i ){
  1449. var itemNode = new Element("div.reportItemNode", {
  1450. "styles" : this.css.reportItemNode,
  1451. "events" : {
  1452. click : function(){
  1453. this.obj.app.common.openReport( this.data );
  1454. }.bind({ obj : this, data : d })
  1455. }
  1456. }).inject( this.reportItemContainer );
  1457. this.tooltipList = this.tooltipList || [];
  1458. this.tooltipList.push( new MWF.xApplication.Report.ReportTooltip(this.app.content, itemNode, this.app, d, {
  1459. axis : "x",
  1460. hiddenDelay : 300,
  1461. displayDelay : 300
  1462. })
  1463. );
  1464. var colorNode = new Element("div.reportItemColorNode", {
  1465. "styles" : this.css.reportItemColorNode,
  1466. "text" : i+1
  1467. }).inject( itemNode );
  1468. var textNode = new Element("div.reportItemTextNode", {
  1469. "styles" : this.css.reportItemTextNode,
  1470. "text" : d.title
  1471. }).inject( itemNode );
  1472. var lp = this.lp.config;
  1473. var status;
  1474. if( d.reportStatus == "审核中" && user.distinguishedName == d.currentPersonName ){
  1475. status = "需要我审核"
  1476. }else{
  1477. status = d.reportStatus;
  1478. }
  1479. switch (status){
  1480. case "汇报者填写":
  1481. colorNode.setStyles({ "background-color": lp.waitColor });
  1482. break;
  1483. case "审核中":
  1484. colorNode.setStyles({ "background-color": lp.progressColor });
  1485. break;
  1486. case "需要我审核":
  1487. colorNode.setStyles({ "background-color": lp.auditColor });
  1488. break;
  1489. case "已完成":
  1490. colorNode.setStyles({ "background-color": lp.completedColor });
  1491. break;
  1492. }
  1493. var y = itemNode.getSize().y ;
  1494. colorNode.setStyle("margin-top", ( y - 20)/2 );
  1495. }.bind(this));
  1496. this.setScrollBar( this.scrollNode );
  1497. if( callback )callback();
  1498. },
  1499. listData : function( callback ){
  1500. this.app.restActions.listReportNextWithFilter((0), 100, {
  1501. targetList : [this.app.userName],
  1502. reportStatus : "汇报者填写"
  1503. }, function(json){
  1504. if( !json.data )json.data = [];
  1505. this.data = json.data;
  1506. this.app.restActions.listReportNextWithFilter((0), 100, {
  1507. currentPersonList : [this.app.userName],
  1508. reportStatus : "审核中"
  1509. }, function(j){
  1510. if( !j.data )j.data = [];
  1511. j.data.each( function( j ){
  1512. this.data.push( j );
  1513. }.bind(this));
  1514. if (callback)callback();
  1515. }.bind(this));
  1516. }.bind(this));
  1517. },
  1518. trigger : function(){
  1519. this.isHidden ? this.show( true ) : this.hide( true )
  1520. },
  1521. hide: function( isFireEvent ){
  1522. var x = this.node.getSize().x - 9;
  1523. var fx = new Fx.Morph(this.node, {
  1524. "duration": "300",
  1525. "transition": Fx.Transitions.Expo.easeOut
  1526. });
  1527. fx.start({
  1528. //"opacity": 0
  1529. }).chain(function(){
  1530. this.isHidden = true;
  1531. //this.node.setStyle("display", "none");
  1532. this.node.setStyles({
  1533. "right": "-"+x+"px"
  1534. });
  1535. this.trapezoid.setStyles( this.css.trapezoid_toLeft );
  1536. //if(isFireEvent)this.app.fireEvent("resize");
  1537. }.bind(this));
  1538. },
  1539. show: function( isFireEvent ){
  1540. this.node.setStyles(this.css.node);
  1541. this.trapezoid.setStyles( this.css.trapezoid_toRight );
  1542. //var x = this.node.getSize().x - 8;
  1543. //this.node.setStyles( "right", "-"+x+"px" );
  1544. var fx = new Fx.Morph(this.node, {
  1545. "duration": "500",
  1546. "transition": Fx.Transitions.Expo.easeOut
  1547. });
  1548. this.app.fireAppEvent("resize");
  1549. fx.start({
  1550. "opacity": 1
  1551. }).chain(function(){
  1552. this.node.setStyles({
  1553. //"position": "static",
  1554. //"width": "auto"
  1555. "right": "0px"
  1556. });
  1557. this.isHidden = false;
  1558. //if(isFireEvent)this.app.fireEvent("resize");
  1559. }.bind(this))
  1560. },
  1561. //show: function(){
  1562. // this.node.setStyles(this.css.configNode);
  1563. // var fx = new Fx.Morph(this.node, {
  1564. // "duration": "500",
  1565. // "transition": Fx.Transitions.Expo.easeOut
  1566. // });
  1567. // fx.start({
  1568. // "opacity": 1
  1569. // }).chain(function(){
  1570. // this.hideFun = this.hide.bind(this);
  1571. // this.app.content.addEvent("mousedown", this.hideFun);
  1572. // }.bind(this));
  1573. //},
  1574. //hide: function(){
  1575. // this.node.destroy();
  1576. // this.app.content.removeEvent("mousedown", this.hideFun);
  1577. // MWF.release(this);
  1578. //},
  1579. resetNodeSize: function(){
  1580. var size = this.container.getSize();
  1581. this.node.setStyle("height", size.y - 50 );
  1582. this.trapezoid.setStyle("top", ( (size.y - 50)/2 - this.trapezoid.getSize().y/2 ));
  1583. var y = size.y - 395;
  1584. var meetContainerY = this.reportItemContainer.getSize().y + 12;
  1585. this.scrollNode.setStyle("height", Math.min( y, meetContainerY ) );
  1586. },
  1587. getSize : function(){
  1588. //var size = this.node.getSize();
  1589. //return {
  1590. // x : this.isHidden ? 9 : size.x,
  1591. // y : size.y
  1592. //}
  1593. return { x : 9, y : 0 }
  1594. },
  1595. showByType : function( type ){
  1596. },
  1597. reload : function(){
  1598. this.destory();
  1599. this.app.reload();
  1600. },
  1601. openReport : function( data ){
  1602. var form = new MWF.xApplication.Report.ReportForm(this, data, {}, {app:this.app});
  1603. form.view = this.app;
  1604. form.open();
  1605. },
  1606. destory : function(){
  1607. this.tooltipList.each( function( t ){
  1608. t.destory();
  1609. });
  1610. this.app.removeEvent("resize", this.resetNodeSizeFun );
  1611. this.app.node.removeEvent("mousedown", this.hideFun);
  1612. this.node.destory();
  1613. }
  1614. });
  1615. MWF.xApplication.Report.ReportArea = new Class({
  1616. initialize: function(container, view, data){
  1617. this.container = container;
  1618. this.view = view;
  1619. this.css = this.view.css;
  1620. this.app = this.view.app;
  1621. this.data = data;
  1622. this.beginDate = Date.parse(this.data.startTime);
  1623. this.endDate = Date.parse(this.data.completedTime);
  1624. this.userName = ( layout.desktop.session.user || layout.user ).distinguishedName;
  1625. this.userId = ( layout.desktop.session.user || layout.user ).id;
  1626. this.path = "../x_component_Report/$Common/default/reportarea/";
  1627. this.cssPath = "../x_component_Report/$Common/default/reportarea/css.wcss";
  1628. this._loadCss();
  1629. this.load();
  1630. },
  1631. load: function(){
  1632. var d = this.data;
  1633. this.node = new Element("div", {"styles": this.css.reportNode}).inject( this.container );
  1634. this.node.addEvents({
  1635. mouseenter : function(){
  1636. this.node.setStyles( this.css.reportNode_over );
  1637. this.subjectNode.setStyles( this.css.reportSubjectNode_over );
  1638. }.bind(this),
  1639. mouseleave : function(){
  1640. this.node.setStyles( this.css.reportNode );
  1641. this.subjectNode.setStyles( this.css.reportSubjectNode );
  1642. }.bind(this),
  1643. click : function(){
  1644. this.openReport()
  1645. }.bind(this)
  1646. });
  1647. this.colorNode = new Element("div", {"styles": this.css.reportColorNode}).inject(this.node);
  1648. this.contentNode = new Element("div", {"styles": this.css.reportContentNode}).inject(this.node);
  1649. //var beginTime = (this.beginDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.beginDate.getHours() ) + ":" + this.getString( this.beginDate.getMinutes() );
  1650. //var endTime = (this.endDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.endDate.getHours() ) + ":" + this.getString( this.endDate.getMinutes() );
  1651. //this.timeNode = new Element("div", {
  1652. // "styles": this.css.reportTimeNode,
  1653. // "text" : beginTime + "-" + endTime
  1654. //}).inject(this.contentNode);
  1655. this.subjectNode = new Element("div", {
  1656. "styles": this.css.reportSubjectNode,
  1657. "text": this.data.title
  1658. }).inject(this.contentNode);
  1659. this.descriptionNode = new Element("div", {
  1660. "styles": this.css.reportDescriptionNode,
  1661. "text" : this.app.lp[d.reportObjType] + this.app.lp[d.reportType] + " " +
  1662. ( d.currentPersonName ? d.currentPersonName.split("@")[0] + " " : "" ) + d.activityName 
  1663. }).inject(this.contentNode);
  1664. var status;
  1665. var lp = this.app.lp.config;
  1666. if( d.reportStatus == "审核中" && this.app.userName == d.currentPersonName ){
  1667. status = "需要我审核"
  1668. }else{
  1669. status = d.reportStatus;
  1670. }
  1671. switch (status){
  1672. case "汇报者填写":
  1673. this.colorNode.setStyles({ "background-color": lp.waitColor });
  1674. break;
  1675. case "审核中":
  1676. this.colorNode.setStyles({ "background-color": lp.progressColor });
  1677. break;
  1678. case "需要我审核":
  1679. this.colorNode.setStyles({ "background-color": lp.auditColor });
  1680. break;
  1681. case "已完成":
  1682. this.colorNode.setStyles({ "background-color": lp.completedColor });
  1683. break;
  1684. }
  1685. this.resetNodeSize();
  1686. this.loadTooltip();
  1687. },
  1688. getString : function( str ){
  1689. var s = "00" + str;
  1690. return s.substr(s.length - 2, 2 );
  1691. },
  1692. _loadCss: function(){
  1693. var key = encodeURIComponent(this.cssPath);
  1694. if (MWF.widget.css[key]){
  1695. this.css = MWF.widget.css[key];
  1696. }else{
  1697. var r = new Request.JSON({
  1698. url: this.cssPath,
  1699. secure: false,
  1700. async: false,
  1701. method: "get",
  1702. noCache: false,
  1703. onSuccess: function(responseJSON, responseText){
  1704. this.css = responseJSON;
  1705. MWF.widget.css[key] = responseJSON;
  1706. }.bind(this),
  1707. onError: function(text, error){
  1708. alert(error + text);
  1709. }
  1710. });
  1711. r.send();
  1712. }
  1713. },
  1714. loadTooltip : function( isHideAttachment ){
  1715. this.tooltip = new MWF.xApplication.Report.ReportTooltip(this.app.content, this.node, this.app, this.data, {
  1716. axis : "x",
  1717. hiddenDelay : 300,
  1718. displayDelay : 300,
  1719. isHideAttachment : isHideAttachment
  1720. });
  1721. },
  1722. openReport : function(){
  1723. this.app.common.openReport( this.data, this.view )
  1724. },
  1725. resetNodeSize: function(){
  1726. var contentSize = this.contentNode.getSize();
  1727. this.colorNode.setStyle("height", contentSize.y );
  1728. },
  1729. destroy: function(){
  1730. if(this.tooltip)this.tooltip.destroy();
  1731. this.node.destroy();
  1732. MWF.release(this);
  1733. }
  1734. });
  1735. MWF.xApplication.Report.KeyWorkTooltip = new Class({
  1736. Extends: MTooltips,
  1737. _loadCustom : function( callback ){
  1738. if(callback)callback();
  1739. },
  1740. _getHtml : function(){
  1741. var d = this.data;
  1742. var lp = this.lp.keyWorkList.popupForm;
  1743. var titleStyle = "font-size:14px;color:#333;";
  1744. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1745. var department = [];
  1746. if( d.deptlist ){
  1747. d.deptlist.each( function( dept ){
  1748. department.push( dept.split("@")[0] )
  1749. })
  1750. }
  1751. var html =
  1752. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1753. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.keyWorkList.name +"</div>"+
  1754. "</div>"+
  1755. "<div style='font-size: 16px;color:#333;padding:0px 10px 15px 20px;'>"+ d.strategydeploytitle +"</div>"+
  1756. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1757. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1758. "<tr><td style='"+titleStyle+"' width='80'>"+ lp.sequencenumber+":</td>" +
  1759. " <td style='"+valueStyle+"'>"+ d.sequencenumber +"</td></tr>" +
  1760. "<tr><td style='"+titleStyle+"'>"+ lp.year +":</td>" +
  1761. " <td style='"+valueStyle+"'>"+ d.strategydeployyear+"</td></tr>" +
  1762. "<tr style='display: "+ (department.length ? "" : "none") +"'><td style='"+titleStyle+"'>"+ lp.department +":</td>" +
  1763. " <td style='"+valueStyle+"'>"+ department.join(" ") +"</td></tr>" +
  1764. "<tr><td style='"+titleStyle+"'>"+ lp.description+":</td>" +
  1765. " <td style='"+valueStyle+"'>"+ d.strategydeploydescribe +"</td></tr>" +
  1766. "</table>";
  1767. return html;
  1768. }
  1769. });
  1770. MWF.xApplication.Report.MeasureTooltip = new Class({
  1771. Extends: MTooltips,
  1772. _loadCustom : function( callback ){
  1773. //if( this.options.measureId ){
  1774. // this.app.restActions.getMeasureById( this.options.measureId, function( json ){
  1775. // this.measureData = json.data;
  1776. // this.setContent();
  1777. // if(callback)callback();
  1778. // }.bind(this))
  1779. //}else{
  1780. // if(callback)callback();
  1781. //}
  1782. //this.measureData = this.data;
  1783. //if(callback)callback();
  1784. var d = this.data;
  1785. var lp = this.lp.measure.popupForm;
  1786. var department = [];
  1787. d.deptlist.each( function( dept ){
  1788. department.push( dept.split("@")[0] )
  1789. });
  1790. var table = new Element( "table", {
  1791. "width":"100%",
  1792. "border":"0",
  1793. "cellpadding":"5",
  1794. "cellspacing":"0",
  1795. "styles" : this.css.formTable
  1796. }).inject( this.contentNode );
  1797. var tr = new Element("tr").inject( table );
  1798. new Element("td", {
  1799. "text" : "举措",
  1800. "width" : "70",
  1801. "styles": this.css.formTableTitle
  1802. }).inject( tr );
  1803. var td =new Element("td", {
  1804. "styles": this.css.formTableValue,
  1805. "text" : d.measuresinfotitle
  1806. }).inject( tr );
  1807. tr = new Element("tr").inject( table );
  1808. new Element("td", {
  1809. "text" : lp.sequencenumber,
  1810. "width" : "70",
  1811. "styles": this.css.formTableTitle
  1812. }).inject( tr );
  1813. var td =new Element("td", {
  1814. "styles": this.css.formTableValue,
  1815. "text" : d.sequencenumber
  1816. }).inject( tr );
  1817. tr = new Element("tr").inject( table );
  1818. new Element("td", {
  1819. "text" : lp.year,
  1820. "width" : "70",
  1821. "styles": this.css.formTableTitle
  1822. }).inject( tr );
  1823. var td =new Element("td", {
  1824. "styles": this.css.formTableValue,
  1825. "text" : d.measuresinfoyear
  1826. }).inject( tr );
  1827. tr = new Element("tr").inject( table );
  1828. new Element("td", {
  1829. "text" : lp.department,
  1830. "width" : "70",
  1831. "styles": this.css.formTableTitle
  1832. }).inject( tr );
  1833. var td =new Element("td", {
  1834. "styles": this.css.formTableValue,
  1835. "text" : department.join(" ")
  1836. }).inject( tr );
  1837. tr = new Element("tr").inject( table );
  1838. new Element("td", {
  1839. "text" : lp.description,
  1840. "width" : "70",
  1841. "styles": this.css.formTableTitle
  1842. }).inject( tr );
  1843. var td =new Element("td", {
  1844. "styles": this.css.formTableValue,
  1845. "text" : d.measuresinfodescribe
  1846. }).inject( tr );
  1847. if(callback)callback();
  1848. },
  1849. setContent : function(){
  1850. //this.contentNode.set( "html", this._getHtml() );
  1851. },
  1852. _getHtml : function(){
  1853. //if( !this.data )return;
  1854. //var d = this.measureData || this.data;
  1855. //var lp = this.lp.measure.popupForm;
  1856. //
  1857. //var titleStyle = "font-size:14px;color:#333";
  1858. //var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1859. //
  1860. //var department = [];
  1861. //d.deptlist.each( function( dept ){
  1862. // department.push( dept.split("@")[0] )
  1863. //});
  1864. //
  1865. //var html =
  1866. // "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1867. // " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.measure.name +"</div>"+
  1868. // "</div>"+
  1869. // "<div style='font-size: 16px;color:#333;padding:0px 10px 15px 20px;'>"+ d.measuresinfotitle +"</div>"+
  1870. // "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1871. // "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1872. // "<tr><td style='"+titleStyle+"' width='80'>"+ lp.sequencenumber+":</td>" +
  1873. // " <td style='"+valueStyle+"'>"+ d.sequencenumber +"</td></tr>" +
  1874. // "<tr><td style='"+titleStyle+"'>"+ lp.year +":</td>" +
  1875. // " <td style='"+valueStyle+"'>"+ d.measuresinfoyear+"</td></tr>" +
  1876. // "<tr><td style='"+titleStyle+"'>"+ lp.department +":</td>" +
  1877. // " <td style='"+valueStyle+"'>"+ department.join(" ") +"</td></tr>" +
  1878. // "<tr><td style='"+titleStyle+"'>"+ lp.description+":</td>" +
  1879. // " <td style='"+valueStyle+"'>"+ d.measuresinfodescribe +"</td></tr>" +
  1880. // "</table>";
  1881. //return html;
  1882. }
  1883. });
  1884. MWF.xApplication.Report.PriorityTooltip = new Class({
  1885. Extends: MTooltips,
  1886. _loadCustom : function( callback ){
  1887. if( this.data.keyWorkId ){
  1888. this.app.strategyActions.getPriorityById( this.data.keyWorkId, function( json ){
  1889. this.priorityData = json.data;
  1890. this.setContent();
  1891. if(callback)callback();
  1892. }.bind(this))
  1893. }else{
  1894. if(callback)callback();
  1895. }
  1896. },
  1897. setContent : function(){
  1898. this.contentNode.set( "html", this._getHtml() );
  1899. },
  1900. _getHtml : function(){
  1901. if( !this.priorityData && this.data.keyWorkId )return;
  1902. var d = this.priorityData || this.data;
  1903. var lp = this.lp.priority.popupForm;
  1904. var titleStyle = "font-size:14px;color:#333";
  1905. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1906. var html =
  1907. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1908. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.priority.name +"</div>"+
  1909. "</div>"+
  1910. "<div style='font-size: 16px;color:#333;padding:0px 10px 15px 20px;'>"+ d.keyworktitle +"</div>"+
  1911. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1912. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1913. "<tr><td style='"+titleStyle+"' width='80'>"+ lp.sequencenumber+":</td>" +
  1914. " <td style='"+valueStyle+"'>"+ d.sequencenumber +"</td></tr>" +
  1915. "<tr><td style='"+titleStyle+"'>"+ lp.year +":</td>" +
  1916. " <td style='"+valueStyle+"'>"+ d.keyworkyear+"</td></tr>" +
  1917. "<tr><td style='"+titleStyle+"'>"+ lp.validDate +":</td>" +
  1918. " <td style='"+valueStyle+"'>"+ d.keyworkbegindate + " "+ lp.validDateConnect + " "+ d.keyworkenddate +"</td></tr>" +
  1919. "<tr><td style='"+titleStyle+"'>"+ lp.department +":</td>" +
  1920. " <td style='"+valueStyle+"'>"+ (d.keyworkunit ? d.keyworkunit.split("@")[0] : "") +"</td></tr>" +
  1921. "<tr><td style='"+titleStyle+"'>"+ lp.description+":</td>" +
  1922. " <td style='"+valueStyle+"'>"+ d.keyworkdescribe +"</td></tr>" +
  1923. "</table>";
  1924. return html;
  1925. }
  1926. });
  1927. MWF.xApplication.Report.ShowMeasureTooltip = new Class({
  1928. Extends: MTooltips,
  1929. options : {
  1930. overflow : "scroll",
  1931. nextMonth : false
  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. var selectableMeasures = this.options.nextMonth ? data.nextMonth_selectableMeasures : data.selectableMeasures;
  1940. ( selectableMeasures || [] ).each( function( measure ){
  1941. measureObject[ measure.id ] = measure;
  1942. }.bind(this));
  1943. this.measuresList.each( function( id ){
  1944. var measure = measureObject[id];
  1945. if( measure ){
  1946. var table = new Element( "table", {
  1947. "width":"100%",
  1948. "border":"0",
  1949. "cellpadding":"5",
  1950. "cellspacing":"0",
  1951. "styles" : this.css.formTable
  1952. }).inject( measureNode );
  1953. var tr = new Element("tr").inject( table );
  1954. new Element("td", {
  1955. "text" : "举措",
  1956. "width" : "70",
  1957. "styles": this.css.formTableTitle
  1958. }).inject( tr );
  1959. new Element("td", {
  1960. "text": measure.measuresinfotitle,
  1961. "styles": this.css.formTableValue
  1962. }).inject( tr );
  1963. tr = new Element("tr").inject( table );
  1964. new Element("td", {
  1965. "text" : "内容",
  1966. "styles": this.css.formTableTitle
  1967. }).inject( tr );
  1968. new Element("td", {
  1969. "text": measure.measuresinfodescribe,
  1970. "styles": this.css.formTableValue
  1971. }).inject( tr );
  1972. }
  1973. }.bind(this));
  1974. if(callback)callback();
  1975. }
  1976. });
  1977. MWF.xApplication.Report.SelectMeasureTooltips = new Class({
  1978. Extends: MTooltips,
  1979. options : {
  1980. overflow : "scroll"
  1981. },
  1982. _loadCustom : function( callback ){
  1983. var data = this.data;
  1984. var measureNode = new Element("div", {
  1985. //styles : this.css.measureDeployNode
  1986. }).inject( this.contentNode );
  1987. measureNode.setStyle("padding-bottom", "10px");
  1988. //var measureObject = {};
  1989. ( data.nextMonth_selectableMeasures || [] ).each( function( measure ){
  1990. //measureObject[ measure.id ] = measure;
  1991. var table = new Element( "table", {
  1992. "width":"100%",
  1993. "border":"0",
  1994. "cellpadding":"5",
  1995. "cellspacing":"0",
  1996. "styles" : this.css.formTable
  1997. }).inject( measureNode );
  1998. var tr = new Element("tr").inject( table );
  1999. tr = new Element("tr").inject( table );
  2000. new Element("td", {
  2001. "text" : "举措",
  2002. "width" : "70",
  2003. "styles": this.css.formTableTitle
  2004. }).inject( tr );
  2005. var td =new Element("td", {
  2006. "styles": this.css.formTableValue
  2007. }).inject( tr );
  2008. var table_select = new Element( "table", {
  2009. "width":"100%",
  2010. "border":"0",
  2011. "cellpadding":"0",
  2012. "cellspacing":"0"
  2013. }).inject( td );
  2014. var tr_select = new Element("tr").inject( table_select );
  2015. var td_select =new Element("td", { width : "30" }).inject( tr_select );
  2016. var checkbox = new Element( "input", {
  2017. type : "checkbox",
  2018. "data-id" : measure.id,
  2019. checked : this.measuresList.contains( measure.id )
  2020. }).inject( td_select );
  2021. checkbox.addEvent("click", function(){
  2022. var value = [];
  2023. this.contentNode.getElements("input[type='checkbox']").each( function( checkbox ){
  2024. if( checkbox.get("checked") ){
  2025. value.push( checkbox.get("data-id") );
  2026. }
  2027. }.bind(this));
  2028. var list = [];
  2029. ( this.data.nextMonth_selectableMeasures || [] ).each( function( measure ){
  2030. if( value.contains( measure.id ) ){
  2031. list.push( measure )
  2032. }
  2033. }.bind(this));
  2034. this.fireEvent("select", [list, value]);
  2035. }.bind(this));
  2036. var td_select =new Element("td").inject( tr_select );
  2037. new Element("div", { "text": measure.measuresinfotitle }).inject( td_select );
  2038. tr = new Element("tr").inject( table );
  2039. new Element("td", {
  2040. "text" : "内容",
  2041. "styles": this.css.formTableTitle
  2042. }).inject( tr );
  2043. new Element("td", {
  2044. "text": measure.measuresinfodescribe,
  2045. "styles": this.css.formTableValue
  2046. }).inject( tr );
  2047. }.bind(this));
  2048. if(callback)callback();
  2049. }
  2050. });
  2051. MWF.xApplication.Report.SelectMeasureForm = new Class({
  2052. Extends: MPopupForm,
  2053. Implements: [Options, Events],
  2054. options: {
  2055. "style": "report",
  2056. "width": 800,
  2057. "height": 450,
  2058. "minWidth" : 700,
  2059. "minHeight" : 300,
  2060. "hasTop": true,
  2061. "hasIcon": false,
  2062. "hasTopIcon" : false,
  2063. "hasTopContent" : false,
  2064. "maxAction" : true,
  2065. "hasBottom": true,
  2066. "draggable": true,
  2067. "resizeable": true,
  2068. "editedAble" : true,
  2069. "closeAction": true
  2070. },
  2071. _createTableContent: function () {
  2072. var data = this.data;
  2073. this.formTopTextNode.set( "text", "选择举措" );
  2074. var node = new Element("div", {
  2075. styles : { "overflow": "hidden", "padding":"10px", "margin" : "20px 20px" }
  2076. }).inject( this.formTableArea );
  2077. //this.loadTooltip( keyworkNode, data, "keywork" );
  2078. var measureNode = new Element("div", {
  2079. styles : this.css.measureDeployNode
  2080. }).inject( node );
  2081. var measureIdList = [];
  2082. var measureTitleList = [];
  2083. var measureObject = {};
  2084. data.selectableMeasures.each( function( measure ){
  2085. measureIdList.push( measure.id );
  2086. measureTitleList.push( measure.measuresinfotitle );
  2087. measureObject[ measure.id ] = measure;
  2088. }.bind(this));
  2089. this.item = new MDomItem( measureNode, {
  2090. name : "measures", type : "checkbox", selectValue: measureIdList, selectText : measureTitleList, value : data.measuresList, style : { "overflow" : "hidden" },
  2091. onPostLoad : function( item ){
  2092. item.items.each( function( it ){
  2093. var iconNode = new Element("span", {
  2094. styles : this.css.measureIconNode
  2095. }).inject( it, "top" );
  2096. var id = it.getElement("input[type='checkbox']").get("value");
  2097. this.loadMeasureTooltip(iconNode, id);
  2098. var d = measureObject[id];
  2099. var descriptionNode = new Element("div",{
  2100. styles : this.css.measuresDescribeNode,
  2101. text : "工作内容:" + d.measuresinfodescribe
  2102. }).inject( it, "after" )
  2103. }.bind(this))
  2104. }.bind(this)
  2105. } , null, this.app, this.css);
  2106. this.item.load();
  2107. },
  2108. _createBottomContent: function () {
  2109. if (this.isNew || this.isEdited) {
  2110. this.okActionNode = new Element("button.inputOkButton", {
  2111. "styles": this.css.inputOkButton,
  2112. "text": "确定"
  2113. }).inject(this.formBottomNode);
  2114. this.okActionNode.addEvent("click", function (e) {
  2115. this.save(e);
  2116. }.bind(this));
  2117. }
  2118. this.cancelActionNode = new Element("button.inputCancelButton", {
  2119. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  2120. "text": this.lp.close
  2121. }).inject(this.formBottomNode);
  2122. this.cancelActionNode.addEvent("click", function (e) {
  2123. this.close(e);
  2124. }.bind(this));
  2125. },
  2126. loadMeasureTooltip: function( node, measureId ){
  2127. new MWF.xApplication.Report.MeasureTooltip( this.app.content, node, this.app, null, {
  2128. position : { x : "right", y : "auto" },
  2129. measureId : measureId,
  2130. displayDelay : 300
  2131. })
  2132. },
  2133. save: function(){
  2134. var list = [];
  2135. var value = this.item.getValue();
  2136. this.data.selectableMeasures.each( function( measure ){
  2137. if( value.contains( measure.id ) ){
  2138. list.push( measure )
  2139. }
  2140. }.bind(this));
  2141. this.fireEvent("postOk", [list, value]);
  2142. this.close()
  2143. }
  2144. });
  2145. MWF.xApplication.Report.StatisticsForm = new Class({
  2146. Extends: MPopupForm,
  2147. Implements: [Options, Events],
  2148. options: {
  2149. "style": "report",
  2150. "width": 800,
  2151. "height": 450,
  2152. "hasTop": true,
  2153. "hasIcon": false,
  2154. "maxAction" : true,
  2155. "draggable": true,
  2156. "resizeable": true,
  2157. "editedAble" : true,
  2158. "category" : ""
  2159. },
  2160. _createTableContent: function () {
  2161. this.lp = {
  2162. ok : "导出",
  2163. close : "取消"
  2164. };
  2165. this.formTopTextNode.set( "text", "导出" );
  2166. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  2167. this.formTableArea.setStyle("margin-top","20px");
  2168. var selectAll = "";
  2169. if( this.app.common.isAdmin() || this.app.exportAllFlag ){
  2170. selectAll = "<tr><td styles='formTableTitleP14' lable='allUnit'></td>" +
  2171. " <td styles='formTableValueP14' item='allUnit' ></td></tr>"
  2172. }
  2173. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  2174. "<tr><td styles='formTableTitleP14' lable='year' width='20%'></td>" +
  2175. " <td styles='formTableValueP14' item='year'></td></tr>" +
  2176. "<tr><td styles='formTableTitleP14' lable='month'></td>" +
  2177. " <td styles='formTableValueP14' item='month' ></td></tr>" +
  2178. "<tr><td styles='formTableTitleP14' lable='wfProcessStatus'></td>" +
  2179. " <td styles='formTableValueP14' item='wfProcessStatus' ></td></tr>" +
  2180. "<tr><td styles='formTableTitleP14' lable='unitList'></td>" +
  2181. " <td styles='formTableValueP14' item='unitList' ></td></tr>" +
  2182. selectAll +
  2183. "</table>";
  2184. this.formTableArea.set("html", html);
  2185. this.loadForm()
  2186. },
  2187. loadForm : function( ){
  2188. var _self = this;
  2189. MWF.xDesktop.requireApp("Template", "MForm", function () {
  2190. this.form = new MForm(this.formTableArea, this.data, {
  2191. usesNewVersion : true,
  2192. isEdited: this.isEdited || this.isNew,
  2193. style : "report",
  2194. hasColon : true,
  2195. itemTemplate: {
  2196. year: { type : "select", notEmpty : true, text : "年度",
  2197. selectText : function(){
  2198. var arr = [];
  2199. var data = new Date();
  2200. data.decrement("year",5);
  2201. for( var i=0; i<11; i++ ){
  2202. data.increment("year",1);
  2203. arr.push(data.getFullYear()+ "年")
  2204. }
  2205. return arr
  2206. },
  2207. selectValue : function(){
  2208. var arr = [];
  2209. var data = new Date();
  2210. data.decrement("year",5);
  2211. for( var i=0; i<11; i++ ){
  2212. data.increment("year",1);
  2213. arr.push(data.getFullYear().toString())
  2214. }
  2215. return arr
  2216. },
  2217. defaultValue : (new Date()).getFullYear().toString(),
  2218. event : {
  2219. change : function(){
  2220. this.listUnitNamesForReport();
  2221. }.bind(this)
  2222. }
  2223. },
  2224. month: { type : "select", notEmpty : true, text : "月份",
  2225. selectText : ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"] ,
  2226. selectValue : ["01","02","03","04","05","06","07","08","09","10","11","12"],
  2227. defaultValue : (new Date().format("%m")).toString(),
  2228. event : {
  2229. change : function(){
  2230. this.listUnitNamesForReport();
  2231. }.bind(this)
  2232. }
  2233. },
  2234. unitList : { type : "checkbox", notEmpty : true, text : "部门" },
  2235. wfProcessStatus: { type : "select", text : "审批状态",
  2236. selectText : ["全部","已完成","流转中"] ,
  2237. selectValue : ["","已完成","流转中"],
  2238. event : {
  2239. change : function(){
  2240. this.listUnitNamesForReport();
  2241. }.bind(this)
  2242. }
  2243. },
  2244. allUnit : { type : "checkbox", text : "所有部门", selectValue : ["yes"], selectText : ["是"], event : {
  2245. change : function(item, ev){
  2246. if(item.getValue().join() == "yes"){
  2247. this.form.getItem("unitList").setValue( this.allUnitList );
  2248. }else{
  2249. this.form.getItem("unitList").setValue("");
  2250. }
  2251. }.bind(this)
  2252. }}
  2253. }
  2254. }, this.app);
  2255. this.form.load();
  2256. this.listUnitNamesForReport( (new Date()).getFullYear().toString(), (new Date().format("%m")).toString() )
  2257. }.bind(this), true);
  2258. },
  2259. listUnitNamesForReport : function(year, month, wfProcessStatus){
  2260. var unitListItem = this.formTableArea.getElement("[item='unitList']");
  2261. if(this.nounitListNode)this.nounitListNode.destroy();
  2262. if( !year )year = this.form.getItem("year").getValue();
  2263. if( !month )month = this.form.getItem("month").getValue();
  2264. if( !wfProcessStatus )wfProcessStatus = this.form.getItem("wfProcessStatus").getValue();
  2265. this.app.restActions.listUnitNamesForReport({
  2266. year : year,
  2267. month : month,
  2268. wfProcessStatus : wfProcessStatus ? [wfProcessStatus] : null
  2269. }, function( json ){
  2270. var value = this.allUnitList = [];
  2271. var text = [];
  2272. var data = json.data || [];
  2273. if( this.app.exportAllFlag ){
  2274. data.each( function( d ){
  2275. value.push(d.value );
  2276. text.push(d.value.split("@")[0] );
  2277. });
  2278. }else{
  2279. data.each(function(d){
  2280. if( this.app.unitWithExport.contains(d.value ) ){
  2281. value.push(d.value );
  2282. text.push(d.value.split("@")[0] );
  2283. }
  2284. }.bind(this));
  2285. }
  2286. if( value.length == 0 ){
  2287. this.form.getItem("unitList").disable();
  2288. this.nounitListNode = new Element("div", {
  2289. text : "系统未找"+year+"年"+ month +"月"+this.form.getItem("wfProcessStatus").getValue()+"的工作汇报"
  2290. }).inject( unitListItem );
  2291. var allUnit = this.form.getItem("allUnit");
  2292. if( allUnit ){
  2293. allUnit.setValue( "" );
  2294. }
  2295. }else{
  2296. if( this.nounitListNode )this.nounitListNode.destroy();
  2297. var unitList = this.form.getItem("unitList");
  2298. unitList.resetItemOptions( value, text, true );
  2299. unitList.setValue( this.allUnitList );
  2300. var allUnit = this.form.getItem("allUnit");
  2301. if( allUnit ){
  2302. allUnit.setValue( "yes" );
  2303. }
  2304. }
  2305. }.bind(this), null, false)
  2306. },
  2307. _createBottomContent: function () {
  2308. if (this.isNew || this.isEdited) {
  2309. this.okActionNode = new Element("button.inputOkButton", {
  2310. "styles": this.css.inputOkButton,
  2311. "text": this.lp.ok
  2312. }).inject(this.formBottomNode);
  2313. this.okActionNode.addEvent("click", function (e) {
  2314. this.export(e);
  2315. }.bind(this));
  2316. }
  2317. this.cancelActionNode = new Element("button.inputCancelButton", {
  2318. "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  2319. "text": this.lp.close
  2320. }).inject(this.formBottomNode);
  2321. this.cancelActionNode.addEvent("click", function (e) {
  2322. this.close(e);
  2323. }.bind(this));
  2324. },
  2325. export: function(){
  2326. var data = this.form.getResult(true,null,true,false,true);
  2327. if( data ){
  2328. data.wfProcessStatus = data.wfProcessStatus ? [data.wfProcessStatus] : null;
  2329. data.unitList = data.unitList || null;
  2330. this.app.restActions.statByUnit( data , function( json ){
  2331. if( json.data && json.data.id ){
  2332. this.app.restActions.getExportFileStream( json.data.id );
  2333. }else{
  2334. this.app.notice("系统中未找到指定条件的数据","error");
  2335. }
  2336. }.bind(this));
  2337. }
  2338. }
  2339. });
  2340. MWF.xApplication.Report.SummarizationForm = new Class({
  2341. Extends: MPopupForm,
  2342. Implements: [Options, Events],
  2343. options: {
  2344. "style": "report",
  2345. "width": "80%",
  2346. "height": "90%",
  2347. "hasTop": true,
  2348. "hasBottom": false,
  2349. "hasIcon": false,
  2350. "maxAction" : true,
  2351. "draggable": true,
  2352. "resizeable": true,
  2353. "editedAble" : true,
  2354. "category" : ""
  2355. },
  2356. createContent: function () {
  2357. this.tableContainer = new Element("div.formTabContainer",{
  2358. styles : {
  2359. "padding-top" : "10px",
  2360. "margin": "0px auto 20px",
  2361. "width": "90%"
  2362. }
  2363. }).inject(this.formNode);
  2364. this.formContentNode = new Element("div.formContentNode", {
  2365. "styles": this.css.formContentNode
  2366. }).inject(this.formNode);
  2367. this.formTableContainer = new Element("div.formTableContainer", {
  2368. "styles": this.css.formTableContainer
  2369. }).inject(this.formContentNode);
  2370. this.formTableArea = new Element("div.formTableArea", {
  2371. "styles": this.css.formTableArea
  2372. }).inject(this.formTableContainer);
  2373. this._createTableContent();
  2374. },
  2375. _createTableContent: function () {
  2376. this.lp = {
  2377. ok : "查询",
  2378. close : "取消"
  2379. };
  2380. this.formTopTextNode.set( "text", "部门五项重点工作统览" );
  2381. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  2382. this.formTableArea.setStyle("margin-top","20px");
  2383. this.formTableContainer.setStyle("width","90%");
  2384. var selectAll = "";
  2385. var html = "<table width='96%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  2386. "<tr><td styles='formTableTitleP14' lable='year'></td>" +
  2387. " <td styles='formTableValueP14' item='year'></td>" +
  2388. " <td styles='formTableTitleP14' lable='month'></td>" +
  2389. " <td styles='formTableValueP14' item='month' ></td>" +
  2390. " <td styles='formTableTitleP14' lable='wfProcessStatus'></td>" +
  2391. " <td styles='formTableValueP14' item='wfProcessStatus' ></td>" +
  2392. " <td styles='formTableValueP14' item='ok' style='width: 80px;'></td></tr>" +
  2393. "</table>";
  2394. this.tableContainer.set("html", html);
  2395. this.loadForm()
  2396. },
  2397. loadForm : function( ){
  2398. var _self = this;
  2399. MWF.xDesktop.requireApp("Template", "MForm", function () {
  2400. this.form = new MForm(this.tableContainer, this.data, {
  2401. usesNewVersion : true,
  2402. isEdited: this.isEdited || this.isNew,
  2403. style : "report",
  2404. hasColon : true,
  2405. itemTemplate: {
  2406. year: { type : "select", notEmpty : true, text : "年度",
  2407. selectText : function(){
  2408. var arr = [];
  2409. var data = new Date();
  2410. data.decrement("year",5);
  2411. for( var i=0; i<11; i++ ){
  2412. data.increment("year",1);
  2413. arr.push(data.getFullYear()+ "年")
  2414. }
  2415. return arr
  2416. },
  2417. selectValue : function(){
  2418. var arr = [];
  2419. var data = new Date();
  2420. data.decrement("year",5);
  2421. for( var i=0; i<11; i++ ){
  2422. data.increment("year",1);
  2423. arr.push(data.getFullYear().toString())
  2424. }
  2425. return arr
  2426. },
  2427. defaultValue : (new Date()).getFullYear().toString()
  2428. },
  2429. month: { type : "select", text : "月份",
  2430. selectText : ["全年","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"] ,
  2431. selectValue : ["","01","02","03","04","05","06","07","08","09","10","11","12"]
  2432. },
  2433. unitList : { type : "checkbox", text : "部门" },
  2434. ok : { type : "button", text : "查询", value : "查询", event : {
  2435. click : function(){ this.ok()}.bind(this)
  2436. } },
  2437. wfProcessStatus: { type : "select", text : "审批状态",
  2438. selectText : ["全部","已完成","流转中"] ,
  2439. selectValue : ["","已完成","流转中"]
  2440. }
  2441. }
  2442. }, this.app);
  2443. this.form.load();
  2444. this.ok();
  2445. }.bind(this), true);
  2446. },
  2447. ok: function(){
  2448. var data = this.form.getResult(true,null,true,false,true);
  2449. data.wfProcessStatus = data.wfProcessStatus ? [data.wfProcessStatus] : null;
  2450. if( !this.app.exportAllFlag )data.unitList = this.app.unitWithExport;
  2451. this.formTableArea.empty();
  2452. this.app.restActions.listWorkInfoByYear( data.year, data, function( json ){
  2453. var table = new Element( "table", {
  2454. "width":"96%",
  2455. "border":"0",
  2456. "cellpadding":"5",
  2457. "cellspacing":"0",
  2458. "styles" : this.form.css.formTable
  2459. }).inject( this.formTableArea );
  2460. var tr = new Element("tr").inject( table );
  2461. var td = new Element("th", {
  2462. "styles": this.form.css.formTableTitleP14,
  2463. "text" : "部门"
  2464. }).inject( tr );
  2465. var td = new Element("th", {
  2466. "styles": this.form.css.formTableTitleP14,
  2467. "text" : "月份"
  2468. }).inject( tr );
  2469. var td = new Element("th", {
  2470. "styles": this.form.css.formTableTitleP14,
  2471. "text" : "重点工作"
  2472. }).inject( tr );
  2473. json.data.each( function( data, i ){
  2474. tr = new Element("tr").inject( table );
  2475. var count = 0;
  2476. var firstTd = td = new Element("td", {
  2477. "styles": this.form.css.formTableValueP14,
  2478. "text" : data.unitName.split("@")[0] + "(" + data.workTotal + ")"
  2479. }).inject( tr );
  2480. td.setStyle("text-align","center");
  2481. if( data.workMonths ){
  2482. var flag = false;
  2483. data.workMonths.each( function( monthData, j ){
  2484. if( monthData.workInfoList ){
  2485. //if( j != 0 )tr = new Element("tr").inject( table );
  2486. if( flag ){
  2487. tr = new Element("tr").inject( table );
  2488. }else{
  2489. flag = true;
  2490. }
  2491. var count2 = 0;
  2492. var secondTd = td = new Element("td", {
  2493. "styles": this.form.css.formTableValueP14,
  2494. "text" : parseInt( monthData.month ) + "月"
  2495. }).inject( tr );
  2496. td.setStyle("text-align","center");
  2497. monthData.workInfoList.each( function( workInfo, k ){
  2498. count = count + 1;
  2499. count2 = count2 + 1;
  2500. if( k != 0 )tr = new Element("tr").inject( table );
  2501. var td = new Element("td", {
  2502. "styles": this.form.css.formTableValueP14,
  2503. "text" : workInfo.workName || "未设置"
  2504. }).inject( tr );
  2505. }.bind(this));
  2506. secondTd.set("rowspan",count2);
  2507. }
  2508. }.bind(this))
  2509. }
  2510. firstTd.set("rowspan",count);
  2511. }.bind(this))
  2512. }.bind(this))
  2513. },
  2514. setFormNodeSize: function (width, height, top, left) {
  2515. if (!width)width = this.options.width ? this.options.width : "50%";
  2516. if (!height)height = this.options.height ? this.options.height : "50%";
  2517. if (!top) top = this.options.top ? this.options.top : 0;
  2518. if (!left) left = this.options.left ? this.options.left : 0;
  2519. var containerSize = this.container.getSize();
  2520. if( containerSize.x < width )width = containerSize.x;
  2521. if( containerSize.y < height )height = containerSize.y;
  2522. var allSize = this.app.content.getSize();
  2523. var limitWidth = allSize.x; //window.screen.width
  2524. var limitHeight = allSize.y; //window.screen.height
  2525. "string" == typeof width && (1 < width.length && "%" == width.substr(width.length - 1, 1)) && (width = parseInt(limitWidth * parseInt(width, 10) / 100, 10));
  2526. "string" == typeof height && (1 < height.length && "%" == height.substr(height.length - 1, 1)) && (height = parseInt(limitHeight * parseInt(height, 10) / 100, 10));
  2527. 300 > width && (width = 300);
  2528. 220 > height && (height = 220);
  2529. top = top || parseInt((limitHeight - height) / 2, 10); //+appTitleSize.y);
  2530. left = left || parseInt((limitWidth - width) / 2, 10);
  2531. this.formAreaNode.setStyles({
  2532. "width": "" + width + "px",
  2533. "height": "" + height + "px",
  2534. "top": "" + top + "px",
  2535. "left": "" + left + "px"
  2536. });
  2537. this.formNode.setStyles({
  2538. "width": "" + width + "px",
  2539. "height": "" + height + "px"
  2540. });
  2541. var iconSize = this.formIconNode ? this.formIconNode.getSize() : {x: 0, y: 0};
  2542. var topSize = this.formTopNode ? this.formTopNode.getSize() : {x: 0, y: 0};
  2543. var bottomSize = this.formBottomNode ? this.formBottomNode.getSize() : {x: 0, y: 0};
  2544. var tabSize = this.tableContainer ? this.tableContainer.getSize() : {x: 0, y: 0};
  2545. var contentHeight = height - iconSize.y - topSize.y - bottomSize.y - tabSize.y - 30;
  2546. //var formMargin = formHeight -iconSize.y;
  2547. this.formContentNode.setStyles({
  2548. "height": "" + contentHeight + "px"
  2549. });
  2550. this.formTableContainer.setStyles({
  2551. "height": "" + contentHeight + "px"
  2552. });
  2553. }
  2554. });