Detail.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. Ext.define('school.view.interaction.timetable.Detail', {
  2. extend: 'school.view.core.form.FormPanel',
  3. xtype: 'interaction-timetable-detail',
  4. controller: 'interaction-timetable-detail',
  5. _title: '课程表',
  6. _idField: 'id',
  7. _codeField: null,
  8. // _readUrl: 'http://10.1.80.35:8560/api/sale/saledown/read',
  9. _readUrl: '/api/school/curriculum/read',
  10. // _saveUrl: 'http://10.1.80.36:9520/api/school/curriculum/save',
  11. _saveUrl: '/api/school/curriculum/save',
  12. _deleteUrl: '/api/school/curriculum/delete',
  13. initId: 0,
  14. cls: 'timetable',
  15. START_TIME: Ext.Date.parse('08:00', 'H:i'), // 开始上课时间
  16. END_TIME: Ext.Date.parse('22:00', 'H:i'), // 结束上课时间
  17. MIN_WHILE: 10, // 一节课最小时间(分钟)
  18. initComponent: function () {
  19. let me = this;
  20. Ext.apply(this, {
  21. defaultItems: [{
  22. xtype: 'hidden',
  23. name: 'id',
  24. fieldLabel: 'id'
  25. }, {
  26. xtype: 'textfield',
  27. name: 'name',
  28. fieldLabel: '课表名称'
  29. }, {
  30. xtype: 'numberfield',
  31. name: 'gradeId',
  32. fieldLabel: '年级(id)',
  33. allowBlank: false
  34. }, {
  35. xtype: 'numberfield',
  36. name: 'clazzId',
  37. fieldLabel: '班级(id)',
  38. allowBlank: false
  39. }, {
  40. xtype: 'textfield',
  41. name: 'creatorName',
  42. fieldLabel: '录入人'
  43. }, {
  44. xtype: 'datefield',
  45. name: 'createTime',
  46. fieldLabel: '录入时间',
  47. format: 'Y-m-d H:i:s'
  48. }, {
  49. xtype: 'textfield',
  50. name: 'status',
  51. fieldLabel: '状态'
  52. }, {
  53. xtype: "textfield",
  54. name: "termName",
  55. fieldLabel: "学期名称"
  56. }, {
  57. xtype: "datefield",
  58. name: "termStart",
  59. fieldLabel: "学期开始时间",
  60. format: 'Y-m-d'
  61. }, {
  62. xtype: 'datefield',
  63. name: 'termEnd',
  64. fieldLabel: '学期结束时间',
  65. format: 'Y-m-d'
  66. }, {
  67. xtype: 'numberfield',
  68. name: 'weekNum',
  69. fieldLabel: '周数'
  70. }, {
  71. name: "timetable",
  72. xtype: "detailGridField",
  73. idColumn: 'id',
  74. detnoColumn: 'lessons',
  75. storeModel: 'school.model.Timetable',
  76. deleteDetailUrl: '/api/school/curriculum/deleteDetail',
  77. allowEmpty: true,
  78. showCount: false,
  79. emptyRows: 10,
  80. rowViewModel: {},
  81. columns: [{
  82. text: 'id',
  83. dataIndex: 'id',
  84. hidden: true
  85. }, {
  86. text: '时间段',
  87. xtype: 'widgetcolumn',
  88. width: 200,
  89. padding: 0,
  90. tdCls: 'x-period-column',
  91. getBindField: function(c) {
  92. return ['startTime', 'endTime']
  93. },
  94. widget: {
  95. xtype: 'container',
  96. style: {
  97. textAlign: 'center'
  98. },
  99. items: [{
  100. xtype: 'button',
  101. text: '0:00',
  102. bind: {
  103. text: '{record._timeText1}',
  104. },
  105. style: {
  106. margin: '5px',
  107. height: '22px',
  108. width: '74px',
  109. padding: 0
  110. },
  111. handler: function(btn) {
  112. me.currentRecord = btn.ownerCt.$widgetRecord;
  113. },
  114. menu: {
  115. xtype: 'menu',
  116. plain: true,
  117. items: [{
  118. xtype: 'timepicker',
  119. maxHeight: 300,
  120. increment: 5,
  121. format: 'H:i',
  122. minValue: Ext.Date.parse('08:00', 'H:i'),
  123. maxValue: Ext.Date.parse('22:00', 'H:i'),
  124. listeners: {
  125. select: function(model, record, index, eOpts) {
  126. me.onSelectPeriod0(this, this.up(), record);
  127. },
  128. }
  129. }]
  130. },
  131. }, {
  132. xtype: 'button',
  133. text: '0:00',
  134. bind: {
  135. text: '{record._timeText2}',
  136. },
  137. style: {
  138. margin: '5px',
  139. height: '22px',
  140. width: '74px',
  141. padding: 0
  142. },
  143. menu: {
  144. xtype: 'menu',
  145. plain: true,
  146. items: [{
  147. xtype: 'timepicker',
  148. maxHeight: 300,
  149. increment: 10,
  150. format: 'H:i',
  151. minValue: Ext.Date.parse('08:00', 'H:i'),
  152. maxValue: Ext.Date.parse('22:00', 'H:i'),
  153. listeners: {
  154. select: function(model, record, index, eOpts) {
  155. me.onSelectPeriod1(this, this.up(), record);
  156. },
  157. }
  158. }],
  159. listeners: {
  160. beforeshow: function(th, eOpts) {
  161. me.currentRecord = th.ownerCmp.ownerCt.$widgetRecord;
  162. let picker = th.down('timepicker');
  163. let startDate = me.currentRecord.get('_time1') || Ext.Date.parse('08:00', 'H:i');
  164. let minValue = Ext.Date.add(startDate, Ext.Date.MINUTE, me.MIN_WHILE);
  165. picker.setMinValue(minValue)
  166. },
  167. }
  168. },
  169. }]
  170. }
  171. }, {
  172. text: '星期一',
  173. dataIndex: 'mon',
  174. xtype: 'subjectcolumn'
  175. }, {
  176. text: '星期二',
  177. dataIndex: 'tues',
  178. xtype: 'subjectcolumn'
  179. }, {
  180. text: '星期三',
  181. dataIndex: 'wed',
  182. xtype: 'subjectcolumn'
  183. }, {
  184. text: '星期四',
  185. dataIndex: 'thur',
  186. xtype: 'subjectcolumn'
  187. }, {
  188. text: '星期五',
  189. dataIndex: 'fri',
  190. xtype: 'subjectcolumn'
  191. }, {
  192. text: '星期六',
  193. dataIndex: 'sat',
  194. xtype: 'subjectcolumn'
  195. }, {
  196. text: '星期日',
  197. dataIndex: 'sunday',
  198. xtype: 'subjectcolumn'
  199. }]
  200. }],
  201. });
  202. this.callParent();
  203. },
  204. onSelectPeriod0: function(picker, menu, record) {
  205. let me = this;
  206. me.currentRecord.set('startTime', Ext.Date.format(record.get('date'), 'H:i:s'));
  207. menu.setVisible(false);
  208. },
  209. onSelectPeriod1: function(picker, menu, record) {
  210. let me = this;
  211. me.currentRecord.set('endTime', Ext.Date.format(record.get('date'), 'H:i:s'));
  212. menu.setVisible(false);
  213. let classTime = Math.abs(Ext.Date.diff(me.currentRecord.get('_time1'), record.get('date'), Ext.Date.MINUTE));
  214. me.CLASS_TIME = classTime;
  215. }
  216. });