FormPanelController.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. from:'sl_date',
  112. to:'pbd_sldate'
  113. },{
  114. from:'sl_kind',
  115. to:'pbd_slkind'
  116. }],
  117. dbtpls: [{
  118. field: 'sl_code',
  119. width: 100
  120. }],
  121. defaultCondition: "sl_vendid<>0 and sl_kind in ('期初余额','采购验收单','采购验退单') and sl_namount<>0",
  122. dbSearchFields:[{
  123. emptyText:'输入源单编号',
  124. xtype : "textfield",
  125. name : "search",
  126. getCondition: function(v) {
  127. return "(upper(sl_code) like '%"+v.toUpperCase()+"%')";
  128. },
  129. allowBlank : true,
  130. columnWidth : 0.25
  131. }],
  132. dbColumns:[{
  133. "text": "源单id",
  134. "hidden": true,
  135. "dataIndex": "id",
  136. "width": 100,
  137. "xtype": "numbercolumn"
  138. },{
  139. "text": "源单编号",
  140. "flex": 1,
  141. "dataIndex": "sl_code",
  142. "width": 100
  143. },{
  144. "text": "源单类型",
  145. "flex": 1,
  146. "dataIndex": "sl_kind",
  147. "width": 100
  148. }, {
  149. "text": "单据金额",
  150. "flex": 1,
  151. "dataIndex": "sl_orderamount",
  152. "width": 100,
  153. align:'right'
  154. }, {
  155. "text": "已核销金额",
  156. "flex": 0,
  157. "dataIndex": "sl_yamount",
  158. "width": 200,
  159. align:'right',
  160. "items": null
  161. }, {
  162. "text": "未核销金额",
  163. "flex": 1,
  164. "dataIndex": "sl_namount",
  165. "width": 100,
  166. align:'right'
  167. },{
  168. "text": "单据日期",
  169. "flex": 1,
  170. "dataIndex": "sl_date",
  171. "width": 100,
  172. align:'right'
  173. }]
  174. });
  175. }
  176. },
  177. 'dbfindtrigger[name=pd_bankname]':{
  178. beforerender: function (f) {
  179. Ext.apply(f, {
  180. dataUrl: '/api/document/bankinformation/list',
  181. addXtype: 'other-bankinformation',
  182. addTitle: '账户资料',
  183. dbfinds: [{
  184. from: 'id',
  185. to: 'pd_bankid'
  186. }, {
  187. from: 'bk_bankcode',
  188. to: 'pd_bankcode'
  189. },{
  190. from: 'bk_bankname',
  191. to: 'pd_bankname'
  192. }],
  193. dbtpls: [{
  194. field: 'bk_bankcode',
  195. width: 100
  196. }, {
  197. field: 'bk_bankname',
  198. width: 100
  199. }],
  200. defaultCondition: "1=1",
  201. dbSearchFields:[{
  202. emptyText:'输入账户名称或者编号',
  203. xtype : "textfield",
  204. name : "search",
  205. getCondition: function(v) {
  206. return "(upper(bk_bankcode) like '%"+v.toUpperCase()+"%' or upper(bk_bankname) like '%"+v.toUpperCase()+"%')";
  207. },
  208. allowBlank : true,
  209. columnWidth : 0.25
  210. }],
  211. dbColumns:[{
  212. "text": "账户id",
  213. "hidden": true,
  214. "dataIndex": "id",
  215. "width": 0,
  216. "xtype": "numbercolumn"
  217. },{
  218. "text": "账户编号",
  219. "flex": 1,
  220. "dataIndex": "bk_bankcode",
  221. "width": 100
  222. }, {
  223. "text": "账户名称",
  224. "flex": 1,
  225. "dataIndex": "bk_bankname",
  226. "width": 100
  227. }]
  228. });
  229. }
  230. }
  231. });
  232. },
  233. addCombo:function(){
  234. var combo=this.ownerCmp;
  235. Ext.create('Ext.window.Window',{
  236. layout:'vbox',
  237. bodyPadding: 15,
  238. width:500,
  239. items:[{
  240. fieldLabel:'实际值',
  241. xtype:'textfield'
  242. },{
  243. fieldLabel:'显示值',
  244. xtype:'textfield'
  245. }],
  246. buttons:[{
  247. text:'确认',
  248. handler:function(b){
  249. combo.setValue('ok');
  250. b.up('window').close();
  251. }
  252. }],
  253. renderTo:this.ownerCmp.ownerCt.getEl()
  254. }).show();
  255. },
  256. turnIn: function() {
  257. var me = this,
  258. form = me.getView(),
  259. id = form.getForm().findField(form._idField);
  260. form.BaseUtil.request({
  261. url: form._turnInUrl+id.value,
  262. method: 'GET',
  263. })
  264. .then(function(localJson) {
  265. if(localJson.success){
  266. showToast('转单成功');
  267. }
  268. })
  269. .catch(function(res) {
  270. console.error(res);
  271. showToast('转单失败: ' + res.message);
  272. });
  273. },
  274. onSave: function() {
  275. var me = this,
  276. form = me.getView(),
  277. viewModel = me.getViewModel(),
  278. store1 = viewModel.get('detail0').detailStore,
  279. store2 = viewModel.get('detail1').detailStore;
  280. var valid = form.isValid();
  281. if(!valid) {
  282. showToast(form.invalidText);
  283. return false;
  284. }
  285. var sum_pd_amount = store1.sum('pd_amount'); // 付款金额合计
  286. var pb_discounts = viewModel.get('pb_discounts'); // 折扣金额
  287. var sum_pbd_nowbalance = store2.sum('pbd_nowbalance'); // 本次核销金额合计
  288. var flag = sum_pd_amount + pb_discounts - sum_pbd_nowbalance;
  289. if(flag != 0) {
  290. var t = flag > 0 ? '大' : '小';
  291. showConfirm('提示', '付款金额' + t + '于本次折扣后核销金额,是否仍要保存?')
  292. .then(function(y) {
  293. if(y == 'yes') {
  294. me.save();
  295. }
  296. });
  297. }else {
  298. me.save();
  299. }
  300. },
  301. });