ListController.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. Ext.define('school.view.interaction.mailbox.ListController', {
  2. extend: 'school.view.core.base.BasePanelController',
  3. alias: 'controller.interaction-mailbox-list',
  4. onActionClick: function(tableView, td, row, col, e, record, tr) {
  5. let me = this;
  6. me.onReply(record.data);
  7. // let targetCls = event.target.classList;
  8. // if(targetCls.contains('fa-pencil')) {
  9. // me.modifyClick(record.data);
  10. // }else if(targetCls.contains('fa-trash-o')) {
  11. // me.onDeleteClick(record.data.subject_id);
  12. // }
  13. },
  14. onReply: function (data) {
  15. let me = this,
  16. tab = school.util.BaseUtil.getCurrentTab(),
  17. view = me.getView(),
  18. win = Ext.getCmp('reply-win');
  19. if (!win) {
  20. win = Ext.create('Ext.window.Window', {
  21. title: '回复',
  22. width: tab.getBox().width * 0.8,
  23. height: tab.getBox().height * 0.8,
  24. id: 'reply-win',
  25. constrain: true,
  26. modal: true,
  27. bodyPadding: 10,
  28. layout: 'fit',
  29. scrollable: true,
  30. items: [{
  31. xtype: 'form',
  32. layout: 'column',
  33. defaults: {
  34. margin: '0 0 10 0',
  35. columnWidth: 1
  36. },
  37. items: [{
  38. xtype: 'hidden',
  39. name: 'id',
  40. }, {
  41. xtype: 'textareafield',
  42. name: 'content',
  43. fieldLabel: '内容',
  44. readOnly: true,
  45. }, {
  46. xtype: 'textareafield',
  47. name: 'text',
  48. fieldLabel: '回复',
  49. allowBlank: false,
  50. maxLength: 500
  51. }],
  52. buttonAlign: 'center',
  53. buttons: [{
  54. text: '确定',
  55. formBind: true,
  56. handler: function () {
  57. let form = this.up('form');
  58. let id = form.getValues().id;
  59. let text = form.getValues().text;
  60. let url, params, headers;
  61. params = {
  62. id: id,
  63. msg: text
  64. };
  65. headers = {
  66. "Content-Type": 'application/x-www-form-urlencoded; charset=UTF-8'
  67. }
  68. view.setLoading(true);
  69. school.util.BaseUtil.request({
  70. // url: 'http://10.1.80.47:9520/api/school/principal/reply',
  71. url: '/api/school/principal/reply',
  72. method: 'POST',
  73. params: params,
  74. headers: headers
  75. }).then(function (res) {
  76. view.setLoading(false);
  77. win.close();
  78. school.util.BaseUtil.showSuccessToast('添加成功');
  79. view.refresh();
  80. }).catch(function (e) {
  81. view.setLoading(false);
  82. school.util.BaseUtil.showErrorToast('添加失败: ' + e.message);
  83. });
  84. }
  85. }]
  86. }]
  87. });
  88. tab.add(win);
  89. win.setTitle(data.mailbox_title);
  90. win.down('form').getForm().findField('id').setValue(data.mailbox_id);
  91. win.down('form').getForm().findField('content').setValue(data.mailbox_context);
  92. win.down('form').getForm().findField('text').setValue(data.mb_reply);
  93. }
  94. win.show();
  95. },
  96. onIgnoreClick: function() {
  97. let me = this,
  98. view = me.getView();
  99. let grid = view.down('grid'),
  100. selectedRecords = grid.getSelection();
  101. let data, flag = false;
  102. data = selectedRecords.map(function(r) {
  103. if(r.get('mb_ignore') == 1) {
  104. flag = true;
  105. return;
  106. }
  107. return {
  108. id: r.get('mailbox_id')
  109. };
  110. });
  111. if(data.length == 0) {
  112. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  113. return;
  114. }
  115. if(flag) {
  116. school.util.BaseUtil.showErrorToast('不可包含已忽略记录');
  117. return;
  118. }
  119. grid.setLoading(true);
  120. school.util.BaseUtil.request({
  121. // url: 'http://10.1.80.47:9520/api/school/principal/batchIgnore',
  122. url: '/api/school/principal/batchIgnore',
  123. method: 'POST',
  124. params: JSON.stringify({
  125. baseDTOs: data
  126. })
  127. }).then(function(res) {
  128. grid.setLoading(false);
  129. school.util.BaseUtil.showSuccessToast('已忽略' + data.length + '条记录');
  130. grid.store.loadPage(grid.store.currentPage);
  131. }).catch(function(e) {
  132. grid.setLoading(false);
  133. school.util.BaseUtil.showErrorToast('添加忽略失败: ' + e.message);
  134. });
  135. },
  136. onUnIgnoreClick: function() {
  137. let me = this,
  138. view = me.getView();
  139. let grid = view.down('grid'),
  140. selectedRecords = grid.getSelection();
  141. let data, flag = false;
  142. data = selectedRecords.map(function(r) {
  143. if(r.get('mb_ignore') != 1) {
  144. flag = true;
  145. return;
  146. }
  147. return {
  148. id: r.get('mailbox_id')
  149. };
  150. });
  151. if(data.length == 0) {
  152. school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
  153. return;
  154. }
  155. if(!!flag) {
  156. school.util.BaseUtil.showErrorToast('不可包含未忽略记录');
  157. return;
  158. }
  159. grid.setLoading(true);
  160. school.util.BaseUtil.request({
  161. // url: 'http://10.1.80.47:9520/api/school/principal/batchUnIgnore',
  162. url: '/api/school/principal/batchUnIgnore',
  163. method: 'POST',
  164. params: JSON.stringify({
  165. baseDTOs: data
  166. })
  167. }).then(function(res) {
  168. grid.setLoading(false);
  169. school.util.BaseUtil.showSuccessToast('取消忽略' + data.length + '条记录');
  170. grid.store.loadPage(grid.store.currentPage);
  171. }).catch(function(e) {
  172. grid.setLoading(false);
  173. school.util.BaseUtil.showErrorToast('添加忽略失败: ' + e.message);
  174. });
  175. },
  176. });