ListController.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Ext.define('school.view.interaction.timetable.ListController', {
  2. extend: 'Ext.app.ViewController',
  3. alias: 'controller.interaction-timetable-list',
  4. onAddClick: function() {
  5. school.util.BaseUtil.openTab('interaction-timetable-detail', '新增课程表', 'interaction-timetable-detail-add');
  6. },
  7. selectionchange: function(table, selected, eOpts) {
  8. let me = this,
  9. refs = me.getReferences(),
  10. btn = refs.publish,
  11. type = btn.type;
  12. btn.setDisabled(false);
  13. if(selected.length == 1) {
  14. btn.setText(selected[0].get('status') == '1' ? '取消发布' : '发布');
  15. btn.type = (selected[0].get('status') == '1' ? 'republish' : 'publish');
  16. btn.path = (selected[0].get('status') == '1' ? 'batchRepublish' : 'batchPublish');
  17. return;
  18. }else if(selected.length == 0) {
  19. btn.setText('发布');
  20. btn.type = 'publish';
  21. btn.path = 'batchPublish';
  22. return;
  23. }else {
  24. for(let i = 0; i < selected.length; i++) {
  25. let s = selected[i];
  26. if((s.get('status') == '1' && type == 'publish') || (s.get('status') == '0' && type == 'republish')) {
  27. btn.setDisabled(true);
  28. return;
  29. }
  30. }
  31. }
  32. },
  33. onPublishClick: function() {
  34. let me = this,
  35. view = me.getView(),
  36. grid = view.down('grid'),
  37. selectedRecords = grid.getSelection(),
  38. refs = me.getReferences(),
  39. btn = refs.publish,
  40. path = btn.path,
  41. data;
  42. data = selectedRecords.map(function (r) {
  43. return {
  44. id: r.get('id')
  45. };
  46. });
  47. if (data.length == 0) {
  48. school.util.BaseUtil.showErrorToast('请先勾选需要发布的记录');
  49. return;
  50. }
  51. grid.setLoading(true);
  52. school.util.BaseUtil.request({
  53. // url: 'http://10.1.80.36:9520/api/school/curriculum/batchDelete',
  54. url: '/api/school/curriculum/' + path,
  55. method: 'POST',
  56. params: JSON.stringify({
  57. baseDTOs: data
  58. })
  59. }).then(function (res) {
  60. grid.setLoading(false);
  61. school.util.BaseUtil.showSuccessToast('操作成功');
  62. grid.store.loadPage(grid.store.currentPage);
  63. grid.getSelectionModel().deselectAll();
  64. }).catch(function (e) {
  65. grid.setLoading(false);
  66. school.util.BaseUtil.showErrorToast('操作失败: ' + e.message);
  67. });
  68. }
  69. });