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); }); }, });