Measure.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. MWF.xApplication.Strategy = MWF.xApplication.Strategy || {};
  2. //MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.xDesktop.requireApp("Strategy", "Template", null, false);
  4. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  5. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  6. MWF.xDesktop.requireApp("Strategy","Attachment",null,false);
  7. MWF.xApplication.Strategy.KeyWorkForm = new Class({
  8. Extends: MPopupForm,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "default",
  12. "width": "90%",
  13. "height": "100%",
  14. "hasTop": true,
  15. "hasIcon": false,
  16. "hasBottom": false,
  17. "title": "",
  18. "draggable": false,
  19. "closeAction": true
  20. },
  21. initialize: function (explorer, actions, data, options) {
  22. this.setOptions(options);
  23. this.explorer = explorer;
  24. this.app = explorer.app;
  25. this.lp = this.app.lp.keyWork.popupForm;
  26. this.actions = this.app.restActions;
  27. this.path = "../x_component_Strategy/$KeyWorkForm/";
  28. this.cssPath = this.path + this.options.style + "/css.wcss";
  29. this._loadCss();
  30. this.options.title = this.lp.title;
  31. this.defaultYear = this.options.year || "";
  32. this.data = data || {};
  33. this.actions = actions;
  34. },
  35. load: function () {
  36. if (this.options.isNew) {
  37. this.create();
  38. } else if (this.options.isEdited) {
  39. this.edit();
  40. } else {
  41. this.open();
  42. }
  43. },
  44. createTopNode: function () {
  45. if (!this.formTopNode) {
  46. this.formTopNode = new Element("div.formTopNode", {
  47. "styles": this.css.formTopNode
  48. }).inject(this.formNode);
  49. this.formTopTextNode = new Element("div", {
  50. "styles": this.css.formTopTextNode,
  51. "text": this.data.title ? this.data.title : "增加工作"
  52. }).inject(this.formTopNode);
  53. if (this.options.closeAction) {
  54. this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  55. this.formTopCloseActionNode.addEvent("click", function () {
  56. this.close()
  57. }.bind(this))
  58. }
  59. this._createTopContent();
  60. }
  61. },
  62. _createTopContent: function () {
  63. },
  64. _createTableContent: function () {
  65. this.getData(function(){this.createTableInfo()}.bind(this));
  66. },
  67. getData:function(callback){
  68. if(!this.options.isNew){
  69. if(this.data.id){
  70. this.id = this.data.id
  71. }else if(this.options.id){
  72. this.id = this.options.id
  73. }
  74. this.actions.getKeyWorkById(this.id,function(json){
  75. this.data = json.data;
  76. if(callback)callback();
  77. }.bind(this));
  78. }else{
  79. if(callback)callback();
  80. }
  81. },
  82. createTableInfo:function(){
  83. var html = "<table styles='formTable'>" +
  84. "<tr>" +
  85. " <td styles='formTableTitle' lable='sequencenumber'></td>" +
  86. " <td styles='formTableValue' item='sequencenumber'></td>" +
  87. "</tr>"+
  88. "<tr>" +
  89. " <td styles='formTableTitle' lable='strategydeploytitle'></td>" +
  90. " <td styles='formTableValue' item='strategydeploytitle'></td>" +
  91. "</tr>"+
  92. "<tr>" +
  93. " <td styles='formTableTitle' lable='strategydeployyear'></td>" +
  94. " <td styles='formTableYearValue' item='strategydeployyear'></td>" +
  95. "</tr>"+
  96. "<tr>" +
  97. " <td styles='formTableTitle' lable='deptlist'></td>" +
  98. " <td styles='formTableValue' item='deptlist'></td>" +
  99. "</tr>"+
  100. "<tr>" +
  101. " <td styles='formTableTitle' lable='strategydeploydescribe'></td>" +
  102. " <td styles='formTableValue' item='strategydeploydescribe'></td>" +
  103. "</tr>"+
  104. "</table>";
  105. this.formTableArea.set("html", html);
  106. this.loadForm();
  107. if(this.options.isNew || this.options.isEdited){
  108. this.createActionBar();
  109. }
  110. },
  111. loadForm: function(){
  112. this.keyWorkForm = new MForm(this.formTableArea, this.data, {
  113. style: "default",
  114. isEdited: this.isEdited || this.isNew,
  115. itemTemplate: this.getItemTemplate(this.lp )
  116. },this.app,this.css);
  117. this.keyWorkForm.load();
  118. var taObj = this.formTableArea.getElements("textarea");
  119. taObj.setStyles({height:"100px"});
  120. //this.attachmentArea = this.formTableArea.getElement("[item='attachments']");
  121. //this.loadAttachment( this.attachmentArea );
  122. },
  123. getItemTemplate: function( lp ){
  124. _self = this;
  125. return {
  126. "sequencenumber":{
  127. text:lp.sequencenumber+":",
  128. notEmpty:true
  129. },
  130. "strategydeploytitle":{
  131. text:lp.title+":",
  132. notEmpty:true
  133. },
  134. "strategydeployyear":{
  135. text:lp.year+":",
  136. notEmpty:true,
  137. type:"select",
  138. value:this.defaultYear,
  139. attr : {style:"width:100%;height:30px;border-radius:3px;"},
  140. selectValue:lp.selectYears.split(","),
  141. selecTtext:lp.selectYears.split(",")
  142. },
  143. "deptlist":{
  144. text:lp.department+":",
  145. notEmpty:true,
  146. type: "org",
  147. orgType:"unit",
  148. name:"deptlist",
  149. count: 0,
  150. attr : {readonly:true}
  151. },
  152. "strategydeploydescribe":{
  153. type:"textarea",
  154. attr:{style:"height:100px"},
  155. text:lp.description+":"
  156. }
  157. };
  158. },
  159. loadAttachment: function( area ){
  160. //this.attachment = new MWF.xApplication.Execution.Attachment( area, this.app, this.actions, this.app.lp, {
  161. // documentId : this.data.id,
  162. // isNew : this.options.isNew,
  163. // isEdited : this.options.isEdited,
  164. // onQueryUploadAttachment : function(){
  165. // this.attachment.isQueryUploadSuccess = true;
  166. // if( !this.data.id || this.data.id=="" ){
  167. // var data = this.form.getResult(true, ",", true, false, true);
  168. // if( !data ){
  169. // this.attachment.isQueryUploadSuccess = false;
  170. // return;
  171. // }
  172. // if(this.options.isNew){
  173. // data.centerId = this.options.centerWorkId || this.data.centerWorkId || this.data.centerId ;
  174. // }
  175. // this.app.restActions.saveTask(data, function(json){
  176. // if(json.type && json.type == "success"){
  177. // if(json.data.id) {
  178. // this.attachment.options.documentId = json.data.id;
  179. // this.data.id = json.data.id;
  180. // //this.options.isNew = false;
  181. // }
  182. // }
  183. // }.bind(this), function(xhr,text,error){
  184. // this.showErrorMessage(xhr,text,error)
  185. // }.bind(this),false)
  186. // }
  187. // }.bind(this)
  188. //});
  189. //
  190. //this.attachment.load();
  191. },
  192. createActionBar:function(){
  193. this.actionContent = new Element("div.actionContent",{"styles":this.css.actionContent}).inject(this.formTableContainer);
  194. this.actionBar = new Element("div.actionBar",{"styles":this.css.actionBar}).inject(this.actionContent);
  195. this.saveAction = new Element("div.saveAction",{
  196. "styles":this.css.saveAction,
  197. "text":this.lp.saveAction
  198. }).inject(this.actionBar).
  199. addEvents({
  200. "click":function(){
  201. this.save();
  202. }.bind(this)
  203. });
  204. this.cancelAction = new Element("div.cancelAction",{
  205. "styles":this.css.cancelAction,
  206. "text":this.lp.cancelAction
  207. }).inject(this.actionBar).
  208. addEvents({
  209. "click":function(){
  210. this.close();
  211. }.bind(this)
  212. })
  213. },
  214. save:function(callback){
  215. var data = this.keyWorkForm.getResult(true, ",", true, false, true);
  216. if(data){
  217. this.app.createShade();
  218. data.deptlist = data.deptlist.split(",");
  219. this.actions.saveKeyWork(data,function(json){
  220. if(json.type == "success"){
  221. this.close();
  222. this.fireEvent("postSave", json);
  223. }else if(json.type == "error"){
  224. this.app.notice(json.message,"error")
  225. }
  226. this.app.destroyShade();
  227. if(callback)callback();
  228. }.bind(this));
  229. }
  230. }
  231. });