FormPanelController.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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: 'document-banksubledger-formpanel',
  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. defaultCondition: "1=1",
  292. dbSearchFields:[{
  293. emptyText:'输入账户名称或者编号',
  294. xtype : "textfield",
  295. name : "search",
  296. getCondition: function(v) {
  297. return "(upper(bk_bankcode) like '%"+v.toUpperCase()+"%' or upper(bk_bankname) like '%"+v.toUpperCase()+"%')";
  298. },
  299. allowBlank : true,
  300. columnWidth : 0.25
  301. }],
  302. dbColumns:[{
  303. "text": "账户id",
  304. "hidden": true,
  305. "dataIndex": "id",
  306. "width": 0,
  307. "xtype": "numbercolumn"
  308. },{
  309. "text": "账户编号",
  310. "flex": 1,
  311. "dataIndex": "bk_bankcode",
  312. "width": 100
  313. }, {
  314. "text": "账户名称",
  315. "flex": 1,
  316. "dataIndex": "bk_bankname",
  317. "width": 100
  318. }]
  319. });
  320. }
  321. }
  322. });
  323. },
  324. addCombo:function(){
  325. var combo=this.ownerCmp;
  326. Ext.create('Ext.window.Window',{
  327. layout:'vbox',
  328. bodyPadding: 15,
  329. width:500,
  330. items:[{
  331. fieldLabel:'实际值',
  332. xtype:'textfield'
  333. },{
  334. fieldLabel:'显示值',
  335. xtype:'textfield'
  336. }],
  337. buttons:[{
  338. text:'确认',
  339. handler:function(b){
  340. combo.setValue('ok');
  341. b.up('window').close();
  342. }
  343. }],
  344. renderTo:this.ownerCmp.ownerCt.getEl()
  345. }).show();
  346. },
  347. turnIn: function() {
  348. var me = this,
  349. form = me.getView(),
  350. id = form.getForm().findField(form._idField);
  351. form.BaseUtil.request({
  352. url: form._turnInUrl+id.value,
  353. method: 'GET',
  354. })
  355. .then(function(localJson) {
  356. if(localJson.success){
  357. showToast('转单成功');
  358. }
  359. })
  360. .catch(function(res) {
  361. console.error(res);
  362. showToast('转单失败: ' + res.message);
  363. });
  364. },
  365. onSave: function() {
  366. var me = this,
  367. form = me.getView(),
  368. viewModel = me.getViewModel(),
  369. store1 = viewModel.get('detail0').detailStore,
  370. store2 = viewModel.get('detail1').detailStore;
  371. var valid = form.isValid();
  372. if(!valid) {
  373. showToast(form.invalidText);
  374. return false;
  375. }
  376. var sum_rd_amount = store1.sum('rd_amount'); // 付款金额合计
  377. var rb_discounts = viewModel.get('rb_discounts'); // 折扣金额
  378. var sum_rbd_nowbalance = store2.sum('rbd_nowbalance'); // 本次核销金额合计
  379. var flag = sum_rd_amount + rb_discounts - sum_rbd_nowbalance;
  380. viewModel.set("rb_preamount",flag);
  381. if(flag != 0) {
  382. var t = flag > 0 ? '大' : '小';
  383. showConfirm('提示', '收款金额' + t + '于本次折扣后核销金额,是否仍要保存?')
  384. .then(function(y) {
  385. if(y == 'yes') {
  386. me.save();
  387. }
  388. });
  389. }else {
  390. me.save();
  391. }
  392. },
  393. custnamechange:function(dbfindtrigger){
  394. var me = this,
  395. viewModel = me.getViewModel();
  396. var c = viewModel.get('rb_custname_change');
  397. if(c!=null&&c!=''){
  398. c = ' and sl_custid='+c;
  399. }else{
  400. c ='';
  401. }
  402. dbfindtrigger.defaultCondition = "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0" + c;
  403. }
  404. });