StrategyExplorerSummary.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. MWF.xApplication.Report.StrategyExplorer.Summary = new Class({
  2. Implements: [Options, Events],
  3. options: {
  4. "style": "default",
  5. "isEdited" : false,
  6. "status" : "summary",
  7. "isToRead" : false,
  8. "isToReadLeader" : false
  9. },
  10. initialize: function (container, explorer, data, options) {
  11. this.setOptions( options );
  12. this.container = container;
  13. this.explorer = explorer;
  14. this.app = this.explorer.app;
  15. this.lp = this.app.lp;
  16. this.css = this.explorer.css;
  17. this.actions = this.app.restActions;
  18. this.data = data;
  19. this.path = "/x_component_Report/$StrategyExplorer/";
  20. },
  21. load: function () {
  22. //this.node = new Element("div", {
  23. // styles : this.css.deplymentNode
  24. //}).inject( this.container );
  25. if( this.options.isToReadLeader ){
  26. this.loadLeaderRead();
  27. }else if( this.options.isToRead ){
  28. this.loadOpinion( true );
  29. }else if( this.data.detail.opinions ){
  30. var opinions = JSON.parse( this.data.detail.opinions );
  31. if( typeOf(opinions) == "array" ){
  32. this.loadOpinion( false );
  33. }
  34. }
  35. this._load();
  36. },
  37. loadOpinion : function( showBotton ){
  38. var table = new Element( "table", {
  39. "width":"96%",
  40. "border":"0",
  41. "cellpadding":"5",
  42. "cellspacing":"0",
  43. "styles" : this.css.formTable
  44. }).inject( this.explorer.ideaContainer );
  45. var tr = new Element("tr").inject( table );
  46. var td = new Element("td", {
  47. "styles": this.css.formTableTitle,
  48. "text" : "领导意见"
  49. }).inject( tr );
  50. td.setStyle("width","14%");
  51. var td = new Element("td", {
  52. "styles": this.css.formTableValue
  53. }).inject( tr );
  54. var opin = this.data.detail.opinions;
  55. if( opin ){
  56. var opinions = JSON.parse( opin );
  57. if( typeOf(opinions) == "array" ){
  58. var div = new Element("div").inject(td);
  59. opinions.each( function(o){
  60. var table1 = new Element( "table", {
  61. "width":"100%",
  62. "border":"0",
  63. "cellpadding":"0",
  64. "cellspacing":"0"
  65. }).inject( div );
  66. var tr1 = new Element("tr").inject( table1 );
  67. var td1 = new Element("td", {
  68. "text" : o.identity.split("@")[0] + ":"
  69. }).inject( tr1 );
  70. td1.setStyle("width","50px");
  71. td1 = new Element("td", {
  72. "text" : ( o.content ? this.app.common.replaceWithBr(o.content) : "已阅" ) + " (" + o.datetime + ")"
  73. }).inject( tr1 );
  74. }.bind(this));
  75. }
  76. }
  77. if(showBotton){
  78. div = new Element("div", {
  79. styles : { "margin-top" : "10px" }
  80. }).inject(td);
  81. var button = new Element("button",{
  82. value : "已阅",
  83. text : "已阅",
  84. styles : this.css.setRead
  85. }).inject(div);
  86. button.addEvent("click", function(e){
  87. this.setReaded(e)
  88. }.bind(this));
  89. }
  90. },
  91. loadLeaderRead : function(){
  92. var idea = "";
  93. if( this.data.detail.opinions ){
  94. var opinions = JSON.parse( this.data.detail.opinions );
  95. if( typeOf(opinions) == "array" ){
  96. opinions.each( function(o){
  97. if( o.name == this.explorer.userName ){
  98. idea = o.content;
  99. }
  100. }.bind(this));
  101. }
  102. }
  103. var table = new Element( "table", {
  104. "width":"96%",
  105. "border":"0",
  106. "cellpadding":"5",
  107. "cellspacing":"0",
  108. "styles" : this.css.formTable
  109. }).inject( this.explorer.ideaContainer );
  110. var tr = new Element("tr").inject( table );
  111. var td = new Element("td", {
  112. "styles": this.css.formTableTitle,
  113. "text" : "填写意见"
  114. }).inject( tr );
  115. td.setStyle("width","14%");
  116. var td = new Element("td", {
  117. "styles": this.css.formTableValue
  118. }).inject( tr );
  119. var div = new Element("div").inject(td);
  120. this.textarea_idea = new Element("textarea",{
  121. styles : this.css.textarea,
  122. value : idea
  123. }).inject( div );
  124. this.textarea_idea.addEvent("blur", function(){
  125. var data = [
  126. {
  127. "identity": null,
  128. "name": ( layout.desktop.session.user || layout.user ).distinguishedName,
  129. "activity": "领导阅知",
  130. "content": this.textarea_idea.get("value")
  131. }
  132. ];
  133. this.app.restActions.saveOpinion( this.data.id, {
  134. opinions : data
  135. })
  136. }.bind(this));
  137. div = new Element("div").inject(td);
  138. var button = new Element("button",{
  139. value : "已阅",
  140. text : "已阅",
  141. styles : this.css.setRead
  142. }).inject(div);
  143. button.addEvent("click", function(e){
  144. this.setReaded(e)
  145. }.bind(this));
  146. },
  147. getWorkId : function(){
  148. var workApp = this.explorer.workApp;
  149. if( workApp.work && workApp.work.id){
  150. return workApp.work.id
  151. }else if( workApp.workCompleted && workApp.workCompleted.id ){
  152. return workApp.workCompleted.id
  153. }else if( workApp.data && workApp.data.$work ){
  154. var work = workApp.data.$work;
  155. if( work.completed ){
  156. return work.workCompletedId;
  157. }else{
  158. return work.workId;
  159. }
  160. }
  161. },
  162. sendRead : function( callback ){
  163. MWF.Actions.get("x_organization_assemble_express").getDutyValue( {"name":"部主管","unit":this.data.targetUnit }, function( js ){
  164. var idList = js.data.identityList;
  165. if( idList && typeOf(idList)=="array" && idList.length > 0 ){
  166. var workId = this.getWorkId();
  167. MWF.Actions.get("x_processplatform_assemble_surface").sendReaderByWorkCompleted( function(){
  168. if( callback )callback();
  169. }.bind(this), null, workId, {"identityList":idList} ,false );
  170. }else{
  171. if( callback )callback();
  172. }
  173. }.bind(this))
  174. },
  175. setReaded: function(e){
  176. var _self = this;
  177. var _setReaded = function(){
  178. var readData = _self.explorer.readData;
  179. if( _self.textarea_idea ){
  180. readData.opinion = _self.textarea_idea.get("value").trim();
  181. }
  182. MWF.Actions.get("x_processplatform_assemble_surface").setReaded(function(){
  183. _self.app.notice("标记已阅成功!");
  184. _self.app.close();
  185. }.bind(_self), null, readData.id, readData );
  186. }.bind(this);
  187. var text = "您确定要标记为已阅吗?";
  188. this.app.confirm("infor", e, "标记已阅确认", text, 350, 130, function(){
  189. if( _self.options.isToReadLeader ){
  190. var value = _self.textarea_idea.get("value").trim();
  191. if( !value || value == "" ){
  192. _self.textarea_idea.set("value","已阅");
  193. //value="已阅";
  194. }
  195. var data = [
  196. {
  197. "identity": null,
  198. "name": ( layout.desktop.session.user || layout.user ).distinguishedName,
  199. "activity": "领导阅知",
  200. "content": _self.textarea_idea.get("value")
  201. }
  202. ];
  203. _self.app.restActions.saveOpinion( _self.data.id, {
  204. opinions : data
  205. }, function(){
  206. _self.app.restActions.modifyReportStatus( _self.data.id, { reportStatus : "结束" }, function(){
  207. _self.sendRead( function(){
  208. _setReaded();
  209. this.close();
  210. }.bind(this));
  211. }.bind(this))
  212. }.bind(this));
  213. //if( value ){
  214. // _self.sendRead( function(){
  215. // _setReaded();
  216. // this.close();
  217. // }.bind(this));
  218. //}else{
  219. // _setReaded();
  220. // this.close();
  221. //}
  222. }else{
  223. _setReaded();
  224. this.close();
  225. }
  226. }, function(){
  227. this.close();
  228. }, null, this.app.content);
  229. },
  230. _load : function(){
  231. this.month = parseInt(this.data.month);
  232. var table = this.table = new Element( "table", {
  233. "width":"96%",
  234. "border":"0",
  235. "cellpadding":"5",
  236. "cellspacing":"0",
  237. "styles" : this.css.formTable
  238. }).inject( this.explorer.totalContainer );
  239. var tr = new Element("tr").inject( table );
  240. new Element("td", { rowspan : 2, "width" : "30", "styles": this.css.formTableTitle, text : "序号" }).inject( tr );
  241. new Element("td", {
  242. "colspan" : 3,
  243. "text" : this.data.year + "年" + parseInt( this.data.month ) + "月工作总结",
  244. "width" : "140",
  245. "styles": this.css.formTableTitle
  246. }).inject( tr );
  247. var nextMonth = new Date( this.data.year, parseInt( this.data.month ) - 1, 1 ).increment("month", 1);
  248. var text = nextMonth.getFullYear() + "年" + (nextMonth.getMonth() + 1) + "月工作计划";
  249. new Element("td", {
  250. "colspan" : 2,
  251. "text" : text,
  252. "width" : "140",
  253. "styles": this.css.formTableTitle
  254. }).inject( tr );
  255. new Element("td", {
  256. rowspan : 2,
  257. "text" : "服务客户",
  258. "width" : "140",
  259. "styles": this.css.formTableTitle
  260. }).inject( tr );
  261. new Element("td", {
  262. rowspan : 2,
  263. "text" : "关爱员工",
  264. "width" : "140",
  265. "styles": this.css.formTableTitle
  266. }).inject( tr );
  267. new Element("td", {
  268. rowspan : 2,
  269. "text" : "意见建议",
  270. "width" : "140",
  271. "styles": this.css.formTableTitle
  272. }).inject( tr );
  273. var tr = new Element("tr").inject( table );
  274. new Element("td", {
  275. "text" : "部门重点工作",
  276. "width" : "140",
  277. "styles": this.css.formTableTitle
  278. }).inject( tr );
  279. new Element("td", {
  280. "text" : "计划",
  281. "width" : "140",
  282. "styles": this.css.formTableTitle
  283. }).inject( tr );
  284. new Element("td", {
  285. "text" : "总结",
  286. "width" : "140",
  287. "styles": this.css.formTableTitle
  288. }).inject( tr );
  289. new Element("td", {
  290. "text" : "部门重点工作",
  291. "width" : "140",
  292. "styles": this.css.formTableTitle
  293. }).inject( tr );
  294. new Element("td", {
  295. "text" : "计划",
  296. "width" : "140",
  297. "styles": this.css.formTableTitle
  298. }).inject( tr );
  299. this.listExtSummaryData( function(){
  300. this.loadContent()
  301. }.bind(this))
  302. },
  303. listExtSummaryData : function( callback ){
  304. //this.actions.listExtWorkWithReportId(this.options.reportId, { "infoLevel": "员工" }, function( json ){
  305. this.extSummaryData = this.data.WoReport_I_Ext_Contents_sumamry || [];
  306. if( callback )callback();
  307. },
  308. loadContent : function(){
  309. var arr = this.getTableData();
  310. arr.each( function( d ){
  311. var tr = new Element("tr").inject( this.table );
  312. new Element("td", {
  313. "text" : d.sequence,
  314. "align" : "center",
  315. "styles": this.css.formTableValue
  316. }).inject( tr );
  317. var td = new Element("td", {
  318. "html" : this.app.common.replaceWithBr(d.thisMonth.title),
  319. "width" : "140",
  320. "styles": this.css.formTableValue
  321. }).inject( tr );
  322. if( d.thisMonth.measuresList.length ){
  323. var showMeasureNode = new Element("input",{
  324. "type" : "button",
  325. "styles" : this.css.showMeasureNode2,
  326. "value" : "查看举措"
  327. }).inject( td );
  328. var tooltip = new MWF.xApplication.Report.ShowMeasureTooltip( this.app.content, showMeasureNode, this.app, this.data, {
  329. style : "report",
  330. position : { x : "auto", y : "auto" },
  331. event : "click"
  332. });
  333. tooltip.measuresList = d.thisMonth.measuresList;
  334. }
  335. new Element("td", {
  336. "html" : this.app.common.replaceWithBr(d.thisMonth.plan),
  337. "width" : "140",
  338. "styles": this.css.formTableValue
  339. }).inject( tr );
  340. new Element("td", {
  341. "html" : this.app.common.replaceWithBr(d.thisMonth.prog),
  342. "width" : "140",
  343. "styles": this.css.formTableValue
  344. }).inject( tr );
  345. td = new Element("td", {
  346. "html" : this.app.common.replaceWithBr(d.nextMonth.title),
  347. "width" : "140",
  348. "styles": this.css.formTableValue
  349. }).inject( tr );
  350. if( d.nextMonth.measuresList.length ){
  351. var showMeasureNode = new Element("input",{
  352. "type" : "button",
  353. "styles" : this.css.showMeasureNode2,
  354. "value" : "查看举措"
  355. }).inject( td );
  356. var tooltip = new MWF.xApplication.Report.ShowMeasureTooltip( this.app.content, showMeasureNode, this.app, this.data, {
  357. style : "report",
  358. nextMonth : true,
  359. position : { x : "auto", y : "auto" },
  360. event : "click"
  361. });
  362. tooltip.measuresList = d.nextMonth.measuresList;
  363. }
  364. new Element("td", {
  365. "html" : this.app.common.replaceWithBr(d.nextMonth.plan),
  366. "width" : "140",
  367. "styles": this.css.formTableValue
  368. }).inject( tr );
  369. new Element("td", {
  370. "html" : this.app.common.replaceWithBr(d.extWork.fuwu),
  371. "width" : "140",
  372. "styles": this.css.formTableValue
  373. }).inject( tr );
  374. new Element("td", {
  375. "html" : this.app.common.replaceWithBr(d.extWork.guanai),
  376. "width" : "140",
  377. "styles": this.css.formTableValue
  378. }).inject( tr );
  379. new Element("td", {
  380. "html" : this.app.common.replaceWithBr(d.extWork.yijian),
  381. "width" : "140",
  382. "styles": this.css.formTableValue
  383. }).inject( tr );
  384. }.bind(this))
  385. },
  386. getTableData : function(){
  387. this.tableData = [];
  388. for( var i=0; i<5; i++ ){
  389. var extWorkData = this.extSummaryData[i];
  390. var thisMonthData = this.data.thisMonth_workList[i];
  391. var nextMonthData = this.data.nextMonth_workList[i];
  392. var object = {
  393. sequence : i+1,
  394. thisMonth : {
  395. title : thisMonthData ? thisMonthData.workTitle : "",
  396. plan : thisMonthData ? thisMonthData.workPlanSummary : "",
  397. prog : thisMonthData ? thisMonthData.workProgSummary : "",
  398. measuresList : thisMonthData ? thisMonthData.measuresList : []
  399. },
  400. nextMonth : {
  401. title : nextMonthData ? nextMonthData.workTitle : "",
  402. plan : nextMonthData ? nextMonthData.workPlanSummary : "",
  403. measuresList : nextMonthData ? nextMonthData.measuresList : []
  404. },
  405. extWork : {
  406. fuwu : extWorkData ? extWorkData.fuwu : "",
  407. guanai : extWorkData ? extWorkData.guanai : "",
  408. yijian : extWorkData ? extWorkData.yijian : ""
  409. }
  410. };
  411. this.tableData.push( object );
  412. }
  413. return this.tableData;
  414. }
  415. });