FormPanelController.js 14 KB

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