FormPanelController.js 16 KB

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