Detail.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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.36:9520/api/school/curriculum/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. }, {
  34. xtype: 'textfield',
  35. name: 'gradeName',
  36. fieldLabel: '年级',
  37. }, {
  38. xtype: 'numberfield',
  39. name: 'clazzId',
  40. fieldLabel: '班级ID'
  41. }, {
  42. xtype: 'textfield',
  43. name: 'clazzName',
  44. fieldLabel: '班级',
  45. }, {
  46. xtype: 'textfield',
  47. name: 'termPart',
  48. fieldLabel: '学年'
  49. }, {
  50. xtype: "textfield",
  51. name: "termName",
  52. fieldLabel: "学期"
  53. }, {
  54. xtype: "textfield",
  55. name: "creatorName",
  56. fieldLabel: "录入人"
  57. }, {
  58. xtype: 'datefield',
  59. name: 'createTime',
  60. fieldLabel: '录入时间',
  61. format: 'Y-m-d H:i:s'
  62. }, {
  63. xtype: 'textfield',
  64. name: 'status',
  65. fieldLabel: '状态'
  66. }, {
  67. name: "timetable",
  68. xtype: "detailGridField",
  69. idColumn: 'id',
  70. detnoColumn: 'lessons',
  71. storeModel: 'school.model.Timetable',
  72. deleteDetailUrl: '/api/school/curriculum/deleteDetail',
  73. allowEmpty: true,
  74. showCount: false,
  75. emptyRows: 10,
  76. rowViewModel: {},
  77. columns: [{
  78. text: 'id',
  79. dataIndex: 'id',
  80. hidden: true
  81. }, {
  82. text: '时间段',
  83. xtype: 'widgetcolumn',
  84. width: 200,
  85. padding: 0,
  86. tdCls: 'x-period-column',
  87. getBindField: function(c) {
  88. return ['startTime', 'endTime']
  89. },
  90. widget: {
  91. xtype: 'container',
  92. style: {
  93. textAlign: 'center'
  94. },
  95. items: [{
  96. xtype: 'button',
  97. text: '0:00',
  98. bind: {
  99. text: '{record._timeText1}',
  100. },
  101. style: {
  102. margin: '5px',
  103. height: '22px',
  104. width: '74px',
  105. padding: 0
  106. },
  107. handler: function(btn) {
  108. me.currentRecord = btn.ownerCt.$widgetRecord;
  109. },
  110. menu: {
  111. xtype: 'menu',
  112. plain: true,
  113. items: [{
  114. xtype: 'timepicker',
  115. maxHeight: 300,
  116. increment: 5,
  117. format: 'H:i',
  118. minValue: Ext.Date.parse('08:00', 'H:i'),
  119. maxValue: Ext.Date.parse('22:00', 'H:i'),
  120. listeners: {
  121. select: function(model, record, index, eOpts) {
  122. me.onSelectPeriod0(this, this.up(), record);
  123. },
  124. }
  125. }]
  126. },
  127. }, {
  128. xtype: 'button',
  129. text: '0:00',
  130. bind: {
  131. text: '{record._timeText2}',
  132. },
  133. style: {
  134. margin: '5px',
  135. height: '22px',
  136. width: '74px',
  137. padding: 0
  138. },
  139. menu: {
  140. xtype: 'menu',
  141. plain: true,
  142. items: [{
  143. xtype: 'timepicker',
  144. maxHeight: 300,
  145. increment: 10,
  146. format: 'H:i',
  147. minValue: Ext.Date.parse('08:00', 'H:i'),
  148. maxValue: Ext.Date.parse('22:00', 'H:i'),
  149. listeners: {
  150. select: function(model, record, index, eOpts) {
  151. me.onSelectPeriod1(this, this.up(), record);
  152. },
  153. }
  154. }],
  155. listeners: {
  156. beforeshow: function(th, eOpts) {
  157. me.currentRecord = th.ownerCmp.ownerCt.$widgetRecord;
  158. let picker = th.down('timepicker');
  159. let startDate = me.currentRecord.get('_time1') || Ext.Date.parse('08:00', 'H:i');
  160. let minValue = Ext.Date.add(startDate, Ext.Date.MINUTE, me.MIN_WHILE);
  161. picker.setMinValue(minValue)
  162. },
  163. }
  164. },
  165. }]
  166. }
  167. }, {
  168. text: '星期一',
  169. dataIndex: 'mon',
  170. xtype: 'subjectcolumn'
  171. }, {
  172. text: '星期二',
  173. dataIndex: 'tues',
  174. xtype: 'subjectcolumn'
  175. }, {
  176. text: '星期三',
  177. dataIndex: 'wed',
  178. xtype: 'subjectcolumn'
  179. }, {
  180. text: '星期四',
  181. dataIndex: 'thur',
  182. xtype: 'subjectcolumn'
  183. }, {
  184. text: '星期五',
  185. dataIndex: 'fri',
  186. xtype: 'subjectcolumn'
  187. }, {
  188. text: '星期六',
  189. dataIndex: 'sat',
  190. xtype: 'subjectcolumn'
  191. }, {
  192. text: '星期日',
  193. dataIndex: 'sunday',
  194. xtype: 'subjectcolumn'
  195. }]
  196. }],
  197. });
  198. this.callParent();
  199. },
  200. onSelectPeriod0: function(picker, menu, record) {
  201. let me = this;
  202. me.currentRecord.set('startTime', Ext.Date.format(record.get('date'), 'H:i:s'));
  203. menu.setVisible(false);
  204. },
  205. onSelectPeriod1: function(picker, menu, record) {
  206. let me = this;
  207. me.currentRecord.set('endTime', Ext.Date.format(record.get('date'), 'H:i:s'));
  208. menu.setVisible(false);
  209. let classTime = Math.abs(Ext.Date.diff(me.currentRecord.get('_time1'), record.get('date'), Ext.Date.MINUTE));
  210. me.CLASS_TIME = classTime;
  211. }
  212. });