FormPanelController.js 14 KB

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