WorkGather-bak.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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", "WorkForm", null, false);
  5. MWF.xApplication.Execution.WorkGather = new Class({
  6. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  7. Implements: [Options, Events],
  8. options: {
  9. //"centerWorkId" : "fc44be47-7271-469f-8f04-deebdb71d3e6",
  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.workGather;
  27. this.actions = this.app.restActions;
  28. this.path = "/x_component_Execution/$WorkGather/";
  29. this.cssPath = this.path + this.options.style + "/css.wcss";
  30. this._loadCss();
  31. this.data = data || {};
  32. this.actions = actions;
  33. },
  34. load: function () {
  35. //alert(JSON.stringify(this.data))
  36. if (this.options.isNew) {
  37. this.create();
  38. } else if (this.options.isEdited) {
  39. this.edit();
  40. } else {
  41. this.open();
  42. }
  43. },
  44. createTopNode: function () {
  45. if (!this.formTopNode) {
  46. this.formTopNode = new Element("div.formTopNode", {
  47. "styles": this.css.formTopNode
  48. }).inject(this.formNode);
  49. this.formTopIconNode = new Element("div", {
  50. "styles": this.css.formTopIconNode
  51. }).inject(this.formTopNode)
  52. this.formTopTextNode = new Element("div", {
  53. "styles": this.css.formTopTextNode,
  54. "text": this.data.title
  55. }).inject(this.formTopNode)
  56. if (this.options.closeAction) {
  57. this.formTopCloseActionNode = new Element("div.formTopCloseActionNode", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  58. this.formTopCloseActionNode.addEvent("click", function () {
  59. this.close()
  60. }.bind(this))
  61. }
  62. this.formTopContentNode = new Element("div", {
  63. "styles": this.css.formTopContentNode
  64. }).inject(this.formTopNode)
  65. this._createTopContent();
  66. }
  67. },
  68. _createTopContent: function () {
  69. },
  70. _createTableContent: function (data) {
  71. this.titleDiv = new Element("div.titleDiv",{
  72. "styles":this.css.titleDiv,
  73. "text":this.data.title
  74. }).inject(this.formTableArea)
  75. this.inforDiv = new Element("div.inforDiv",{"styles":this.css.inforDiv}).inject(this.formTableArea);
  76. this.gatherDiv = new Element("div.gatherDiv",{"styles":this.css.gatherDiv}).inject(this.formTableArea);
  77. this.getDepartmentGather();
  78. },
  79. getDepartmentGather: function(){
  80. this.reportDataArr = [];
  81. this.gatherDiv.empty();
  82. this.WorkReportView = new MWF.xApplication.Execution.WorkGather.WorkReportView(this.gatherDiv, this.app, this, { templateUrl : this.path+"listItem.json" })
  83. this.WorkReportView.load();
  84. },
  85. openWorkReport: function(workReportId,workId){
  86. MWF.xDesktop.requireApp("Execution", "WorkReport", function(){
  87. var data = {
  88. workReportId : workReportId,
  89. workId : workId
  90. }
  91. this.workReport = new MWF.xApplication.Execution.WorkReport(this, this.actions,data,{
  92. "isEdited":false,
  93. "width":"90%",
  94. "height":"90%",
  95. onReloadView : function( data ){
  96. this.getDepartmentGather();
  97. }.bind(this)
  98. } );
  99. this.workReport.load();
  100. }.bind(this));
  101. },
  102. _createBottomContent: function () {
  103. this.submitActionNode = new Element("div.submitActionNode", {
  104. "styles": this.css.formActionNode,
  105. "text": this.lp.bottomAction.submit
  106. }).inject(this.formBottomNode);
  107. var _self = this;
  108. this.submitActionNode.addEvent("click", function (e) {
  109. this.app.confirm("warn",e,this.lp.submitWarn.warnTitle,this.lp.submitWarn.warnContent,300,120,function(){
  110. _self.submitGather()
  111. this.close();
  112. },function(){
  113. this.close();
  114. })
  115. }.bind(this));
  116. this.closeActionNode = new Element("div.formActionNode", {
  117. "styles": this.css.formActionNode,
  118. "text": this.lp.bottomAction.close
  119. }).inject(this.formBottomNode);
  120. this.closeActionNode.addEvent("click", function (e) {
  121. this.close(e);
  122. }.bind(this));
  123. },
  124. submit:function(workReportData){
  125. var adminText = this.gatherDiv.getElementById("admin"+workReportData.id);
  126. var adminValue = "";
  127. if(adminText) adminValue = adminText.get("value");
  128. var opinionValue = ""
  129. var opinionText = this.gatherDiv.getElementById("opinion"+workReportData.id);
  130. if(opinionText) opinionValue = opinionText.get("value");
  131. var submitData = {
  132. workId : workReportData.workId,
  133. id : workReportData.id,
  134. adminSuperviseInfo : adminValue,
  135. opinion : opinionValue
  136. }
  137. this.actions.submitWorkReport( submitData, function(json){
  138. if(json.type == "success"){
  139. this.app.notice(json.userMessage,"success");
  140. this.actions.getDepartmentGather(this.data.gatherId,function(json){
  141. if(json.data.reportInfos && json.data.reportInfos.length==0){
  142. this.fireEvent("reloadView");
  143. this.close()
  144. }else{
  145. this.getDepartmentGather();
  146. }
  147. }.bind(this),null,false)
  148. }
  149. }.bind(this),function(xhr,text,error){
  150. var errorText = error;
  151. if (xhr) errorMessage = xhr.responseText;
  152. var e = JSON.parse(errorMessage);
  153. if(e.userMessage){
  154. this.app.notice( e.userMessage,"error");
  155. }else{
  156. this.app.notice( errorText,"error");
  157. }
  158. }.bind(this));
  159. },
  160. submitGather:function(){
  161. this.submitStatus = true;
  162. this.submitError = "";
  163. for(var i=0;i<this.reportDataArr.length;i++){
  164. this.currentReportData = this.reportDataArr[i]
  165. if(this.submitStatus){
  166. var adminText = this.gatherDiv.getElementById("admin"+this.currentReportData.id);
  167. var adminValue = "";
  168. if(adminText) adminValue = adminText.get("value");
  169. var opinionValue = ""
  170. var opinionText = this.gatherDiv.getElementById("opinion"+this.currentReportData.id);
  171. if(opinionText) opinionValue = opinionText.get("value");
  172. var submitData = {
  173. workId : this.currentReportData.workId,
  174. id : this.currentReportData.id,
  175. adminSuperviseInfo : adminValue,
  176. opinion : opinionValue
  177. }
  178. //if(i==0){
  179. // submitData.workId = "fefwfwfwfewfwfewfe";
  180. // submitData.id = "eeeeeeeeee"
  181. //
  182. //}
  183. this.actions.submitWorkReport( submitData, function(json){
  184. }.bind(this), function(xhr){
  185. var json = JSON.parse(xhr.responseText);
  186. this.submitError = "《"+this.currentReportData.title+"》"+json.userMessage
  187. this.submitStatus = false;
  188. }.bind(this),false);
  189. }
  190. }
  191. if(!this.submitStatus){
  192. this.app.notice(this.submitError, "error");
  193. this.getDepartmentGather();
  194. }else{
  195. this.app.notice(this.lp.submitWarn.submitSuccess, "success");
  196. this.fireEvent("reloadView");
  197. this.close();
  198. }
  199. }
  200. })
  201. MWF.xApplication.Execution.WorkGather.WorkReportView = new Class({
  202. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  203. _createDocument: function(data){
  204. return new MWF.xApplication.Execution.WorkGather.WorkReportDocument(this.viewNode, data, this.explorer, this);
  205. },
  206. _getCurrentPageData: function(callback, count){
  207. this.actions.getDepartmentGather(this.explorer.data.gatherId,function(json){ //alert(JSON.stringify(json))
  208. if(callback) callback(json)
  209. }.bind(this),null,false)
  210. },
  211. loadElementList: function (count) {
  212. if (!this.isItemsLoaded) {
  213. if (!this.isItemLoadding) {
  214. this.isItemLoadding = true;
  215. this._getCurrentPageData(function (json) {
  216. //if( !json.data )return;
  217. var length = json.count; //|| json.data.length;
  218. //if (!this.isCountShow){
  219. // this.filterAllProcessNode.getFirst("span").set("text", "("+this.count+")");
  220. // this.isCountShow = true;
  221. //}
  222. if (length <= this.items.length) {
  223. this.isItemsLoaded = true;
  224. }
  225. json.data.reportInfos.each(function (data) {
  226. if (!this.documents[data.id]) {
  227. var item = this._createDocument(data);
  228. this.items.push(item);
  229. this.documents[data.id] = item;
  230. }
  231. }.bind(this));
  232. this.isItemLoadding = false;
  233. if (this.loadItemQueue > 0) {
  234. this.loadItemQueue--;
  235. this.loadElementList();
  236. }
  237. }.bind(this), count);
  238. } else {
  239. this.loadItemQueue++;
  240. }
  241. }
  242. },
  243. _removeDocument: function(documentData, all){
  244. },
  245. _create: function(data){
  246. },
  247. _openDocument: function( documentData ){
  248. //this.workForm = new MWF.xApplication.Execution.WorkForm(this, this.actions, documentData, {
  249. // "isNew": false,
  250. // "isEdited": false
  251. //})
  252. //this.workForm.load();
  253. },
  254. _queryCreateViewNode: function(){
  255. },
  256. _postCreateViewNode: function( viewNode ){
  257. },
  258. _queryCreateViewHead:function(){
  259. },
  260. _postCreateViewHead: function( headNode ){
  261. }
  262. })
  263. MWF.xApplication.Execution.WorkGather.WorkReportDocument = new Class({
  264. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  265. _queryCreateDocumentNode:function( itemData ){
  266. },
  267. _postCreateDocumentNode: function( itemNode, itemData ){
  268. //alert(JSON.stringify(itemData))
  269. //alert(itemNode.get("html"))
  270. if( itemData.reports ){
  271. itemData.reports.each(function(d){
  272. this.view.explorer.reportDataArr.push(d);
  273. var trNode = new Element("tr.trNodeTitle",{"styles":this.view.css.trNodeTitle}).inject(this.view.viewNode);
  274. var tdNode = new Element("td.tdNodeTitle",{
  275. "styles":this.view.css.tdNodeTitle,
  276. "text": d.title,
  277. "colspan":"6"
  278. }).inject(trNode).
  279. addEvents({
  280. "click":function(){
  281. this.view.explorer.openWorkReport(d.id, d.workId);
  282. }.bind(this)
  283. })
  284. trNode = new Element("tr.trNode",{"styles":this.view.css.trNode}).inject(this.view.viewNode)
  285. tdNode = new Element("td.tdNodeContent",{
  286. "styles":this.view.css.tdNodeContent
  287. }).inject(trNode);
  288. divNode = new Element("div.divNode",{
  289. "styles":this.view.css.divNode,
  290. "text": d.workInfo.shortProgressAction?d.workInfo.shortProgressAction:"",
  291. "title": d.workInfo.shortProgressAction?d.workInfo.shortProgressAction:""
  292. }).inject(tdNode);
  293. tdNode = new Element("td.tdNodeContent",{
  294. "styles":this.view.css.tdNodeContent
  295. }).inject(trNode);
  296. divNode = new Element("div.divNode",{
  297. "styles":this.view.css.divNode,
  298. "text": d.progressDescription,
  299. "title": d.progressDescription
  300. }).inject(tdNode);
  301. tdNode = new Element("td.tdNodeContent",{
  302. "styles":this.view.css.tdNodeContent
  303. }).inject(trNode);
  304. divNode = new Element("div.divNode",{
  305. "styles":this.view.css.divNode,
  306. "text": d.workPlan,
  307. "title": d.workPlan
  308. }).inject(tdNode);
  309. //管理员
  310. if(d.isWorkAdmin && d.processStatus == this.view.lp.activityName.manager){
  311. tdNode = new Element("td.tdNodeContent",{
  312. "styles":this.view.css.tdNodeContent
  313. }).inject(trNode);
  314. var teextareaNode = new Element("textarea.tetareaNode",{
  315. "styles":this.view.css.textareaNode,
  316. "id":"admin"+ d.id
  317. }).inject(tdNode);
  318. }else{
  319. tdNode = new Element("td.tdNodeContent",{
  320. "styles":this.view.css.tdNodeContent
  321. }).inject(trNode);
  322. divNode = new Element("div.divNode", {
  323. "styles": this.view.css.divNode,
  324. "text": d.adminSuperviseInfo,
  325. "title": d.adminSuperviseInfo
  326. }).inject(tdNode)
  327. }
  328. //领导
  329. //this.workReportData.processStatus == this.lp.activityName.leader && this.workReportData.isReadLeader && this.processIdentity.indexOf(this.app.identity)>-1
  330. if(d.processStatus == this.view.lp.activityName.leader && d.isReadLeader && d.currentProcessorIdentity.indexOf(this.app.identity)>-1){
  331. tdNode = new Element("td.tdNodeContent",{
  332. "styles":this.view.css.tdNodeContent
  333. }).inject(trNode);
  334. var teextareaNode = new Element("textarea.tetareaNode",{
  335. "styles":this.view.css.textareaNode,
  336. "id":"opinion"+ d.id
  337. }).inject(tdNode);
  338. }else{
  339. tdNode = new Element("td.tdNodeContent",{
  340. "styles":this.view.css.tdNodeContent,
  341. "text": ""
  342. }).inject(trNode);
  343. }
  344. var tdNodeAction = new Element("td.tdNodeAction",{
  345. "styles":this.view.css.tdNodeAction,
  346. }).inject(trNode);
  347. var actionTxt = new Element("a.actionTxt",{
  348. "styles":this.view.css.actionTxt,
  349. "text":this.view.lp.viewSubmit
  350. }).inject(tdNodeAction)
  351. .addEvents({
  352. "click":function(){
  353. this.view.explorer.submit(d)
  354. }.bind(this)
  355. })
  356. }.bind(this))
  357. //this.view.viewNode.getElements("textarea").setStyle("height","100%")
  358. }
  359. }
  360. })