FormController.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Ext.define('saas.view.document.customer.panel.FormController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.customer-panel-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({});
  7. },
  8. auditBtnClick: function() {
  9. var me = this,
  10. form = me.getView(),
  11. statusCodeField = form._statusCodeField,
  12. viewModel = me.getViewModel(),
  13. status = viewModel.data[statusCodeField];
  14. status == 'OPEN' ? me.unAudit() : me.audit();
  15. },
  16. audit: function(){
  17. var me = this,
  18. form = this.getView(),
  19. viewModel = me.getViewModel();
  20. me.BaseUtil.request({
  21. url: form._openUrl+'/'+viewModel.data.id,
  22. params: '',
  23. method: 'POST',
  24. })
  25. .then(function(res) {
  26. var localJson = new Ext.decode(res.responseText);
  27. if(localJson.success){
  28. Ext.Msg.alert('提示','启用成功');
  29. form.initId = localJson.data.id;
  30. form.FormUtil.loadData(form);
  31. viewModel.set('base.editable', false);
  32. }
  33. })
  34. .catch(function() {
  35. Ext.Msg.alert('提示','启用失败');
  36. });
  37. },
  38. unAudit: function() {
  39. var me = this,
  40. form = this.getView(),
  41. viewModel = me.getViewModel();
  42. me.BaseUtil.request({
  43. url: form._closeUrl+'/'+viewModel.data.id,
  44. params: '',
  45. method: 'POST',
  46. })
  47. .then(function(res) {
  48. var localJson = new Ext.decode(res.responseText);
  49. if(localJson.success){
  50. Ext.Msg.alert('提示','禁用成功');
  51. form.initId = localJson.data.id;
  52. form.FormUtil.loadData(form);
  53. viewModel.set('base.editable', false);
  54. }
  55. })
  56. .catch(function() {
  57. Ext.Msg.alert('提示','禁用失败');
  58. });
  59. }
  60. });