FormPanelController.js 13 KB

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