| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- /**
- * 课程表
- */
- 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: '发布',
- type: 'publish',
- path: 'batchPublish',
- reference: 'publish',
- handler: 'onPublishClick'
- }, {
- 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' ? '已生效' : '未生效'
- }
- }],
- listeners: {
- selectionchange: 'selectionchange'
- }
- },
- });
- 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();
- }
- });
|