FormPanelController.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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. "dataIndex": "sl_code",
  228. "width": 180
  229. }, {
  230. "text": "源单类型",
  231. "flex": 1,
  232. "dataIndex": "sl_kind",
  233. "width": 100
  234. },{
  235. "text": "单据金额",
  236. "flex": 1,
  237. "dataIndex": "sl_orderamount",
  238. "width": 100,
  239. xtype: 'numbercolumn',
  240. align:'end'
  241. }, {
  242. "text": "已核销金额",
  243. "flex": 0,
  244. "dataIndex": "sl_yamount",
  245. "width": 200,
  246. "items": null,
  247. xtype: 'numbercolumn',
  248. align:'end'
  249. }, {
  250. "text": "未核销金额",
  251. "flex": 1,
  252. "dataIndex": "sl_namount",
  253. "width": 100,
  254. xtype: 'numbercolumn',
  255. align:'end'
  256. },{
  257. "text": "单据日期",
  258. "flex": 1,
  259. "dataIndex": "sl_date",
  260. "width": 120,
  261. xtype: 'datecolumn',
  262. align:'end'
  263. }]
  264. });
  265. }
  266. },
  267. 'dbfindtrigger[name=rd_bankname]':{
  268. beforerender: function (f) {
  269. Ext.apply(f, {
  270. dataUrl: '/api/document/bankinformation/list',
  271. addXtype: 'other-bankinformation',
  272. addTitle: '资金账户',
  273. dbfinds: [{
  274. from: 'id',
  275. to: 'rd_bankid',ignore:true
  276. }, {
  277. from: 'bk_bankcode',
  278. to: 'rd_bankcode'
  279. },{
  280. from: 'bk_bankname',
  281. to: 'rd_bankname'
  282. }],
  283. dbtpls: [{
  284. field: 'bk_bankcode',
  285. width: 100
  286. }, {
  287. field: 'bk_bankname',
  288. width: 100
  289. }],
  290. dbSearchFields: [{
  291. emptyText: '查找资金账户',
  292. xtype: "textfield",
  293. name: "search",
  294. getCondition: function (v) {
  295. return "(upper(bk_bankcode) like '%"+v.toUpperCase()+"%' or upper(bk_bankname) like '%"+v.toUpperCase()+"%')";
  296. },
  297. allowBlank: true,
  298. columnWidth: 0.25
  299. }],
  300. dbColumns: [{
  301. "text": "账户ID",
  302. "flex": 0,
  303. "dataIndex": "id",
  304. "width": 0,
  305. "xtype": ""
  306. }, {
  307. "text": "资金账户",
  308. "flex": 1,
  309. "dataIndex": "bk_bankcode",
  310. "width": 120,
  311. "xtype": ""
  312. }, {
  313. "text": "账户名称",
  314. "flex": 1,
  315. "dataIndex": "bk_bankname",
  316. "width": 150,
  317. "xtype": ""
  318. }, {
  319. "text": "账户类别",
  320. "flex": 1,
  321. "dataIndex": "bk_type",
  322. "width": 120,
  323. "xtype": ""
  324. }, {
  325. "text": "账户余额",
  326. "flex": 1,
  327. "dataIndex": "bk_thisamount",
  328. "width": 120,
  329. xtype: 'numbercolumn',
  330. }, {
  331. "text": "建帐日期",
  332. "flex": 1,
  333. "dataIndex": "bk_date",
  334. "width": 120,
  335. "xtype": "datecolumn"
  336. }]
  337. });
  338. }
  339. }
  340. });
  341. },
  342. addCombo:function(){
  343. var combo=this.ownerCmp;
  344. Ext.create('Ext.window.Window',{
  345. layout:'vbox',
  346. bodyPadding: 15,
  347. width:500,
  348. items:[{
  349. fieldLabel:'实际值',
  350. xtype:'textfield'
  351. },{
  352. fieldLabel:'显示值',
  353. xtype:'textfield'
  354. }],
  355. buttons:[{
  356. text:'确认',
  357. handler:function(b){
  358. combo.setValue('ok');
  359. b.up('window').close();
  360. }
  361. }],
  362. renderTo:this.ownerCmp.ownerCt.getEl()
  363. }).show();
  364. },
  365. turnIn: function() {
  366. var me = this,
  367. form = me.getView(),
  368. id = form.getForm().findField(form._idField);
  369. saas.util.BaseUtil.request({
  370. url: form._turnInUrl+id.value,
  371. method: 'GET',
  372. })
  373. .then(function(localJson) {
  374. if(localJson.success){
  375. saas.util.BaseUtil.showToast('转单成功');
  376. }
  377. })
  378. .catch(function(res) {
  379. console.error(res);
  380. saas.util.BaseUtil.showToast('转单失败: ' + res.message);
  381. });
  382. },
  383. onSave: function() {
  384. var me = this,
  385. form = me.getView(),
  386. viewModel = me.getViewModel(),
  387. store1 = viewModel.get('detail0').detailStore,
  388. store2 = viewModel.get('detail1').detailStore;
  389. var valid = form.isValid();
  390. if(!valid) {
  391. saas.util.BaseUtil.showToast(form.invalidText);
  392. return false;
  393. }
  394. var sum_rd_amount = store1.sum('rd_amount'); // 付款金额合计
  395. var rb_discounts = viewModel.get('rb_discounts'); // 折扣金额
  396. var sum_rbd_nowbalance = store2.sum('rbd_nowbalance'); // 本次核销金额合计
  397. var flag = sum_rd_amount + rb_discounts - sum_rbd_nowbalance;
  398. viewModel.set("rb_preamount",flag);
  399. if(flag != 0) {
  400. var t = flag > 0 ? '大' : '小';
  401. saas.util.BaseUtil.showConfirm('提示', '收款金额' + t + '于本次折扣后核销金额,是否仍要保存?')
  402. .then(function(y) {
  403. if(y == 'yes') {
  404. me.save();
  405. }
  406. });
  407. }else {
  408. me.save();
  409. }
  410. },
  411. custnamechange:function(dbfindtrigger){
  412. var me = this,
  413. viewModel = me.getViewModel();
  414. var c = viewModel.get('rb_custname_change');
  415. if(c!=null&&c!=''){
  416. c = ' and sl_custid='+c;
  417. }else{
  418. c ='';
  419. }
  420. dbfindtrigger.defaultCondition = "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0" + c;
  421. }
  422. });