Detail.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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.47:9520/api/school/curriculum/read',
  9. _readUrl: '/api/school/curriculum/read',
  10. // _saveUrl: 'http://10.1.80.47: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. hidden: true
  34. }, {
  35. xtype: 'gradecombo',
  36. name: 'gradeName',
  37. fieldLabel: '年级',
  38. allowBlank: false,
  39. listeners: {
  40. select: function (combo, record, eOpts) {
  41. combo.up('form').getForm().findField('gradeId').setValue(record.get('grade_id'));
  42. combo.up('form').getForm().findField('clazzId').setValue(null);
  43. combo.up('form').getForm().findField('clazzName').setValue(null);
  44. }
  45. }
  46. }, {
  47. xtype: 'numberfield',
  48. name: 'clazzId',
  49. fieldLabel: '班级ID',
  50. hidden: true
  51. }, {
  52. xtype: 'classcombo',
  53. name: 'clazzName',
  54. fieldLabel: '班级',
  55. allowBlank: false,
  56. listeners: {
  57. expand: function (combo, eOpts) {
  58. combo.store.clearFilter();
  59. var gradeCombo = combo.up('form').getForm().findField('gradeName');
  60. var gradeName = gradeCombo.getValue();
  61. var filter = new Ext.util.Filter({
  62. property: 'clazz_grade',
  63. value: gradeName
  64. });
  65. if (!!gradeName) {
  66. combo.store.setFilters([filter]);
  67. }
  68. },
  69. select: function (combo, record, eOpts) {
  70. combo.up('form').getForm().findField('clazzId').setValue(record.get('clazz_id'));
  71. combo.up('form').getForm().findField('gradeId').setValue(record.get('grade_id'));
  72. combo.up('form').getForm().findField('gradeName').setValue(record.get('clazz_grade'));
  73. }
  74. }
  75. }, {
  76. xtype: 'combobox',
  77. name: 'termPart',
  78. fieldLabel: '学年',
  79. allowBlank: false,
  80. queryModel: 'local',
  81. displayField: 'value',
  82. valueField: 'value',
  83. store: Ext.create('Ext.data.ArrayStore', {
  84. fields: ['value'],
  85. data: (function() {
  86. let now = new Date();
  87. let year = now.getFullYear();
  88. let op = [], o1, o2;
  89. o1 = [(year - 1) + '-' + year];
  90. o2 = [year + '-' + (year + 1)];
  91. op.push(o1);
  92. op.push(o2);
  93. return op;
  94. })()
  95. }),
  96. defaultValue: (function() {
  97. let now = new Date();
  98. let year = now.getFullYear();
  99. let month = now.getMonth() + 1;
  100. let o1, o2;
  101. o1 = [(year - 1) + '-' + year];
  102. o2 = [year + '-' + (year + 1)];
  103. return (month < 9) ? o1 : o2
  104. })()
  105. }, {
  106. xtype: "combobox",
  107. name: "termName",
  108. fieldLabel: "学期",
  109. allowBlank: false,
  110. queryModel: 'local',
  111. displayField: 'value',
  112. valueField: 'value',
  113. store: Ext.create('Ext.data.ArrayStore', {
  114. fields: ['value'],
  115. data: [['第一学期'], ['第二学期']]
  116. }),
  117. defaultValue: (function() {
  118. let now = new Date();
  119. let month = now.getMonth() + 1;
  120. return (month < 9) ? '第一学期' : '第二学期'
  121. })()
  122. }, {
  123. xtype: "textfield",
  124. name: "creatorName",
  125. fieldLabel: "录入人",
  126. defaultValue: school.util.BaseUtil.getCurrentUser().username,
  127. readOnly: true
  128. }, {
  129. xtype: 'datefield',
  130. name: 'createTime',
  131. fieldLabel: '录入时间',
  132. format: 'Y-m-d H:i:s',
  133. defaultValue: new Date(),
  134. readOnly: true
  135. }, {
  136. xtype: 'combobox',
  137. name: 'status',
  138. fieldLabel: '状态',
  139. displayField: 'name',
  140. valueField: 'value',
  141. editable: false,
  142. readOnly: true,
  143. minChars: 0,
  144. queryMode: 'local',
  145. store: Ext.create('Ext.data.ArrayStore', {
  146. fields: ['name', 'value'],
  147. data: [['已生效', '1'], ['未生效', '0']]
  148. }),
  149. defaultValue: 0
  150. }, {
  151. name: "timetable",
  152. xtype: "detailGridField",
  153. idColumn: 'id',
  154. detnoColumn: 'lessons',
  155. storeModel: 'school.model.Timetable',
  156. deleteDetailUrl: '/api/school/curriculum/deleteDetail',
  157. allowEmpty: true,
  158. showCount: false,
  159. emptyRows: 10,
  160. rowViewModel: {},
  161. columns: [{
  162. text: 'id',
  163. dataIndex: 'id',
  164. hidden: true
  165. }, {
  166. text: '时间段',
  167. xtype: 'widgetcolumn',
  168. width: 200,
  169. padding: 0,
  170. tdCls: 'x-period-column',
  171. getBindField: function(c) {
  172. return ['startTime', 'endTime']
  173. },
  174. widget: {
  175. xtype: 'container',
  176. style: {
  177. textAlign: 'center'
  178. },
  179. items: [{
  180. xtype: 'button',
  181. text: '0:00',
  182. bind: {
  183. text: '{record._timeText1}',
  184. },
  185. style: {
  186. margin: '5px',
  187. height: '22px',
  188. width: '74px',
  189. padding: 0
  190. },
  191. handler: function(btn) {
  192. me.currentRecord = btn.ownerCt.$widgetRecord;
  193. },
  194. menu: {
  195. xtype: 'menu',
  196. plain: true,
  197. items: [{
  198. xtype: 'timepicker',
  199. maxHeight: 300,
  200. increment: 5,
  201. format: 'H:i',
  202. minValue: Ext.Date.parse('08:00', 'H:i'),
  203. maxValue: Ext.Date.parse('22:00', 'H:i'),
  204. listeners: {
  205. select: function(model, record, index, eOpts) {
  206. me.onSelectPeriod0(this, this.up(), record);
  207. },
  208. }
  209. }]
  210. },
  211. }, {
  212. xtype: 'button',
  213. text: '0:00',
  214. bind: {
  215. text: '{record._timeText2}',
  216. },
  217. style: {
  218. margin: '5px',
  219. height: '22px',
  220. width: '74px',
  221. padding: 0
  222. },
  223. menu: {
  224. xtype: 'menu',
  225. plain: true,
  226. items: [{
  227. xtype: 'timepicker',
  228. maxHeight: 300,
  229. increment: 10,
  230. format: 'H:i',
  231. minValue: Ext.Date.parse('08:00', 'H:i'),
  232. maxValue: Ext.Date.parse('22:00', 'H:i'),
  233. listeners: {
  234. select: function(model, record, index, eOpts) {
  235. me.onSelectPeriod1(this, this.up(), record);
  236. },
  237. }
  238. }],
  239. listeners: {
  240. beforeshow: function(th, eOpts) {
  241. me.currentRecord = th.ownerCmp.ownerCt.$widgetRecord;
  242. let picker = th.down('timepicker');
  243. let startDate = me.currentRecord.get('_time1') || Ext.Date.parse('08:00', 'H:i');
  244. let minValue = Ext.Date.add(startDate, Ext.Date.MINUTE, me.MIN_WHILE);
  245. picker.setMinValue(minValue)
  246. },
  247. }
  248. },
  249. }]
  250. }
  251. }, {
  252. text: '星期一',
  253. dataIndex: 'mon',
  254. xtype: 'subjectcolumn'
  255. }, {
  256. text: '星期二',
  257. dataIndex: 'tues',
  258. xtype: 'subjectcolumn'
  259. }, {
  260. text: '星期三',
  261. dataIndex: 'wed',
  262. xtype: 'subjectcolumn'
  263. }, {
  264. text: '星期四',
  265. dataIndex: 'thur',
  266. xtype: 'subjectcolumn'
  267. }, {
  268. text: '星期五',
  269. dataIndex: 'fri',
  270. xtype: 'subjectcolumn'
  271. }, {
  272. text: '星期六',
  273. dataIndex: 'sat',
  274. xtype: 'subjectcolumn',
  275. hidden: true
  276. }, {
  277. text: '星期日',
  278. dataIndex: 'sunday',
  279. xtype: 'subjectcolumn',
  280. hidden: true
  281. }]
  282. }],
  283. });
  284. this.callParent();
  285. },
  286. onSelectPeriod0: function(picker, menu, record) {
  287. let me = this;
  288. me.currentRecord.set('startTime', Ext.Date.format(record.get('date'), 'H:i:s'));
  289. menu.setVisible(false);
  290. },
  291. onSelectPeriod1: function(picker, menu, record) {
  292. let me = this;
  293. me.currentRecord.set('endTime', Ext.Date.format(record.get('date'), 'H:i:s'));
  294. menu.setVisible(false);
  295. let classTime = Math.abs(Ext.Date.diff(me.currentRecord.get('_time1'), record.get('date'), Ext.Date.MINUTE));
  296. me.CLASS_TIME = classTime;
  297. },
  298. refresh: function() {
  299. Ext.StoreMgr.get('store_grade').load();
  300. Ext.StoreMgr.get('store_class').load();
  301. Ext.StoreMgr.get('store_subject').load();
  302. }
  303. });