WorkReport.js 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. MWF.xApplication.Execution = MWF.xApplication.Execution || {};
  2. MWF.xDesktop.requireApp("Template", "MPopupForm", 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: MPopupForm,
  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||explorer;
  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.container = this.options.container||this.app.content;
  32. this.options.title = this.lp.title;
  33. this.data = data || {};
  34. this.actions = actions;
  35. },
  36. load: function () {
  37. if (this.options.isNew) {
  38. this.create();
  39. } else if (this.options.isEdited) {
  40. this.edit();
  41. } else {
  42. this.open();
  43. }
  44. this.setContentSize();
  45. this.setContentSizeFun = this.setContentSize.bind(this);
  46. this.app.addEvent("resize", this.setContentSizeFun);
  47. if(this.workReportData){
  48. //百分比
  49. if(this.completeProgressContentDiv){
  50. var obj = this.completeProgressContentDiv.getElements(".completeProgressLineDiv");
  51. obj.setStyles({"background":"#ccc"});
  52. var curLen = parseInt(this.workReportData.progressPercent/10);
  53. obj.each(function(d,j){
  54. if(j<curLen){
  55. d.setStyles({"background":"#369"})
  56. }
  57. })
  58. }
  59. //是否完成
  60. if(this.completeSelect){
  61. this.completeSelect.set("value",this.workReportData.isWorkCompleted?"yes":"no")
  62. }
  63. }
  64. },
  65. setContentSize: function () {
  66. var allSize = this.app.content.getSize();
  67. this.reportContentInforHeight = ( allSize.y - (this.formTopNode.getSize().y ) );
  68. //alert(reportContentInforHeight)
  69. if(this.prevReportInforListDiv){
  70. this.prevReportInforListDiv.setStyles({
  71. "height": "" + this.reportContentInforHeight + "px"
  72. });
  73. }
  74. },
  75. reload:function(data){
  76. },
  77. createTopNode: function () {
  78. if (!this.formTopNode) {
  79. this.formTopNode = new Element("div.formTopNode", {
  80. "styles": this.css.formTopNode
  81. }).inject(this.formNode);
  82. this.formTopIconNode = new Element("div", {
  83. "styles": this.css.formTopIconNode
  84. }).inject(this.formTopNode);
  85. this.formTopTextNode = new Element("div.formTopTextNode", {
  86. "styles": this.css.formTopTextNode,
  87. "text": this.lp.topTitle + ( this.data.title ? ("-" + this.data.title ) : "" )
  88. }).inject(this.formTopNode);
  89. if (this.options.closeAction) {
  90. this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  91. this.formTopCloseActionNode.addEvent("click", function () {
  92. this.close()
  93. }.bind(this))
  94. }
  95. this.formTopContentNode = new Element("div", {
  96. "styles": this.css.formTopContentNode
  97. }).inject(this.formTopNode);
  98. this._createTopContent();
  99. }
  100. },
  101. _createTopContent: function () {
  102. },
  103. createContent: function () {
  104. this.formContentNode = new Element("div.formContentNode", {
  105. "styles": this.css.formContentNode
  106. }).inject(this.formNode);
  107. this.formTableContainer = new Element("div.formTableContainer", {
  108. "styles": this.css.formTableContainer
  109. }).inject(this.formContentNode);
  110. this.formTableArea = new Element("div.formTableArea", {
  111. "styles": this.css.formTableArea
  112. }).inject(this.formTableContainer);
  113. this.reportLinksDiv = new Element("div.reportLinksDiv",{
  114. "styles":this.css.reportLinksDiv,
  115. "text":this.lp.reportLinks
  116. }).inject(this.formTableArea)
  117. .addEvents({
  118. "click":function(){
  119. this.createPrevReport();
  120. }.bind(this)
  121. });
  122. this.titleDiv = new Element("div.titleDiv",{
  123. "styles":this.css.titleDiv,
  124. "text":this.lp.topTitle + ( this.data.title ? ("-" + this.data.title ) : "" ),
  125. "title":this.lp.topTitle + ( this.data.title ? ("-" + this.data.title ) : "" )
  126. }).inject(this.formTableArea);
  127. this.centerWorkDiv = new Element("div.centerWorkDiv",{"styles":this.css.centerWorkDiv}).inject(this.formTableArea);
  128. this.centerWorkTitleDiv = new Element("div.centerWorkTitleDiv",{
  129. "styles":this.css.tabTitleDiv,
  130. "text":this.lp.title
  131. }).inject(this.centerWorkDiv);
  132. this.tableContentDiv = new Element("div.tableContentDiv").inject(this.formTableArea);
  133. if(this.options.workReportId){
  134. this.workReportId = this.options.workReportId;
  135. }
  136. this.workId = this.data.workId;
  137. this.processStatus = "";
  138. this.processIdentity = "";
  139. if(this.options.from && this.options.from == "drafter"){
  140. this.actions.workReportDrafter(this.data.workId, function( json ){
  141. if(json.type && json.type=="success"){
  142. this.workReportData = json.data;
  143. if(json.data.id){
  144. this.workReportId = json.data.id;
  145. }
  146. if(json.data.currentProcessorIdentityList){
  147. this.processIdentity = json.data.currentProcessorIdentityList
  148. }
  149. if(json.data.processStatus){
  150. this.processStatus = json.data.processStatus
  151. }
  152. }
  153. }.bind(this),null,false);
  154. }else{ //不是草稿的 直接获取this.data信息
  155. this.actions.getWorkReport(this.data.workReportId,function(json){ //alert(JSON.stringify(json))
  156. if(json.type=="success"){
  157. this.workReportData = json.data;
  158. if(json.data.id){
  159. this.workReportId = json.data.id
  160. }
  161. }
  162. }.bind(this),null,false);
  163. if(this.workReportData.currentProcessorIdentityList){
  164. this.processIdentity = this.workReportData.currentProcessorIdentityList
  165. }
  166. if(this.workReportData.processStatus){
  167. this.processStatus = this.workReportData.processStatus
  168. }
  169. }
  170. //alert("workreportData="+JSON.stringify(this.workReportData))
  171. //获取工作信息
  172. if(this.data.workId){
  173. this.actions.getTask(this.workId, function(json){
  174. if(json.data){
  175. this.workData = json.data;
  176. }
  177. }.bind(this),null,false);
  178. }
  179. //alert("this.workReportId="+this.workReportId)
  180. //alert("this.workId="+this.workId)
  181. //获取具体工作详细信息
  182. if(this.data.workId){
  183. this.actions.getBaseWorkDetails(this.workId, function (json) {
  184. this.workData.workSplitAndDescription = json.data.workDetail;
  185. this.workData.specificActionInitiatives = json.data.progressAction;
  186. this.workData.cityCompanyDuty = json.data.dutyDescription;
  187. this.workData.milestoneMark = json.data.landmarkDescription;
  188. this.workData.importantMatters = json.data.majorIssuesDescription;
  189. }.bind(this),null,false);
  190. }
  191. this._createTableContent();
  192. if(this.workReportData.title){
  193. this.titleDiv.set("text",this.workReportData.title.length>50?this.workReportData.title.substr(0,50)+"...":this.workReportData.title);
  194. this.titleDiv.set("title",this.workReportData.title);
  195. }
  196. //委派记录
  197. if(this.workData.okrWorkAuthorizeRecords){
  198. //if(this.workData.workDeployAuthorizeRecords){
  199. this.appointContentDiv = new Element("div.appointContentDiv",{
  200. "styles":this.css.appointContentDiv
  201. }).inject(this.formTableArea);
  202. this.appointContentTitleDiv = new Element("div.appointContentTitleDiv",{
  203. "styles":this.css.tabTitleDiv,
  204. "text":this.lp.appointTitle
  205. }).inject(this.appointContentDiv);
  206. this.appointContentInfor = new Element("div.appointContentInfor",{
  207. "styles": this.css.appointContentInfor
  208. }).inject(this.appointContentDiv);
  209. this.workData.okrWorkAuthorizeRecords.each(function(d){
  210. if(d.operationType == "AUTHORIZE"){
  211. var ttext = d.source.split("@")[0]+this.lp.appointFor+ d.target.split("@")[0];
  212. ttext += "("+ d.operationTime+") ";
  213. ttext += "意见:" + d.opinion;
  214. }
  215. if(d.operationType == "TACKBACK"){
  216. var ttext = d.source.split("@")[0]+this.lp.appointBack;
  217. ttext += "("+ d.operationTime+") ";
  218. ttext += "意见:" + d.opinion;
  219. }
  220. this.appointRecordDiv = new Element("div.appointRecordDiv",{
  221. "styles":this.css.appointRecordDiv,
  222. "text": ttext
  223. }).inject(this.appointContentInfor)
  224. }.bind(this))
  225. }
  226. //判断状态 如果草稿并且当前人是拟稿人,显示contentTextarea1,contentTextarea2 编辑状态 其他只读
  227. //当前秘书状态、并且当前人是秘书 contentTextarea3 编辑,其他只读
  228. //当前领导、并且当前人领导(当前处理人):contentTextarea4编辑 其他只读
  229. //拟稿人填写
  230. this.reportContentDiv = new Element("div.centerWorkDiv",{"styles":this.css.reportContentDiv}).inject(this.formTableArea);
  231. this.reportContentTitleDiv = new Element("div.reportContentTitleDiv",{
  232. "styles":this.css.tabTitleDiv,
  233. "text":this.lp.reportContentTitle
  234. }).inject(this.reportContentDiv);
  235. this.reportContentInfor = new Element("div.reportContentInfor",{
  236. "styles": this.css.reportContentInfor
  237. }).inject(this.reportContentDiv);
  238. this.contentTitle1 = new Element("div.contentTitle1",{
  239. "styles":this.css.contentTitle,
  240. "text":this.lp.contentTitle1 + ":"
  241. }).inject(this.reportContentInfor);
  242. if(this.workReportData.processStatus == this.lp.activityName.drafter && this.workReportData.isReporter){
  243. this.contentTextarea1 = new Element("textarea.contentTextarea1",{
  244. "styles":this.css.contentTextarea,
  245. "text" : this.workReportData.progressDescription?this.workReportData.progressDescription:""
  246. }).inject(this.reportContentInfor);
  247. }else{
  248. this.contentTextStr1 = new Element("div.contentTextStr1",{
  249. "styles": this.css.contentTextStr,
  250. "text" : this.workReportData.progressDescription?this.workReportData.progressDescription:""
  251. }).inject(this.reportContentInfor)
  252. }
  253. this.contentTitle2 = new Element("div.contentTitle2",{
  254. "styles":this.css.contentTitle,
  255. "text":this.lp.contentTitle2 + ":"
  256. }).inject(this.reportContentInfor);
  257. if(this.workReportData.processStatus == this.lp.activityName.drafter && this.workReportData.isReporter){
  258. this.contentTextarea2 = new Element("textarea.contentTextarea2",{
  259. "styles":this.css.contentTextarea,
  260. "text" : this.workReportData.workPlan?this.workReportData.workPlan:""
  261. }).inject(this.reportContentInfor);
  262. }else{
  263. this.contentTextStr2 = new Element("div.contentTextStr2",{
  264. "styles" : this.css.contentTextStr,
  265. "text" : this.workReportData.workPlan?this.workReportData.workPlan:""
  266. }).inject(this.reportContentInfor)
  267. }
  268. //是否办结
  269. this.completeDiv = new Element("div.completeDiv",{
  270. "styles":this.css.completeDiv
  271. }).inject(this.reportContentInfor);
  272. this.completeTextSpan = new Element("span.completeTextSpan",{
  273. "styles":this.css.completeTextSpan,
  274. "text":this.lp.isCompleted
  275. }).inject(this.completeDiv);
  276. //if(this.processIdentity == this.app.identity || this.processIdentity.indexOf(this.app.identity)>-1) {
  277. if((this.workReportData.processStatus == this.lp.activityName.drafter && this.workReportData.isReporter)|| (this.workReportData.processStatus == this.lp.activityName.manager && (this.processIdentity == this.app.identity || this.processIdentity.indexOf(this.app.identity)>-1))){
  278. this.completeSelect = new Element("select.completeSelect",{
  279. styles:this.css.completeSelect
  280. }).inject(this.completeDiv);
  281. //this.completeSelectOption = new Element("option.completeSelectOption",{"text":"","value":"no"}).inject(this.completeSelect)
  282. this.completeSelectOption = new Element("option.completeSelectOption",{"text":this.lp.isCompletedNoOption,"value":"no"}).inject(this.completeSelect);
  283. this.completeSelectOption = new Element("option.completeSelectOption",{"text":this.lp.isCompletedYesOption,"value":"yes"}).inject(this.completeSelect);
  284. this.completeSelect.addEvents({
  285. "change":function(){
  286. if(this.completeSelect.get("value")=="yes"){
  287. var obj = this.completeProgressContentDiv.getElements(".completeProgressLineDiv");
  288. obj.setStyles({"background":"#369"});
  289. this.completePercentRateSpan.set("text","100%");
  290. }else{
  291. this.completePercentRateSpan.set("text",parseInt(this.workReportData.progressPercent)+"%");
  292. var obj = this.completeProgressContentDiv.getElements(".completeProgressLineDiv");
  293. obj.setStyles({"background":"#ccc"});
  294. var curLen = parseInt(this.workReportData.progressPercent/10);
  295. obj.each(function(d,j){
  296. if(j<curLen){
  297. d.setStyles({"background":"#369"});
  298. }
  299. })
  300. }
  301. }.bind(this)
  302. })
  303. }else{
  304. var tmpstr = this.workReportData.isWorkCompleted?this.lp.isCompletedYesOption:this.lp.isCompletedNoOption;
  305. this.completeTextSpan.set("text",this.completeTextSpan.get("text")+" "+tmpstr)
  306. }
  307. this.completePercentSpan = new Element("span.completePercentSpan",{
  308. "styles":this.css.completePercentSpan,
  309. "text":this.lp.completePercent
  310. }).inject(this.completeDiv);
  311. this.completePercentRateSpan = new Element("span.completePercentRateSpan",{
  312. "id":"completePercentRateSpan",
  313. "styles":this.css.completePercentRateSpan,
  314. "text":parseInt(this.workReportData.progressPercent)+"%"
  315. }).inject(this.completeDiv);
  316. if((this.workReportData.processStatus == this.lp.activityName.drafter && this.workReportData.isReporter)|| (this.workReportData.processStatus == this.lp.activityName.manager && (this.processIdentity == this.app.identity || this.processIdentity.indexOf(this.app.identity)>-1))){
  317. this.completeProgressDiv = new Element("div.completeProgressDiv",{
  318. "styles":this.css.completeProgressDiv
  319. }).inject(this.completeDiv);
  320. this.completeProgressContentDiv = new Element("div.completeProgressContentDiv",{
  321. "styles":this.css.completeProgressContentDiv
  322. }).inject(this.completeProgressDiv);
  323. var _self = this;
  324. for(i=0;i<11;i++){
  325. var tmpPointDiv = new Element("div.completeProgressPointDiv",{
  326. "styles":this.css.completeProgressPointDiv,
  327. "position":i
  328. }).inject(_self.completeProgressContentDiv);
  329. tmpPointDiv.setStyles({"left":(i*50)+"px"});
  330. tmpPointDiv.addEvents({
  331. "click":function(){
  332. _self.selectProgress(parseInt(this.get("position")),"point")
  333. }
  334. });
  335. if(i<10){
  336. var tmpLineDiv = new Element("div.completeProgressLineDiv",{
  337. "styles":this.css.completeProgressLineDiv,
  338. "position":i
  339. }).inject(_self.completeProgressContentDiv);
  340. tmpLineDiv.setStyles({"left":(i*50)+"px"});
  341. tmpLineDiv.addEvents({
  342. "click":function(){
  343. _self.selectProgress(parseInt(this.get("position"))+1,"line");
  344. }
  345. })
  346. }
  347. }
  348. this.completeProgressTextDiv = new Element("div.completeProgressTextDiv",{
  349. "styles":this.css.completeProgressTextDiv
  350. }).inject(this.completeProgressDiv);
  351. for(i=0;i<11;i++){
  352. var tmpCompletePercentTextSpan = new Element("lable.tmpCompletePercentTextSpan",{
  353. "styles":this.css.tmpCompletePercentTextSpan,
  354. "text":(i*10)+"%"
  355. }).inject(this.completeProgressTextDiv)
  356. }
  357. }
  358. //是否办结
  359. this.reportAttachment = new Element("div.reportAttachment",{
  360. "item":"reportAttachments"
  361. }).inject(this.reportContentInfor);
  362. this.reportAttachment.setStyles({"width":"95%"});
  363. var isUpload = false;
  364. if(this.workReportData.processStatus == this.lp.activityName.drafter && this.workReportData.isReporter){
  365. isUpload = true
  366. }
  367. this.reportAttachmentArea = this.formTableArea.getElement("[item='reportAttachments']");
  368. this.loadReportAttachment( this.reportAttachmentArea,isUpload );
  369. //获取秘书及领导评价信息
  370. var opinionData = {};
  371. opinionData.workReportId = "";
  372. //this.actions.getWorkReportOpinion();
  373. //管理员填写
  374. if(this.workReportData.needAdminAudit){
  375. this.createAdminContent();
  376. }
  377. //领导填写,在草稿和督办员环节不显示
  378. if(this.workReportData && (this.workReportData.activityName != this.lp.activityName.drafter && this.workReportData.activityName != this.lp.activityName.manager)){
  379. this.reportContentDiv = new Element("div.centerWorkDiv",{"styles":this.css.reportContentDiv}).inject(this.formTableArea);
  380. this.reportContentTitleDiv = new Element("div.reportContentTitleDiv",{
  381. "styles":this.css.tabTitleDiv,
  382. "text":this.lp.leaderContentTitle
  383. }).inject(this.reportContentDiv);
  384. this.reportContentInfor = new Element("div.reportContentInfor",{
  385. "styles": this.css.reportContentInfor
  386. }).inject(this.reportContentDiv);
  387. this.getLeaderOpinions();
  388. if(this.workReportData.processStatus == this.lp.activityName.leader && this.workReportData.isReadLeader && this.processIdentity.indexOf(this.app.identity)>-1){
  389. this.contentTextarea4 = new Element("textarea.contentTextarea4",{
  390. "styles":this.css.contentTextarea,
  391. "text" : this.leaderOpinionDrafter?this.leaderOpinionDrafter:""
  392. }).inject(this.reportContentInfor);
  393. }else{
  394. //if(this.workReportData.reportWorkflowType && this.workReportData.reportWorkflowType == "DEPLOYER"){
  395. // //一对一,上下级
  396. // this.contentTextStr4 = new Element("div.contentTextStr4",{
  397. // "styles": this.css.contentTextStr,
  398. // "text":"意见"
  399. // }).inject(this.reportContentInfor)
  400. //}else{
  401. // this.getLeaderOpinions();
  402. //}
  403. }
  404. }
  405. //权限控制,如果已归档,则输入框去掉
  406. if(this.workReportData && this.workReportData.status == this.lp.statuArchive){
  407. if(this.contentTextarea1)this.contentTextarea1.destroy();
  408. if(this.contentTextarea2)this.contentTextarea2.destroy();
  409. if(this.contentTextarea3)this.contentTextarea3.destroy();
  410. if(this.contentTextarea4)this.contentTextarea4.destroy();
  411. }
  412. },
  413. selectProgress:function(i,s){
  414. var obj = this.completeProgressContentDiv.getElements(".completeProgressLineDiv");
  415. obj.setStyles({"background":"#ccc"});
  416. obj.each(function(d,j){
  417. if(j<i){
  418. d.setStyles({"background":"#369"})
  419. }
  420. });
  421. this.completePercentRateSpan.set("text",(i*10)+"%");
  422. if(i==10 && this.completeSelect){
  423. this.completeSelect.set("value","yes")
  424. }
  425. if(i<10 && this.completeSelect){
  426. this.completeSelect.set("value","no")
  427. }
  428. },
  429. getLeaderOpinions: function(){
  430. //获取领导意见
  431. var logs = this.workReportData.processLogs;
  432. this.leaderTitle = [];
  433. this.leaderValue = [];
  434. if(logs){
  435. logs.each(function(data){
  436. if(data.activityName == this.lp.activityName.leader && data.processStatus == this.lp.status.drafter && data.processorIdentity == this.app.identity){
  437. this.leaderOpinionDrafter = data.opinion
  438. }else{
  439. if(data.activityName == this.lp.activityName.leader && data.processStatus == this.lp.status.effect){
  440. this.leaderTitle.push(data.processorIdentity.split("@")[0]+"("+data.processTimeStr+")");
  441. this.leaderValue.push(data.opinion )
  442. }
  443. }
  444. }.bind(this))
  445. }
  446. //领导意见显示区域
  447. this.reportLeaderOpinionsDiv = new Element("div.reportLeaderOpinionsDiv",{
  448. "styles":this.css.reportLeaderOpinionsDiv
  449. }).inject(this.reportContentInfor);
  450. for(var i=0;i<this.leaderTitle.length;i++){
  451. var reportLeaderContentDiv = new Element("div.reportLeaderContentDiv",{"styles":this.css.reportLeaderContentDiv}).inject(this.reportLeaderOpinionsDiv);
  452. var reportLeaderTitleDiv = new Element("div.reportLeaderTitleDiv",{
  453. "styles":this.css.reportLeaderTitleDiv,
  454. "text":this.leaderTitle[i]+":"
  455. }).inject(reportLeaderContentDiv);
  456. var reportLeaderValueDiv = new Element("div.reportLeaderValueDiv",{
  457. "styles":this.css.reportLeaderValueDiv,
  458. "text":this.leaderValue[i]
  459. }).inject(reportLeaderContentDiv);
  460. }
  461. },
  462. createPrevReport: function(){
  463. if(this.prevReportDiv) this.prevReportDiv.destroy();
  464. this.prevReportDiv = new Element("div.prevReportDiv",{
  465. styles:this.css.prevReportDiv
  466. }).inject(this.formTableContainer);
  467. this.prevReportTopDiv = new Element("div.prevReportTopDiv",{
  468. "styles":this.css.prevReportTopDiv
  469. }).inject(this.prevReportDiv);
  470. this.prevReportTopTitleDiv = new Element("div.prevReportTopTitleDiv",{
  471. "styles": this.css.prevReportTopTitleDiv,
  472. "text" : this.lp.reportLinks+":"
  473. }).inject(this.prevReportTopDiv);
  474. this.prevReportTopCloseDiv = new Element("div.prevReportTopCloseDiv",{
  475. "styles": this.css.prevReportTopCloseDiv
  476. }).inject(this.prevReportTopDiv)
  477. .addEvents({
  478. "click": function(){
  479. this.prevReportDiv.destroy();
  480. }.bind(this)
  481. });
  482. this.prevReportListDiv = new Element("div.prevReportListDiv",{
  483. "styles":this.css.prevReportListDiv
  484. }).inject(this.prevReportDiv);
  485. this.actions.getWorkReportList(this.workReportData.workId, function( json ){
  486. if(json.type && json.type=="success" && json.data){
  487. json.data.each(function(data){
  488. var createTimes = data.createTime.split(" ")[0];
  489. var prevReportWorkId = data.id;
  490. var prevReportListLi = new Element("li.prevReportListLi",{
  491. "styles": this.css.prevReportListLi,
  492. "id" : prevReportWorkId,
  493. "text": createTimes + "-" + data.shortTitle
  494. }).inject(this.prevReportListDiv)
  495. .addEvents({
  496. "mouseover":function(){
  497. prevReportListLi.setStyle("background-color","#3c76c1");
  498. }.bind(this),
  499. "mouseout":function(){
  500. if(prevReportWorkId != this.currentPrevReportLinkId){
  501. prevReportListLi.setStyle("background-color","");
  502. }
  503. }.bind(this),
  504. "click" :function(){
  505. this.prevReportTopCloseDiv.setStyle("display","none");
  506. this.expandWorkReportInfor(prevReportListLi);
  507. }.bind(this)
  508. })
  509. }.bind(this))
  510. }
  511. }.bind(this),null,false);
  512. //this.createPrevReportInfor();
  513. },
  514. createPrevReportInfor : function(workReportId){
  515. if(this.prevReportInforDiv) this.prevReportInforDiv.destroy();
  516. this.prevReportInforDiv = new Element("div.prevReportInforDiv",{
  517. "styles": this.css.prevReportInforDiv
  518. }).inject(this.formTableContainer);
  519. this.prevReportInforTopDiv = new Element("div.prevReportInforTopDiv",{
  520. "styles":this.css.prevReportInforTopDiv
  521. }).inject(this.prevReportInforDiv);
  522. this.prevReportInforTopCloseDiv = new Element("div.prevReportInforTopCloseDiv",{
  523. "styles": this.css.prevReportInforTopCloseDiv
  524. }).inject(this.prevReportInforTopDiv)
  525. .addEvents({
  526. "click": function(){
  527. this.prevReportDiv.destroy();
  528. this.prevReportInforDiv.destroy();
  529. }.bind(this)
  530. });
  531. this.prevReportInforListDiv = new Element("div.prevReportInforListDiv",{
  532. "styles":this.css.prevReportInforListDiv
  533. }).inject(this.prevReportInforDiv);
  534. this.prevReportInforListDiv.setStyles({"height":this.reportContentInforHeight+"px"})
  535. //这里显示具体内容
  536. this.actions.getWorkReport(workReportId,function(json){
  537. //alert(JSON.stringify(json))
  538. if(json.type == "success"){
  539. var prevContentDiv = new Element("div.prevContentDiv",{
  540. "styles": this.css.prevContentDiv
  541. }).inject(this.prevReportInforListDiv);
  542. var prevContentTitleDiv = new Element("div.prevContentTitleDiv",{
  543. "styles" : this.css.prevContentTitleDiv,
  544. "text" : this.lp.contentTitle1 + ":"
  545. }).inject(prevContentDiv);
  546. var prevContentValueDiv = new Element("div.prevContentValueDiv",{
  547. "styles": this.css.prevContentValueDiv,
  548. "text" : json.data.progressDescription
  549. }).inject(prevContentDiv);
  550. prevContentDiv = new Element("div.prevContentDiv",{
  551. "styles": this.css.prevContentDiv
  552. }).inject(this.prevReportInforListDiv);
  553. prevContentTitleDiv = new Element("div.prevContentTitleDiv",{
  554. "styles" : this.css.prevContentTitleDiv,
  555. "text" : this.lp.contentTitle2 + ":"
  556. }).inject(prevContentDiv);
  557. prevContentValueDiv = new Element("div.prevContentValueDiv",{
  558. "styles": this.css.prevContentValueDiv,
  559. "text" : json.data.workPlan
  560. }).inject(prevContentDiv);
  561. //是否办结
  562. prevContentTitleDiv = new Element("div.prevContentTitleDiv",{
  563. "styles" : this.css.prevContentTitleDiv,
  564. "text" : this.lp.contentTitle2 + ":"
  565. }).inject(prevContentDiv);
  566. var tmpstr = json.data.isWorkCompleted?" "+this.lp.isCompletedYesOption+" ":" "+this.lp.isCompletedNoOption+" ";
  567. tmpstr = this.lp.isCompleted+":" + tmpstr;
  568. tmpstr = tmpstr + " " +this.lp.completePercent + " " + parseInt(json.data.progressPercent)+"%";
  569. prevContentTitleDiv.set("text",tmpstr);
  570. //管理员督办
  571. if(json.data.needAdminAudit){
  572. prevContentDiv = new Element("div.prevContentDiv",{
  573. "styles": this.css.prevContentDiv
  574. }).inject(this.prevReportInforListDiv);
  575. prevContentTitleDiv = new Element("div.prevContentTitleDiv",{
  576. "styles" : this.css.prevContentTitleDiv,
  577. "text" : this.lp.adminContentTitle + ":"
  578. }).inject(prevContentDiv);
  579. prevContentValueDiv = new Element("div.prevContentValueDiv",{
  580. "styles": this.css.prevContentValueDiv,
  581. "text" : json.data.adminSuperviseInfo?json.data.adminSuperviseInfo:""
  582. }).inject(prevContentDiv);
  583. }
  584. //领导评价
  585. prevContentDiv = new Element("div.prevContentDiv",{
  586. "styles": this.css.prevContentDiv
  587. }).inject(this.prevReportInforListDiv);
  588. prevContentTitleDiv = new Element("div.prevContentTitleDiv",{
  589. "styles" : this.css.prevContentTitleDiv,
  590. "text" : this.lp.leaderContentTitle + ":"
  591. }).inject(prevContentDiv);
  592. prevContentValueDiv = new Element("div.prevContentValueDiv",{
  593. "styles": this.css.prevContentValueDiv
  594. }).inject(prevContentDiv);
  595. var reportLeaderOpinionsDiv = new Element("div.reportLeaderOpinionsDiv",{
  596. "styles":this.css.reportLeaderOpinionsDiv
  597. }).inject(prevContentValueDiv);
  598. var preLogs = json.data.processLogs;
  599. this.preLeaderTitle = [];
  600. this.preLeaderValue = [];
  601. if(preLogs){
  602. preLogs.each(function(data){
  603. if(data.activityName == this.lp.activityName.leader && data.processStatus == this.lp.status.drafter && data.processorIdentity == this.app.identity){
  604. this.leaderOpinionDrafter = data.opinion
  605. }else{
  606. if(data.activityName == this.lp.activityName.leader && data.processStatus == this.lp.status.effect){
  607. this.preLeaderTitle.push(data.processorIdentity.split("@")[0]+"("+data.processTimeStr+")");
  608. this.preLeaderValue.push(data.opinion )
  609. }
  610. }
  611. }.bind(this))
  612. }
  613. for(var i=0;i<this.preLeaderTitle.length;i++){
  614. var reportLeaderContentDiv = new Element("div.reportLeaderContentDiv",{"styles":this.css.reportLeaderContentDiv}).inject(reportLeaderOpinionsDiv);
  615. reportLeaderContentDiv.setStyle("border-bottom","1px dashed #3c76c1");
  616. var reportLeaderTitleDiv = new Element("div.reportLeaderTitleDiv",{
  617. "styles":this.css.reportLeaderTitleDiv,
  618. "text":this.preLeaderTitle[i]+":"
  619. }).inject(reportLeaderContentDiv);
  620. var reportLeaderValueDiv = new Element("div.reportLeaderValueDiv",{
  621. "styles":this.css.reportLeaderValueDiv,
  622. "text":this.preLeaderValue[i]
  623. }).inject(reportLeaderContentDiv);
  624. }
  625. //附件
  626. prevContentDiv = new Element("div.prevContentDiv",{
  627. "styles": this.css.prevContentDiv
  628. }).inject(this.prevReportInforListDiv);
  629. prevContentTitleDiv = new Element("div.prevContentTitleDiv",{
  630. "styles" : this.css.prevContentTitleDiv,
  631. "text" : this.lp.attachment+":"
  632. }).inject(prevContentDiv);
  633. prevContentValueDiv = new Element("div.prevContentValueDiv",{
  634. "styles": this.css.prevContentValueDiv
  635. }).inject(prevContentDiv);
  636. this.loadPreReportAttachment(prevContentValueDiv,workReportId);
  637. }
  638. }.bind(this),null,false);
  639. this.setScrollBar(this.prevReportInforListDiv);
  640. },
  641. loadPreReportAttachment: function( area,id ){
  642. this.attachment = new MWF.xApplication.Execution.ReportAttachment( area, this.app, this.actions, this.app.lp, {
  643. //documentId : this.data.workId,
  644. documentId : id,
  645. isNew : this.options.isNew,
  646. isEdited : false,
  647. "size":"min"
  648. });
  649. this.attachment.load();
  650. },
  651. expandWorkReportInfor:function(prevReportListLi){
  652. this.currentPrevReportLinkId = prevReportListLi.get("id");
  653. var liObj = this.prevReportListDiv.getElements("li");
  654. liObj.setStyle("background-color","");
  655. prevReportListLi.setStyle("background-color","#3c76c1");
  656. this.createPrevReportInfor(this.currentPrevReportLinkId);
  657. this.prevReportInforDiv.setStyle("display","");
  658. },
  659. createAdminContent: function(){
  660. this.reportContentDiv = new Element("div.centerWorkDiv",{"styles":this.css.reportContentDiv}).inject(this.formTableArea);
  661. this.reportContentTitleDiv = new Element("div.reportContentTitleDiv",{
  662. "styles":this.css.tabTitleDiv,
  663. "text":this.lp.adminContentTitle
  664. }).inject(this.reportContentDiv);
  665. this.reportContentInfor = new Element("div.reportContentInfor",{
  666. "styles": this.css.reportContentInfor
  667. }).inject(this.reportContentDiv);
  668. if(this.workReportData.processStatus == this.lp.activityName.manager && this.workReportData.isWorkAdmin){
  669. this.contentTextarea3 = new Element("textarea.contentTextarea3",{
  670. "styles":this.css.contentTextarea,
  671. "value":this.workReportData.adminSuperviseInfo?this.workReportData.adminSuperviseInfo:""
  672. }).inject(this.reportContentInfor);
  673. }else{
  674. this.contentTextStr3 = new Element("div.contentTextStr3",{
  675. "styles": this.css.contentTextStr,
  676. "text" : this.workReportData.adminSuperviseInfo?this.workReportData.adminSuperviseInfo:""
  677. }).inject(this.reportContentInfor)
  678. }
  679. },
  680. _createTableContent: function () {
  681. var html = "<table style='width:95%; margin:10px 40px; margin-bottom: 0px;' border='0'>" +
  682. "<tr>"+
  683. " <td styles='formTableTitle' lable='deployPerson' width='10%'></td>" +
  684. " <td styles='formTableValue' item='deployPerson' width='20%'></td>" +
  685. " <td styles='formTableTitle' lable='timeLimit' width='10%'></td>" +
  686. " <td styles='formTableValue' item='timeLimit' width='20%'></td>" +
  687. " <td styles='formTableTitle' lable='' width='10%'></td>" +
  688. " <td styles='formTableValue' item='' width='20%'></td>" +
  689. "</tr>"+
  690. "<tr>"+
  691. " <td styles='formTableTitle' lable='dutyDepartment'></td>" +
  692. " <td styles='formTableValue' item='dutyDepartment'></td>" +
  693. " <td styles='formTableTitle' lable='dutyPerson'></td>" +
  694. " <td styles='formTableValue' item='dutyPerson'></td>" +
  695. " <td styles='formTableTitle' lable='reportCycle'></td>" +
  696. " <td styles='formTableValue'><span item='reportCycle'></span><span item='reportDay'></span></td>" +
  697. "</tr>"+
  698. "<tr>"+
  699. " <td styles='formTableTitle' lable='secondDepartment'></td>" +
  700. " <td styles='formTableValue' item='secondDepartment'></td>" +
  701. " <td styles='formTableTitle' lable='secondPerson'></td>" +
  702. " <td styles='formTableValue' item='secondPerson'></td>" +
  703. " <td styles='formTableTitle' lable='readReader'></td>" +
  704. " <td styles='formTableValue' item='readReader'></td>" +
  705. "</tr>"+
  706. "</table>"+
  707. "<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>"+
  708. "<table id='workDetails' style='width:95%; margin:0px 40px; display:none' border='0'>"+
  709. "<tr>"+
  710. " <td styles='formTableTitle' lable='workSplitAndDescription' width='10%' valign='top'></td>" +
  711. " <td styles='formTableValue' item='workSplitAndDescription' colspan='5'></td>" +
  712. "</tr>"+
  713. "<tr>"+
  714. " <td styles='formTableTitle' lable='specificActionInitiatives' valign='top'></td>" +
  715. " <td styles='formTableValue' item='specificActionInitiatives' colspan='5'></td>" +
  716. "</tr>"+
  717. "<tr>"+
  718. " <td styles='formTableTitle' lable='milestoneMark' valign='top'></td>" +
  719. " <td styles='formTableValue' item='milestoneMark' colspan='5'></td>" +
  720. "</tr>"+
  721. "<tr>"+
  722. " <td styles='formTableValue' colspan='6'>" +
  723. " <div styles='formTableValueDiv' item='attachments'></div>"+
  724. " </td>"+
  725. "<tr>"+
  726. "</table>"+
  727. "<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>"
  728. this.tableContentDiv.set("html", html);
  729. this.expandDiv = this.tableContentDiv.getElementById("expandIcon");
  730. this.foldDiv = this.tableContentDiv.getElementById("foldIcon");
  731. this.workDetailsTab = this.tableContentDiv.getElementById("workDetails");
  732. if(this.expandDiv){
  733. this.expandDiv.addEvents({
  734. "click":function(){
  735. if(this.workDetailsTab) this.workDetailsTab.setStyle("display","");
  736. this.expandDiv.setStyle("display","none");
  737. this.foldDiv.setStyle("display","");
  738. }.bind(this)
  739. })
  740. }
  741. if(this.foldDiv){
  742. this.foldDiv.addEvents({
  743. "click":function(){
  744. if(this.workDetailsTab) this.workDetailsTab.setStyle("display","none");
  745. this.expandDiv.setStyle("display","");
  746. this.foldDiv.setStyle("display","none");
  747. }.bind(this)
  748. })
  749. }
  750. this.loadForm();
  751. },
  752. loadForm: function(){
  753. this.form = new MForm(this.formTableArea, this.workData, {
  754. style: "execution",
  755. isEdited: this.isEdited || this.isNew,
  756. itemTemplate: this.getItemTemplate(this.lp )
  757. },this.app);
  758. this.form.load();
  759. this.attachmentArea = this.formTableArea.getElement("[item='attachments']");
  760. this.loadAttachment( this.attachmentArea );
  761. },
  762. getItemTemplate: function( lp ){
  763. _self = this;
  764. return {
  765. workType: {
  766. text: lp.workType + ":",
  767. selectValue: lp.workTypeValue.split(",")
  768. },
  769. workLevel: {
  770. text: lp.workLevel + ":",
  771. type: "select",
  772. notEmpty:true,
  773. selectValue: lp.workLevelValue.split(",")
  774. },
  775. timeLimit: {text: lp.timeLimit + ":", tType: "date",name:"completeDateLimitStr",notEmpty:true},
  776. reportCycle: {
  777. text: lp.reportCycle + ":",
  778. type: "select",
  779. notEmpty:true,
  780. //selectValue: lp.reportCycleValue.split(","),
  781. selectText: lp.reportCycleText.split(",")
  782. },
  783. reportDay: {
  784. type: "select",
  785. name:"reportDayInCycle",
  786. //aa:function(){alert(JSON.stringify(this.workData.reportCycle))}.bind(this),
  787. selectValue: (!this.workData.reportCycle || this.workData.reportCycle==lp.reportCycleText.split(",")[0])?lp.weekDayValue.split(","):lp.monthDayValue.split(","),
  788. selectText: (!this.workData.reportCycle || this.workData.reportCycle==lp.reportCycleText.split(",")[0])?lp.weekDayText.split(","):lp.monthDayText.split(",")
  789. },
  790. dutyDepartment: {text: lp.dutyDepartment + ":", type:"org",orgType: "unit",name:"responsibilityUnitName"},
  791. dutyPerson: {text: lp.dutyPerson + ":", type:"org",orgType: "identity",count:1,name:"responsibilityIdentity",notEmpty:true},
  792. secondDepartment: {
  793. text: lp.secondDepartment + ":", type:"org",orgType: "unit",
  794. name:"cooperateUnitNameList",
  795. value:this.workData.cooperateUnitNameList?this.workData.cooperateUnitNameList.join(","):""
  796. },
  797. secondPerson: {
  798. text: lp.secondPerson + ":", type:"org",orgType: "identity",
  799. name:"cooperateIdentityList",
  800. value:this.workData.cooperateIdentityList?this.workData.cooperateIdentityList.join(","):"",
  801. count: 0
  802. },
  803. readReader: {
  804. text: lp.readReader + ":", type:"org",orgType: "identity",
  805. name:"readLeaderIdentityList",
  806. value:this.workData.readLeaderIdentityList?this.workData.readLeaderIdentityList.join(","):"",
  807. count: 0
  808. },
  809. deployPerson :{text: lp.deployPerson,name:"deployerIdentity",type:"org",orgType: "identity"},
  810. subject: {text: lp.subject + ":",name:"title",notEmpty:true},
  811. workSplitAndDescription: {text: lp.workSplitAndDescription + ":", type: "textarea",name:"workDetail",notEmpty:true},
  812. specificActionInitiatives: {text: lp.specificActionInitiatives + ":", type: "textarea",name:"progressAction"},
  813. cityCompanyDuty: {text: lp.cityCompanyDuty + ":", type: "textarea",name:"dutyDescription"},
  814. milestoneMark: {text: lp.milestoneMark + ":", type: "textarea",name:"landmarkDescription"},
  815. importantMatters: {text: lp.importantMatters + ":", type: "textarea",name:"majorIssuesDescription"}
  816. }
  817. },
  818. loadAttachment: function( area ){
  819. this.attachment = new MWF.xApplication.Execution.Attachment( area, this.app, this.actions, this.app.lp, {
  820. documentId : this.data.workId,
  821. isNew : this.options.isNew,
  822. isEdited : this.options.isEdited
  823. });
  824. this.attachment.load();
  825. },
  826. loadReportAttachment: function( area,edit ){
  827. this.attachment = new MWF.xApplication.Execution.ReportAttachment( area, this.app, this.actions, this.app.lp, {
  828. //documentId : this.data.workId,
  829. documentId : this.workReportId,
  830. isNew : this.options.isNew,
  831. isEdited : edit,
  832. "size":this.workReportData.processStatus == this.lp.activityName.drafter ? "max":"min",
  833. onQueryUploadAttachment : function(){
  834. var saveData = {};
  835. saveData.workId = this.workReportData.workId;
  836. saveData.id = this.workReportData.id;
  837. if(this.workReportData.processStatus == this.lp.activityName.drafter){
  838. saveData.progressDescription = this.contentTextarea1.value;
  839. saveData.workPlan = this.contentTextarea2.value
  840. }
  841. this.actions.saveWorkReport( saveData, function(json){
  842. if(json.type == "success"){
  843. this.attachment.isQueryUploadSuccess = true;
  844. }
  845. }.bind(this),function(xhr,text,error){
  846. this.attachment.isQueryUploadSuccess = false;
  847. }.bind(this),false);
  848. }.bind(this)
  849. });
  850. this.attachment.load();
  851. },
  852. readDone: function(){
  853. //alert(this.data.todoId)
  854. this.actions.readDone(this.data.todoId,function(json){
  855. this.app.notice(this.lp.prompt.readDone,"success");
  856. this.fireEvent("reloadView", json);
  857. this.close();
  858. }.bind(this),function(xhr){}.bind(this))
  859. },
  860. save: function(){
  861. this.createShade();
  862. //this.saveActionNode.removeEvents("click")
  863. var saveData = {};
  864. saveData.workId = this.workReportData.workId;
  865. saveData.id = this.workReportData.id;
  866. var rateTmp = 0;
  867. rateTmp = parseInt(this.completePercentRateSpan.get("text").replace("%",""));
  868. if(this.workReportData.processStatus == this.lp.activityName.drafter){
  869. saveData.progressDescription = this.contentTextarea1.value;
  870. saveData.workPlan = this.contentTextarea2.value;
  871. saveData.isWorkCompleted = this.completeSelect.get("value")=="yes"?true:false
  872. //saveData.progressPercent = this.completePercentRateSpan.get("text")*100
  873. saveData.progressPercent = rateTmp
  874. }else if(this.workReportData.processStatus == this.lp.activityName.manager){
  875. saveData.adminSuperviseInfo = this.contentTextarea3.value;
  876. saveData.isWorkCompleted = this.completeSelect.get("value")=="yes"?true:false
  877. saveData.progressPercent = rateTmp
  878. }else if(this.workReportData.processStatus == this.lp.activityName.leader){
  879. saveData.opinion = this.contentTextarea4.value
  880. }
  881. if(saveData.progressDescription){
  882. if(saveData.progressDescription.length>600){
  883. this.app.notice( "字数不能大于600","error");
  884. this.destroyShade();
  885. return false;
  886. }
  887. }
  888. if(saveData.workPlan){
  889. if(saveData.workPlan.length>600){
  890. this.app.notice( "字数不能大于600","error");
  891. this.destroyShade();
  892. return false;
  893. }
  894. }
  895. this.actions.saveWorkReport( saveData, function(json){
  896. if(json.type == "success"){
  897. this.app.notice(this.lp.information.saveSuccess, "success");
  898. this.destroyShade();
  899. }
  900. }.bind(this),function(xhr,text,error){
  901. var errorText = error;
  902. if (xhr) errorMessage = xhr.responseText;
  903. var e = JSON.parse(errorMessage);
  904. if(e.message){
  905. this.app.notice( e.message,"error");
  906. }else{
  907. this.app.notice( errorText,"error");
  908. }
  909. this.destroyShade();
  910. }.bind(this),true);
  911. //this.saveActionNode.addEvents({
  912. // "click": function () {
  913. // this.save();
  914. // }.bind(this)
  915. //})
  916. },
  917. submit: function(e){
  918. if(this.contentTextarea1){
  919. if(this.contentTextarea1.value == ""){
  920. this.app.notice(this.lp.contentTitle1+this.lp.checkEmpty, "error");
  921. return false;
  922. }
  923. }
  924. if(this.contentTextarea2){
  925. if(this.contentTextarea2.value == ""){
  926. this.app.notice(this.lp.contentTitle2+this.lp.checkEmpty, "error");
  927. return false;
  928. }
  929. }
  930. var saveData = {};
  931. saveData.workId = this.workReportData.workId;
  932. saveData.id = this.workReportData.id;
  933. var rateTmp = 0;
  934. rateTmp = parseInt(this.completePercentRateSpan.get("text").replace("%",""));
  935. if(this.workReportData.processStatus == this.lp.activityName.drafter){
  936. saveData.progressDescription = this.contentTextarea1.value;
  937. saveData.workPlan = this.contentTextarea2.value;
  938. saveData.isWorkCompleted = this.completeSelect.get("value")=="yes"?true:false
  939. //saveData.progressPercent = this.completePercentRateSpan.get("text")*100
  940. saveData.progressPercent = rateTmp
  941. }else if(this.workReportData.processStatus == this.lp.activityName.manager){
  942. saveData.adminSuperviseInfo = this.contentTextarea3.value;
  943. saveData.isWorkCompleted = this.completeSelect.get("value")=="yes"?true:false
  944. //saveData.progressPercent = this.completePercentRateSpan.get("text")*100
  945. saveData.progressPercent = rateTmp
  946. }else if(this.workReportData.processStatus == this.lp.activityName.leader){
  947. saveData.opinion = this.contentTextarea4.value
  948. }
  949. if(saveData.progressDescription){
  950. if(saveData.progressDescription.length>600){
  951. this.app.notice( "字数不能大于600","error");
  952. return false;
  953. }
  954. }
  955. if(saveData.workPlan){
  956. if(saveData.workPlan.length>600){
  957. this.app.notice( "字数不能大于600","error");
  958. return false;
  959. }
  960. }
  961. if(this.completeSelect && this.completeSelect.get("value")=="yes"){
  962. var _self = this;
  963. this.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnContent,300,150,function(){
  964. _self.createShade();
  965. _self.actions.submitWorkReport( saveData, function(json){
  966. if(json.type == "success"){
  967. _self.app.notice(_self.lp.prompt.submitWorkReport,"success");
  968. _self.fireEvent("reloadView", json);
  969. _self.close();
  970. }
  971. _self.destroyShade()
  972. }.bind(_self),function(xhr,text,error){
  973. var errorText = error;
  974. if (xhr) errorMessage = xhr.responseText;
  975. var e = JSON.parse(errorMessage);
  976. if(e.message){
  977. _self.app.notice( e.message,"error");
  978. }else{
  979. _self.app.notice( errorText,"error");
  980. }
  981. _self.destroyShade()
  982. }.bind(_self),true);
  983. this.close();
  984. },function(){
  985. this.close();
  986. })
  987. }else{
  988. this.createShade();
  989. this.actions.submitWorkReport( saveData, function(json){
  990. if(json.type == "success"){
  991. this.app.notice(this.lp.prompt.submitWorkReport,"success");
  992. this.fireEvent("reloadView", json);
  993. this.close();
  994. }
  995. this.destroyShade()
  996. }.bind(this),function(xhr,text,error){
  997. var errorText = error;
  998. if (xhr) errorMessage = xhr.responseText;
  999. var e = JSON.parse(errorMessage);
  1000. if(e.message){
  1001. this.app.notice( e.message,"error");
  1002. }else{
  1003. this.app.notice( errorText,"error");
  1004. }
  1005. this.destroyShade()
  1006. }.bind(this),true);
  1007. }
  1008. },
  1009. _createBottomContent: function () {
  1010. if(this.processIdentity == this.app.identity || this.processIdentity.indexOf(this.app.identity)>-1) {
  1011. this.submitActionNode = new Element("div.submitActionNode", {
  1012. "styles": this.css.formCancelActionNode,
  1013. "text": this.lp.bottomAction.submit
  1014. }).inject(this.formBottomNode)
  1015. .addEvents({
  1016. "click": function (e) {
  1017. this.submit(e);
  1018. }.bind(this)
  1019. })
  1020. }
  1021. if(this.processIdentity == this.app.identity || this.processIdentity.indexOf(this.app.identity)>-1) {
  1022. this.saveActionNode = new Element("div.saveActionNode", {
  1023. "styles": this.css.formCancelActionNode,
  1024. "text": this.lp.bottomAction.save
  1025. }).inject(this.formBottomNode)
  1026. .addEvents({
  1027. "click": function () {
  1028. this.save();
  1029. }.bind(this)
  1030. })
  1031. }
  1032. if(this.options.isRead){
  1033. this.readActionNode = new Element("div.readActionNode", {
  1034. "styles": this.css.formCancelActionNode,
  1035. "text": this.lp.bottomAction.readDone
  1036. }).inject(this.formBottomNode);
  1037. this.readActionNode.addEvent("click", function (e) {
  1038. this.readDone(e);
  1039. }.bind(this));
  1040. }
  1041. this.cancelActionNode = new Element("div.formCancelActionNode", {
  1042. "styles": this.css.formCancelActionNode,
  1043. "text": this.lp.bottomAction.close
  1044. }).inject(this.formBottomNode);
  1045. this.cancelActionNode.addEvent("click", function (e) {
  1046. this.cancel(e);
  1047. }.bind(this));
  1048. //控制按钮权限
  1049. //如果已归档,则只留下关闭按钮
  1050. if (this.workReportData && this.workReportData.status == this.lp.statuArchive) {
  1051. if(this.submitActionNode)this.submitActionNode.destroy();
  1052. if(this.saveActionNode)this.saveActionNode.destroy();
  1053. if(this.readActionNode)this.readActionNode.destroy();
  1054. }
  1055. },
  1056. createShade: function(o,txtInfo){
  1057. var defaultObj = this.formAreaNode||this.container||this.app;
  1058. var obj = o || defaultObj;
  1059. var txt = txtInfo || "loading...";
  1060. if(this.shadeDiv){ this.shadeDiv.destroy()}
  1061. if(this["shadeTxtDiv"]) this["shadeTxtDiv"].destroy();
  1062. this.shadeDiv = new Element("div.shadeDiv").inject(obj);
  1063. this.inforDiv = new Element("div.inforDiv",{
  1064. styles:{"height":"16px","display":"inline-block","position":"absolute","background-color":"#000000","border-radius":"3px","padding":"5px 10px"}
  1065. }).inject(this.shadeDiv);
  1066. this.loadImg = new Element("img.loadImg",{
  1067. styles:{"width":"16px","height":"16px","float":"left"},
  1068. src:this.path+"default/icon/loading.gif"
  1069. }).inject(this.inforDiv);
  1070. this.shadeTxtSpan = new Element("span.shadeTxtSpan").inject(this.inforDiv);
  1071. this.shadeTxtSpan.set("text",txt);
  1072. this.shadeDiv.setStyles({
  1073. "width":"100%","height":"100%","position":"absolute","opacity":"0.6","background-color":"#cccccc","z-index":"999"
  1074. });
  1075. this.shadeTxtSpan.setStyles({"color":"#ffffff","font-size":"12px","display":"inline-block","line-height":"16px","padding-left":"5px"});
  1076. var x = obj.getSize().x;
  1077. var y = obj.getSize().y;
  1078. this.shadeDiv.setStyles({
  1079. "left":(obj.getLeft()-defaultObj.getLeft())+"px",
  1080. "top":(obj.getTop()-defaultObj.getTop())+"px",
  1081. "width":x+"px",
  1082. "height":y+"px"
  1083. });
  1084. if(obj.getStyle("position")=="absolute"){
  1085. this.shadeDiv.setStyles({
  1086. "left":"0px",
  1087. "top":"0px"
  1088. })
  1089. }
  1090. this.inforDiv.setStyles({
  1091. "left":(x/2)+"px",
  1092. "top":(y/2)+"px"
  1093. })
  1094. },
  1095. destroyShade : function(){
  1096. if(this.shadeDiv) this.shadeDiv.destroy();
  1097. //if(this.shadeDiv) this.shadeDiv.destroy()
  1098. },
  1099. showErrorMessage:function(xhr,text,error){
  1100. var errorText = error;
  1101. var errorMessage;
  1102. if (xhr) errorMessage = xhr.responseText;
  1103. if(errorMessage!=""){
  1104. var e = JSON.parse(errorMessage);
  1105. if(e.message){
  1106. this.notice( e.message,"error");
  1107. }else{
  1108. this.notice( errorText,"error");
  1109. }
  1110. }else{
  1111. this.notice(errorText,"error");
  1112. }
  1113. }
  1114. });