FormPanelController.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. Ext.define('saas.view.money.payBalance.FormPanelController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.money-paybalance-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. // 供应商名称
  8. 'dbfindtrigger[name=pb_vendname]':{
  9. beforerender: function (f) {
  10. Ext.apply(f, {
  11. dataUrl: '/api/document/vendor/list',
  12. addXtype: 'document-vendor-formpanel',
  13. addTitle: '供应商资料',
  14. dbfinds: [{
  15. from: 've_code',
  16. to: 'pb_vendcode'
  17. }, {
  18. from: 've_name',
  19. to: 'pb_vendname'
  20. },{
  21. from: 've_leftamount',
  22. to: 've_leftamount'
  23. }],
  24. dbtpls: [{
  25. field: 've_code',
  26. width: 100
  27. }, {
  28. field: 've_name',
  29. width: 100
  30. },{
  31. field:'ve_leftamount',
  32. width: 100
  33. }],
  34. defaultCondition: "ve_statuscode='OPEN'",
  35. dbSearchFields:[{
  36. emptyText:'输入供应商编号或名称',
  37. xtype : "textfield",
  38. name : "search",
  39. getCondition: function(v) {
  40. return "(upper(ve_code) like '%"+v.toUpperCase()+"%' or upper(ve_name) like '%"+v.toUpperCase()+"%')";
  41. },
  42. allowBlank : true,
  43. columnWidth : 0.25
  44. }],
  45. dbColumns:[{
  46. "text": "供应商ID",
  47. "hidden": true,
  48. "dataIndex": "id",
  49. "width": 100,
  50. "xtype": "numbercolumn"
  51. },{
  52. "text": "供应商编号",
  53. "dataIndex": "ve_code",
  54. "width": 200
  55. }, {
  56. "text": "供应商名称",
  57. "dataIndex": "ve_name",
  58. "width": 200
  59. }, {
  60. "text": "供应商类型",
  61. "dataIndex": "ve_type",
  62. "width": 180,
  63. "items": null
  64. }, {
  65. "text": "税率",
  66. "dataIndex": "ve_taxrate",
  67. "width": 100,
  68. align:'right'
  69. }, {
  70. "text": "承付天数",
  71. "dataIndex": "ve_promisedays",
  72. "width": 100,
  73. align:'right'
  74. }, {
  75. "text": "纳税人识别号",
  76. "dataIndex": "ve_bankaccount",
  77. "width": 150
  78. }, {
  79. "text": "开户银行",
  80. "dataIndex": "ve_bankaccount",
  81. "width": 100
  82. }, {
  83. "text": "银行账户",
  84. "dataIndex": "ve_bankcode",
  85. "width": 100
  86. }]
  87. });
  88. }
  89. },
  90. 'multidbfindtrigger[name=pbd_slcode]': {
  91. beforerender: function (f) {
  92. Ext.apply(f, {
  93. dataUrl: '/api/money/subledger/list',
  94. addTitle: '源单资料',
  95. dbfinds: [{
  96. from: 'id',
  97. to: 'pbd_slid'
  98. }, {
  99. from: 'sl_code',
  100. to: 'pbd_slcode'
  101. },{
  102. from: 'sl_orderamount',
  103. to: 'pbd_amount'
  104. },{
  105. from: 'sl_yamount',
  106. to: 'pb_havebalance'
  107. },{
  108. from: 'sl_namount',
  109. to: 'pb_pbdamount'
  110. }],
  111. dbtpls: [{
  112. field: 'sl_code',
  113. width: 100
  114. }],
  115. defaultCondition: "sl_vendid<>0 and sl_kind in ('期初余额','采购验收单','采购验退单') and sl_namount<>0",
  116. dbSearchFields:[{
  117. emptyText:'输入源单编号',
  118. xtype : "textfield",
  119. name : "search",
  120. getCondition: function(v) {
  121. return "(upper(sl_code) like '%"+v.toUpperCase()+"%')";
  122. },
  123. allowBlank : true,
  124. columnWidth : 0.25
  125. }],
  126. dbColumns:[{
  127. "text": "源单id",
  128. "hidden": true,
  129. "dataIndex": "id",
  130. "width": 100,
  131. "xtype": "numbercolumn"
  132. },{
  133. "text": "源单编号",
  134. "flex": 1,
  135. "dataIndex": "sl_code",
  136. "width": 100
  137. }, {
  138. "text": "单据金额",
  139. "flex": 1,
  140. "dataIndex": "sl_orderamount",
  141. "width": 100,
  142. align:'right'
  143. }, {
  144. "text": "已核销金额",
  145. "flex": 0,
  146. "dataIndex": "sl_yamount",
  147. "width": 200,
  148. align:'right',
  149. "items": null
  150. }, {
  151. "text": "未核销金额",
  152. "flex": 1,
  153. "dataIndex": "sl_namount",
  154. "width": 100,
  155. align:'right'
  156. }]
  157. });
  158. }
  159. },
  160. 'dbfindtrigger[name=pd_bankname]':{
  161. beforerender: function (f) {
  162. Ext.apply(f, {
  163. dataUrl: '/api/document/bankinformation/list',
  164. addXtype: 'other-bankinformation',
  165. addTitle: '账户资料',
  166. dbfinds: [{
  167. from: 'id',
  168. to: 'pd_bankid'
  169. }, {
  170. from: 'bk_bankcode',
  171. to: 'pd_bankcode'
  172. },{
  173. from: 'bk_bankname',
  174. to: 'pd_bankname'
  175. }],
  176. dbtpls: [{
  177. field: 'bk_bankcode',
  178. width: 100
  179. }, {
  180. field: 'bk_bankname',
  181. width: 100
  182. }],
  183. defaultCondition: "1=1",
  184. dbSearchFields:[{
  185. emptyText:'输入账户名称或者编号',
  186. xtype : "textfield",
  187. name : "search",
  188. getCondition: function(v) {
  189. return "(upper(bk_bankcode) like '%"+v.toUpperCase()+"%' or upper(bk_bankname) like '%"+v.toUpperCase()+"%')";
  190. },
  191. allowBlank : true,
  192. columnWidth : 0.25
  193. }],
  194. dbColumns:[{
  195. "text": "账户id",
  196. "hidden": true,
  197. "dataIndex": "id",
  198. "width": 0,
  199. "xtype": "numbercolumn"
  200. },{
  201. "text": "账户编号",
  202. "flex": 1,
  203. "dataIndex": "bk_bankcode",
  204. "width": 100
  205. }, {
  206. "text": "账户名称",
  207. "flex": 1,
  208. "dataIndex": "bk_bankname",
  209. "width": 100
  210. }]
  211. });
  212. }
  213. }
  214. });
  215. },
  216. addCombo:function(){
  217. var combo=this.ownerCmp;
  218. Ext.create('Ext.window.Window',{
  219. layout:'vbox',
  220. bodyPadding: 15,
  221. width:500,
  222. items:[{
  223. fieldLabel:'实际值',
  224. xtype:'textfield'
  225. },{
  226. fieldLabel:'显示值',
  227. xtype:'textfield'
  228. }],
  229. buttons:[{
  230. text:'确认',
  231. handler:function(b){
  232. combo.setValue('ok');
  233. b.up('window').close();
  234. }
  235. }],
  236. renderTo:this.ownerCmp.ownerCt.getEl()
  237. }).show();
  238. },
  239. turnIn: function() {
  240. var me = this,
  241. form = me.getView(),
  242. id = form.getForm().findField(form._idField);
  243. form.BaseUtil.request({
  244. url: form._turnInUrl+id.value,
  245. method: 'GET',
  246. })
  247. .then(function(localJson) {
  248. if(localJson.success){
  249. showToast('转单成功');
  250. }
  251. })
  252. .catch(function(res) {
  253. console.error(res);
  254. showToast('转单失败: ' + res.message);
  255. });
  256. },
  257. onSave: function() {
  258. var me = this,
  259. form = me.getView(),
  260. viewModel = me.getViewModel(),
  261. store1 = viewModel.get('detail0').detailStore,
  262. store2 = viewModel.get('detail1').detailStore;
  263. var valid = form.isValid();
  264. if(!valid) {
  265. showToast(form.invalidText);
  266. return false;
  267. }
  268. var sum_pd_amount = store1.sum('pd_amount'); // 付款金额合计
  269. var pb_discounts = viewModel.get('pb_discounts'); // 折扣金额
  270. var sum_pbd_nowbalance = store2.sum('pbd_nowbalance'); // 本次核销金额合计
  271. var flag = sum_pd_amount + pb_discounts - sum_pbd_nowbalance;
  272. if(flag != 0) {
  273. var t = flag > 0 ? '大' : '小';
  274. showConfirm('提示', '付款金额' + t + '于本次折扣后核销金额,是否仍要保存?')
  275. .then(function(y) {
  276. if(y == 'yes') {
  277. me.save();
  278. }
  279. });
  280. }else {
  281. me.save();
  282. }
  283. },
  284. });