FormPanelController.js 16 KB

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