FormPanelController.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. defaultCondition: "1=1",
  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. "hidden": true,
  226. "dataIndex": "id",
  227. "width": 0,
  228. "xtype": "numbercolumn"
  229. },{
  230. "text": "账户编号",
  231. "flex": 1,
  232. "dataIndex": "bk_bankcode",
  233. "width": 100
  234. }, {
  235. "text": "账户名称",
  236. "flex": 1,
  237. "dataIndex": "bk_bankname",
  238. "width": 100
  239. }]
  240. });
  241. }
  242. }
  243. });
  244. },
  245. addCombo:function(){
  246. var combo=this.ownerCmp;
  247. Ext.create('Ext.window.Window',{
  248. layout:'vbox',
  249. bodyPadding: 15,
  250. width:500,
  251. items:[{
  252. fieldLabel:'实际值',
  253. xtype:'textfield'
  254. },{
  255. fieldLabel:'显示值',
  256. xtype:'textfield'
  257. }],
  258. buttons:[{
  259. text:'确认',
  260. handler:function(b){
  261. combo.setValue('ok');
  262. b.up('window').close();
  263. }
  264. }],
  265. renderTo:this.ownerCmp.ownerCt.getEl()
  266. }).show();
  267. },
  268. turnIn: function() {
  269. var me = this,
  270. form = me.getView(),
  271. id = form.getForm().findField(form._idField);
  272. form.BaseUtil.request({
  273. url: form._turnInUrl+id.value,
  274. method: 'GET',
  275. })
  276. .then(function(localJson) {
  277. if(localJson.success){
  278. showToast('转单成功');
  279. }
  280. })
  281. .catch(function(res) {
  282. console.error(res);
  283. showToast('转单失败: ' + res.message);
  284. });
  285. },
  286. onSave: function() {
  287. var me = this,
  288. form = me.getView(),
  289. viewModel = me.getViewModel(),
  290. store1 = viewModel.get('detail0').detailStore,
  291. store2 = viewModel.get('detail1').detailStore;
  292. var valid = form.isValid();
  293. if(!valid) {
  294. showToast(form.invalidText);
  295. return false;
  296. }
  297. var sum_pd_amount = store1.sum('pd_amount'); // 付款金额合计
  298. var pb_discounts = viewModel.get('pb_discounts'); // 折扣金额
  299. var sum_pbd_nowbalance = store2.sum('pbd_nowbalance'); // 本次核销金额合计
  300. var flag = sum_pd_amount + pb_discounts - sum_pbd_nowbalance;
  301. viewModel.set("pb_preamount",flag);
  302. if(flag != 0) {
  303. var t = flag > 0 ? '大' : '小';
  304. showConfirm('提示', '付款金额' + t + '于本次折扣后核销金额,是否仍要保存?')
  305. .then(function(y) {
  306. if(y == 'yes') {
  307. me.save();
  308. }
  309. });
  310. }else {
  311. me.save();
  312. }
  313. },
  314. vendnamechange:function(dbfindtrigger){
  315. var me = this,
  316. viewModel = me.getViewModel();
  317. var c = viewModel.get('pb_vendname_change');
  318. if(c!=null&&c!=''){
  319. c = ' and sl_vendid='+c;
  320. }else{
  321. c ='';
  322. }
  323. dbfindtrigger.defaultCondition = "sl_vendid<>0 and sl_kind in ('期初余额','采购验收单','采购验退单') and sl_namount<>0" + c;
  324. }
  325. });