WorkReport.js 55 KB

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