testtask.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. Ext.onReady(function() {
  2. SchedulerDemo.init();
  3. });
  4. SchedulerDemo = {
  5. // Initialize application
  6. init : function() {
  7. Ext.define('MyResource', {
  8. extend: 'Sch.model.Resource',
  9. idProperty : 'EmCode',
  10. nameField : 'Name',
  11. fields: [
  12. 'EmCode',
  13. 'Name',
  14. 'Id' ,
  15. 'EmId'
  16. ]
  17. });
  18. /* var resourceStore = Ext.create('Sch.data.ResourceStore', {
  19. model : 'MyResource',
  20. data : [
  21. {"Id":3097,"Name":"周袁","EmCode":"A016","EmId":3014},
  22. {"Id":3099,"Name":"马丹","EmCode":"A014","EmId":3012},
  23. {"Id":3101,"Name":"李瑞娟","EmCode":"A012","EmId":3010},
  24. {"Id":3103,"Name":"陈劲松","EmCode":"A006","EmId":3004},
  25. {"Id":3105,"Name":"陈正亮","EmCode":"A003","EmId":3001},
  26. {"Id":3113,"Name":"胡兴文","EmCode":"A005","EmId":3003},
  27. {"Id":3221,"Name":"姚振兴","EmCode":"A011","EmId":3009},
  28. {"Id":3096,"Name":"彭龙","EmCode":"A017","EmId":3015},
  29. {"Id":3098,"Name":"应鹏","EmCode":"A015","EmId":3013},
  30. {"Id":3100,"Name":"游凡","EmCode":"A013","EmId":3011},
  31. {"Id":3102,"Name":"钟燕玲","EmCode":"A007","EmId":3005},
  32. {"Id":3104,"Name":"陈正明","EmCode":"A008","EmId":3006},
  33. {"Id":3112,"Name":"吴伟","EmCode":"A024","EmId":3023},
  34. {"Id":3220,"Name":"蒋浏洋","EmCode":"A027","EmId":3025},
  35. {"Id":3222,"Name":"吉伟宁","EmCode":"A018","EmId":3016}
  36. ]
  37. });*/
  38. var resourceStore = Ext.create("Sch.data.ResourceStore", {
  39. model : 'MyResource',
  40. autoLoad: true,
  41. autoSync: true,
  42. proxy : {
  43. type : 'ajax',
  44. method: 'POST',
  45. reader: {
  46. root: 'resources',
  47. type : 'json'
  48. },
  49. extraParams : {
  50. condition : 'prjplan_id=3147'// formCondition
  51. },
  52. api: {
  53. read: basePath + 'task/resource.action',
  54. create: 'e-create.php',
  55. destroy: 'e-destroy.php',
  56. update: 'e-update.php'
  57. },
  58. writer : {
  59. type : 'json',
  60. root: 'resources',
  61. encode: true,
  62. writeAllFields: true,
  63. listful : true,
  64. allowSingle: false
  65. }
  66. }
  67. });
  68. Ext.define('MyEvent', {
  69. extend: 'Sch.model.Event',
  70. nameField : 'Name',
  71. startDateField : 'StartDate',
  72. endDateField : 'EndDate',
  73. resourceIdField : 'ResourceId',
  74. fields: [
  75. // Define your own model fields
  76. {name : 'StartDate', type : 'date', dateFormat : 'Y-m-d'},
  77. {name : 'EndDate', type : 'date', dateFormat : 'Y-m-d'},
  78. 'Name',
  79. 'ResourceId',
  80. 'TaskId'
  81. ]
  82. });
  83. /*var eventStore = Ext.create('Sch.data.EventStore', {
  84. resourceStore : resourceStore,
  85. data: [
  86. { MyResourceId: 'A016', MyName: 'Some task', MyStartDate: "2010-11-09 10:00", MyEndDate: "2010-11-09 13:00" },
  87. { MyResourceId: 'A014', MyName: 'Foo task', MyStartDate: "2010-11-09 14:00", MyEndDate: "2010-11-09 17:00" }
  88. {"ResourceId":"A007","Name":"MRP/MPS","StartDate":"2012-10-17","EndDate":"2012-10-27"},
  89. {"ResourceId":"A005","Name":"财务表结构","StartDate":"2012-10-17","EndDate":"2012-10-20"},
  90. {"ResourceId":"A014","Name":"供应链","StartDate":"2012-10-16","EndDate":"2012-10-20"},
  91. {"ResourceId":"A012","Name":"邮箱","StartDate":"2012-10-17","EndDate":"2012-10-20"},
  92. {"ResourceId":"A015","Name":"基本技术开发","StartDate":"2012-10-17","EndDate":"2012-10-27"},
  93. {"ResourceId":"A015","Name":"BUG管理、测试","StartDate":"2012-10-17","EndDate":"2012-10-20"},
  94. {"ResourceId":"A012","Name":"车辆管理","StartDate":"2012-10-12","EndDate":"2012-10-16"},
  95. {"ResourceId":"A012","Name":"请假管理","StartDate":"2012-10-22","EndDate":"2012-10-24"},
  96. {"ResourceId":"A024","Name":"加班申请","StartDate":"2012-10-24","EndDate":"2012-10-27"},
  97. {"ResourceId":"A015","Name":"特殊界面处理","StartDate":"2012-10-18","EndDate":"2012-10-27"},
  98. {"ResourceId":"A015","Name":"自定义流程问题","StartDate":"2012-10-22","EndDate":"2012-10-27"}
  99. ],
  100. model: 'MyEvent'
  101. });*/
  102. var eventStore = Ext.create("Sch.data.EventStore", {
  103. model: 'MyEvent',
  104. resourceStore : resourceStore,
  105. autoLoad: true,
  106. autoSync: true,
  107. proxy : {
  108. type : 'ajax',
  109. method: 'POST',
  110. reader: {
  111. root: 'assignments',
  112. type : 'json'
  113. },
  114. extraParams : {
  115. condition : 'prjplan_id=3147'// formCondition
  116. },
  117. api: {
  118. read: basePath + 'task/assignment.action',
  119. create: 'e-create.php',
  120. destroy: 'e-destroy.php',
  121. update: 'e-update.php'
  122. },
  123. writer : {
  124. type : 'json',
  125. root: 'assignments',
  126. encode: true,
  127. writeAllFields: true,
  128. listful : true,
  129. allowSingle: false
  130. }
  131. }
  132. });
  133. var sched = Ext.create("Sch.panel.SchedulerGrid", {
  134. height : 600,
  135. width : 1000,
  136. eventBarTextField : 'Name',
  137. viewPreset : 'weekAndDay',
  138. startDate : new Date(2012, 9, 9),
  139. endDate : new Date(2012, 12, 12),
  140. rowHeight: 30,
  141. // Setup static columns
  142. columns : [
  143. {header : '编号', sortable:true, width:50, dataIndex : 'EmCode'},
  144. {header : '姓名', sortable:true, width:60, dataIndex : 'Name'},
  145. {header : '员工序号', sortable:true, width:50, dataIndex : 'EmId'},
  146. {header : '序号', sortable:true, width:50, dataIndex : 'Id'}
  147. ],
  148. // Store holding all the resources
  149. resourceStore : resourceStore,
  150. // Store holding all the events
  151. eventStore : eventStore,
  152. onEventCreated : function(newEventRecord) {
  153. // Overridden to provide some defaults before adding it to the store
  154. newEventRecord.set('Name', 'New task...');
  155. }
  156. });
  157. sched.render(Ext.getBody());
  158. }
  159. };
  160. /*Ext.onReady(function() {
  161. SchedulerDemo.init();
  162. });
  163. SchedulerDemo = {
  164. // Initialize application
  165. init : function() {
  166. var summaryCol = Ext.create("Sch.plugin.SummaryColumn", {
  167. header : 'Time allocated',
  168. width: 80,
  169. showPercent : false
  170. });
  171. var summaryCol2 = Ext.create("Sch.plugin.SummaryColumn", {
  172. header : '% allocated',
  173. showPercent : true,
  174. align : 'center',
  175. width: 60
  176. });
  177. var resourceStore = Ext.create("Sch.data.ResourceStore", {
  178. model : 'Sch.model.Resource',
  179. //limit resources to 5 per page
  180. pageSize : 5,
  181. autoSync: true,
  182. proxy : {
  183. type : 'ajax',
  184. method: 'POST',
  185. reader: {
  186. type : 'json',
  187. root : 'resources',
  188. //name of the response property containing nuber of all records
  189. totalProperty : 'total'
  190. },
  191. extraParams : {
  192. condition : 'prjplan_id=3147'// formCondition
  193. },
  194. api: {
  195. read: basePath + 'plm/resourceassignment.action'
  196. },
  197. writer : {
  198. type : 'json',
  199. root: 'data',
  200. encode: true,
  201. writeAllFields: true,
  202. listful : true,
  203. allowSingle: false
  204. }
  205. }
  206. });
  207. var eventStore = Ext.create("Sch.data.EventStore", {
  208. autoLoad: true,
  209. autoSync: true,
  210. proxy : {
  211. type : 'ajax',
  212. method: 'POST',
  213. reader: {
  214. type : 'json'
  215. },
  216. extraParams : {
  217. condition : 'prjplan_id=3147'// formCondition
  218. },
  219. api: {
  220. read: basePath + 'plm/resourceassignment.action',
  221. create: 'e-create.php',
  222. destroy: 'e-destroy.php',
  223. update: 'e-update.php'
  224. },
  225. writer : {
  226. type : 'json',
  227. root: 'assignments',
  228. encode: true,
  229. writeAllFields: true,
  230. listful : true,
  231. allowSingle: false
  232. }
  233. }
  234. });
  235. var vp = new Ext.Viewport({
  236. layout : 'border',
  237. items : [
  238. {
  239. xtype : 'tabpanel',
  240. region : 'center',
  241. activeTab : 1,
  242. items : [
  243. {
  244. xtype : 'schedulergrid',
  245. eventBarTextField : 'Name',
  246. viewPreset : 'dayAndWeek',
  247. startDate : new Date(2010, 11, 1),
  248. endDate : new Date(2010, 11, 14),
  249. rowHeight : 36,
  250. title : 'Tab 2 - Scheduler',
  251. //snapToIncrement : true,
  252. eventResizeHandles : 'both',
  253. // Setup static columns
  254. columns : [
  255. {header : 'Name', sortable:true, width:200, dataIndex : 'Name'},
  256. {header : 'Some link', sortable:true, width:80, locked : true, renderer : function(v) { return '<a class="mylink" href="#">Click me!</a>'; }},
  257. summaryCol,
  258. summaryCol2
  259. ],
  260. // Store holding all the resources
  261. resourceStore : Ext.create("Sch.data.ResourceStore", {
  262. model : 'Sch.model.Resource',
  263. data : [
  264. {Id : 'r1', Name : 'Mike'},
  265. {Id : 'r2', Name : 'Linda'},
  266. {Id : 'r3', Name : 'Don'},
  267. {Id : 'r4', Name : 'Karen'},
  268. {Id : 'r5', Name : 'Doug'},
  269. {Id : 'r6', Name : 'Peter'}
  270. ]
  271. }),
  272. // Store holding all the events
  273. eventStore : Ext.create("Sch.data.EventStore", {
  274. data : [
  275. {Id : 'e10', ResourceId: 'r1', Name : 'Assignment 1', StartDate : "2010-12-02", EndDate : "2010-12-03"},
  276. {Id : 'e11', ResourceId: 'r2', Name : 'Assignment 2', StartDate : "2010-12-04", EndDate : "2010-12-07"},
  277. {Id : 'e21', ResourceId: 'r3', Name : 'Assignment 3', StartDate : "2010-12-01", EndDate : "2010-12-04"},
  278. {Id : 'e22', ResourceId: 'r4', Name : 'Assignment 4', StartDate : "2010-12-05", EndDate : "2010-12-07"},
  279. {Id : 'e32', ResourceId: 'r5', Name : 'Assignment 5', StartDate : "2010-12-07", EndDate : "2010-12-11"},
  280. {Id : 'e33', ResourceId: 'r6', Name : 'Assignment 6', StartDate : "2010-12-09", EndDate : "2010-12-11"}
  281. ]
  282. }),
  283. resourceStore:resourceStore,
  284. eventStore:eventStore,
  285. plugins : [ summaryCol, summaryCol2 ],
  286. onEventCreated : function(newEventRecord) {
  287. newEventRecord.setName('New task...');
  288. }
  289. }
  290. ]
  291. }
  292. ]
  293. });
  294. var sched = Ext.ComponentQuery.query('schedulergrid[lockable=true]')[0],
  295. lockedSection = sched.lockedGrid,
  296. view = lockedSection.getView();
  297. lockedSection.el.on('click', function(e, t) {
  298. var rowNode = view.findItemByChild(t);
  299. var resource = view.getRecord(rowNode);
  300. Ext.Msg.alert('Hey', 'You clicked ' + resource.get('Name'));
  301. e.stopEvent();
  302. }, null, { delegate : '.mylink' });
  303. }
  304. };
  305. */