FormPanelController.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. //赋值
  11. dbfinds:[{
  12. from: 'id', to: 'rb_custid',ignore:true
  13. }, {
  14. from:'cu_code', to:'rb_custcode'
  15. },{
  16. from:'cu_name', to:'rb_custname'
  17. },{
  18. from:'cu_leftamount', to:'cu_leftamount'
  19. }],
  20. }) ;
  21. }
  22. },
  23. 'dbfindtrigger[name=rd_bankname]':{
  24. beforerender:function(f){
  25. Ext.apply(f,{
  26. //赋值
  27. dbfinds:[{
  28. from: 'id', to: 'rd_bankid',ignore:true
  29. }, {
  30. from:'bk_bankcode', to:'rd_bankcode'
  31. },{
  32. from:'bk_bankname', to:'rd_bankname'
  33. }],
  34. }) ;
  35. }
  36. },
  37. 'multidbfindtrigger[name=rbd_slcode]': {
  38. beforerender: function (f) {
  39. Ext.apply(f, {
  40. dataUrl: '/api/money/subledger/list',
  41. addTitle: '源单单据',
  42. dbfinds: [{
  43. from: 'id',
  44. to: 'rbd_slid',ignore:true
  45. }, {
  46. from: 'sl_code',
  47. to: 'rbd_slcode'
  48. },{
  49. from: 'sl_orderamount',
  50. to: 'rbd_amount'
  51. },{
  52. from: 'sl_yamount',
  53. to: 'sl_yamount'
  54. },{
  55. from: 'sl_namount',
  56. to: 'sl_namount'
  57. },{
  58. from:'sl_date',
  59. to:'rbd_sldate'
  60. },{
  61. from:'sl_kind',
  62. to:'rbd_slkind'
  63. },{
  64. from: 'sl_namount',
  65. to: 'rbd_nowbalance'
  66. }],
  67. dbtpls: [{
  68. field: 'sl_code',
  69. width: 100
  70. }],
  71. defaultCondition: "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0",
  72. dbSearchFields:[{
  73. emptyText:'输入源单编号',
  74. xtype : "textfield",
  75. name : "search",
  76. getCondition: function(v) {
  77. return "(upper(sl_code) like '%"+v.toUpperCase()+"%')";
  78. },
  79. allowBlank : true,
  80. columnWidth : 0.25
  81. }],
  82. dbColumns:[{
  83. "text": "源单id",
  84. "hidden": true,
  85. "dataIndex": "id",
  86. "width": 100,
  87. "xtype": "numbercolumn"
  88. },{
  89. "text": "源单编号",
  90. "dataIndex": "sl_code",
  91. "width": 180
  92. }, {
  93. "text": "源单类型",
  94. "flex": 1,
  95. "dataIndex": "sl_kind",
  96. "width": 100
  97. },{
  98. "text": "单据金额",
  99. "flex": 1,
  100. "dataIndex": "sl_orderamount",
  101. "width": 100,
  102. xtype: 'numbercolumn',
  103. align:'end'
  104. }, {
  105. "text": "已核销金额",
  106. "flex": 0,
  107. "dataIndex": "sl_yamount",
  108. "width": 200,
  109. "items": null,
  110. xtype: 'numbercolumn',
  111. align:'end'
  112. }, {
  113. "text": "未核销金额",
  114. "flex": 1,
  115. "dataIndex": "sl_namount",
  116. "width": 100,
  117. xtype: 'numbercolumn',
  118. align:'end'
  119. },{
  120. "text": "单据日期",
  121. "flex": 1,
  122. "dataIndex": "sl_date",
  123. "width": 120,
  124. xtype: 'datecolumn',
  125. align:'end'
  126. }]
  127. });
  128. }
  129. },
  130. });
  131. },
  132. addCombo:function(){
  133. var combo=this.ownerCmp;
  134. Ext.create('Ext.window.Window',{
  135. layout:'vbox',
  136. bodyPadding: 15,
  137. width:500,
  138. items:[{
  139. fieldLabel:'实际值',
  140. xtype:'textfield'
  141. },{
  142. fieldLabel:'显示值',
  143. xtype:'textfield'
  144. }],
  145. buttons:[{
  146. text:'确认',
  147. handler:function(b){
  148. combo.setValue('ok');
  149. b.up('window').close();
  150. }
  151. }],
  152. renderTo:this.ownerCmp.ownerCt.getEl()
  153. }).show();
  154. },
  155. turnIn: function() {
  156. var me = this,
  157. form = me.getView(),
  158. id = form.getForm().findField(form._idField);
  159. saas.util.BaseUtil.request({
  160. url: form._turnInUrl+id.value,
  161. method: 'GET',
  162. })
  163. .then(function(localJson) {
  164. if(localJson.success){
  165. saas.util.BaseUtil.showToast('转单成功');
  166. }
  167. })
  168. .catch(function(res) {
  169. console.error(res);
  170. saas.util.BaseUtil.showToast('转单失败: ' + res.message);
  171. });
  172. },
  173. onSave: function() {
  174. var me = this,
  175. form = me.getView(),
  176. viewModel = me.getViewModel(),
  177. store1 = viewModel.get('detail0').detailStore,
  178. store2 = viewModel.get('detail1').detailStore;
  179. var valid = form.isValid();
  180. if(!valid) {
  181. saas.util.BaseUtil.showToast(form.invalidText);
  182. return false;
  183. }
  184. var sum_rd_amount = store1.sum('rd_amount'); // 付款金额合计
  185. var rb_discounts = viewModel.get('rb_discounts'); // 折扣金额
  186. var sum_rbd_nowbalance = store2.sum('rbd_nowbalance'); // 本次核销金额合计
  187. var flag = sum_rd_amount + rb_discounts - sum_rbd_nowbalance;
  188. viewModel.set("rb_preamount",flag);
  189. if(flag != 0) {
  190. var t = flag > 0 ? '大' : '小';
  191. saas.util.BaseUtil.showConfirm('提示', '收款金额' + t + '于本次折扣后核销金额,是否仍要保存?')
  192. .then(function(y) {
  193. if(y == 'yes') {
  194. me.save();
  195. }
  196. });
  197. }else {
  198. me.save();
  199. }
  200. },
  201. custnamechange:function(dbfindtrigger){
  202. var me = this,
  203. viewModel = me.getViewModel();
  204. var c = viewModel.get('rb_custname_change');
  205. if(c!=null&&c!=''){
  206. c = ' and sl_custid='+c;
  207. }else{
  208. c ='';
  209. }
  210. dbfindtrigger.defaultCondition = "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0" + c;
  211. }
  212. });