FormController.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. 'currencyDbfindTrigger[name=cu_currency]':{
  21. beforerender:function(f){
  22. Ext.apply(f,{
  23. dbfinds:[{
  24. from:'cr_name',to:'cu_currency'
  25. }],
  26. }) ;
  27. }
  28. }
  29. });
  30. },
  31. auditBtnClick: function() {
  32. var me = this,
  33. form = me.getView(),
  34. statusCodeField = form._statusCodeField,
  35. viewModel = me.getViewModel(),
  36. status = viewModel.data[statusCodeField];
  37. status == 'ENABLE' ? me.unAudit() : me.audit();
  38. },
  39. audit: function(){
  40. var me = this,
  41. form = this.getView(),
  42. viewModel = me.getViewModel();
  43. saas.util.BaseUtil.request({
  44. url: form._openUrl+'/'+viewModel.data.id,
  45. params: '',
  46. method: 'POST',
  47. })
  48. .then(function(localJson) {
  49. if(localJson.success){
  50. saas.util.BaseUtil.showSuccessToast('启用成功');
  51. form.initId = localJson.data.id;
  52. saas.util.FormUtil.loadData(form);
  53. viewModel.set('base.editable', false);
  54. }
  55. })
  56. .catch(function(e) {
  57. saas.util.BaseUtil.showErrorToast('启用失败: ' + e.message);
  58. });
  59. },
  60. unAudit: function() {
  61. var me = this,
  62. form = this.getView(),
  63. viewModel = me.getViewModel();
  64. saas.util.BaseUtil.request({
  65. url: form._closeUrl+'/'+viewModel.data.id,
  66. params: '',
  67. method: 'POST',
  68. })
  69. .then(function(localJson) {
  70. if(localJson.success){
  71. form.initId = localJson.data.id;
  72. saas.util.FormUtil.loadData(form);
  73. viewModel.set('base.editable', false);
  74. saas.util.BaseUtil.showSuccessToast('禁用成功');
  75. }
  76. })
  77. .catch(function(e) {
  78. saas.util.BaseUtil.showErrorToast('禁用失败: ' + e.message);
  79. });
  80. }
  81. });