FormPanelController.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. Ext.define('saas.view.money.recBalance.FormPanelController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.money-recbalance-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. 'dbfindtrigger[name=rb_custname]':{
  8. beforerender:function(f){
  9. Ext.apply(f,{
  10. //数据接口
  11. dataUrl: '/api/document/customer/list',
  12. addXtype: 'document-customer-formpanel',
  13. addTitle: '客户资料',
  14. //赋值
  15. dbfinds:[{
  16. from: 'id', to: 'rb_custid'
  17. }, {
  18. from:'cu_code', to:'rb_custcode'
  19. },{
  20. from:'cu_name', to:'rb_custname'
  21. },{
  22. from:'cu_leftamount', to:'cu_leftamount'
  23. }],
  24. //联想设置
  25. dbtpls:[{
  26. field:'cu_code',width:100
  27. },{
  28. field:'cu_name',width:100
  29. },{
  30. field:'cu_leftamount',width:100
  31. }],
  32. defaultCondition: 'cu_statuscode="OPEN"',
  33. dbSearchFields:[{
  34. emptyText:'输入客户编号或名称',
  35. xtype : "textfield",
  36. name : "search",
  37. getCondition: function(v) {
  38. return "(upper(cu_code) like '%"+v.toUpperCase()+"%' or upper(cu_name) like '%"+v.toUpperCase()+"%')";
  39. },
  40. allowBlank : true,
  41. columnWidth : 0.25
  42. }],
  43. //放大镜窗口列表
  44. dbColumns:[{
  45. "text": "客户ID",
  46. "hidden": true,
  47. "dataIndex": "id",
  48. },{
  49. "text": "客户编号",
  50. "dataIndex": "cu_code",
  51. "width": 200,
  52. }, {
  53. "text": "客户名称",
  54. "dataIndex": "cu_name",
  55. "width": 200
  56. },{
  57. "text": "客户类型",
  58. "dataIndex": "cu_name",
  59. "width": 100
  60. },{
  61. "text": "业务员",
  62. "dataIndex": "cu_sellername",
  63. "width": 100
  64. },{
  65. "text": "应收款余额",
  66. "dataIndex": "cu_leftamount",
  67. "width": 100,
  68. xtype: 'numbercolumn',
  69. align:'end'
  70. },{
  71. "text": "税率",
  72. "dataIndex": "cu_taxrate",
  73. "width": 100,
  74. xtype: 'numbercolumn',
  75. align:'end'
  76. },{
  77. "text": "承付天数",
  78. "dataIndex": "cu_promisedays",
  79. "width": 100,
  80. xtype: 'numbercolumn',
  81. align:'end',
  82. renderer : function(v) {
  83. return Ext.util.Format.number(v, '0');
  84. }
  85. },{
  86. "text": "额度",
  87. "dataIndex": "cu_credit",
  88. "width": 100,
  89. xtype: 'numbercolumn',
  90. align:'end'
  91. }]
  92. }) ;
  93. }
  94. },
  95. 'dbfindtrigger[name=rd_bankname]':{
  96. beforerender:function(f){
  97. Ext.apply(f,{
  98. //数据接口
  99. dataUrl: '/api/document/customer/list',
  100. addXtype: 'document-customer-formpanel',
  101. addTitle: '客户资料',
  102. //赋值
  103. dbfinds:[{
  104. from: 'id', to: 'rb_custid'
  105. }, {
  106. from:'cu_code', to:'rb_custcode'
  107. },{
  108. from:'cu_name', to:'rb_custname'
  109. }],
  110. //联想设置
  111. dbtpls:[{
  112. field:'cu_code',width:100
  113. },{
  114. field:'cu_name',width:100
  115. }],
  116. //联想查询条件
  117. defaultCondition: 'cu_statuscode="OPEN"',
  118. //放大镜窗口字段
  119. dbSearchFields:[{
  120. emptyText:'输入客户编号或名称',
  121. name : "cu_name",
  122. getCondition: function(v) {
  123. return "(upper(cu_code) like '%"+v.toUpperCase()+"%' or upper(cu_name) like '%"+v.toUpperCase()+"%')";
  124. },
  125. fieldLabel : "客户名称",
  126. columnWidth : 0.25
  127. }],
  128. //放大镜窗口列表
  129. dbColumns:[{
  130. "text": "客户ID",
  131. "hidden": true,
  132. "dataIndex": "id",
  133. },{
  134. "text": "客户编号",
  135. "dataIndex": "cu_code",
  136. "width": 200,
  137. }, {
  138. "text": "客户名称",
  139. "dataIndex": "cu_name",
  140. "width": 200
  141. },{
  142. "text": "客户类型",
  143. "dataIndex": "cu_name",
  144. "width": 100
  145. },{
  146. "text": "业务员",
  147. "dataIndex": "cu_sellername",
  148. "width": 100
  149. },{
  150. "text": "税率",
  151. "dataIndex": "cu_taxrate",
  152. "width": 100,
  153. xtype: 'numbercolumn',
  154. align:'end'
  155. },{
  156. "text": "承付天数",
  157. "dataIndex": "cu_promisedays",
  158. "width": 100,
  159. xtype: 'numbercolumn',
  160. align:'end',
  161. renderer : function(v) {
  162. return Ext.util.Format.number(v, '0');
  163. }
  164. },{
  165. "text": "额度",
  166. "dataIndex": "cu_credit",
  167. "width": 100,
  168. xtype: 'numbercolumn',
  169. align:'end'
  170. }]
  171. }) ;
  172. }
  173. },
  174. 'multidbfindtrigger[name=rbd_slcode]': {
  175. beforerender: function (f) {
  176. Ext.apply(f, {
  177. dataUrl: '/api/money/subledger/list',
  178. addTitle: '源单资料',
  179. dbfinds: [{
  180. from: 'id',
  181. to: 'rbd_slid'
  182. }, {
  183. from: 'sl_code',
  184. to: 'rbd_slcode'
  185. },{
  186. from: 'sl_orderamount',
  187. to: 'rbd_amount'
  188. },{
  189. from: 'sl_yamount',
  190. to: 'sl_yamount'
  191. },{
  192. from: 'sl_namount',
  193. to: 'sl_namount'
  194. },{
  195. from:'sl_date',
  196. to:'rbd_sldate'
  197. },{
  198. from:'sl_kind',
  199. to:'rbd_slkind'
  200. },{
  201. from: 'sl_namount',
  202. to: 'rbd_nowbalance'
  203. }],
  204. dbtpls: [{
  205. field: 'sl_code',
  206. width: 100
  207. }],
  208. defaultCondition: "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0",
  209. dbSearchFields:[{
  210. emptyText:'输入源单编号',
  211. xtype : "textfield",
  212. name : "search",
  213. getCondition: function(v) {
  214. return "(upper(sl_code) 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": 100,
  224. "xtype": "numbercolumn"
  225. },{
  226. "text": "源单编号",
  227. "flex": 1,
  228. "dataIndex": "sl_code",
  229. "width": 100
  230. }, {
  231. "text": "源单类型",
  232. "flex": 1,
  233. "dataIndex": "sl_kind",
  234. "width": 100
  235. },{
  236. "text": "单据金额",
  237. "flex": 1,
  238. "dataIndex": "sl_orderamount",
  239. "width": 100,
  240. xtype: 'numbercolumn',
  241. align:'end'
  242. }, {
  243. "text": "已核销金额",
  244. "flex": 0,
  245. "dataIndex": "sl_yamount",
  246. "width": 200,
  247. "items": null,
  248. xtype: 'numbercolumn',
  249. align:'end'
  250. }, {
  251. "text": "未核销金额",
  252. "flex": 1,
  253. "dataIndex": "sl_namount",
  254. "width": 100,
  255. xtype: 'numbercolumn',
  256. align:'end'
  257. },{
  258. "text": "单据日期",
  259. "flex": 1,
  260. "dataIndex": "sl_date",
  261. "width": 120,
  262. xtype: 'datecolumn',
  263. align:'end'
  264. }]
  265. });
  266. }
  267. },
  268. 'dbfindtrigger[name=rd_bankname]':{
  269. beforerender: function (f) {
  270. Ext.apply(f, {
  271. dataUrl: '/api/document/bankinformation/list',
  272. addXtype: 'other-bankinformation',
  273. addTitle: '资金账户',
  274. dbfinds: [{
  275. from: 'id',
  276. to: 'rd_bankid'
  277. }, {
  278. from: 'bk_bankcode',
  279. to: 'rd_bankcode'
  280. },{
  281. from: 'bk_bankname',
  282. to: 'rd_bankname'
  283. }],
  284. dbtpls: [{
  285. field: 'bk_bankcode',
  286. width: 100
  287. }, {
  288. field: 'bk_bankname',
  289. width: 100
  290. }],
  291. dbSearchFields: [{
  292. emptyText: '查找资金账户',
  293. xtype: "textfield",
  294. name: "search",
  295. getCondition: function (v) {
  296. return "(upper(bk_bankcode) like '%"+v.toUpperCase()+"%' or upper(bk_bankname) like '%"+v.toUpperCase()+"%')";
  297. },
  298. allowBlank: true,
  299. columnWidth: 0.25
  300. }],
  301. dbColumns: [{
  302. "text": "账户ID",
  303. "flex": 0,
  304. "dataIndex": "id",
  305. "width": 0,
  306. "xtype": ""
  307. }, {
  308. "text": "资金账户",
  309. "flex": 1,
  310. "dataIndex": "bk_bankcode",
  311. "width": 120,
  312. "xtype": ""
  313. }, {
  314. "text": "账户名称",
  315. "flex": 1,
  316. "dataIndex": "bk_bankname",
  317. "width": 150,
  318. "xtype": ""
  319. }, {
  320. "text": "账户类别",
  321. "flex": 1,
  322. "dataIndex": "bk_type",
  323. "width": 120,
  324. "xtype": ""
  325. }, {
  326. "text": "账户余额",
  327. "flex": 1,
  328. "dataIndex": "bk_thisamount",
  329. "width": 120,
  330. xtype: 'numbercolumn',
  331. }, {
  332. "text": "建帐日期",
  333. "flex": 1,
  334. "dataIndex": "bk_date",
  335. "width": 120,
  336. "xtype": "datecolumn"
  337. }]
  338. });
  339. }
  340. }
  341. });
  342. },
  343. addCombo:function(){
  344. var combo=this.ownerCmp;
  345. Ext.create('Ext.window.Window',{
  346. layout:'vbox',
  347. bodyPadding: 15,
  348. width:500,
  349. items:[{
  350. fieldLabel:'实际值',
  351. xtype:'textfield'
  352. },{
  353. fieldLabel:'显示值',
  354. xtype:'textfield'
  355. }],
  356. buttons:[{
  357. text:'确认',
  358. handler:function(b){
  359. combo.setValue('ok');
  360. b.up('window').close();
  361. }
  362. }],
  363. renderTo:this.ownerCmp.ownerCt.getEl()
  364. }).show();
  365. },
  366. turnIn: function() {
  367. var me = this,
  368. form = me.getView(),
  369. id = form.getForm().findField(form._idField);
  370. form.BaseUtil.request({
  371. url: form._turnInUrl+id.value,
  372. method: 'GET',
  373. })
  374. .then(function(localJson) {
  375. if(localJson.success){
  376. showToast('转单成功');
  377. }
  378. })
  379. .catch(function(res) {
  380. console.error(res);
  381. showToast('转单失败: ' + res.message);
  382. });
  383. },
  384. onSave: function() {
  385. var me = this,
  386. form = me.getView(),
  387. viewModel = me.getViewModel(),
  388. store1 = viewModel.get('detail0').detailStore,
  389. store2 = viewModel.get('detail1').detailStore;
  390. var valid = form.isValid();
  391. if(!valid) {
  392. showToast(form.invalidText);
  393. return false;
  394. }
  395. var sum_rd_amount = store1.sum('rd_amount'); // 付款金额合计
  396. var rb_discounts = viewModel.get('rb_discounts'); // 折扣金额
  397. var sum_rbd_nowbalance = store2.sum('rbd_nowbalance'); // 本次核销金额合计
  398. var flag = sum_rd_amount + rb_discounts - sum_rbd_nowbalance;
  399. viewModel.set("rb_preamount",flag);
  400. if(flag != 0) {
  401. var t = flag > 0 ? '大' : '小';
  402. showConfirm('提示', '收款金额' + t + '于本次折扣后核销金额,是否仍要保存?')
  403. .then(function(y) {
  404. if(y == 'yes') {
  405. me.save();
  406. }
  407. });
  408. }else {
  409. me.save();
  410. }
  411. },
  412. custnamechange:function(dbfindtrigger){
  413. var me = this,
  414. viewModel = me.getViewModel();
  415. var c = viewModel.get('rb_custname_change');
  416. if(c!=null&&c!=''){
  417. c = ' and sl_custid='+c;
  418. }else{
  419. c ='';
  420. }
  421. dbfindtrigger.defaultCondition = "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0" + c;
  422. }
  423. });