|
|
@@ -17,7 +17,10 @@ Ext.define('school.view.interaction.timetable.Detail', {
|
|
|
|
|
|
START_TIME: Ext.Date.parse('08:00', 'H:i'), // 开始上课时间
|
|
|
END_TIME: Ext.Date.parse('22:00', 'H:i'), // 结束上课时间
|
|
|
- MIN_WHILE: 10, // 一节课最小时间(分钟)
|
|
|
+ MIN_MIN_WHILE: 5, // 最小一节课时间(分钟)
|
|
|
+ CLASS_TIME: 30, // 一节课时间(分钟)
|
|
|
+ MIN_BREAK_TIME: 5, // 最小课间休息时间(分钟)
|
|
|
+ BREAK_TIME: 5, // 课间休息时间(分钟)
|
|
|
|
|
|
|
|
|
initComponent: function () {
|
|
|
@@ -164,8 +167,9 @@ Ext.define('school.view.interaction.timetable.Detail', {
|
|
|
deleteDetailUrl: '/api/school/curriculum/deleteDetail',
|
|
|
allowEmpty: true,
|
|
|
showCount: false,
|
|
|
- emptyRows: 10,
|
|
|
+ emptyRows: 8,
|
|
|
rowViewModel: {},
|
|
|
+ minHeight: 350,
|
|
|
columns: [{
|
|
|
text: 'id',
|
|
|
dataIndex: 'id',
|
|
|
@@ -186,7 +190,6 @@ Ext.define('school.view.interaction.timetable.Detail', {
|
|
|
},
|
|
|
items: [{
|
|
|
xtype: 'button',
|
|
|
- text: '0:00',
|
|
|
bind: {
|
|
|
text: '{record._timeText1}',
|
|
|
},
|
|
|
@@ -197,7 +200,21 @@ Ext.define('school.view.interaction.timetable.Detail', {
|
|
|
padding: 0
|
|
|
},
|
|
|
handler: function(btn) {
|
|
|
- me.currentRecord = btn.ownerCt.$widgetRecord;
|
|
|
+ let record = btn.ownerCt.$widgetRecord;
|
|
|
+ let store = record.store;
|
|
|
+ let idx = record.get('lessons') - 2;
|
|
|
+ let preRecord, preDate;
|
|
|
+
|
|
|
+ if(idx > -1) {
|
|
|
+ preRecord = store.getAt(idx);
|
|
|
+ preDate = preRecord.get('_time2');
|
|
|
+
|
|
|
+ if(!!preDate && Ext.Date.format(preDate, 'H:i') != '00:00') {
|
|
|
+ record.set('startTime', Ext.Date.format(Ext.Date.add(preDate, Ext.Date.MINUTE, me.BREAK_TIME), 'H:i:s'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ me.currentRecord = record;
|
|
|
},
|
|
|
menu: {
|
|
|
xtype: 'menu',
|
|
|
@@ -207,18 +224,46 @@ Ext.define('school.view.interaction.timetable.Detail', {
|
|
|
maxHeight: 300,
|
|
|
increment: 5,
|
|
|
format: 'H:i',
|
|
|
- minValue: Ext.Date.parse('08:00', 'H:i'),
|
|
|
- maxValue: Ext.Date.parse('22:00', 'H:i'),
|
|
|
+ minValue: me.START_TIME,
|
|
|
+ maxValue: me.END_TIME,
|
|
|
listeners: {
|
|
|
select: function(model, record, index, eOpts) {
|
|
|
me.onSelectPeriod0(this, this.up(), record);
|
|
|
},
|
|
|
}
|
|
|
- }]
|
|
|
+ }],
|
|
|
+ listeners: {
|
|
|
+ beforeshow: function(th, eOpts) {
|
|
|
+ let record = th.ownerCmp.ownerCt.$widgetRecord
|
|
|
+ let picker = th.down('timepicker');
|
|
|
+ let store = th.ownerCmp.ownerCt.$widgetRecord.store;
|
|
|
+ let idx = record.get('lessons') - 2;
|
|
|
+ let preRecord, preDate, minValue;
|
|
|
+
|
|
|
+ me.currentRecord = record;
|
|
|
+
|
|
|
+ if(idx > -1) {
|
|
|
+ preRecord = store.getAt(idx);
|
|
|
+ preDate = preRecord.get('_time2');
|
|
|
+ if(Ext.Date.format(preDate, 'H:i') == '00:00') {
|
|
|
+ school.util.BaseUtil.showErrorToast('请先完成上一课时设置');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(Ext.Date.format(preDate, 'H:i') == '22:00') {
|
|
|
+ school.util.BaseUtil.showErrorToast('已无可用课时(08:00~22:00)');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ minValue = Ext.Date.add(preDate, Ext.Date.MINUTE, me.BREAK_TIME);
|
|
|
+ }else {
|
|
|
+ minValue = Ext.Date.parse('08:00', 'H:i');
|
|
|
+ }
|
|
|
+
|
|
|
+ picker.setMinValue(minValue)
|
|
|
+ },
|
|
|
+ }
|
|
|
},
|
|
|
}, {
|
|
|
xtype: 'button',
|
|
|
- text: '0:00',
|
|
|
bind: {
|
|
|
text: '{record._timeText2}',
|
|
|
},
|
|
|
@@ -228,16 +273,26 @@ Ext.define('school.view.interaction.timetable.Detail', {
|
|
|
width: '74px',
|
|
|
padding: 0
|
|
|
},
|
|
|
+ handler: function(btn) {
|
|
|
+ let record = btn.ownerCt.$widgetRecord;
|
|
|
+ let startDate = record.get('_time1');
|
|
|
+
|
|
|
+ if(Ext.Date.format(startDate, 'H:i') != '00:00') {
|
|
|
+ record.set('endTime', Ext.Date.format(Ext.Date.add(startDate, Ext.Date.MINUTE, me.CLASS_TIME), 'H:i:s'));
|
|
|
+ }
|
|
|
+
|
|
|
+ me.currentRecord = record;
|
|
|
+ },
|
|
|
menu: {
|
|
|
xtype: 'menu',
|
|
|
plain: true,
|
|
|
items: [{
|
|
|
xtype: 'timepicker',
|
|
|
maxHeight: 300,
|
|
|
- increment: 10,
|
|
|
+ increment: 5,
|
|
|
format: 'H:i',
|
|
|
- minValue: Ext.Date.parse('08:00', 'H:i'),
|
|
|
- maxValue: Ext.Date.parse('22:00', 'H:i'),
|
|
|
+ minValue: me.START_TIME,
|
|
|
+ maxValue: me.END_TIME,
|
|
|
listeners: {
|
|
|
select: function(model, record, index, eOpts) {
|
|
|
me.onSelectPeriod1(this, this.up(), record);
|
|
|
@@ -246,10 +301,18 @@ Ext.define('school.view.interaction.timetable.Detail', {
|
|
|
}],
|
|
|
listeners: {
|
|
|
beforeshow: function(th, eOpts) {
|
|
|
- me.currentRecord = th.ownerCmp.ownerCt.$widgetRecord;
|
|
|
+ let record = th.ownerCmp.ownerCt.$widgetRecord;
|
|
|
let picker = th.down('timepicker');
|
|
|
- let startDate = me.currentRecord.get('_time1') || Ext.Date.parse('08:00', 'H:i');
|
|
|
- let minValue = Ext.Date.add(startDate, Ext.Date.MINUTE, me.MIN_WHILE);
|
|
|
+
|
|
|
+ if(Ext.Date.format(record.get('_time1'), 'H:i') == '00:00') {
|
|
|
+ school.util.BaseUtil.showErrorToast('请先设置开始时间');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ let startDate = record.get('_time1') || Ext.Date.parse('08:00', 'H:i');
|
|
|
+ let minValue = Ext.Date.add(startDate, Ext.Date.MINUTE, me.MIN_MIN_WHILE);
|
|
|
+ me.currentRecord = record;
|
|
|
+
|
|
|
picker.setMinValue(minValue)
|
|
|
},
|
|
|
}
|
|
|
@@ -294,15 +357,27 @@ Ext.define('school.view.interaction.timetable.Detail', {
|
|
|
|
|
|
onSelectPeriod0: function(picker, menu, record) {
|
|
|
let me = this;
|
|
|
- me.currentRecord.set('startTime', Ext.Date.format(record.get('date'), 'H:i:s'));
|
|
|
+ let cRecord = me.currentRecord;
|
|
|
+ let store = cRecord.store,
|
|
|
+ preIdx = cRecord.get('lessons') - 2, preRecord;
|
|
|
+
|
|
|
+ cRecord.set('startTime', Ext.Date.format(record.get('date'), 'H:i:s'));
|
|
|
menu.setVisible(false);
|
|
|
+
|
|
|
+ if(preIdx > -1) {
|
|
|
+ preRecord = store.getAt(preIdx);
|
|
|
+ if(!!preRecord) {
|
|
|
+ let breakTime = Math.abs(Ext.Date.diff(cRecord.get('_time1'), preRecord.get('_time2'), Ext.Date.MINUTE));
|
|
|
+ me.BREAK_TIME = breakTime;
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
onSelectPeriod1: function(picker, menu, record) {
|
|
|
let me = this;
|
|
|
me.currentRecord.set('endTime', Ext.Date.format(record.get('date'), 'H:i:s'));
|
|
|
menu.setVisible(false);
|
|
|
- let classTime = Math.abs(Ext.Date.diff(me.currentRecord.get('_time1'), record.get('date'), Ext.Date.MINUTE));
|
|
|
+ let classTime = Math.abs(Ext.Date.diff(me.currentRecord.get('_time1'), me.currentRecord.get('_time2'), Ext.Date.MINUTE));
|
|
|
me.CLASS_TIME = classTime;
|
|
|
},
|
|
|
|