FormController.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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(res) {
  48. console.error(res);
  49. saas.util.BaseUtil.showErrorToast('启用失败: ' + res.message);
  50. });
  51. },
  52. unAudit: function() {
  53. var me = this,
  54. form = this.getView(),
  55. viewModel = me.getViewModel();
  56. saas.util.BaseUtil.request({
  57. url: form._closeUrl+'/'+viewModel.data.id,
  58. params: '',
  59. method: 'POST',
  60. })
  61. .then(function(localJson) {
  62. if(localJson.success){
  63. form.initId = localJson.data.id;
  64. saas.util.FormUtil.loadData(form);
  65. viewModel.set('base.editable', false);
  66. saas.util.BaseUtil.showSuccessToast('禁用成功');
  67. }
  68. })
  69. .catch(function(res) {
  70. saas.util.BaseUtil.showErrorToast('禁用失败: ' + res.message);
  71. });
  72. }
  73. });