CoreWork.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. MWF.xApplication.Execution = MWF.xApplication.Execution || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  4. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  5. MWF.xDesktop.requireApp("Execution", "WorkForm", null, false);
  6. MWF.xApplication.Execution.CoreWork = 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;
  26. this.lp = this.app.lp.coreWork;
  27. this.actions = this.app.restActions;
  28. this.path = "/x_component_Execution/$CoreWork/";
  29. this.cssPath = this.path + this.options.style + "/css.wcss";
  30. this._loadCss();
  31. this.options.title = this.lp.title;
  32. this.data = data || {};
  33. this.actions = actions;
  34. },
  35. load: function () {
  36. if (this.options.isNew) {
  37. this.create();
  38. } else if (this.options.isEdited) {
  39. this.edit();
  40. } else {
  41. this.open();
  42. }
  43. },
  44. 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.options.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. var html = "<span styles='formTopContentTitle' lable='drafter'></span>" +
  70. " <span styles='formTopContentValue' item='drafter'></span>" +
  71. "<span styles='formTopContentTitle' lable='draftDepartment'></span>" +
  72. " <span styles='formTopContentValue' item='draftDepartment'></span>" +
  73. "<span styles='formTopContentTitle' lable='draftDate'></span>" +
  74. " <span styles='formTopContentValue' item='draftDate'></span>"
  75. this.formTopContentNode.set("html", html);
  76. var form = new MForm(this.formTopContentNode, {
  77. drafter: "xadmin",
  78. draftDepartment: "开发部",
  79. draftDate: "2016-02-02"
  80. }, {
  81. isEdited: this.isEdited || this.isNew,
  82. itemTemplate: {
  83. drafter: {text: this.lp.drafter + ":", type: "innertext"},
  84. draftDepartment: {text: this.lp.draftDepartment + ":", type: "innertext"},
  85. draftDate: {text: this.lp.draftDate + ":", type: "innertext"}
  86. }
  87. }, this.app, this.css);
  88. form.load();
  89. },
  90. _createTableContent: function () {
  91. this.createCoreWorkInfor();
  92. this.createMyWorkList();
  93. this.createSplitWorkList();
  94. },
  95. createCoreWorkInfor: function() {
  96. var workContentArea = new Element("div.workContentArea", {
  97. "styles": this.css.workContentArea
  98. }).inject(this.formTableArea);
  99. var workContentTitleNode = new Element("div", {
  100. "styles": this.css.workContentTitleNode,
  101. "text": this.lp.coreWorkInfor
  102. }).inject(workContentArea);
  103. var workContentNode = new Element("div", {
  104. "styles": this.css.workContentNode
  105. }).inject(workContentArea);
  106. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='coreWorkInforTable'>" +
  107. "<tr><td styles='coreWorkInforTitle' lable='coreWorkTitle'></td>" +
  108. " <td styles='coreWorkInforValue' item='coreWorkTitle'></td></tr>" +
  109. "<tr><td>" +
  110. "<span styles='coreWorkInforTitleDiv' lable='defaultWorkType'></span>" +
  111. " <span styles='coreWorkInforValueDiv' item='defaultWorkType'></span>" +
  112. " <span styles='coreWorkInforTitleDiv' lable='defaultWorkLevel'></span>" +
  113. " <span styles='coreWorkInforValueDiv' item='defaultWorkLevel'></span>" +
  114. " <span styles='coreWorkInforTitleDiv' lable='workCompletedLimit'></span>" +
  115. " <span styles='coreWorkInforValueDiv' item='workCompletedLimit'></span>" +
  116. "</td></tr>" +
  117. "<tr><td styles='coreWorkInforTitle' lable='coreWorkMemo'></td>" +
  118. " <td styles='coreWorkInforValue' item='coreWorkMemo'></td></tr>" +
  119. "</table>"
  120. workContentNode.set("html", html);
  121. var form = new MForm(workContentNode, {data: "data"}, {
  122. isEdited: this.isEdited || this.isNew,
  123. itemTemplate: {
  124. coreWorkTitle: {text: this.lp.coreWorkTitle + ":", type: "innertext"},
  125. defaultWorkType: {text: this.lp.defaultWorkType + ":", type: "innertext"},
  126. defaultWorkLevel: {text: this.lp.defaultWorkLevel + ":", type: "innertext"},
  127. workCompletedLimit: {text: this.lp.workCompletedLimit + ":", type: "innertext"},
  128. coreWorkMemo: {
  129. text: this.lp.coreWorkMemo + ":",
  130. type: "innertext"
  131. }
  132. }
  133. }, this.app);
  134. form.load();
  135. },
  136. createMyWorkList : function(){
  137. var workContentArea = new Element("div.workContentArea", {
  138. "styles": this.css.workContentArea
  139. }).inject(this.formTableArea);
  140. var workContentTitleNode = new Element("div", {
  141. "styles": this.css.workContentTitleNode,
  142. "text": this.lp.myWorkInfor
  143. }).inject(workContentArea);
  144. var workContentNode = new Element("div", {
  145. "styles": this.css.workContentNode
  146. }).inject(workContentArea);
  147. var list = new MWF.xApplication.Execution.CoreWork.MyWorkView(workContentNode, this.app, this, { templateUrl : this.path+"listItem.json" })
  148. list.load();
  149. },
  150. createSplitWorkList : function(){
  151. var workContentArea = new Element("div.workContentArea", {
  152. "styles": this.css.workContentArea
  153. }).inject(this.formTableArea);
  154. var workContentTitleNode = new Element("div", {
  155. "styles": this.css.workContentTitleNode,
  156. "text": this.lp.splitWorkInfor
  157. }).inject(workContentArea);
  158. var workContentNode = new Element("div", {
  159. "styles": this.css.workContentNode
  160. }).inject(workContentArea);
  161. var list = new MWF.xApplication.Execution.CoreWork.MyWorkView(workContentNode, this.app, this, { templateUrl : this.path+"listItem.json" })
  162. list.load();
  163. }
  164. })
  165. MWF.xApplication.Execution.CoreWork.MyWorkView = new Class({
  166. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  167. _createDocument: function(data){
  168. return new MWF.xApplication.Execution.CoreWork.MyWorkDocument(this.viewNode, data, this.explorer, this);
  169. },
  170. _getCurrentPageData: function(callback, count){
  171. //this.actions.listHolidayAll(function(json){
  172. // if (callback) callback(json);
  173. //});
  174. var json = {
  175. "type": "success",
  176. "data": [
  177. {
  178. "id": "53a508ec-7862-4036-a273-c15830cd3f86",
  179. "createTime": "2016-04-19 15:38:50",
  180. "updateTime": "2016-04-19 15:38:50",
  181. "sequence": "2016041915385053a508ec-7862-4036-a273-c15830cd3f46",
  182. "subject": "2016年人力资源部弹性福利系统优化和福利套餐方案制定工作",
  183. "defaultWorkLevel": "公司重点工作",
  184. "defaultWorkType": "深化改革",
  185. "dutyDepartent": "人力资源部",
  186. "doDepartment": "公司领导",
  187. "secondDepartment": "综合部,信息化事业部",
  188. "dutyPerson": "蒋艺娟",
  189. "doPerson": "蔡全根",
  190. "secondPerson": "宋兰美,周琼",
  191. "timeLimit": "2016-08-18"
  192. },
  193. {
  194. "id": "53a508ec-7862-4036-a273-c15830cd3f88",
  195. "createTime": "2016-04-19 15:38:50",
  196. "updateTime": "2016-04-19 15:38:50",
  197. "sequence": "2016041915385053a508ec-7862-4036-a273-c15830cd3f46",
  198. "subject": "2016年人力资源部弹性福利系统优化和福利套餐方案制定工作",
  199. "defaultWorkLevel": "公司重点工作",
  200. "defaultWorkType": "深化改革",
  201. "dutyDepartent": "人力资源部",
  202. "doDepartment": "公司领导",
  203. "secondDepartment": "综合部,信息化事业部",
  204. "dutyPerson": "蒋艺娟",
  205. "doPerson": "蔡全根",
  206. "secondPerson": "宋兰美,周琼",
  207. "timeLimit": "2016-08-18"
  208. }
  209. ],
  210. "date": "2016-05-27 14:20:07",
  211. "spent": 2,
  212. "size": 2,
  213. "count": 0,
  214. "position": 0,
  215. "message": ""
  216. }
  217. if (callback) callback(json);
  218. },
  219. _removeDocument: function(documentData, all){
  220. this.actions.deleteSchedule(documentData.id, function(json){
  221. this.reload();
  222. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  223. }.bind(this));
  224. },
  225. _create: function(){
  226. },
  227. _openDocument: function( documentData ){
  228. this.workForm = new MWF.xApplication.Execution.WorkForm(this, this.actions, documentData, {
  229. "isNew": false,
  230. "isEdited": false
  231. })
  232. this.workForm.load();
  233. },
  234. _queryCreateViewNode: function(){
  235. },
  236. _postCreateViewNode: function( viewNode ){
  237. },
  238. _queryCreateViewHead:function(){
  239. },
  240. _postCreateViewHead: function( headNode ){
  241. }
  242. })
  243. MWF.xApplication.Execution.CoreWork.MyWorkDocument = new Class({
  244. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  245. action_comfirm : function(){
  246. },
  247. action_split:function(){
  248. this.workForm = new MWF.xApplication.Execution.WorkForm(this, this.actions, this.data, {
  249. "isNew": true,
  250. "isEdited": false
  251. })
  252. this.workForm.load();
  253. },
  254. _queryCreateDocumentNode:function( itemData ){
  255. },
  256. _postCreateDocumentNode: function( itemNode, itemData ){
  257. }
  258. //open: function(){
  259. // alert("open")
  260. //}
  261. })