StrategyExplorerDeploy.js 16 KB

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