|
|
@@ -4,5 +4,73 @@ Ext.define('school.view.interaction.timetable.ListController', {
|
|
|
|
|
|
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);
|
|
|
+ });
|
|
|
}
|
|
|
});
|