| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- Ext.define('school.view.interaction.timetable.ListController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.interaction-timetable-list',
- onAddClick: function() {
- school.util.BaseUtil.openTab('interaction-timetable-detail', '新增课程表', 'interaction-timetable-detail-add');
- },
- selectionchange: function(table, selected, eOpts) {
- let me = this,
- refs = me.getReferences(),
- btn = refs.publish,
- type = btn.type;
- btn.setDisabled(false);
- if(selected.length == 1) {
- btn.setText(selected[0].get('status') == '1' ? '取消发布' : '发布');
- btn.type = (selected[0].get('status') == '1' ? 'republish' : 'publish');
- btn.path = (selected[0].get('status') == '1' ? 'batchRepublish' : 'batchPublish');
- return;
- }else if(selected.length == 0) {
- btn.setText('发布');
- btn.type = 'publish';
- btn.path = 'batchPublish';
- return;
- }else {
- for(let i = 0; i < selected.length; i++) {
- let s = selected[i];
- if((s.get('status') == '1' && type == 'publish') || (s.get('status') == '0' && type == 'republish')) {
- btn.setDisabled(true);
- return;
- }
- }
- }
- },
- onPublishClick: function() {
- let me = this,
- view = me.getView(),
- grid = view.down('grid'),
- selectedRecords = grid.getSelection(),
- refs = me.getReferences(),
- btn = refs.publish,
- path = btn.path,
- 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: 'http://10.1.80.36:9520/api/school/curriculum/batchDelete',
- url: '/api/school/curriculum/' + path,
- method: 'POST',
- params: JSON.stringify({
- baseDTOs: data
- })
- }).then(function (res) {
- grid.setLoading(false);
- school.util.BaseUtil.showSuccessToast('操作成功');
- grid.store.loadPage(grid.store.currentPage);
- grid.getSelectionModel().deselectAll();
- }).catch(function (e) {
- grid.setLoading(false);
- school.util.BaseUtil.showErrorToast('操作失败: ' + e.message);
- });
- }
- });
|