FormPanelController.js 12 KB

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