WorkReport.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. MWF.xApplication.Execution = MWF.xApplication.Execution || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  4. MWF.xDesktop.requireApp("Execution","Attachment",null,false);
  5. MWF.xDesktop.requireApp("Execution","ReportAttachment",null,false);
  6. MWF.xApplication.Execution.WorkReport = new Class({
  7. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  8. Implements: [Options, Events],
  9. options: {
  10. "style": "default",
  11. "width": "100%",
  12. "height": "100%",
  13. "hasTop": true,
  14. "hasIcon": false,
  15. "hasBottom": true,
  16. "title": "",
  17. "draggable": false,
  18. "closeAction": true,
  19. "isNew": false,
  20. "isEdited": true
  21. },
  22. initialize: function (explorer, actions, data, options) {
  23. this.setOptions(options);
  24. this.explorer = explorer;
  25. this.app = explorer.app;
  26. this.lp = this.app.lp.WorkReport;
  27. this.actions = this.app.restActions;
  28. this.path = "/x_component_Execution/$WorkReport/";
  29. this.cssPath = this.path + this.options.style + "/css.wcss";
  30. this._loadCss();
  31. this.options.title = this.lp.title;
  32. this.data = data || {};
  33. this.actions = actions;
  34. },
  35. load: function () {
  36. if (this.options.isNew) {
  37. this.create();
  38. } else if (this.options.isEdited) {
  39. this.edit();
  40. } else {
  41. this.open();
  42. }
  43. },
  44. reload:function(data){
  45. },
  46. createTopNode: function () {
  47. if (!this.formTopNode) {
  48. this.formTopNode = new Element("div.formTopNode", {
  49. "styles": this.css.formTopNode
  50. }).inject(this.formNode);
  51. this.formTopIconNode = new Element("div", {
  52. "styles": this.css.formTopIconNode
  53. }).inject(this.formTopNode)
  54. this.formTopTextNode = new Element("div.formTopTextNode", {
  55. "styles": this.css.formTopTextNode,
  56. "text": this.lp.topTitle + ( this.data.title ? ("-" + this.data.title ) : "" )
  57. }).inject(this.formTopNode)
  58. if (this.options.closeAction) {
  59. this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  60. this.formTopCloseActionNode.addEvent("click", function () {
  61. this.close()
  62. }.bind(this))
  63. }
  64. this.formTopContentNode = new Element("div", {
  65. "styles": this.css.formTopContentNode
  66. }).inject(this.formTopNode)
  67. this._createTopContent();
  68. }
  69. },
  70. _createTopContent: function () {
  71. },
  72. createContent: function () {
  73. this.formContentNode = new Element("div.formContentNode", {
  74. "styles": this.css.formContentNode
  75. }).inject(this.formNode);
  76. this.formTableContainer = new Element("div.formTableContainer", {
  77. "styles": this.css.formTableContainer
  78. }).inject(this.formContentNode);
  79. this.formTableArea = new Element("div.formTableArea", {
  80. "styles": this.css.formTableArea
  81. }).inject(this.formTableContainer);
  82. this.reportLinksDiv = new Element("div.reportLinksDiv",{
  83. "styles":this.css.reportLinksDiv,
  84. "text":this.lp.reportLinks
  85. }).inject(this.formTableArea)
  86. .addEvents({
  87. "click":function(){
  88. this.createPrevReport();
  89. }.bind(this)
  90. })
  91. this.titleDiv = new Element("div.titleDiv",{
  92. "styles":this.css.titleDiv,
  93. "text":this.lp.topTitle + ( this.data.title ? ("-" + this.data.title ) : "" ),
  94. "title":this.lp.topTitle + ( this.data.title ? ("-" + this.data.title ) : "" )
  95. }).inject(this.formTableArea)
  96. this.centerWorkDiv = new Element("div.centerWorkDiv",{"styles":this.css.centerWorkDiv}).inject(this.formTableArea);
  97. this.centerWorkTitleDiv = new Element("div.centerWorkTitleDiv",{
  98. "styles":this.css.tabTitleDiv,
  99. "text":this.lp.title
  100. }).inject(this.centerWorkDiv);
  101. this.tableContentDiv = new Element("div.tableContentDiv").inject(this.formTableArea);
  102. if(this.options.workReportId){
  103. this.workReportId = this.options.workReportId;
  104. }
  105. this.workId = this.data.workId;
  106. this.processStatus = "";
  107. this.processIdentity = "";
  108. if(this.options.from && this.options.from == "drafter"){
  109. this.actions.workReportDrafter(this.data.workId, function( json ){
  110. if(json.type && json.type=="success"){
  111. this.workReportData = json.data;
  112. if(json.data.id){
  113. this.workReportId = json.data.id;
  114. }
  115. if(json.data.currentProcessorIdentity){
  116. this.processIdentity = json.data.currentProcessorIdentity
  117. }
  118. if(json.data.processStatus){
  119. this.processStatus = json.data.processStatus
  120. }
  121. }
  122. }.bind(this),null,false);
  123. }else{ //不是草稿的 直接获取this.data信息
  124. this.actions.getWorkReport(this.data.workReportId,function(json){ //alert(JSON.stringify(json))
  125. if(json.type=="success"){
  126. this.workReportData = json.data;
  127. if(json.data.id){
  128. this.workReportId = json.data.id
  129. }
  130. }
  131. }.bind(this),null,false)
  132. if(this.workReportData.currentProcessorIdentity){
  133. this.processIdentity = this.workReportData.currentProcessorIdentity
  134. }
  135. if(this.workReportData.processStatus){
  136. this.processStatus = this.workReportData.processStatus
  137. }
  138. }
  139. //alert("workreportData="+JSON.stringify(this.workReportData))
  140. //获取工作信息
  141. if(this.data.workId){
  142. this.actions.getTask(this.workId, function(json){
  143. if(json.data){
  144. this.workData = json.data;
  145. }
  146. }.bind(this),null,false)
  147. }
  148. //alert("this.workReportId="+this.workReportId)
  149. //alert("this.workId="+this.workId)
  150. //获取具体工作详细信息
  151. if(this.data.workId){
  152. this.actions.getBaseWorkDetails(this.workId, function (json) {
  153. this.workData.workSplitAndDescription = json.data.workDetail
  154. this.workData.specificActionInitiatives = json.data.progressAction
  155. this.workData.cityCompanyDuty = json.data.dutyDescription
  156. this.workData.milestoneMark = json.data.landmarkDescription
  157. this.workData.importantMatters = json.data.majorIssuesDescription
  158. }.bind(this),null,false)
  159. }
  160. this._createTableContent();
  161. if(this.workReportData.title){
  162. this.titleDiv.set("text",this.workReportData.title.length>50?this.workReportData.title.substr(0,50)+"...":this.workReportData.title)
  163. this.titleDiv.set("title",this.workReportData.title)
  164. }
  165. //委派记录
  166. if(this.workData.okrWorkAuthorizeRecords){
  167. this.appointContentDiv = new Element("div.appointContentDiv",{
  168. "styles":this.css.appointContentDiv
  169. }).inject(this.formTableArea)
  170. this.appointContentTitleDiv = new Element("div.appointContentTitleDiv",{
  171. "styles":this.css.tabTitleDiv,
  172. "text":this.lp.appointTitle
  173. }).inject(this.appointContentDiv);
  174. this.appointContentInfor = new Element("div.appointContentInfor",{
  175. "styles": this.css.appointContentInfor
  176. }).inject(this.appointContentDiv);
  177. this.workData.okrWorkAuthorizeRecords.each(function(d){
  178. var ttext = d.delegatorName+this.lp.appointFor+ d.targetName
  179. ttext += "("+ d.delegateDateTime+") "
  180. ttext += "委派意见:" + d.delegateOpinion
  181. this.appointRecordDiv = new Element("div.appointRecordDiv",{
  182. "styles":this.css.appointRecordDiv,
  183. "text": ttext
  184. }).inject(this.appointContentInfor)
  185. }.bind(this))
  186. }
  187. //判断状态 如果草稿并且当前人是拟稿人,显示contentTextarea1,contentTextarea2 编辑状态 其他只读
  188. //当前秘书状态、并且当前人是秘书 contentTextarea3 编辑,其他只读
  189. //当前领导、并且当前人领导(当前处理人):contentTextarea4编辑 其他只读
  190. //拟稿人填写
  191. this.reportContentDiv = new Element("div.centerWorkDiv",{"styles":this.css.reportContentDiv}).inject(this.formTableArea);
  192. this.reportContentTitleDiv = new Element("div.reportContentTitleDiv",{
  193. "styles":this.css.tabTitleDiv,
  194. "text":this.lp.reportContentTitle
  195. }).inject(this.reportContentDiv);
  196. this.reportContentInfor = new Element("div.reportContentInfor",{
  197. "styles": this.css.reportContentInfor
  198. }).inject(this.reportContentDiv);
  199. this.contentTitle1 = new Element("div.contentTitle1",{
  200. "styles":this.css.contentTitle,
  201. "text":this.lp.contentTitle1 + ":"
  202. }).inject(this.reportContentInfor);
  203. if(this.workReportData.processStatus == this.lp.activityName.drafter && this.workReportData.isReporter){
  204. this.contentTextarea1 = new Element("textarea.contentTextarea1",{
  205. "styles":this.css.contentTextarea,
  206. "text" : this.workReportData.progressDescription?this.workReportData.progressDescription:""
  207. }).inject(this.reportContentInfor);
  208. }else{
  209. this.contentTextStr1 = new Element("div.contentTextStr1",{
  210. "styles": this.css.contentTextStr,
  211. "text" : this.workReportData.progressDescription?this.workReportData.progressDescription:""
  212. }).inject(this.reportContentInfor)
  213. }
  214. this.contentTitle2 = new Element("div.contentTitle2",{
  215. "styles":this.css.contentTitle,
  216. "text":this.lp.contentTitle2 + ":"
  217. }).inject(this.reportContentInfor);
  218. if(this.workReportData.processStatus == this.lp.activityName.drafter && this.workReportData.isReporter){
  219. this.contentTextarea2 = new Element("textarea.contentTextarea2",{
  220. "styles":this.css.contentTextarea,
  221. "text" : this.workReportData.workPlan?this.workReportData.workPlan:""
  222. }).inject(this.reportContentInfor);
  223. }else{
  224. this.contentTextStr2 = new Element("div.contentTextStr2",{
  225. "styles" : this.css.contentTextStr,
  226. "text" : this.workReportData.workPlan?this.workReportData.workPlan:""
  227. }).inject(this.reportContentInfor)
  228. }
  229. this.reportAttachment = new Element("div.reportAttachment",{
  230. "item":"reportAttachments"
  231. }).inject(this.reportContentInfor)
  232. this.reportAttachment.setStyles({"width":"95%"})
  233. var isUpload = false
  234. if(this.workReportData.processStatus == this.lp.activityName.drafter && this.workReportData.isReporter){
  235. isUpload = true
  236. }
  237. this.reportAttachmentArea = this.formTableArea.getElement("[item='reportAttachments']");
  238. this.loadReportAttachment( this.reportAttachmentArea,isUpload );
  239. //获取秘书及领导评价信息
  240. var opinionData = {};
  241. opinionData.workReportId = "";
  242. //this.actions.getWorkReportOpinion();
  243. //管理员填写
  244. if(this.workReportData.needAdminAudit){
  245. this.createAdminContent();
  246. }
  247. //领导填写,在草稿和督办员环节不显示
  248. if(this.workReportData && (this.workReportData.activityName != this.lp.activityName.drafter && this.workReportData.activityName != this.lp.activityName.manager)){
  249. this.reportContentDiv = new Element("div.centerWorkDiv",{"styles":this.css.reportContentDiv}).inject(this.formTableArea);
  250. this.reportContentTitleDiv = new Element("div.reportContentTitleDiv",{
  251. "styles":this.css.tabTitleDiv,
  252. "text":this.lp.leaderContentTitle
  253. }).inject(this.reportContentDiv);
  254. this.reportContentInfor = new Element("div.reportContentInfor",{
  255. "styles": this.css.reportContentInfor
  256. }).inject(this.reportContentDiv);
  257. this.getLeaderOpinions();
  258. if(this.workReportData.processStatus == this.lp.activityName.leader && this.workReportData.isReadLeader && this.processIdentity.indexOf(this.app.identity)>-1){
  259. this.contentTextarea4 = new Element("textarea.contentTextarea4",{
  260. "styles":this.css.contentTextarea,
  261. "text" : this.leaderOpinionDrafter?this.leaderOpinionDrafter:""
  262. }).inject(this.reportContentInfor);
  263. }else{
  264. //if(this.workReportData.reportWorkflowType && this.workReportData.reportWorkflowType == "DEPLOYER"){
  265. // //一对一,上下级
  266. // this.contentTextStr4 = new Element("div.contentTextStr4",{
  267. // "styles": this.css.contentTextStr,
  268. // "text":"意见"
  269. // }).inject(this.reportContentInfor)
  270. //}else{
  271. // this.getLeaderOpinions();
  272. //}
  273. }
  274. }
  275. //权限控制,如果已归档,则输入框去掉
  276. if(this.workReportData && this.workReportData.status == this.lp.statuArchive){
  277. if(this.contentTextarea1)this.contentTextarea1.destroy();
  278. if(this.contentTextarea2)this.contentTextarea2.destroy();
  279. if(this.contentTextarea3)this.contentTextarea3.destroy();
  280. if(this.contentTextarea4)this.contentTextarea4.destroy();
  281. }
  282. },
  283. getLeaderOpinions: function(){
  284. //获取领导意见
  285. var logs = this.workReportData.processLogs;
  286. this.leaderTitle = [];
  287. this.leaderValue = [];
  288. if(logs){
  289. logs.each(function(data){
  290. if(data.activityName == this.lp.activityName.leader && data.processStatus == this.lp.status.drafter && data.processorIdentity == this.app.identity){
  291. this.leaderOpinionDrafter = data.opinion
  292. }else{
  293. if(data.activityName == this.lp.activityName.leader && data.processStatus == this.lp.status.effect){
  294. this.leaderTitle.push(data.processorIdentity+"("+data.processTimeStr+")");
  295. this.leaderValue.push(data.opinion )
  296. }
  297. }
  298. }.bind(this))
  299. }
  300. //领导意见显示区域
  301. this.reportLeaderOpinionsDiv = new Element("div.reportLeaderOpinionsDiv",{
  302. "styles":this.css.reportLeaderOpinionsDiv
  303. }).inject(this.reportContentInfor);
  304. for(var i=0;i<this.leaderTitle.length;i++){
  305. var reportLeaderContentDiv = new Element("div.reportLeaderContentDiv",{"styles":this.css.reportLeaderContentDiv}).inject(this.reportLeaderOpinionsDiv);
  306. var reportLeaderTitleDiv = new Element("div.reportLeaderTitleDiv",{
  307. "styles":this.css.reportLeaderTitleDiv,
  308. "text":this.leaderTitle[i]+":"
  309. }).inject(reportLeaderContentDiv);
  310. var reportLeaderValueDiv = new Element("div.reportLeaderValueDiv",{
  311. "styles":this.css.reportLeaderValueDiv,
  312. "text":this.leaderValue[i]
  313. }).inject(reportLeaderContentDiv);
  314. }
  315. },
  316. createPrevReport: function(){
  317. if(this.prevReportDiv) this.prevReportDiv.destroy();
  318. this.prevReportDiv = new Element("div.prevReportDiv",{
  319. styles:this.css.prevReportDiv
  320. }).inject(this.formTableContainer);
  321. this.prevReportTopDiv = new Element("div.prevReportTopDiv",{
  322. "styles":this.css.prevReportTopDiv
  323. }).inject(this.prevReportDiv);
  324. this.prevReportTopTitleDiv = new Element("div.prevReportTopTitleDiv",{
  325. "styles": this.css.prevReportTopTitleDiv,
  326. "text" : this.lp.reportLinks+":"
  327. }).inject(this.prevReportTopDiv);
  328. this.prevReportTopCloseDiv = new Element("div.prevReportTopCloseDiv",{
  329. "styles": this.css.prevReportTopCloseDiv
  330. }).inject(this.prevReportTopDiv)
  331. .addEvents({
  332. "click": function(){
  333. this.prevReportDiv.destroy();
  334. }.bind(this)
  335. })
  336. this.prevReportListDiv = new Element("div.prevReportListDiv",{
  337. "styles":this.css.prevReportListDiv
  338. }).inject(this.prevReportDiv)
  339. this.actions.getWorkReportList(this.workReportData.workId, function( json ){
  340. if(json.type && json.type=="success" && json.data){
  341. json.data.each(function(data){
  342. var createTimes = data.createTime.split(" ")[0]
  343. var prevReportWorkId = data.id;
  344. var prevReportListLi = new Element("li.prevReportListLi",{
  345. "styles": this.css.prevReportListLi,
  346. "id" : prevReportWorkId,
  347. "text": createTimes + "-" + data.shortTitle
  348. }).inject(this.prevReportListDiv)
  349. .addEvents({
  350. "mouseover":function(){
  351. prevReportListLi.setStyle("background-color","#3c76c1");
  352. }.bind(this),
  353. "mouseout":function(){
  354. if(prevReportWorkId != this.currentPrevReportLinkId){
  355. prevReportListLi.setStyle("background-color","");
  356. }
  357. }.bind(this),
  358. "click" :function(){
  359. this.prevReportTopCloseDiv.setStyle("display","none");
  360. this.expandWorkReportInfor(prevReportListLi);
  361. }.bind(this)
  362. })
  363. }.bind(this))
  364. }
  365. }.bind(this),null,false);
  366. //this.createPrevReportInfor();
  367. },
  368. createPrevReportInfor : function(workReportId){
  369. if(this.prevReportInforDiv) this.prevReportInforDiv.destroy();
  370. this.prevReportInforDiv = new Element("div.prevReportInforDiv",{
  371. "styles": this.css.prevReportInforDiv
  372. }).inject(this.formTableContainer);
  373. this.prevReportInforTopDiv = new Element("div.prevReportInforTopDiv",{
  374. "styles":this.css.prevReportInforTopDiv
  375. }).inject(this.prevReportInforDiv);
  376. this.prevReportInforTopCloseDiv = new Element("div.prevReportInforTopCloseDiv",{
  377. "styles": this.css.prevReportInforTopCloseDiv
  378. }).inject(this.prevReportInforTopDiv)
  379. .addEvents({
  380. "click": function(){
  381. this.prevReportDiv.destroy();
  382. this.prevReportInforDiv.destroy();
  383. }.bind(this)
  384. })
  385. this.prevReportInforListDiv = new Element("div.prevReportInforListDiv",{
  386. "styles":this.css.prevReportInforListDiv
  387. }).inject(this.prevReportInforDiv);
  388. //这里显示具体内容
  389. this.actions.getWorkReport(workReportId,function(json){
  390. //alert(JSON.stringify(json))
  391. if(json.type == "success"){
  392. var prevContentDiv = new Element("div.prevContentDiv",{
  393. "styles": this.css.prevContentDiv
  394. }).inject(this.prevReportInforListDiv);
  395. var prevContentTitleDiv = new Element("div.prevContentTitleDiv",{
  396. "styles" : this.css.prevContentTitleDiv,
  397. "text" : this.lp.contentTitle1 + ":"
  398. }).inject(prevContentDiv)
  399. var prevContentValueDiv = new Element("div.prevContentValueDiv",{
  400. "styles": this.css.prevContentValueDiv,
  401. "text" : json.data.progressDescription
  402. }).inject(prevContentDiv);
  403. prevContentDiv = new Element("div.prevContentDiv",{
  404. "styles": this.css.prevContentDiv
  405. }).inject(this.prevReportInforListDiv);
  406. prevContentTitleDiv = new Element("div.prevContentTitleDiv",{
  407. "styles" : this.css.prevContentTitleDiv,
  408. "text" : this.lp.contentTitle2 + ":"
  409. }).inject(prevContentDiv)
  410. prevContentValueDiv = new Element("div.prevContentValueDiv",{
  411. "styles": this.css.prevContentValueDiv,
  412. "text" : json.data.workPlan
  413. }).inject(prevContentDiv);
  414. //管理员督办
  415. if(json.data.needAdminAudit){
  416. prevContentDiv = new Element("div.prevContentDiv",{
  417. "styles": this.css.prevContentDiv
  418. }).inject(this.prevReportInforListDiv);
  419. prevContentTitleDiv = new Element("div.prevContentTitleDiv",{
  420. "styles" : this.css.prevContentTitleDiv,
  421. "text" : this.lp.adminContentTitle + ":"
  422. }).inject(prevContentDiv)
  423. prevContentValueDiv = new Element("div.prevContentValueDiv",{
  424. "styles": this.css.prevContentValueDiv,
  425. "text" : json.data.adminSuperviseInfo?json.data.adminSuperviseInfo:""
  426. }).inject(prevContentDiv);
  427. }
  428. //领导评价
  429. prevContentDiv = new Element("div.prevContentDiv",{
  430. "styles": this.css.prevContentDiv
  431. }).inject(this.prevReportInforListDiv);
  432. prevContentTitleDiv = new Element("div.prevContentTitleDiv",{
  433. "styles" : this.css.prevContentTitleDiv,
  434. "text" : this.lp.leaderContentTitle + ":"
  435. }).inject(prevContentDiv)
  436. prevContentValueDiv = new Element("div.prevContentValueDiv",{
  437. "styles": this.css.prevContentValueDiv
  438. }).inject(prevContentDiv);
  439. var reportLeaderOpinionsDiv = new Element("div.reportLeaderOpinionsDiv",{
  440. "styles":this.css.reportLeaderOpinionsDiv
  441. }).inject(prevContentValueDiv);
  442. var preLogs = json.data.processLogs;
  443. this.preLeaderTitle = [];
  444. this.preLeaderValue = [];
  445. if(preLogs){
  446. preLogs.each(function(data){
  447. if(data.activityName == this.lp.activityName.leader && data.processStatus == this.lp.status.drafter && data.processorIdentity == this.app.identity){
  448. this.leaderOpinionDrafter = data.opinion
  449. }else{
  450. if(data.activityName == this.lp.activityName.leader && data.processStatus == this.lp.status.effect){
  451. this.preLeaderTitle.push(data.processorIdentity+"("+data.processTimeStr+")");
  452. this.preLeaderValue.push(data.opinion )
  453. }
  454. }
  455. }.bind(this))
  456. }
  457. for(var i=0;i<this.preLeaderTitle.length;i++){
  458. var reportLeaderContentDiv = new Element("div.reportLeaderContentDiv",{"styles":this.css.reportLeaderContentDiv}).inject(reportLeaderOpinionsDiv);
  459. reportLeaderContentDiv.setStyle("border-bottom","1px dashed #3c76c1");
  460. var reportLeaderTitleDiv = new Element("div.reportLeaderTitleDiv",{
  461. "styles":this.css.reportLeaderTitleDiv,
  462. "text":this.preLeaderTitle[i]+":"
  463. }).inject(reportLeaderContentDiv);
  464. var reportLeaderValueDiv = new Element("div.reportLeaderValueDiv",{
  465. "styles":this.css.reportLeaderValueDiv,
  466. "text":this.preLeaderValue[i]
  467. }).inject(reportLeaderContentDiv);
  468. }
  469. }
  470. }.bind(this),null,false)
  471. },
  472. expandWorkReportInfor:function(prevReportListLi){
  473. this.currentPrevReportLinkId = prevReportListLi.get("id");
  474. var liObj = this.prevReportListDiv.getElements("li");
  475. liObj.setStyle("background-color","");
  476. prevReportListLi.setStyle("background-color","#3c76c1");
  477. this.createPrevReportInfor(this.currentPrevReportLinkId);
  478. this.prevReportInforDiv.setStyle("display","");
  479. },
  480. createAdminContent: function(){
  481. this.reportContentDiv = new Element("div.centerWorkDiv",{"styles":this.css.reportContentDiv}).inject(this.formTableArea);
  482. this.reportContentTitleDiv = new Element("div.reportContentTitleDiv",{
  483. "styles":this.css.tabTitleDiv,
  484. "text":this.lp.adminContentTitle
  485. }).inject(this.reportContentDiv);
  486. this.reportContentInfor = new Element("div.reportContentInfor",{
  487. "styles": this.css.reportContentInfor
  488. }).inject(this.reportContentDiv);
  489. if(this.workReportData.processStatus == this.lp.activityName.manager && this.workReportData.isWorkAdmin){
  490. this.contentTextarea3 = new Element("textarea.contentTextarea3",{
  491. "styles":this.css.contentTextarea,
  492. "value":this.workReportData.adminSuperviseInfo?this.workReportData.adminSuperviseInfo:""
  493. }).inject(this.reportContentInfor);
  494. }else{
  495. this.contentTextStr3 = new Element("div.contentTextStr3",{
  496. "styles": this.css.contentTextStr,
  497. "text" : this.workReportData.adminSuperviseInfo?this.workReportData.adminSuperviseInfo:""
  498. }).inject(this.reportContentInfor)
  499. }
  500. },
  501. _createTableContent: function () {
  502. var html = "<table style='width:95%; margin:10px 40px; margin-bottom: 0px;' border='0'>" +
  503. "<tr>"+
  504. " <td styles='formTableTitle' lable='deployPerson' width='10%'></td>" +
  505. " <td styles='formTableValue' item='deployPerson' width='20%'></td>" +
  506. " <td styles='formTableTitle' lable='timeLimit' width='10%'></td>" +
  507. " <td styles='formTableValue' item='timeLimit' width='20%'></td>" +
  508. " <td styles='formTableTitle' lable='' width='10%'></td>" +
  509. " <td styles='formTableValue' item='' width='20%'></td>" +
  510. "</tr>"+
  511. "<tr>"+
  512. " <td styles='formTableTitle' lable='dutyDepartment'></td>" +
  513. " <td styles='formTableValue' item='dutyDepartment'></td>" +
  514. " <td styles='formTableTitle' lable='dutyPerson'></td>" +
  515. " <td styles='formTableValue' item='dutyPerson'></td>" +
  516. " <td styles='formTableTitle' lable='reportCycle'></td>" +
  517. " <td styles='formTableValue'><span item='reportCycle'></span><span item='reportDay'></span></td>" +
  518. "</tr>"+
  519. "<tr>"+
  520. " <td styles='formTableTitle' lable='secondDepartment'></td>" +
  521. " <td styles='formTableValue' item='secondDepartment'></td>" +
  522. " <td styles='formTableTitle' lable='secondPerson'></td>" +
  523. " <td styles='formTableValue' item='secondPerson'></td>" +
  524. " <td styles='formTableTitle' lable='readReader'></td>" +
  525. " <td styles='formTableValue' item='readReader'></td>" +
  526. "</tr>"+
  527. //"<tr>"+
  528. //" <td styles='formTableTitle' lable='subject'></td>" +
  529. //" <td styles='formTableValue' item='subject' colspan='5'></td>" +
  530. //"</tr>"+
  531. "</table>"+
  532. "<div id='expandIcon' style='text-align: center; cursor:pointer;'><img style='width:20px;height:10px;' src='/x_component_Execution/$WorkReport/default/icon/expand.gif'></div>"+
  533. "<table id='workDetails' style='width:95%; margin:0px 40px; display:none' border='0'>"+
  534. "<tr>"+
  535. " <td styles='formTableTitle' lable='workSplitAndDescription' width='10%' valign='top'></td>" +
  536. " <td styles='formTableValue' item='workSplitAndDescription' colspan='5'></td>" +
  537. "</tr>"+
  538. "<tr>"+
  539. " <td styles='formTableTitle' lable='specificActionInitiatives' valign='top'></td>" +
  540. " <td styles='formTableValue' item='specificActionInitiatives' colspan='5'></td>" +
  541. "</tr>"+
  542. "<tr>"+
  543. " <td styles='formTableTitle' lable='milestoneMark' valign='top'></td>" +
  544. " <td styles='formTableValue' item='milestoneMark' colspan='5'></td>" +
  545. "</tr>"+
  546. "<tr>"+
  547. " <td styles='formTableValue' colspan='6'>" +
  548. " <div styles='formTableValueDiv' item='attachments'></div>"+
  549. " </td>"+
  550. "<tr>"+
  551. "</table>"+
  552. "<div id='foldIcon' style='text-align: center; cursor:pointer;display:none;'><img style='width:20px;height:10px;' src='/x_component_Execution/$WorkReport/default/icon/fold.gif'></div>"
  553. this.tableContentDiv.set("html", html);
  554. this.expandDiv = this.tableContentDiv.getElementById("expandIcon");
  555. this.foldDiv = this.tableContentDiv.getElementById("foldIcon");
  556. this.workDetailsTab = this.tableContentDiv.getElementById("workDetails")
  557. if(this.expandDiv){
  558. this.expandDiv.addEvents({
  559. "click":function(){
  560. if(this.workDetailsTab) this.workDetailsTab.setStyle("display","");
  561. this.expandDiv.setStyle("display","none");
  562. this.foldDiv.setStyle("display","");
  563. }.bind(this)
  564. })
  565. }
  566. if(this.foldDiv){
  567. this.foldDiv.addEvents({
  568. "click":function(){
  569. if(this.workDetailsTab) this.workDetailsTab.setStyle("display","none");
  570. this.expandDiv.setStyle("display","");
  571. this.foldDiv.setStyle("display","none");
  572. }.bind(this)
  573. })
  574. }
  575. this.loadForm();
  576. },
  577. loadForm: function(){
  578. this.form = new MForm(this.formTableArea, this.workData, {
  579. style: "execution",
  580. isEdited: this.isEdited || this.isNew,
  581. itemTemplate: this.getItemTemplate(this.lp )
  582. },this.app);
  583. this.form.load();
  584. this.attachmentArea = this.formTableArea.getElement("[item='attachments']");
  585. this.loadAttachment( this.attachmentArea );
  586. },
  587. getItemTemplate: function( lp ){
  588. _self = this;
  589. return {
  590. workType: {
  591. text: lp.workType + ":",
  592. selectValue: lp.workTypeValue.split(",")
  593. },
  594. workLevel: {
  595. text: lp.workLevel + ":",
  596. type: "select",
  597. notEmpty:true,
  598. selectValue: lp.workLevelValue.split(",")
  599. },
  600. timeLimit: {text: lp.timeLimit + ":", tType: "date",name:"completeDateLimitStr",notEmpty:true},
  601. reportCycle: {
  602. text: lp.reportCycle + ":",
  603. type: "select",
  604. notEmpty:true,
  605. //selectValue: lp.reportCycleValue.split(","),
  606. selectText: lp.reportCycleText.split(","),
  607. className: "inputSelectUnformatWidth",
  608. event: {
  609. change: function (item, ev) {
  610. if (item.get("value") == lp.reportCycleText.split(",")[0]) {
  611. this.form.getItem("reportDay").resetItemOptions(lp.weekDayValue.split(","),lp.weekDayText.split(","))
  612. } else if (item.get("value") == lp.reportCycleText.split(",")[1]) {
  613. this.form.getItem("reportDay").resetItemOptions(lp.monthDayValue.split(","),lp.monthDayText.split(","))
  614. }
  615. }.bind(this)
  616. }
  617. },
  618. reportDay: {
  619. type: "select",
  620. name:"reportDayInCycle",
  621. notEmpty:true,
  622. aa:function(){}.bind(this),
  623. selectValue: (!this.data.reportCycle || this.data.reportCycle==lp.reportCycleText.split(",")[0])?lp.weekDayValue.split(","):lp.monthDayValue.split(","), //lp.weekDayValue.split(","),
  624. selectText: (!this.data.reportCycle || this.data.reportCycle==lp.reportCycleText.split(",")[0])?lp.weekDayText.split(","):lp.monthDayText.split(","),
  625. className: "inputSelectUnformatWidth"
  626. },
  627. dutyDepartment: {text: lp.dutyDepartment + ":", tType: "department",name:"responsibilityOrganizationName",notEmpty:true,event:{
  628. "change":function(item){
  629. var department = item.getValue();
  630. if( department ){
  631. _self.getDepartmentLeader( department, function( leader ){
  632. _self.form.getItem("dutyPerson").setValue(leader);
  633. })
  634. }
  635. }
  636. }},
  637. dutyPerson: {text: lp.dutyPerson + ":", tType: "identity",count:1,name:"responsibilityIdentity",notEmpty:true},
  638. secondDepartment: {text: lp.secondDepartment + ":", tType: "department",name:"cooperateOrganizationName", count: 0,event:{
  639. "change":function(item){
  640. var deptstr = item.getValue();
  641. if(deptstr){
  642. var depts = deptstr.split(",");
  643. var users = ""
  644. for(var i=0;i<depts.length;i++){
  645. if(depts[i]!=""){
  646. _self.getDepartmentLeader( depts[i], function( leader ){
  647. if(users=="") users = leader
  648. else users = users + ","+leader
  649. })
  650. }
  651. }
  652. _self.form.getItem("secondPerson").setValue(users);
  653. }
  654. }
  655. }},
  656. secondPerson: {text: lp.secondPerson + ":", tType: "identity",name:"cooperateIdentity", count: 0},
  657. readReader: {text: lp.readReader + ":", tType: "identity", name:"readLeaderIdentity",count: 0},
  658. deployPerson :{text: lp.deployPerson,name:"deployerIdentity"},
  659. subject: {text: lp.subject + ":",name:"title",notEmpty:true},
  660. workSplitAndDescription: {text: lp.workSplitAndDescription + ":", type: "textarea",name:"workDetail",notEmpty:true},
  661. specificActionInitiatives: {text: lp.specificActionInitiatives + ":", type: "textarea",name:"progressAction"},
  662. cityCompanyDuty: {text: lp.cityCompanyDuty + ":", type: "textarea",name:"dutyDescription"},
  663. milestoneMark: {text: lp.milestoneMark + ":", type: "textarea",name:"landmarkDescription"},
  664. importantMatters: {text: lp.importantMatters + ":", type: "textarea",name:"majorIssuesDescription"}
  665. }
  666. },
  667. loadAttachment: function( area ){
  668. this.attachment = new MWF.xApplication.Execution.Attachment( area, this.app, this.actions, this.app.lp, {
  669. documentId : this.data.workId,
  670. isNew : this.options.isNew,
  671. isEdited : this.options.isEdited
  672. })
  673. this.attachment.load();
  674. },
  675. loadReportAttachment: function( area,edit ){
  676. this.attachment = new MWF.xApplication.Execution.ReportAttachment( area, this.app, this.actions, this.app.lp, {
  677. //documentId : this.data.workId,
  678. documentId : this.workReportId,
  679. isNew : this.options.isNew,
  680. isEdited : edit,
  681. "size":this.workReportData.processStatus == this.lp.activityName.drafter ? "max":"min",
  682. onQueryUploadAttachment : function(){
  683. var saveData = {}
  684. saveData.workId = this.workReportData.workId;
  685. saveData.id = this.workReportData.id;
  686. if(this.workReportData.processStatus == this.lp.activityName.drafter){
  687. saveData.progressDescription = this.contentTextarea1.value;
  688. saveData.workPlan = this.contentTextarea2.value
  689. }
  690. this.actions.saveWorkReport( saveData, function(json){
  691. if(json.type == "success"){
  692. this.attachment.isQueryUploadSuccess = true;
  693. }
  694. }.bind(this),function(xhr,text,error){
  695. this.attachment.isQueryUploadSuccess = false;
  696. }.bind(this),false);
  697. }.bind(this)
  698. })
  699. this.attachment.load();
  700. },
  701. readDone: function(){
  702. //alert(this.data.todoId)
  703. this.actions.readDone(this.data.todoId,function(json){
  704. this.app.notice(this.lp.prompt.readDone,"success");
  705. this.fireEvent("reloadView", json);
  706. this.close();
  707. }.bind(this),function(xhr){}.bind(this))
  708. },
  709. save: function(){
  710. var saveData = {}
  711. saveData.workId = this.workReportData.workId;
  712. saveData.id = this.workReportData.id;
  713. if(this.workReportData.processStatus == this.lp.activityName.drafter){
  714. saveData.progressDescription = this.contentTextarea1.value;
  715. saveData.workPlan = this.contentTextarea2.value
  716. }else if(this.workReportData.processStatus == this.lp.activityName.manager){
  717. saveData.adminSuperviseInfo = this.contentTextarea3.value
  718. }else if(this.workReportData.processStatus == this.lp.activityName.leader){
  719. saveData.opinion = this.contentTextarea4.value
  720. }
  721. this.actions.saveWorkReport( saveData, function(json){
  722. if(json.type == "success"){
  723. this.app.notice(this.lp.information.saveSuccess, "success");
  724. }
  725. }.bind(this),function(xhr,text,error){
  726. var errorText = error;
  727. if (xhr) errorMessage = xhr.responseText;
  728. var e = JSON.parse(errorMessage);
  729. if(e.message){
  730. this.app.notice( e.message,"error");
  731. }else{
  732. this.app.notice( errorText,"error");
  733. }
  734. }.bind(this));
  735. },
  736. submit: function(){
  737. if(this.contentTextarea1){
  738. if(this.contentTextarea1.value == ""){
  739. this.app.notice(this.lp.contentTitle1+this.lp.checkEmpty, "error");
  740. return false;
  741. }
  742. }
  743. if(this.contentTextarea2){
  744. if(this.contentTextarea2.value == ""){
  745. this.app.notice(this.lp.contentTitle2+this.lp.checkEmpty, "error");
  746. return false;
  747. }
  748. }
  749. //if(this.contentTextarea3){
  750. // if(this.contentTextarea3.value == ""){
  751. // this.app.notice(this.lp.adminContentTitle+this.lp.checkEmpty, "error");
  752. // return false;
  753. // }
  754. //}
  755. //if(this.contentTextarea4){
  756. // if(this.contentTextarea4.value == ""){
  757. // this.app.notice(this.lp.leaderContentTitle+this.lp.checkEmpty, "error");
  758. // return false;
  759. // }
  760. //}
  761. var saveData = {}
  762. saveData.workId = this.workReportData.workId;
  763. saveData.id = this.workReportData.id;
  764. if(this.workReportData.processStatus == this.lp.activityName.drafter){
  765. saveData.progressDescription = this.contentTextarea1.value;
  766. saveData.workPlan = this.contentTextarea2.value
  767. }else if(this.workReportData.processStatus == this.lp.activityName.manager){
  768. saveData.adminSuperviseInfo = this.contentTextarea3.value
  769. }else if(this.workReportData.processStatus == this.lp.activityName.leader){
  770. saveData.opinion = this.contentTextarea4.value
  771. }
  772. this.actions.submitWorkReport( saveData, function(json){
  773. if(json.type == "success"){
  774. this.app.notice(this.lp.prompt.submitWorkReport,"success");
  775. this.fireEvent("reloadView", json);
  776. this.close();
  777. }
  778. }.bind(this),function(xhr,text,error){
  779. var errorText = error;
  780. if (xhr) errorMessage = xhr.responseText;
  781. var e = JSON.parse(errorMessage);
  782. if(e.message){
  783. this.app.notice( e.message,"error");
  784. }else{
  785. this.app.notice( errorText,"error");
  786. }
  787. }.bind(this));
  788. },
  789. _createBottomContent: function () {
  790. if(this.processIdentity == this.app.identity || this.processIdentity.indexOf(this.app.identity)>-1) {
  791. this.submitActionNode = new Element("div.submitActionNode", {
  792. "styles": this.css.formCancelActionNode,
  793. "text": this.lp.bottomAction.submit
  794. }).inject(this.formBottomNode)
  795. .addEvents({
  796. "click": function () {
  797. this.submit();
  798. }.bind(this)
  799. })
  800. }
  801. if(this.processIdentity == this.app.identity || this.processIdentity.indexOf(this.app.identity)>-1) {
  802. this.saveActionNode = new Element("div.saveActionNode", {
  803. "styles": this.css.formCancelActionNode,
  804. "text": this.lp.bottomAction.save
  805. }).inject(this.formBottomNode)
  806. .addEvents({
  807. "click": function () {
  808. this.save();
  809. }.bind(this)
  810. })
  811. }
  812. if(this.options.isRead){
  813. this.readActionNode = new Element("div.readActionNode", {
  814. "styles": this.css.formCancelActionNode,
  815. "text": this.lp.bottomAction.readDone
  816. }).inject(this.formBottomNode);
  817. this.readActionNode.addEvent("click", function (e) {
  818. this.readDone(e);
  819. }.bind(this));
  820. }
  821. this.cancelActionNode = new Element("div.formCancelActionNode", {
  822. "styles": this.css.formCancelActionNode,
  823. "text": this.lp.bottomAction.close
  824. }).inject(this.formBottomNode);
  825. this.cancelActionNode.addEvent("click", function (e) {
  826. this.cancel(e);
  827. }.bind(this));
  828. //控制按钮权限
  829. //如果已归档,则只留下关闭按钮
  830. if (this.workReportData && this.workReportData.status == this.lp.statuArchive) {
  831. if(this.submitActionNode)this.submitActionNode.destroy();
  832. if(this.saveActionNode)this.saveActionNode.destroy();
  833. if(this.readActionNode)this.readActionNode.destroy();
  834. }
  835. }
  836. });