/** * 学生信息 */ Ext.define('school.view.basic.student.StudentList', { extend: 'school.view.core.base.BasePanel', xtype: 'basic-student-studentlist', dataUrl: '/api/school/student/list', // dataUrl: 'http:/api/school/student/list', _title: '学生信息', caller: 'Student', pathKey: 'student', initComponent: function() { var me = this; Ext.apply(this, { searchField: [{ xtype: 'gradecombo', name: 'stu_grade', fieldLabel: '年级', listeners: { select: function (combo, record, eOpts) { combo.up('form').getForm().findField('stu_class').setValue(null); } } }, { xtype: 'classcombo', name: 'stu_class', fieldLabel: '班级', listeners: { expand: function (combo, eOpts) { combo.store.clearFilter(); var gradeCombo = combo.up('form').getForm().findField('stu_grade'); 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('stu_grade').setValue(record.get('clazz_grade')); } } }, { xtype: 'textfield', name: 'stu_number', fieldLabel:'学号' }, { xtype: 'textfield', name: 'stu_name', fieldLabel: '姓名' }, { xtype: 'condatefield', name: 'stu_enroll_date', fieldLabel: '入学日期', columnWidth: 0.5 }], gridConfig: { addTitle: '学生信息', addXtype: 'basic-student-studentdetail', idField: 'stu_id', codeField: 'stu_number', detailField: 'stu_number', 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: function() { school.util.BaseUtil.openTab('basic-student-studentdetail', '新增学生信息', 'basic-student-studentdetail-add'); } }, { xtype: 'importbutton', 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('stu_id') }; }); if(data.length == 0) { school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录'); return; } grid.setLoading(true); school.util.BaseUtil.request({ // url: 'http://10.1.80.47:9560/student/batchDelete', url: '/api/school/student/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: 'stu_id', hidden: true }, { text: '学号', dataIndex: 'stu_number', width: 150 }, { text: '姓名', dataIndex: 'stu_name', width: 120 }, { text: '性别', dataIndex: 'stu_sex', width: 120, renderer: function(v, m, r) { return v == 1 ? '男' : (v == 0 ? '女' : '未知'); } }, { text: '年级', dataIndex: 'stu_grade', editor: { xtype: 'combobox', displayField: 'name', valueField: 'value', store: { type: 'store_grade' }, queryMode: 'local' }, }, { text: '班级', dataIndex: 'stu_class' }, { text: '入学日期', dataIndex: 'stu_enroll_date', xtype: 'datecolumn', format: 'Y-m-d' }, { text: '出生日期', dataIndex: 'stu_birthday', width: 120, xtype: 'datecolumn', format: 'Y-m-d' }] }, }); this.callParent(arguments); }, refresh: function() { Ext.StoreMgr.get('store_grade').load(); Ext.StoreMgr.get('store_class').load(); this.items.items[0].store.load(); } });