/** * 课程表 */ 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.36: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: 'name', fieldLabel: '课表名称' }, { xtype: 'textfield', name: 'gradeName', fieldLabel: '年级' }, { xtype: 'textfield', name: 'clazzName', fieldLabel: '班级' }, { xtype: 'numberfield', name: 'text', fieldLabel: '学年', getCondition: function(v) { return '1=1'; } }, { xtype: 'textfield', name: 'termName', fieldLabel: '学期' }], gridConfig: { addTitle: '课程表', addXtype: 'interaction-timetable-detail', idField: 'id', codeField: null, 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; } grid.setLoading(true); school.util.BaseUtil.request({ url: '/api/school/curriculum/deleteDetail', 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: 'xn' }, { text: '学期', dataIndex: 'termName', width: 120 }] }, }); this.callParent(arguments); }, /** * 处理部分字段值 */ getConditionValue: function (field, value) { var me = this, xtypes = field.getXTypes().split('/'), conditionValue; if (me.isContainsAny(xtypes, ['datefield'])) { conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s'); } else if (me.isContainsAny(xtypes, ['conmonthfield'])) { var from = value.from, to = value.to; conditionValue = from + ',' + to; } else if (me.isContainsAny(xtypes, ['condatefield'])) { var from = value.from, to = value.to; conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59'); } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) { conditionValue = value; } else if (me.isContainsAny(xtypes, ['combobox', 'combo'])) { conditionValue = value; } else if (me.isContainsAny(xtypes, ['multicombo'])) { conditionValue = value.map ? value.map(function (v) { return v.value; }).join(',') : ''; } else { conditionValue = value; } return conditionValue; }, getExtraParams: function(store, op, condition) { var temp = {}; for(let x = 0; x < condition.length; x++) { let c = condition[x]; if(c.field == 'keyword') { temp.keyword = c.value; }else if(c.field == 'date') { temp.fromDate = new Date(c.value.split(',')[0]).getTime(); temp.endDate = new Date(c.value.split(',')[1]).getTime(); }else if(c.field == 'quoted') { temp.quoted = c.value == 'all' ? null : c.value; }else if(c.field == 'closed') { // temp.endDate = c.value == 'all' ? null : ( // c.value == '0' ? // ); } } let obj = { pageNumber: store.exportNumber?store.exportNumber:op._page, pageSize: store.exportPageSize?store.exportPageSize:store.pageSize }; for(let k in temp) { if(!!temp[k]) { obj[k] = temp[k]; } } return obj; }, });