123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- Ext.define('saas.view.message.NoticeListController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.sys-notice-list',
- /**
- * 新增
- */
- handleAdd: function () {
- var me = this, vm = me.getViewModel(), store = vm.getStore('list');
- Ext.create({
- xtype: 'sys-notice-win',
- modal: true,
- autoShow: true,
- onConfirm: function (data, panel) {
- me.save(data).then(res => {
- panel.close();
- store.reload();
- });
- }
- });
- },
- /**
- * 行编辑按钮
- * @param {*} view
- * @param {*} rowIndex
- */
- handleEdit: function (view, rowIndex) {
- var me = this, vm = me.getViewModel(),
- store = vm.getStore('list'),
- record = store.getAt(rowIndex);
- var panel = Ext.create({
- xtype: 'sys-notice-win',
- modal: true,
- autoShow: true,
- onConfirm: function (data) {
- me.save(data).then(res => {
- panel.close();
- store.reload();
- });
- }
- });
- panel.loadData(record.getPersistData());
- },
- save: function (data) {
- return Ext.Ajax.payload({
- url: '/api/operation/sys_notice/save',
- jsonData: data
- }).then(function (res) {
- if (res.success) {
- saas.util.BaseUtil.showSuccessToast('保存成功');
- return res;
- }
- }).catch(function (e) {
- saas.util.BaseUtil.showErrorToast('保存失败: ' + e.message);
- });
- },
- /**
- * 行删除按钮
- * @param {*} view
- * @param {*} rowIndex
- */
- handleDelete: function (view, rowIndex) {
- var me = this;
- saas.util.BaseUtil.showConfirm('提示', '删除的公告将不能恢复,请确认是否删除?')
- .then(function (y) {
- if (y == 'yes') {
- var store = view.getStore(), record = store.getAt(rowIndex);
- me.delete(record.get('id')).then(res => {
- store.remove(record);
- });
- }
- });
- },
- delete: function (id) {
- return Ext.Ajax.payload({
- url: '/api/operation/sys_notice/delete/' + id
- }).then(function (res) {
- if (res.success) {
- saas.util.BaseUtil.showSuccessToast('删除成功');
- return res;
- }
- }).catch(function (e) {
- saas.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
- });
- },
- /**
- * 上线
- * @param {*} column
- * @param {*} recordIndex
- * @param {*} checked
- * @param {*} record
- */
- onCheckChange: function (column, recordIndex, checked, record) {
- var operation = checked ? '上线' : '下线',
- grid = column.getView().grid,
- id = record.get('id');
- Ext.Ajax.post({
- url: '/api/operation/sys_notice/' + (checked ? 'online' : 'offline') + '/' + id
- }).then(function (res) {
- if (res.success) {
- saas.util.BaseUtil.showSuccessToast(operation + '成功');
- grid.getStore().reload();
- }
- }).catch(function (e) {
- saas.util.BaseUtil.showErrorToast(operation + '失败: ' + e.message);
- });
- },
- });
|