FormPanelController.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. Ext.define('saas.view.money.recBalance.FormPanelController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.money-recbalance-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. 'dbfindtrigger[name=rb_custname]':{
  8. beforerender:function(f){
  9. Ext.apply(f,{
  10. dbColumns: [{
  11. conditionCode: 'id',
  12. text: "客户ID",
  13. dataIndex: "id",
  14. hidden:true,
  15. xtype: "",
  16. }, {
  17. conditionCode: 'cu_code',
  18. text: "客户编号",
  19. dataIndex: "cu_code",
  20. width: 150,
  21. xtype: "",
  22. }, {
  23. conditionCode: 'cu_name',
  24. text: "客户名称",
  25. dataIndex: "cu_name",
  26. width: 200,
  27. xtype: "",
  28. }, {
  29. conditionCode: 'cu_type',
  30. text: "客户类型",
  31. dataIndex: "cu_type",
  32. width: 110,
  33. xtype: "",
  34. }, {
  35. text: "业务员编号",
  36. dataIndex: "cu_sellercode",
  37. width:110
  38. }, {
  39. text: "业务员",
  40. dataIndex: "cu_sellername",
  41. width:110
  42. }, {
  43. text: "税率",
  44. dataIndex: "cu_taxrate",
  45. xtype: 'numbercolumn',
  46. width:80,
  47. renderer: function (v) {
  48. return Ext.util.Format.number(v, '0');
  49. }
  50. },{
  51. text: "应收款余额",
  52. dataIndex: "cu_leftamount",
  53. width:110,
  54. xtype: 'numbercolumn',
  55. renderer : function(v) {
  56. if(!v) {
  57. return 0;
  58. }
  59. var arr = (v + '.').split('.');
  60. var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
  61. var format = '0.' + xr.join();
  62. return Ext.util.Format.number(v, format);
  63. }
  64. }, {
  65. text: "结算天数",
  66. dataIndex: "cu_promisedays",
  67. width:110,
  68. xtype: 'numbercolumn',
  69. renderer: function (v) {
  70. return Ext.util.Format.number(v, '0');
  71. }
  72. }, {
  73. text: "额度",
  74. dataIndex: "cu_credit",
  75. width:110,
  76. xtype: 'numbercolumn',
  77. }, {
  78. text: "客户地址",
  79. dataIndex: "ca_address",
  80. width: 250
  81. }],
  82. //赋值
  83. dbfinds:[{
  84. from: 'id', to: 'rb_custid',ignore:true
  85. }, {
  86. from:'cu_code', to:'rb_custcode'
  87. },{
  88. from:'cu_name', to:'rb_custname'
  89. },{
  90. from:'cu_leftamount', to:'cu_leftamount'
  91. }],
  92. }) ;
  93. }
  94. },
  95. 'dbfindtrigger[name=rd_bankname]':{
  96. beforerender:function(f){
  97. Ext.apply(f,{
  98. //赋值
  99. dbfinds:[{
  100. from: 'id', to: 'rd_bankid',ignore:true
  101. }, {
  102. from:'bk_bankcode', to:'rd_bankcode'
  103. },{
  104. from:'bk_bankname', to:'rd_bankname'
  105. }],
  106. }) ;
  107. }
  108. },
  109. 'oriOrderMutiDbfindTrigger[name=rbd_slcode]': {
  110. beforerender: function (f) {
  111. Ext.apply(f, {
  112. dbfinds: [{
  113. from: 'id',
  114. to: 'rbd_slid',ignore:true
  115. }, {
  116. from: 'sl_code',
  117. to: 'rbd_slcode'
  118. },{
  119. from: 'sl_orderamount',
  120. to: 'rbd_amount'
  121. },{
  122. from: 'sl_yamount',
  123. to: 'sl_yamount'
  124. },{
  125. from: 'sl_namount',
  126. to: 'sl_namount'
  127. },{
  128. from:'sl_date',
  129. to:'rbd_sldate'
  130. },{
  131. from:'sl_kind',
  132. to:'rbd_slkind'
  133. },{
  134. from: 'sl_namount',
  135. to: 'rbd_nowbalance'
  136. }],
  137. defaultCondition: "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0"
  138. });
  139. }
  140. },
  141. });
  142. },
  143. addCombo:function(){
  144. var combo=this.ownerCmp;
  145. Ext.create('Ext.window.Window',{
  146. layout:'vbox',
  147. bodyPadding: 15,
  148. width:500,
  149. items:[{
  150. fieldLabel:'实际值',
  151. xtype:'textfield'
  152. },{
  153. fieldLabel:'显示值',
  154. xtype:'textfield'
  155. }],
  156. buttons:[{
  157. text:'确认',
  158. handler:function(b){
  159. combo.setValue('ok');
  160. b.up('window').close();
  161. }
  162. }],
  163. renderTo:this.ownerCmp.ownerCt.getEl()
  164. }).show();
  165. },
  166. turnIn: function() {
  167. var me = this,
  168. form = me.getView(),
  169. id = form.getForm().findField(form._idField);
  170. saas.util.BaseUtil.request({
  171. url: form._turnInUrl+id.value,
  172. method: 'GET',
  173. })
  174. .then(function(localJson) {
  175. if(localJson.success){
  176. saas.util.BaseUtil.showSuccessToast('转单成功');
  177. }
  178. })
  179. .catch(function(res) {
  180. console.error(res);
  181. saas.util.BaseUtil.showErrorToast('转单失败: ' + res.message);
  182. });
  183. },
  184. onSave: function() {
  185. var me = this,
  186. form = me.getView(),
  187. viewModel = me.getViewModel(),
  188. store1 = viewModel.get('detail0').detailStore,
  189. store2 = viewModel.get('detail1').detailStore;
  190. var valid = form.isValid();
  191. if(!valid) {
  192. saas.util.BaseUtil.showErrorToast(form.invalidText);
  193. return false;
  194. }
  195. var sum_rd_amount = store1.sum('rd_amount'); // 付款金额合计
  196. var rb_discounts = viewModel.get('rb_discounts'); // 折扣金额
  197. var sum_rbd_nowbalance = store2.sum('rbd_nowbalance'); // 本次核销金额合计
  198. var flag = sum_rd_amount + rb_discounts - sum_rbd_nowbalance;
  199. viewModel.set("rb_preamount",flag);
  200. if(flag != 0) {
  201. var t = flag > 0 ? '大' : '小';
  202. saas.util.BaseUtil.showConfirm('提示', '收款金额' + t + '于本次核销金额,是否仍要保存?')
  203. .then(function(y) {
  204. if(y == 'yes') {
  205. me.save();
  206. }
  207. });
  208. }else {
  209. me.save();
  210. }
  211. },
  212. custnamechange:function(dbfindtrigger){
  213. var me = this,
  214. viewModel = me.getViewModel();
  215. var c = viewModel.get('rb_custname_change');
  216. if(c!=null&&c!=''){
  217. c = ' and sl_custid='+c;
  218. }else{
  219. c ='';
  220. }
  221. dbfindtrigger.defaultCondition = "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0" + c;
  222. },
  223. myInitCopyData: function(formData) {
  224. var main = formData.main;
  225. main.rb_auditman = '';
  226. main.rb_auditdate = null;
  227. return formData;
  228. }
  229. });