SchoolNoticeController.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Ext.define('school.view.interaction.notice.SchoolNoticeController', {
  2. extend: 'school.view.core.form.FormPanelController',
  3. alias: 'controller.interaction-notice-schoolnotice',
  4. getMySaveParams: function(params) {
  5. return params.main;
  6. },
  7. onAfterSave: function(localJson) {
  8. var form = this.getView();
  9. var id = localJson.data.id;
  10. var code = localJson.data.code;
  11. form.initId = id;
  12. school.util.FormUtil.loadData(form).then(function(data) {
  13. var newId = form.xtype + '-' + id;
  14. var newTitle = form._title + '(' + data.main.notify_title + ')';
  15. school.util.BaseUtil.refreshTabTitle(newId, newTitle);
  16. });
  17. },
  18. onPublish: function() {
  19. let me = this,
  20. view = me.getView(),
  21. viewModel = me.getViewModel(),
  22. id = viewModel.data.notify_id;
  23. view.setLoading(true);
  24. school.util.BaseUtil.request({
  25. // url: 'http://10.1.80.180:9520/api/school/notice/publish/' + id,
  26. url: '/api/school/notice/publish/' + id,
  27. method: 'POST'
  28. })
  29. .then(function() {
  30. view.setLoading(false);
  31. school.util.BaseUtil.showSuccessToast('发布成功');
  32. viewModel.set('notify_status', 1);
  33. me.refresh();
  34. })
  35. .catch(function(e) {
  36. view.setLoading(false);
  37. school.util.BaseUtil.showErrorToast('发布失败: ' + e.message);
  38. });
  39. },
  40. onNotifyClassComboReady: function(classCombo) {
  41. var classStore = Ext.StoreMgr.get('store_class');
  42. if(classStore.getCount() === 0 || classCombo.store.getCount() === 2) {
  43. classStore.load(function(records) {
  44. var classData = records.map(function(record) {
  45. var name = record.get('clazz_grade') + ' | '+ record.get('clazz_name');
  46. var value = record.get('clazz_id');
  47. return {name: name, value: value};
  48. });
  49. classCombo.store.insert(2, classData);
  50. classCombo.setValue(classCombo.value); // 重新触发一次setValue以正确显示值
  51. });
  52. }
  53. },
  54. onNotifyClassComboExpand: function(combo) {
  55. var classStore = Ext.StoreMgr.get('store_class');
  56. if(classStore.getCount() === 0 || combo.store.getCount() === 2) {
  57. combo.setLoading(true);
  58. classStore.load(function(records) {
  59. var classData = records.map(function(record) {
  60. var name = record.get('clazz_grade') + ' | '+ record.get('clazz_name');
  61. var value = record.get('clazz_id');
  62. return {name: name, value: value};
  63. });
  64. combo.store.insert(2, classData);
  65. classCombo.setValue(classCombo.value);
  66. combo.setLoading(false);
  67. });
  68. }
  69. }
  70. });