Explorer.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. MWF.xDesktop.requireApp("Report", "Attachment", null, false);
  2. MWF.xApplication.Report.Explorer = new Class({
  3. Extends: MWF.widget.Common,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "id" : "",
  8. "type" : "app" //flow
  9. },
  10. initialize: function(node, app, actions, options){
  11. this.setOptions(options);
  12. this.app = app;
  13. this.path = "../x_component_Report/$Explorer/";
  14. this.cssPath = "../x_component_Report/$Explorer/"+this.options.style+"/css.wcss";
  15. this._loadCss();
  16. this.lp = this.app.lp;
  17. this.actions = actions;
  18. this.node = $(node);
  19. },
  20. reload: function(){
  21. this.node.empty();
  22. this.loadLayout();
  23. },
  24. destroy : function(){
  25. if( this.options.type != "flow" ){
  26. this.app.removeEvent("resize", this.resetNodeSizeFun );
  27. }
  28. this.node.empty();
  29. delete this;
  30. },
  31. load: function(){
  32. this.loadLayout();
  33. if( this.options.type != "flow" ){
  34. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  35. this.app.addEvent("resize", this.resetNodeSizeFun );
  36. }
  37. },
  38. loadLayout : function(){
  39. this.createNode();
  40. this.actions.getReport( this.options.id, function( json ){
  41. this.data = json.data;
  42. this.userName = ( layout.desktop.session.user || layout.user ).distinguishedName;
  43. this.isEdited = false;
  44. if( this.data.reportStatus == "汇报者填写" && ( this.app.common.isAdmin() || this.userName == this.data.targetPerson ) ){
  45. this.isEdited = true;
  46. }
  47. this.app.setTitle( this.data.title );
  48. this.createTopNode();
  49. this.loadContentNode();
  50. if( this.options.type != "flow" ){
  51. this.resetNodeSize();
  52. }
  53. }.bind(this));
  54. },
  55. createNode: function(){
  56. this.container = new Element("div.container", {
  57. "styles": this.css.container
  58. }).inject(this.node);
  59. this.contentContainer = new Element("div.contentContainerNode", {
  60. "styles": this.css[ this.options.type=="flow" ? "contentContainer_flow": "contentContainer" ]
  61. }).inject(this.container);
  62. },
  63. createTopNode: function(){
  64. var topNode = this.topNode = new Element("div.topNode", {
  65. "styles": this.css.topNode
  66. }).inject(this.contentContainer);
  67. var topTitleMiddleNode = new Element("div.topTitleMiddleNode", {
  68. "styles": this.css.topTitleMiddleNode
  69. }).inject(topNode);
  70. var topItemTitleNode = new Element("div.topItemTitleNode", {
  71. "styles": this.css.topItemTitleNode,
  72. "text": this.lp.title
  73. }).inject(topTitleMiddleNode);
  74. topItemTitleNode.addEvent("click", function(){
  75. var appId = "Report";
  76. if (this.app.desktop.apps[appId]){
  77. this.app.desktop.apps[appId].setCurrent();
  78. }else {
  79. this.app.desktop.openApplication(null, "Report", {});
  80. }
  81. }.bind(this));
  82. var topItemSepNode = new Element("div.topItemSepNode", {
  83. "styles": this.css.topItemSepNode,
  84. "text" : ">"
  85. }).inject(topTitleMiddleNode);
  86. var topItemTitleNode = new Element("div.topItemTitleNode", {
  87. "styles": this.css.topItemTitleLastNode,
  88. "text": this.data.title
  89. }).inject(topTitleMiddleNode);
  90. },
  91. loadContentNode: function(){
  92. this.middleNode = new Element("div.middleNode", {
  93. "styles": this.css.middleNode
  94. }).inject(this.contentContainer);
  95. this.inforNode = new Element("div",{
  96. "styles": this.css.inforNode
  97. }).inject( this.middleNode );
  98. this.planNode = new Element("div.listContainer", {
  99. styles : this.css.listContainer
  100. }).inject( this.middleNode );
  101. this.workNode = new Element("div.listContainer", {
  102. styles : this.css.listContainer
  103. }).inject( this.middleNode );
  104. this.planNodeNext = new Element("div.listContainer", {
  105. styles : this.css.listContainer
  106. }).inject( this.middleNode );
  107. this.loadInforContent();
  108. this.loadPlanTop( this.planNode, true, false );
  109. this.loadPlanView( this.planNode );
  110. this.loadWorkTop();
  111. this.loadWorkView();
  112. this.loadWorkAction();
  113. this.loadPlanTop( this.planNodeNext, true ,true );
  114. this.loadPlanViewNext( this.planNodeNext );
  115. this.loadPlanAction( this.planNodeNext );
  116. },
  117. loadInforContent: function(){
  118. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' >" +
  119. "<tr><td styles='formTableTitleP10' lable='createDateString'></td>" +
  120. " <td styles='formTableValueP10' item='createDateString'></td>" +
  121. " <td styles='formTableTitleP10' lable='targetPerson'></td>" +
  122. " <td styles='formTableValueP10' item='targetPerson'></td>"+
  123. " <td styles='formTableTitleP10' lable='activityName'></td>" +
  124. " <td styles='formTableValueP10' item='activityName'></td>"+
  125. " <td styles='formTableTitleP10' lable='currentPersonName'></td>" +
  126. " <td styles='formTableValueP10' item='currentPersonName'></td>"+
  127. " <td styles='formTableTitleP10' lable='reportObjType'></td>" +
  128. " <td styles='formTableValueP10' item='reportObjType'></td>"+
  129. "</tr>" +
  130. //"<tr><td styles='formTableTitle' lable='title'></td>" +
  131. //" <td styles='formTableValue' item='title'></td>" +
  132. //" <td styles='formTableTitle' lable='workId'></td>" +
  133. //" <td styles='formTableValue14' item='title'></td>"+
  134. //"</tr>" +
  135. "</table>";
  136. this.inforNode.set("html", html);
  137. MWF.xDesktop.requireApp("Template", "MForm", function () {
  138. var form = new MForm(this.inforNode, this.data, {
  139. usesNewVersion : true,
  140. isEdited: false,
  141. style : "report",
  142. hasColon : true,
  143. itemTemplate: {
  144. createDateString: { text : this.lp.reportDate, type : "innertext"},
  145. targetPerson: { text : this.lp.targetPerson, type : "org", orgType : "person"},
  146. reportObjType: { text : this.lp.reportObjType, type : "select", selectValue : ["","PERSON","UNIT"], selectText : ["","个人汇报","组织汇报"] },
  147. activityName: { text : this.lp.activityName, type : "innertext"},
  148. currentPersonName: { text : this.lp.currentPersonName, type : "org", orgType : "person"}
  149. }
  150. }, this);
  151. form.load();
  152. }.bind(this), true);
  153. },
  154. loadPlanTop: function( container, addEnable, isNextPlan ){
  155. var planTop = new Element("div.listTop", {
  156. "styles" : this.css.listTop,
  157. "text" : isNextPlan ? "下月工作计划" : "本月工作计划"
  158. }).inject( container );
  159. if( addEnable && this.isEdited ){
  160. var listTopAction = new Element("div.listTopAction", {
  161. "styles" : this.css.listTopAction,
  162. "text" : "增加"
  163. }).inject( planTop );
  164. listTopAction.addEvents( {
  165. "mouseover" : function(){
  166. this.node.setStyles( this._self.css.listTopAction_over )
  167. }.bind({_self : this , node : listTopAction }),
  168. "mouseout" : function(){
  169. this.node.setStyles( this._self.css.listTopAction )
  170. }.bind({_self : this , node : listTopAction }),
  171. "click" : function(){
  172. this._self.app.common.addPlan(this._self.data, isNextPlan ? this._self.planViewNext : this._self.planView, isNextPlan );
  173. }.bind({_self : this })
  174. } )
  175. }
  176. },
  177. loadPlanView : function( container ){
  178. this.planViewNode = new Element("div").inject( container );
  179. this.planView = new MWF.xApplication.Report.Explorer.PlanView(this.planViewNode, this.app, this, {
  180. "style": "default",
  181. "templateUrl": "listItemPlan.json"
  182. });
  183. this.planView.load();
  184. },
  185. loadPlanViewNext : function( container ){
  186. this.planViewNextNode = new Element("div").inject( container );
  187. this.planViewNext = new MWF.xApplication.Report.Explorer.PlanViewNext(this.planViewNextNode, this.app, this, {
  188. "style": "default",
  189. "templateUrl": "listItemPlan.json"
  190. });
  191. this.planViewNext.load();
  192. },
  193. loadPlanAction: function(container){
  194. if(this.isEdited){
  195. this.addPlanNode = new Element("div.listAddAction", {
  196. styles : this.css.listAddActionContainer,
  197. events : {
  198. "mouseover" : function(){
  199. this.addPlanNode.setStyles( this.css.listAddActionContainer_over );
  200. this.addPlanAction.setStyles( this.css.listAddAction_over )
  201. }.bind(this),
  202. "mouseout" : function(){
  203. this.addPlanNode.setStyles( this.css.listAddActionContainer );
  204. this.addPlanAction.setStyles( this.css.listAddAction )
  205. }.bind(this),
  206. "click" : function(){
  207. this._self.app.common.addPlan(this._self.data, this._self.planViewNext, true);
  208. }.bind({_self : this })
  209. }
  210. }).inject( container );
  211. this.addPlanAction = new Element("div.listAddAction", {
  212. styles : this.css.listAddAction,
  213. text : "增加计划"
  214. }).inject( this.addPlanNode );
  215. }
  216. },
  217. loadWorkTop: function( addEnable ){
  218. var workTop = new Element("div.listTop", {
  219. "styles" : this.css.listTop,
  220. "text" : "本月完成情况"
  221. }).inject( this.workNode );
  222. if( this.isEdited ){
  223. var listTopAction = new Element("div.listTopAction", {
  224. "styles" : this.css.listTopAction,
  225. "text" : "增加"
  226. }).inject( workTop );
  227. listTopAction.addEvents( {
  228. "mouseover" : function(){
  229. this.node.setStyles( this._self.css.listTopAction_over )
  230. }.bind({_self : this , node : listTopAction }),
  231. "mouseout" : function(){
  232. this.node.setStyles( this._self.css.listTopAction )
  233. }.bind({_self : this , node : listTopAction }),
  234. "click" : function(){
  235. this._self.app.common.addWork( this._self.data, this._self.workView );
  236. }.bind({_self : this })
  237. } )
  238. }
  239. },
  240. loadWorkView : function(){
  241. this.workViewNode = new Element("div").inject(this.workNode);
  242. this.workView = new MWF.xApplication.Report.Explorer.WorkView(this.workViewNode, this.app, this, {
  243. "style": "default",
  244. "templateUrl": "listItemWork.json"
  245. });
  246. this.workView.load();
  247. },
  248. loadWorkAction : function(){
  249. if( this.isEdited ){
  250. this.addWorkNode = new Element("div.listAddAction", {
  251. styles : this.css.listAddActionContainer,
  252. events : {
  253. "mouseover" : function(){
  254. this.addWorkNode.setStyles( this.css.listAddActionContainer_over );
  255. this.addWorkAction.setStyles( this.css.listAddAction_over )
  256. }.bind(this),
  257. "mouseout" : function(){
  258. this.addWorkNode.setStyles( this.css.listAddActionContainer );
  259. this.addWorkAction.setStyles( this.css.listAddAction )
  260. }.bind(this),
  261. "click" : function(){
  262. this._self.app.common.addWork( this._self.data, this._self.workView );
  263. }.bind({_self : this })
  264. }
  265. }).inject( this.workNode );
  266. this.addWorkAction = new Element("div.listAddAction", {
  267. styles : this.css.listAddAction,
  268. text : "增加工作"
  269. }).inject( this.addWorkNode );
  270. }
  271. },
  272. resetNodeSize: function () {
  273. var topSize = this.topNode ? this.topNode.getSize() : {"x": 0, "y": 0};
  274. var nodeSize = this.node.getSize();
  275. var pt = this.contentContainer.getStyle("padding-top").toFloat();
  276. var pb = this.contentContainer.getStyle("padding-bottom").toFloat();
  277. var height = nodeSize.y - pt - pb; //- topSize.y
  278. this.contentContainer.setStyle("height", "" + height + "px");
  279. }
  280. });
  281. MWF.xApplication.Report.Explorer.WorkView = new Class({
  282. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  283. _createDocument: function (data, index) {
  284. return new MWF.xApplication.Report.Explorer.WorkDocument(this.viewNode, data, this.explorer, this, null, index);
  285. },
  286. _getCurrentPageData: function(callback, count, pageNum){
  287. this.actions.listWork( this.explorer.data.id, function( json ){
  288. if( callback )callback( json );
  289. })
  290. },
  291. _removeDocument: function (documentData, all) {
  292. this.app.common.deleteWork( documentData, e, function(){
  293. this.reload();
  294. }.bind(this))
  295. },
  296. _create: function () {
  297. },
  298. _openDocument: function (documentData) {
  299. this.app.common.openWork( documentData, this.explorer.data, this, this.explorer.isEdited );
  300. },
  301. _queryCreateViewNode: function () {
  302. },
  303. _postCreateViewNode: function (viewNode) {
  304. },
  305. _queryCreateViewHead: function () {
  306. },
  307. _postCreateViewHead: function (headNode) {
  308. }
  309. });
  310. MWF.xApplication.Report.Explorer.WorkDocument = new Class({
  311. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  312. _queryCreateDocumentNode: function (itemData) {
  313. },
  314. _postCreateDocumentNode: function (itemNode, itemData) {
  315. },
  316. open: function( ){
  317. this.view._openDocument( this.data )
  318. },
  319. edit: function(node, ev){
  320. this.app.common.editWork( this.data, this.explorer.data, this.view );
  321. ev.stopPropagation();
  322. },
  323. delete : function(node, ev){
  324. this.app.common.deleteWork( this.data, ev, function(){
  325. this.view.reload();
  326. }.bind(this));
  327. ev.stopPropagation();
  328. }
  329. });
  330. MWF.xApplication.Report.Explorer.PlanView = new Class({
  331. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  332. _createDocument: function (data, index) {
  333. return new MWF.xApplication.Report.Explorer.PlanDocument(this.viewNode, data, this.explorer, this, null, index);
  334. },
  335. _getCurrentPageData: function(callback, count, pageNum){
  336. this.actions.listPlan( this.explorer.data.id, function( json ){
  337. if( callback )callback( json );
  338. })
  339. },
  340. _create: function () {
  341. },
  342. _openDocument: function (documentData) {
  343. this.app.common.openPlan( documentData, this.explorer.data, this, false, this.explorer.isEdited );
  344. },
  345. _queryCreateViewNode: function () {
  346. },
  347. _postCreateViewNode: function (viewNode) {
  348. },
  349. _queryCreateViewHead: function () {
  350. },
  351. _postCreateViewHead: function (headNode) {
  352. }
  353. });
  354. MWF.xApplication.Report.Explorer.PlanDocument = new Class({
  355. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  356. _queryCreateDocumentNode: function (itemData) {
  357. },
  358. _postCreateDocumentNode: function (itemNode, itemData) {
  359. },
  360. open: function( ){
  361. this.view._openDocument( this.data )
  362. },
  363. edit: function( node , ev ){
  364. this.app.common.editPlan( this.data, this.explorer.data, this.view, false );
  365. ev.stopPropagation();
  366. },
  367. delete : function(node, ev){
  368. this.app.common.deletePlan( this.data, ev, function (){
  369. this.view.reload();
  370. }.bind(this));
  371. ev.stopPropagation();
  372. }
  373. });
  374. MWF.xApplication.Report.Explorer.PlanViewNext = new Class({
  375. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  376. _createDocument: function (data, index) {
  377. return new MWF.xApplication.Report.Explorer.PlanDocumentNext(this.viewNode, data, this.explorer, this, null, index);
  378. },
  379. _getCurrentPageData: function(callback, count, pageNum){
  380. this.actions.listPlanNext( this.explorer.data.id, function( json ){
  381. if( callback )callback( json );
  382. })
  383. },
  384. _create: function () {
  385. },
  386. _openDocument: function (documentData) {
  387. this.app.common.openPlan( documentData, this.explorer.data, this.view, true );
  388. },
  389. _queryCreateViewNode: function () {
  390. },
  391. _postCreateViewNode: function (viewNode) {
  392. },
  393. _queryCreateViewHead: function () {
  394. },
  395. _postCreateViewHead: function (headNode) {
  396. }
  397. });
  398. MWF.xApplication.Report.Explorer.PlanDocumentNext = new Class({
  399. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  400. _queryCreateDocumentNode: function (itemData) {
  401. },
  402. _postCreateDocumentNode: function (itemNode, itemData) {
  403. },
  404. open: function( ){
  405. this.view._openDocument( this.data )
  406. },
  407. edit: function( node , ev ){
  408. this.app.common.editPlan( this.data, this.explorer.data, this.view, true );
  409. ev.stopPropagation();
  410. },
  411. delete : function(node, ev){
  412. this.app.common.deletePlanNext( this.data, ev, function () {
  413. this.view.reload();
  414. }.bind(this));
  415. ev.stopPropagation();
  416. }
  417. });