StrategyExplorer.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. MWF.xDesktop.requireApp("Report", "Attachment", null, false);
  2. MWF.xDesktop.requireApp("Template", "MSelector", null, false);
  3. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  4. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  5. MWF.xApplication.Report.StrategyExplorer = new Class({
  6. Extends: MWF.widget.Common,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default",
  10. "id" : "",
  11. "type" : "app" //flow print
  12. },
  13. initialize: function( app, actions, options){
  14. this.setOptions(options);
  15. this.app = app;
  16. this.path = "../x_component_Report/$StrategyExplorer/";
  17. this.cssPath = "../x_component_Report/$StrategyExplorer/"+this.options.style+"/css.wcss";
  18. this._loadCss();
  19. this.lp = this.app.lp;
  20. this.actions = actions;
  21. },
  22. reload: function(){
  23. this.node.empty();
  24. this.loadLayout();
  25. },
  26. destroy : function(){
  27. if( this.options.type == "app" ){
  28. this.app.removeEvent("resize", this.resetNodeSizeFun );
  29. }
  30. this.node.empty();
  31. delete this;
  32. },
  33. load: function( callback ){
  34. if( this.reportContainer )this.node = $( this.reportContainer );
  35. //summaryContainer planContainer threeworkContainer
  36. this.loadLayout( callback );
  37. if( this.options.type == "app" ){
  38. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  39. this.app.addEvent("resize", this.resetNodeSizeFun );
  40. }
  41. },
  42. loadLayout : function(callback){
  43. this.createNode();
  44. this.actions.getReport( this.options.id, function( json ){
  45. this.data = json.data;
  46. if(callback)callback( this.data );
  47. this.userName = ( layout.desktop.session.user || layout.user ).distinguishedName;
  48. this.isEdited = false;
  49. this.getStatus( function(){
  50. this.app.setTitle( this.getTitle() );
  51. //this.createTopNode();
  52. this.loadContentNode();
  53. if( this.options.type == "app" ){
  54. this.resetNodeSize();
  55. }
  56. }.bind(this))
  57. }.bind(this));
  58. },
  59. getTitle : function(){
  60. var current = this.data.year + "年" + parseInt( this.data.month ) + "月工作总结";
  61. var nextMonth = new Date( this.data.year, parseInt( this.data.month ) - 1, 1 ).increment("month", 1);
  62. var next = nextMonth.getFullYear() + "年" + (nextMonth.getMonth() + 1) + "月工作计划";
  63. return this.data.targetUnit.split("@")[0] + current + "和" + next;
  64. },
  65. isToReadLeader : function( callback ){
  66. MWF.Actions.get("x_organization_assemble_express").getUnitWithIdentityAndLevelValue( {"identity":this.data.targetIdentity,"level":"1"}, function( json ){
  67. var topUnit = json.data.unit;
  68. if( topUnit ){
  69. MWF.Actions.get("x_organization_assemble_express").getDutyValue({"name":"董事长","unit":topUnit}, function( js ){
  70. var flag = false;
  71. var leaders = js.data.identityList || [];
  72. ( layout.desktop.session.user || layout.user ).identityList.each( function( id ){
  73. if( leaders.contains( id.distinguishedName ) ){
  74. flag = true;
  75. }
  76. });
  77. if( callback )callback( flag );
  78. }.bind(this))
  79. }else{
  80. if( callback )callback( false );
  81. }
  82. }.bind(this));
  83. },
  84. isToRead : function(){
  85. var flag = false;
  86. (this.workApp.readList || []).each( function( read ){
  87. if( this.userName == read.person ){
  88. flag = true;
  89. this.readData = read;
  90. }
  91. }.bind(this) );
  92. return flag;
  93. //return this.workApp.control.allowReadProcessing || false;
  94. },
  95. getStatus : function( callback ){
  96. this.isEdited = this.workApp.control.allowProcessing || this.workApp.control.allowSave;
  97. this.activityName = this.workApp.activity ? this.workApp.activity.name : "";
  98. this.activityAlias = this.workApp.activity ? this.workApp.activity.alias : "";
  99. if( this.data.reportStatus == "月度汇报员分派填写人" || this.data.activityName == "拟稿" || this.activityName == "月度汇报员分派填写人" || this.activityAlias == "deployment" ){
  100. this.status = "deployment";
  101. //if( ( this.app.common.isAdmin() || this.userName == this.data.targetPerson ) ){
  102. // this.isEdited = true;
  103. //}
  104. if( callback )callback();
  105. }else if( this.activityName == "汇报人" || this.activityAlias == "write" ) {
  106. this.status = "write";
  107. //this.app.common.getIdentity( "", function( identityList ){
  108. // var flag = false;
  109. // identityList.each( function( id ){
  110. // if( this.data.workreportPersonList.contains( id ) ){
  111. // flag = true;
  112. // }
  113. // }.bind(this));
  114. // if (( this.app.common.isAdmin() || this.userName == this.data.targetPerson || flag )) {
  115. // this.isEdited = true;
  116. // }
  117. // if( callback )callback();
  118. //}.bind(this))
  119. if( callback )callback();
  120. }else if( this.activityName == "月度汇报员汇总" || this.activityAlias == "confirm" ) {
  121. this.status = "confirm";
  122. //if (( this.app.common.isAdmin() || this.userName == this.data.targetPerson )) {
  123. // this.isEdited = true;
  124. //}
  125. if (callback)callback();
  126. }else if(this.activityName == "战略负责人审核" || this.activityAlias == "audit"){
  127. this.status = "audit";
  128. //if (( this.app.common.isAdmin() || this.userName == this.data.targetPerson )) {
  129. // this.isEdited = true;
  130. //}
  131. if (callback)callback();
  132. }else if(this.activityName == "公司领导阅" ){
  133. this.status = "summary";
  134. //if (( this.app.common.isAdmin() || this.userName == this.data.targetPerson )) {
  135. // this.isEdited = true;
  136. //}
  137. if (callback)callback();
  138. }else{
  139. this.status = "summary";
  140. //this.data.reportStatus == "审核中"
  141. //this.data.reportStatus == "已完成"
  142. //this.isEdited = false;
  143. if( callback )callback();
  144. }
  145. },
  146. createNode: function(){
  147. this.container = new Element("div.container", {
  148. "styles": this.css.container
  149. }).inject(this.node);
  150. this.contentContainer = new Element("div.contentContainerNode", {
  151. "styles": this.css[ this.options.type=="app" ? "contentContainer" : "contentContainer_flow"]
  152. }).inject(this.container);
  153. },
  154. createTopNode: function(){
  155. var topNode = this.topNode = new Element("div.topNode", {
  156. "styles": this.css.topNode
  157. }).inject(this.contentContainer);
  158. if(this.isPrinted)topNode.setStyle("width","auto");
  159. var topTitleMiddleNode = new Element("div.topTitleMiddleNode", {
  160. "styles": this.css.topTitleMiddleNode
  161. }).inject(topNode);
  162. var topItemTitleNode = new Element("div.topItemTitleNode", {
  163. "styles": this.css.topItemTitleNode,
  164. "text": this.lp.title
  165. }).inject(topTitleMiddleNode);
  166. topItemTitleNode.addEvent("click", function(){
  167. var appId = "Report";
  168. if (this.app.desktop.apps[appId]){
  169. this.app.desktop.apps[appId].setCurrent();
  170. }else {
  171. this.app.desktop.openApplication(null, "Report", {});
  172. }
  173. }.bind(this));
  174. var topItemSepNode = new Element("div.topItemSepNode", {
  175. "styles": this.css.topItemSepNode,
  176. "text" : ">"
  177. }).inject(topTitleMiddleNode);
  178. var topItemTitleNode = new Element("div.topItemTitleNode", {
  179. "styles": this.css.topItemTitleLastNode,
  180. "text": this.data.title
  181. }).inject(topTitleMiddleNode);
  182. },
  183. loadContentNode: function(){
  184. this.middleNode = new Element("div.middleNode", {
  185. "styles": this.css.middleNode
  186. }).inject(this.contentContainer);
  187. if(this.isPrinted)this.middleNode.setStyle("width","auto");
  188. this.inforNode = new Element("div",{
  189. "styles": this.css.inforNode
  190. }).inject( this.middleNode );
  191. //this.selectNode = new Element("div",{
  192. // "styles": this.css.selectNode
  193. //}).inject( this.middleNode );
  194. this.mainContentNode = new Element("div.mainContentNode", {
  195. "styles": this.css.mainContentNode
  196. }).inject(this.middleNode);
  197. this.loadInforContent();
  198. if( this.options.type == "print" ){
  199. MWF.xDesktop.requireApp("Report", "StrategyExplorerPrint", null, false);
  200. this.print = new MWF.xApplication.Report.StrategyExplorer.Print(this.mainContentNode, this, this.data, {
  201. isEdited : false,
  202. isKeyworkEdited : false,
  203. status : this.status
  204. });
  205. this.print.load();
  206. }else if( this.status == "deployment" ){
  207. MWF.xDesktop.requireApp("Report", "StrategyExplorerDeploy", null, false);
  208. this.deployment = new MWF.xApplication.Report.StrategyExplorer.Deployment(this.mainContentNode, this, this.data, {
  209. isEdited : this.isEdited,
  210. isKeyworkEdited : false //this.data.workPlanModifyable
  211. });
  212. this.deployment.load();
  213. }else if( this.status == "summary" ){
  214. var loadSummary = function( isToRead, isLeader ){
  215. MWF.xDesktop.requireApp("Report", "StrategyExplorerSummary", null, false);
  216. this.summary = new MWF.xApplication.Report.StrategyExplorer.Summary(this.mainContentNode, this, this.data, {
  217. isToRead : isToRead,
  218. isToReadLeader : isLeader,
  219. isEdited : this.isEdited,
  220. status : this.status
  221. });
  222. this.summary.load();
  223. }.bind(this);
  224. if( this.isToRead() ){
  225. this.isToReadLeader( function( isLeader ){
  226. loadSummary( true, isLeader );
  227. })
  228. }else{
  229. loadSummary( false, false );
  230. }
  231. }else{
  232. MWF.xDesktop.requireApp("Report", "StrategyExplorerWrite", null, false);
  233. this.write = new MWF.xApplication.Report.StrategyExplorer.Write(this.mainContentNode, this, this.data, {
  234. isEdited : this.isEdited,
  235. status : this.status
  236. });
  237. this.write.load();
  238. }
  239. },
  240. verifyProcess : function( status ){
  241. if( status == "confirm" || status == "audit" ){
  242. return this.write.verifyProcess( status )
  243. }
  244. return true;
  245. },
  246. loadInforContent: function(){
  247. if( this.status == "summary" || this.options.type == "print" ){
  248. var html = "<table width='96%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' >" +
  249. " <td styles='formTableTitleP10' lable='unitManager' style='width:90px;'></td>" +
  250. " <td styles='formTableValueP10' item='unitManager' style='width:100px;'></td>"+
  251. " <td styles='formTableTitleP10' lable='activityName2' style='width:50px;'></td>" +
  252. " <td styles='formTableValueP10' item='activityName2' style='width:100px;'></td>"+
  253. "</tr>";
  254. html +="</table>";
  255. this.inforNode.set("html", html);
  256. MWF.xDesktop.requireApp("Template", "MForm", function () {
  257. var form = new MForm(this.inforNode, this.data, {
  258. usesNewVersion : true,
  259. isEdited: false,
  260. style : "report",
  261. hasColon : true,
  262. itemTemplate: {
  263. createDateString: { text : this.lp.reportDate, type : "innertext"},
  264. unitManager: { text : "部主管", type : "org", orgType : "person", defaultValue : this.data.unitManager },
  265. activityName2: { text : this.lp.activityName, type : "innertext", defaultValue : ( this.data.reportStatus || this.data.activityName ) }
  266. }
  267. }, this);
  268. form.load();
  269. }.bind(this), true);
  270. }else{
  271. var html = "<table width='96%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' >" +
  272. " <td styles='formTableTitleP10' lable='targetPerson' style='width:90px;'></td>" +
  273. " <td styles='formTableValueP10' item='targetPerson' style='width:100px;'></td>"+
  274. " <td styles='formTableTitleP10' lable='activityName2' style='width:50px;'></td>" +
  275. " <td styles='formTableValueP10' item='activityName2' style='width:100px;'></td>"+
  276. "</tr>";
  277. if( this.status != "deployment" || this.options.type == "print" ){
  278. html += "<tr>"+
  279. " <td styles='formTableTitleP10' lable='currentPersonName' style='width:70px;'></td>" +
  280. " <td styles='formTableValueP10' item='currentPersonName' colspan='3'></td>"+
  281. "</tr>"
  282. }
  283. html +="</table>";
  284. this.inforNode.set("html", html);
  285. MWF.xDesktop.requireApp("Template", "MForm", function () {
  286. var form = new MForm(this.inforNode, this.data, {
  287. usesNewVersion : true,
  288. isEdited: false,
  289. style : "report",
  290. hasColon : true,
  291. itemTemplate: {
  292. createDateString: { text : this.lp.reportDate, type : "innertext"},
  293. targetPerson: { text : "月度汇报员", type : "org", orgType : "person"},
  294. currentPersonName: { text : "汇报人", type : "org", orgType : "person", defaultValue : this.data.workreportPersonList },
  295. reportObjType: { text : this.lp.reportObjType, type : "select", selectValue : ["","PERSON","UNIT"], selectText : ["","个人汇报","组织汇报"] },
  296. activityName2: { text : this.lp.activityName, type : "innertext", defaultValue : ( this.data.reportStatus || this.data.activityName ) }
  297. }
  298. }, this);
  299. form.load();
  300. }.bind(this), true);
  301. }
  302. },
  303. resetNodeSize: function () {
  304. var topSize = this.topNode ? this.topNode.getSize() : {"x": 0, "y": 0};
  305. var nodeSize = this.node.getSize();
  306. var pt = this.contentContainer.getStyle("padding-top").toFloat();
  307. var pb = this.contentContainer.getStyle("padding-bottom").toFloat();
  308. var height = nodeSize.y - pt - pb; //- topSize.y
  309. this.contentContainer.setStyle("height", "" + height + "px");
  310. },
  311. perview : function(){
  312. var url = this.getPerviewUrl();
  313. var previewer = new MWF.xApplication.Report.StrategyExplorer.Previewer(this, {
  314. url : url
  315. }, {}, { app: this.app });
  316. previewer.open();
  317. },
  318. getPerviewUrl : function(){
  319. var businessData = this.workApp.appForm.businessData;
  320. var application = (businessData.work) ? businessData.work.application : businessData.workCompleted.application;
  321. var appForm = this.workApp.appForm;
  322. var form = appForm.json.id;
  323. if (appForm.json.printForm) form = appForm.json.printForm;
  324. if ( businessData.workCompleted){
  325. var application = businessData.workCompleted.application;
  326. return window.location.protocol + "//" + window.location.host +"../x_component_Report/$Common/printWork.html?workCompletedId="+ businessData.workCompleted.id+"&app="+application+"&form="+form+"&debugger";
  327. }else{
  328. var application = businessData.work.application;
  329. return window.location.protocol + "//" + window.location.host +"../x_component_Report/$Common/printWork.html?workid="+ businessData.work.id+"&app="+application+"&form="+form+"&debugger";
  330. }
  331. }
  332. });
  333. MWF.xApplication.Report.StrategyExplorer.Previewer = new Class({
  334. Extends: MPopupForm,
  335. Implements: [Options, Events],
  336. options: {
  337. "style": "report",
  338. "width": "95%",
  339. "height": "95%",
  340. "minWidth" : 300,
  341. "minHeight" : 220,
  342. "hasTop": true,
  343. "hasTopIcon" : false,
  344. "hasTopContent" : false,
  345. "hasIcon": false,
  346. "hasScroll" : false,
  347. "hasBottom": true,
  348. "hasMask" : true,
  349. "closeByClickMask" : true,
  350. "title": "预览",
  351. "draggable": false,
  352. "resizeable" : false,
  353. "maxAction" : true,
  354. "closeAction": true,
  355. "relativeToApp" : true,
  356. "sizeRelateTo" : "app" //desktop
  357. },
  358. _createTableContent: function () {
  359. this.formTableContainer.setStyles({
  360. "width":"99%",
  361. "height" : "99%"
  362. });
  363. this.formTableArea.setStyle( "text-align","center" );
  364. this.iframe = new Element("iframe", {
  365. src : this.data.url,
  366. frameborder : 0,
  367. height : "100%",
  368. width : "100%",
  369. scrolling : "auto",
  370. seamless : "seamless"
  371. }).inject( this.formTableArea )
  372. },
  373. _setNodesSize : function(width, height, formContentHeight, formTableHeight ){
  374. this.iframe.set("width", width - 100 );
  375. this.iframe.set("height", formTableHeight - 5 );
  376. },
  377. _createBottomContent: function () {
  378. if (this.isNew || this.isEdited) {
  379. this.okActionNode = new Element("button.inputOkButton", {
  380. "styles": this.css.inputOkButton,
  381. "text": this.lp.save
  382. }).inject(this.formBottomNode);
  383. this.okActionNode.addEvent("click", function (e) {
  384. this.save(e);
  385. }.bind(this));
  386. }
  387. this.cancelActionNode = new Element("button.inputCancelButton", {
  388. "styles": (this.isEdited || this.isNew ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  389. "text": this.lp.close
  390. }).inject(this.formBottomNode);
  391. this.cancelActionNode.addEvent("click", function (e) {
  392. this.close(e);
  393. }.bind(this));
  394. }
  395. });