StrategyExplorerDeploy.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. MWF.xApplication.Report.StrategyExplorer.Deployment = new Class({
  2. Implements: [Options, Events],
  3. options: {
  4. "style": "default",
  5. "isEdited" : true,
  6. "isKeyworkEdited" : true
  7. },
  8. initialize: function (container, explorer, data, options) {
  9. this.setOptions( options );
  10. this.container = container;
  11. this.explorer = explorer;
  12. this.app = this.explorer.app;
  13. this.lp = this.app.lp;
  14. this.css = this.explorer.css;
  15. this.actions = this.app.restActions;
  16. this.data = data;
  17. this.path = "/x_component_Report/$StrategyExplorer/";
  18. },
  19. load: function () {
  20. this.month = parseInt(this.data.month);
  21. this.node = new Element("div", {
  22. styles : this.css.deplymentNode
  23. }).inject( this.container );
  24. this.loadPerson();
  25. this.keyWorkContainer = new Element("div").inject( this.node );
  26. this.keyworkList = [];
  27. this.data.thisMonth_workList.each( function( data, i ){
  28. this.loadKeyWork( data, i+1 );
  29. }.bind(this))
  30. },
  31. loadPerson: function(){
  32. this.personNode = new Element("div.personDeployNode",{
  33. styles : this.css.personDeployNode
  34. }).inject( this.node );
  35. var html = "<table width='96%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' >" +
  36. "<tr>" +
  37. " <td style='width: 15%;font-size: 14px;' styles='formTableTitleP10'>汇报填写人员</td>" +
  38. " <td style='width: 85%' item='workreportPersonList' styles='formTableValueP10'></td>"+
  39. "</tr>" +
  40. "</table>";
  41. this.personNode.set("html", html);
  42. MWF.xDesktop.requireApp("Template", "MForm", function () {
  43. this.peronform = new MForm(this.personNode, this.data, {
  44. verifyType : "single",
  45. isEdited: this.options.isEdited,
  46. style : "report",
  47. itemTemplate: {
  48. workreportPersonList: { text : this.lp.targetPerson, type : "org", orgType : "identity", isEdited : this.options.isEdited,
  49. count : 0, notEmpty : true, units : [this.data.targetUnit.split("@")[0]], event :{
  50. change : function( item ){
  51. this.save( item.getElements()[0] );
  52. }.bind(this)
  53. } }
  54. }
  55. }, this.app );
  56. this.peronform.load();
  57. }.bind(this), true);
  58. },
  59. loadKeyWork : function( data, index ){
  60. var keywork = new MWF.xApplication.Report.StrategyExplorer.Deployment.KeyWorkItem( this.keyWorkContainer, this, data, {
  61. reportId : this.data.id,
  62. isEdited : this.options.isKeyworkEdited && this.options.isEdited,
  63. orderNumber : this.data.orderNumber || index
  64. } );
  65. keywork.load();
  66. this.keyworkList.push( keywork );
  67. },
  68. getPersonString : function(){
  69. },
  70. arrayIsContains : function( array, identity ){
  71. for( var i=0; i<array.length; i++ ){
  72. if( array[i].woPerson.distinguishedName == identity.woPerson.distinguishedName ){
  73. return true;
  74. }
  75. }
  76. return false;
  77. },
  78. getPerson : function( ){
  79. debugger;
  80. var indentityList = this.peronform.getItem("workreportPersonList").dom.getData(true);
  81. var indentity = Object.clone( ( layout.desktop.session.user || layout.user ).identityList[0] );
  82. var user = ( layout.desktop.session.user || layout.user );
  83. indentity.woPerson = user;
  84. var identity1 = MWF.org.parseOrgData( indentity );
  85. if( !this.arrayIsContains( indentityList, identity1 ) ){
  86. indentityList.push( identity1 );
  87. }
  88. return indentityList;
  89. },
  90. submit: function(){
  91. if( this.errorNodeList ){
  92. this.errorNodeList.each( function(node){
  93. node.destroy();
  94. })
  95. }
  96. var flag = false;
  97. var result = this.getResult( true );
  98. if( result ){
  99. var data = this.getPerson();
  100. var person = [];
  101. var identity = [];
  102. debugger;
  103. data.each( function( d ){
  104. var dn = d.woPerson ? d.woPerson.distinguishedName : d.distinguishedName;
  105. if( !person.contains( dn ) ){
  106. person.push( dn );
  107. }
  108. if( !identity.contains(d.distinguishedName) ){
  109. identity.push( d.distinguishedName )
  110. }
  111. });
  112. result.workreportPersonList = identity;
  113. var readerList = [];
  114. person.each( function( p ){
  115. readerList.push({
  116. permission : "阅读",
  117. permissionObjectType : "人员",
  118. permissionObjectName : p
  119. })
  120. });
  121. result.readerList = readerList;
  122. var authorList = [];
  123. person.each( function( p ){
  124. authorList.push({
  125. permission : "作者",
  126. permissionObjectType : "人员",
  127. permissionObjectName : p
  128. })
  129. });
  130. result.authorList = authorList;
  131. this.actions.submitWorkPerson( result, function(){
  132. //this.app.notice("保存成功");
  133. flag = true;
  134. }.bind(this), null, false )
  135. }
  136. return flag;
  137. },
  138. save: function( node ){
  139. var flag = false;
  140. var result = this.getResult( false );
  141. if( result ){
  142. this.actions.saveWorkPerson( result, function(){
  143. this.app.notice("保存并上传成功", "success" );
  144. flag = true;
  145. }.bind(this), null, false )
  146. }
  147. return flag;
  148. },
  149. getResult : function( verify ){
  150. var flag = true;
  151. var p = this.peronform.getResult( verify, null, true, false, true );
  152. if( verify && !p )flag = false;
  153. if( this.options.isKeyworkEdited ){
  154. var workList = [];
  155. this.keyworkList.each( function( keywork ){
  156. var title = keywork.getWorkTitle();
  157. if( !title || title.length == 0 ){
  158. if( verify ){
  159. this.createErrorNode( keywork.workTitleInput, "请填写工作标题", { "float" : "left" } );
  160. flag = false;
  161. }
  162. }
  163. var measuresList = keywork.getMeasuresList();
  164. if( !measuresList || measuresList.length == 0 ){
  165. if( verify ){
  166. this.createErrorNode( keywork.measureContentNode, "请选择举措" );
  167. flag = false;
  168. }
  169. }
  170. workList.push({
  171. id : keywork.data.id,
  172. orderNumber : keywork.options.orderNumber,
  173. workTitle : title,
  174. measuresList : measuresList
  175. }) ;
  176. if( verify ){
  177. var planDataList = keywork.getPlanData();
  178. if( !planDataList || planDataList.length == 0 ){
  179. this.createErrorNode( keywork.planListNode, "请填写计划" );
  180. flag = false;
  181. }
  182. }
  183. }.bind(this));
  184. if( !flag )return false;
  185. return {
  186. id : this.data.id,
  187. workreportPersonList : p.workreportPersonList,
  188. workList : workList
  189. }
  190. }else{
  191. if( !flag )return false;
  192. return {
  193. id : this.data.id,
  194. workreportPersonList : p.workreportPersonList
  195. }
  196. }
  197. },
  198. listPlan : function( workInfoId, refresh, callback ){
  199. if( !refresh && this.planDataObject ) {
  200. if(callback)callback( this.planDataObject[workInfoId] || [] ) ;
  201. }else{
  202. this.actions.listPlan( this.data.id || this.options.id, function( json ){
  203. this.planDataObject = {};
  204. json.data.each( function( d ){
  205. if( !this.planDataObject[d.workInfoId] ) {
  206. this.planDataObject[d.workInfoId] = [];
  207. }
  208. this.planDataObject[d.workInfoId].push( d );
  209. }.bind(this));
  210. if(callback)callback( this.planDataObject[workInfoId] || [] ) ;
  211. }.bind(this))
  212. }
  213. },
  214. createErrorNode : function(node, text, styles){
  215. if( !this.errorNodeList )this.errorNodeList = [];
  216. var div = new Element("div", {
  217. text : text,
  218. styles : this.css.warningMessageNode
  219. }).inject( node, "after" );
  220. if(styles)div.setStyles(styles);
  221. this.errorNodeList.push( div );
  222. }
  223. });
  224. MWF.xApplication.Report.StrategyExplorer.Deployment.KeyWorkItem = new Class({
  225. Implements: [Options, Events],
  226. options: {
  227. "style": "default",
  228. "reportId" : "",
  229. "isEdited" : true,
  230. "orderNumber" : 1
  231. },
  232. initialize: function(container, explorer, data, options ) {
  233. this.setOptions(options);
  234. this.container = container;
  235. this.explorer = explorer;
  236. this.app = this.explorer.app;
  237. this.lp = this.app.lp;
  238. this.css = this.explorer.css;
  239. this.actions = this.app.restActions;
  240. this.data = data;
  241. },
  242. load: function(){
  243. //this.node = new Element("div.keyWorkNode", { styles : this.css.keyWorkNode }).inject( this.container );
  244. var table = new Element( "table", {
  245. "width":"96%",
  246. "border":"0",
  247. "cellpadding":"5",
  248. "cellspacing":"0",
  249. "styles" : this.css.formTable
  250. }).inject( this.container );
  251. var tr = new Element("tr").inject( table );
  252. new Element("td", {
  253. "rowspan" : 2,
  254. "text" : this.data.orderNumber || this.options.orderNumber,
  255. "styles": this.css.formTableTitle
  256. }).inject( tr );
  257. new Element("td", {
  258. "text" : "部门重点工作",
  259. "width" : "140",
  260. "styles": this.css.formTableTitle
  261. }).inject( tr );
  262. var contentTd = new Element("td", {
  263. "styles": this.css.formTableValue
  264. }).inject( tr );
  265. if( this.options.isEdited ){
  266. this.workTitleInput = new Element("input", {
  267. "value" : this.data.workTitle,
  268. "styles" : this.css.keyWorkTitleInput
  269. }).inject( contentTd )
  270. }else{
  271. new Element("div", {
  272. "html" : this.app.common.replaceWithBr( this.data.workTitle ),
  273. styles : { "width" : "870px", "float" : "left" }
  274. }).inject( contentTd )
  275. }
  276. var showMeasureNode = new Element("input",{
  277. "type" : "button",
  278. "styles" : this.css.showMeasureNode,
  279. "value" : "查看举措"
  280. }).inject( contentTd );
  281. var tooltip = new MWF.xApplication.Report.ShowMeasureTooltip( this.app.content, showMeasureNode, this.app, this.explorer.data, {
  282. style : "report",
  283. position : { x : "auto", y : "auto" },
  284. event : "click"
  285. });
  286. tooltip.measuresList = this.data.measuresList;
  287. tr = new Element("tr").inject( table );
  288. new Element("td", {
  289. "text" : "工作计划",
  290. "styles": this.css.formTableTitle
  291. }).inject( tr );
  292. contentTd = new Element("td", {
  293. "styles": this.css.formTableValue,
  294. "html" : this.app.common.replaceWithBr( this.data.workPlanSummary )
  295. }).inject( tr );
  296. //this.loadWorkTitle();
  297. //this.loadMeasure();
  298. },
  299. //loadWorkTitle : function(){
  300. // var topNode = new Element("div.keyWorkTopNode", { styles : this.css.keyWorkTopNode }).inject( this.node );
  301. //
  302. // var orderNumber = this.data.orderNumber || this.options.orderNumber;
  303. // var tetNode = new Element("div.keyWorkTopTextNode", {
  304. // styles : this.css.keyWorkTopTextNode,
  305. // text : "【"+ this.explorer.month + "月" +"】"+"部门重点工作"+ this.lp[ orderNumber ] +":"
  306. // }).inject( topNode );
  307. // if( this.options.isEdited ){
  308. // this.workTitleInput = new Element("input", {
  309. // "value" : this.data.workTitle,
  310. // "styles" : this.css.keyWorkTitleInput
  311. // }).inject( topNode )
  312. // }else{
  313. // new Element("div", {
  314. // "text" : this.data.workTitle
  315. // }).inject( topNode )
  316. // }
  317. //
  318. // var showMeasureNode = new Element("div",{
  319. // "styles" : {
  320. // "float" : "right"
  321. // },
  322. // "text" : "查看举措"
  323. // }).inject( topNode );
  324. // var tooltip = new MWF.xApplication.Report.ShowMeasureTooltip( this.app.content, showMeasureNode, this.app, this.explorer.data, {
  325. // style : "report",
  326. // position : { x : "auto", y : "auto" },
  327. // event : "click"
  328. // });
  329. // tooltip.measuresList = this.data.measuresList;
  330. //},
  331. getWorkTitle : function(){
  332. return this.workTitleInput.get("value");
  333. },
  334. getMeasuresList : function(){
  335. return this.measuresList || this.data.measuresList
  336. },
  337. //loadMeasure: function(){
  338. // var _self = this;
  339. // this.measureListNode = new Element("div.measureListNode", {
  340. // styles : this.css.listContainer
  341. // }).inject( this.node );
  342. //
  343. // var listTopNode = new Element("div.measureTopNode", {
  344. // styles : this.css.listTop,
  345. // text : "【"+ this.explorer.month + "月" +"】"+"举措:"
  346. // }).inject( this.measureListNode );
  347. // if( this.options.isEdited ){
  348. // new Element("button", {
  349. // text : "选择举措",
  350. // styles : this.css.listTopAction,
  351. // events : {
  352. // "mouseover" : function( ev ){
  353. // ev.target.setStyles( _self.css.listTopAction_over )
  354. // },
  355. // "mouseout" : function(ev){
  356. // ev.target.setStyles( _self.css.listTopAction )
  357. // },
  358. // "click" : function(){
  359. // var form = new MWF.xApplication.Report.SelectMeasureForm(this, this.explorer.data, {
  360. // onPostOk: function( list, value ){
  361. // this.measuresList = value;
  362. // this.measureContentNode.empty();
  363. // list.each( function(d,i){
  364. // this.createMeasureNode(d,i);
  365. // }.bind(this))
  366. // }.bind(this)
  367. // }, { app : this.app });
  368. // form.edit();
  369. // }.bind(this)
  370. // }
  371. // }).inject( listTopNode )
  372. // }
  373. //
  374. // this.measureContentNode = new Element("div", {
  375. // styles: this.css.listNode
  376. // }).inject(this.measureListNode);
  377. //
  378. // this.selectableMeasureObject = {};
  379. // this.explorer.data.selectableMeasures.each(function (m) {
  380. // this.selectableMeasureObject[m.id] = m;
  381. // }.bind(this));
  382. // this.data.measuresList.each(function (id, i) {
  383. // if (id) {
  384. // var data = this.selectableMeasureObject[id];
  385. // this.createMeasureNode( data, i );
  386. // }
  387. // }.bind(this));
  388. //
  389. //
  390. //},
  391. //createMeasureNode : function( data ,i ){
  392. // var measureNoe = new Element("div", {
  393. // styles: this.css.itemMeasureNode
  394. // }).inject(this.measureContentNode);
  395. //
  396. // var iconNode = new Element("div.itemMeasureIconNode", {styles: this.css.itemMeasureIconNode}).inject(measureNoe);
  397. // var tetNode = new Element("div.itemMeasureTextNode", {
  398. // styles: this.css.itemMeasureTextNode,
  399. // text: "举措" + (i + 1) + ":" + data.measuresinfotitle
  400. // }).inject(measureNoe);
  401. // this.loadMeasureTooltip(iconNode, data.id);
  402. //},
  403. getPlanData : function(){
  404. return this.planDataList
  405. },
  406. loadMeasureTooltip: function( node, measureId ){
  407. new MWF.xApplication.Report.MeasureTooltip( this.app.content, node, this.app, null, {
  408. position : { x : "right", y : "auto" },
  409. measureId : measureId,
  410. displayDelay : 300
  411. })
  412. }
  413. });