1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- Ext.define('saas.view.help.DocProjectListController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.help-docproject-list',
- /**
- * 新增
- */
- handleAdd: function () {
- var me = this, vm = me.getViewModel(), store = vm.getStore('list');
- Ext.create({
- xtype: 'help-docproject-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: 'help-docproject-win',
- modal: true,
- autoShow: true,
- onConfirm: function (data) {
- me.save(data).then(res => {
- panel.close();
- store.reload();
- });
- }
- });
- panel.loadData(record.data);
- },
- save: function (data) {
- return Ext.Ajax.payload({
- url: '/api/help/project/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/help/project/delete/' + id
- }).then(function (res) {
- if (res.success) {
- saas.util.BaseUtil.showSuccessToast('删除成功');
- return res;
- }
- }).catch(function (e) {
- saas.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
- });
- },
- onItemDblClick: function (gridview, record) {
- var addXtype = 'help-docitem-panel', id = record.get('id'), name = record.get('name');
- saas.util.BaseUtil.openTab(addXtype, name, addXtype + '-' + id, {
- initId: id
- });
- }
- });
|