FormController.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. Ext.define('saas.view.document.customer.FormController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.document-customer-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. 'employeeDbfindTrigger[name=cu_sellername]':{
  8. beforerender:function(f){
  9. Ext.apply(f,{
  10. dbfinds:[{
  11. from:'id',to:'cu_sellerid',ignore:true
  12. },{
  13. from:'em_code',to:'cu_sellercode'
  14. },{
  15. from:'em_name',to:'cu_sellername'
  16. }],
  17. }) ;
  18. }
  19. }
  20. });
  21. },
  22. auditBtnClick: function() {
  23. var me = this,
  24. form = me.getView(),
  25. statusCodeField = form._statusCodeField,
  26. viewModel = me.getViewModel(),
  27. status = viewModel.data[statusCodeField];
  28. status == 'ENABLE' ? me.unAudit() : me.audit();
  29. },
  30. audit: function(){
  31. var me = this,
  32. form = this.getView(),
  33. viewModel = me.getViewModel();
  34. saas.util.BaseUtil.request({
  35. url: form._openUrl+'/'+viewModel.data.id,
  36. params: '',
  37. method: 'POST',
  38. })
  39. .then(function(localJson) {
  40. if(localJson.success){
  41. saas.util.BaseUtil.showSuccessToast('启用成功');
  42. form.initId = localJson.data.id;
  43. saas.util.FormUtil.loadData(form);
  44. viewModel.set('base.editable', false);
  45. }
  46. })
  47. .catch(function(e) {
  48. saas.util.BaseUtil.showErrorToast('启用失败: ' + e.message);
  49. });
  50. },
  51. unAudit: function() {
  52. var me = this,
  53. form = this.getView(),
  54. viewModel = me.getViewModel();
  55. saas.util.BaseUtil.request({
  56. url: form._closeUrl+'/'+viewModel.data.id,
  57. params: '',
  58. method: 'POST',
  59. })
  60. .then(function(localJson) {
  61. if(localJson.success){
  62. form.initId = localJson.data.id;
  63. saas.util.FormUtil.loadData(form);
  64. viewModel.set('base.editable', false);
  65. saas.util.BaseUtil.showSuccessToast('禁用成功');
  66. }
  67. })
  68. .catch(function(e) {
  69. saas.util.BaseUtil.showErrorToast('禁用失败: ' + e.message);
  70. });
  71. }
  72. });