FormPanelController.js 12 KB

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