| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- Ext.define('school.view.interaction.mailbox.ListController', {
- extend: 'school.view.core.base.BasePanelController',
- alias: 'controller.interaction-mailbox-list',
- onActionClick: function(tableView, td, row, col, e, record, tr) {
- let me = this;
- me.onReply(record.data);
- // let targetCls = event.target.classList;
- // if(targetCls.contains('fa-pencil')) {
- // me.modifyClick(record.data);
- // }else if(targetCls.contains('fa-trash-o')) {
- // me.onDeleteClick(record.data.subject_id);
- // }
- },
- onReply: function (data) {
- let me = this,
- tab = school.util.BaseUtil.getCurrentTab(),
- view = me.getView(),
- win = Ext.getCmp('reply-win');
- if (!win) {
- win = Ext.create('Ext.window.Window', {
- title: '回复',
- width: tab.getBox().width * 0.8,
- height: tab.getBox().height * 0.8,
- id: 'reply-win',
- constrain: true,
- modal: true,
- bodyPadding: 10,
- layout: 'fit',
- scrollable: true,
- items: [{
- xtype: 'form',
- layout: 'column',
- defaults: {
- margin: '0 0 10 0',
- columnWidth: 1
- },
- items: [{
- xtype: 'hidden',
- name: 'id',
- }, {
- xtype: 'textareafield',
- name: 'content',
- fieldLabel: '内容',
- readOnly: true,
- }, {
- xtype: 'textareafield',
- name: 'text',
- fieldLabel: '回复',
- allowBlank: false,
- maxLength: 500
- }],
- buttonAlign: 'center',
- buttons: [{
- text: '确定',
- formBind: true,
- handler: function () {
- let form = this.up('form');
- let id = form.getValues().id;
- let text = form.getValues().text;
- let url, params, headers;
-
- params = {
- id: id,
- msg: text
- };
- headers = {
- "Content-Type": 'application/x-www-form-urlencoded; charset=UTF-8'
- }
- view.setLoading(true);
- school.util.BaseUtil.request({
- // url: 'http://10.1.80.47:9520/api/school/principal/reply',
- url: '/api/school/principal/reply',
- method: 'POST',
- params: params,
- headers: headers
- }).then(function (res) {
- view.setLoading(false);
- win.close();
- school.util.BaseUtil.showSuccessToast('添加成功');
- view.refresh();
- }).catch(function (e) {
- view.setLoading(false);
- school.util.BaseUtil.showErrorToast('添加失败: ' + e.message);
- });
- }
- }]
- }]
- });
- tab.add(win);
- win.setTitle(data.mailbox_title);
- win.down('form').getForm().findField('id').setValue(data.mailbox_id);
- win.down('form').getForm().findField('content').setValue(data.mailbox_context);
- win.down('form').getForm().findField('text').setValue(data.mb_reply);
- }
- win.show();
- },
- onIgnoreClick: function() {
- let me = this,
- view = me.getView();
- let grid = view.down('grid'),
- selectedRecords = grid.getSelection();
- let data, flag = false;
- data = selectedRecords.map(function(r) {
- if(r.get('mb_ignore') == 1) {
- flag = true;
- return;
- }
- return {
- id: r.get('mailbox_id')
- };
- });
- if(data.length == 0) {
- school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
- return;
- }
- if(flag) {
- school.util.BaseUtil.showErrorToast('不可包含已忽略记录');
- return;
- }
- grid.setLoading(true);
- school.util.BaseUtil.request({
- // url: 'http://10.1.80.47:9520/api/school/principal/batchIgnore',
- url: '/api/school/principal/batchIgnore',
- method: 'POST',
- params: JSON.stringify({
- baseDTOs: data
- })
- }).then(function(res) {
- grid.setLoading(false);
- school.util.BaseUtil.showSuccessToast('已忽略' + data.length + '条记录');
- grid.store.loadPage(grid.store.currentPage);
- }).catch(function(e) {
- grid.setLoading(false);
- school.util.BaseUtil.showErrorToast('添加忽略失败: ' + e.message);
- });
- },
- onUnIgnoreClick: function() {
- let me = this,
- view = me.getView();
- let grid = view.down('grid'),
- selectedRecords = grid.getSelection();
- let data, flag = false;
- data = selectedRecords.map(function(r) {
- if(r.get('mb_ignore') != 1) {
- flag = true;
- return;
- }
- return {
- id: r.get('mailbox_id')
- };
- });
- if(data.length == 0) {
- school.util.BaseUtil.showErrorToast('请先勾选需要删除的记录');
- return;
- }
- if(!!flag) {
- school.util.BaseUtil.showErrorToast('不可包含未忽略记录');
- return;
- }
- grid.setLoading(true);
- school.util.BaseUtil.request({
- // url: 'http://10.1.80.47:9520/api/school/principal/batchUnIgnore',
- url: '/api/school/principal/batchUnIgnore',
- method: 'POST',
- params: JSON.stringify({
- baseDTOs: data
- })
- }).then(function(res) {
- grid.setLoading(false);
- school.util.BaseUtil.showSuccessToast('取消忽略' + data.length + '条记录');
- grid.store.loadPage(grid.store.currentPage);
- }).catch(function(e) {
- grid.setLoading(false);
- school.util.BaseUtil.showErrorToast('添加忽略失败: ' + e.message);
- });
- },
- });
|