/** * 课程表 */ Ext.define('school.view.interaction.timetable.List', { extend: 'school.view.core.base.BasePanel', xtype: 'interaction-timetable-list', controller: 'interaction-timetable-list', // dataUrl: 'http://10.1.80.47:9520/api/school/curriculum/list', dataUrl: '/api/school/curriculum/list', _title: '课程表', caller: 'Curriculum', pathKey: 'curriculum', initComponent: function() { var me = this; Ext.apply(this, { searchField: [{ xtype: 'textfield', name: 'mcur_name', fieldLabel: '课表名称' }, { xtype: 'gradecombo', name: 'grade_name', fieldLabel: '年级', listeners: { select: function (combo, record, eOpts) { combo.up('form').getForm().findField('clazz_name').setValue(null); } } }, { xtype: 'classcombo', name: 'clazz_name', fieldLabel: '班级', listeners: { expand: function (combo, eOpts) { combo.store.clearFilter(); var gradeCombo = combo.up('form').getForm().findField('grade_name'); var gradeName = gradeCombo.getValue(); var filter = new Ext.util.Filter({ property: 'clazz_grade', value: gradeName }); if (!!gradeName) { combo.store.setFilters([filter]); } }, select: function (combo, record, eOpts) { combo.up('form').getForm().findField('grade_name').setValue(record.get('clazz_grade')); } } }, { xtype: 'combobox', name: 'mcur_term_part', fieldLabel: '学年', queryModel: 'local', displayField: 'value', valueField: 'value', store: Ext.create('Ext.data.ArrayStore', { fields: ['value'], data: (function() { let now = new Date(); let year = now.getFullYear(); let op = [], o1, o2; o1 = [(year - 1) + '-' + year]; o2 = [year + '-' + (year + 1)]; op.push(o1); op.push(o2); return op; })() }), value: (function() { let now = new Date(); let year = now.getFullYear(); let month = now.getMonth() + 1; let o1, o2, termPart; o1 = [(year - 1) + '-' + year]; o2 = [year + '-' + (year + 1)]; if((month > 2 && month < 8) || (month == 2 && date > 15) || (month == 8 && date < 15)) { termPart = o1[0]; }else { termPart = o2[0]; } return termPart; })() }, { xtype: "combobox", name: "mcur_term_name", fieldLabel: "学期", queryModel: 'local', displayField: 'value', valueField: 'value', editable: false, clearable: true, store: Ext.create('Ext.data.ArrayStore', { fields: ['value'], data: [['第一学期'], ['第二学期']] }), value: (function() { let now = new Date(), month = now.getMonth() + 1, date = now.getDate(), term; if((month > 2 && month < 8) || (month == 2 && date > 15) || (month == 8 && date < 15)) { term = '第二学期'; }else { term = '第一学期' } return term; })() }, { xtype: 'combobox', name: 'status', fieldLabel: '发布状态', displayField: 'name', valueField: 'value', editable: false, clearable: true, store: Ext.create('Ext.data.ArrayStore', { fields: ['name', 'value'], data: [ ['已生效', 1], ['未生效', 0] ] }), minChars: 0, queryMode: 'local' }], gridConfig: { addTitle: '课程表', addXtype: 'interaction-timetable-detail', idField: 'id', codeField: 'name', detailField: 'name', dataUrl: me.dataUrl, caller: null, rootProperty: 'data.list', totalProperty: 'data.total', actionColumn: [], selModel: { checkOnly:true, type:'checkboxmodel', mode : "MULTI" , ignoreRightMouseSelection : false }, hiddenTools: false, toolBtns: [{ xtype: 'button', text: '新增', handler: 'onAddClick' }, { xtype: 'importbutton', text: '导入', belong: me, caller: me.caller, pathKey: me.pathKey, onSuccess: function () { //刷新界面 var g = me.down('grid'); g.store.loadPage(g.store.currentPage); } }, { xtype: 'button', text: '删除', handler: function() { let grid = this.up('grid'), selectedRecords = grid.getSelection(); let data; data = selectedRecords.map(function (r) { return { id: r.get('id') }; }); if (data.length == 0) { school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录'); return; } school.util.BaseUtil.showConfirm('确认删除', '确定要删除这' + data.length + '条记录吗?') .then(function(yes) { if(yes == 'yes') { grid.setLoading(true); school.util.BaseUtil.request({ // url: 'http://10.1.80.36:9520/api/school/curriculum/batchDelete', url: '/api/school/curriculum/batchDelete', method: 'POST', params: JSON.stringify({ baseDTOs: data }) }).then(function (res) { grid.setLoading(false); school.util.BaseUtil.showSuccessToast('成功删除' + data.length + '条记录'); grid.store.loadPage(grid.store.currentPage); }).catch(function (e) { grid.setLoading(false); school.util.BaseUtil.showErrorToast('删除失败: ' + e.message); }); } }); } }], columns : [{ text: 'id', dataIndex: 'id', hidden: true }, { text: '课表名称', dataIndex: 'name', width: 120, // tdCls: 'x-detail-column', // listeners: { // click: function(view, td, row, col, e, record, tr, eOpts, event) { // let gridConfig = me.gridConfig; // school.util.BaseUtil.openTab(gridConfig.addXtype, gridConfig.addTitle + '(' + record.get('id') + ')', gridConfig.addXtype + record.get(gridConfig.idField), { // initId: record.get(gridConfig.idField) // }); // } // } }, { text: '年级', dataIndex: 'gradeName' }, { text: '班级', dataIndex: 'clazzName' }, { text: '学年', dataIndex: 'termPart' }, { text: '学期', dataIndex: 'termName', width: 120 }, { text: '状态', dataIndex: 'status', renderer: function(v) { return v == '1' ? '已生效' : '未生效' } }] }, }); this.callParent(arguments); }, refresh: function() { Ext.StoreMgr.get('store_grade').load(); Ext.StoreMgr.get('store_class').load(); Ext.StoreMgr.get('store_subject').load(); this.items.items[0].store.load(); } });