FormPanel.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. Ext.define('saas.view.money.recBalance.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: 'money-recbalance-formpanel',
  4. controller: 'money-recbalance-formpanel',
  5. viewModel: 'money-recbalance-formpanel',
  6. viewName: 'money-recbalance-formpanel',
  7. caller: 'RecBalance',
  8. //字段属性
  9. _title: '收款单',
  10. _idField: 'id',
  11. _codeField: 'rb_code',
  12. _statusField: 'rb_status',
  13. _statusCodeField: 'rb_statuscode',
  14. _auditmanField: 'rb_auditman',
  15. _auditdateField: 'rb_auditdate',
  16. _readUrl: '/api/money/recbalance/read',
  17. _saveUrl: '/api/money/recbalance/save',
  18. _auditUrl: '/api/money/recbalance/audit',
  19. _unAuditUrl: '/api/money/recbalance/unAudit',
  20. _deleteUrl: '/api/money/recbalance/delete',
  21. initId: 0,
  22. initComponent: function () {
  23. Ext.apply(this, {
  24. defaultItems: [{
  25. xtype: 'hidden',
  26. name: 'id',
  27. fieldLabel: 'id'
  28. }, {
  29. xtype: 'hidden',
  30. name: 'rb_custid',
  31. fieldLabel: '客户ID'
  32. }, {
  33. xtype: 'hidden',
  34. name: 'rb_kind',
  35. fieldLabel: '单据类型',
  36. defaultValue: '收款单',
  37. readOnly: true
  38. }, {
  39. xtype: 'hidden',
  40. name: 'rb_custcode',
  41. fieldLabel: '客户编号'
  42. }, {
  43. xtype: "customerDbfindTrigger",
  44. name: "rb_custname",
  45. fieldLabel: "客户名称",
  46. allowBlank: false,
  47. columnWidth: 0.5,
  48. listeners: {
  49. change: 'clearDetails'
  50. },
  51. aftertrigger:function(f,record){
  52. let form = f.ownerCt
  53. let custName = f.value
  54. let currency = form.down('[xtype=condbfindtrigger]').items.items[0].value
  55. if(custName&&custName!=''&&currency&&currency!=''&&record.get('cu_code')&&record.get('cu_code')!=''){
  56. Ext.Ajax.request({
  57. url: '/api/document/custaramount/getCustArByCustCodeAndCurrency',
  58. params:{
  59. custCode:record.get('cu_code'),
  60. currency:currency
  61. },
  62. method: 'post',
  63. headers: {
  64. 'Access-Control-Allow-Origin': '*',
  65. 'Authorization': saas.util.State.get('session').token,
  66. "Content-Type": 'application/x-www-form-urlencoded;charset=UTF-8'
  67. },
  68. success: function (response, opts) {
  69. var res = Ext.decode(response.responseText);
  70. if(res.success&&res.data){
  71. let ca_leftamount = res.data.ca_leftamount
  72. form.down('[name=cu_leftamount]').setValue(ca_leftamount)
  73. }else{
  74. //清除总欠款
  75. form.down('[name=cu_leftamount]').setValue(0)
  76. }
  77. },
  78. failure: function (response, opts) {
  79. var res = Ext.decode(response.responseText);
  80. saas.util.BaseUtil.showErrorToast('查询总欠款失败: ' + res.message);
  81. }
  82. });
  83. }else{
  84. //清除总欠款
  85. form.down('[name=cu_leftamount]').setValue(0)
  86. }
  87. }
  88. }, {
  89. xtype: 'condbfindtrigger',
  90. fieldLabel: '币别汇率',
  91. allowBlank: false,
  92. dbType: 'currencyDbfindTrigger',
  93. dbfinds: [{
  94. from: 'cr_name', to: 'rb_currency'
  95. }, {
  96. from: 'cr_rate', to: 'rb_rate'
  97. }],
  98. listeners: {
  99. change: 'clearDetails'
  100. },
  101. mainFieldConfig:{
  102. aftertrigger:function(f,record){
  103. let form = f.ownerCt.ownerCt
  104. let currency = f.value
  105. let custCode = form.down('[name=rb_custcode]').value
  106. if(custCode&&custCode!=''&&currency&&currency!=''){
  107. Ext.Ajax.request({
  108. url: '/api/document/custaramount/getCustArByCustCodeAndCurrency',
  109. params:{
  110. custCode:custCode,
  111. currency:currency
  112. },
  113. method: 'post',
  114. headers: {
  115. 'Access-Control-Allow-Origin': '*',
  116. 'Authorization': saas.util.State.get('session').token,
  117. "Content-Type": 'application/x-www-form-urlencoded;charset=UTF-8'
  118. },
  119. success: function (response, opts) {
  120. var res = Ext.decode(response.responseText);
  121. if(res.success&&res.data){
  122. let ca_leftamount = res.data.ca_leftamount
  123. form.down('[name=cu_leftamount]').setValue(ca_leftamount)
  124. }else{
  125. form.down('[name=cu_leftamount]').setValue(0)
  126. }
  127. },
  128. failure: function (response, opts) {
  129. var res = Ext.decode(response.responseText);
  130. saas.util.BaseUtil.showErrorToast('查询总欠款失败: ' + res.message);
  131. }
  132. });
  133. }else{
  134. //清除总欠款
  135. form.down('[name=cu_leftamount]').setValue(0)
  136. }
  137. }
  138. },
  139. supFieldConfig: {
  140. xtype: 'numberfield',
  141. readOnly: false,
  142. defaultReadOnly: false,
  143. decimalPrecision: 6,
  144. vtype: 'positiveNumber',
  145. listeners: {
  146. change: function(f, v) {
  147. var defaultCurrency = Ext.getCmp('mainView').getViewModel().get('defaultCurrency');
  148. f.setReadOnly(f.ownerCt.items.items[0].value == defaultCurrency);
  149. }
  150. }
  151. }
  152. },{
  153. xtype: "datefield",
  154. name: "rb_date",
  155. fieldLabel: "日期",
  156. defaultValue: new Date(),
  157. allowBlank: false
  158. }, {
  159. xtype: "textfield",
  160. name: "rb_manname",
  161. fieldLabel: "收款人",
  162. defaultValue: saas.util.BaseUtil.getCurrentUser().realname
  163. }, {
  164. xtype: "numberfield",
  165. name: "cu_leftamount",
  166. fieldLabel: "总欠款(元)",
  167. thousandSeparator: ',',
  168. ignore: true,
  169. readOnly: true
  170. }, {
  171. xtype: 'hidden',
  172. name: 'rb_rbdamount',
  173. fieldLabel: '本次核销金额(元)',
  174. thousandSeparator: ',',
  175. hidden: true
  176. }, {
  177. xtype: 'hidden',
  178. name: 'rb_rdamount',
  179. fieldLabel: '本次付款金额(元)',
  180. thousandSeparator: ',',
  181. hidden: true
  182. }, {
  183. xtype: "numberfield",
  184. name: "rb_discounts",
  185. fieldLabel: "整单折扣",
  186. hidden: true
  187. }, {
  188. xtype: 'numberfield',
  189. name: 'rb_preamount',
  190. fieldLabel: '本次预收(元)',
  191. thousandSeparator: ',',
  192. readOnly: true
  193. }, {
  194. xtype: 'numberfield',
  195. name: 'rb_havebalance',
  196. fieldLabel: '已核销金额(元)',
  197. hidden: true
  198. }, {
  199. xtype: "detailGridField",
  200. name: 'detail1',
  201. storeModel: 'saas.model.money.RecBalance1',
  202. detnoColumn: 'rd_detno',
  203. deleteDetailUrl: '/api/money/recbalance/deleteDetail1',
  204. columns: [{
  205. text: 'ID',
  206. dataIndex: 'id',
  207. hidden: true
  208. }, {
  209. text: '期间',
  210. dataIndex: 'rd_ym',
  211. defaultValue: Ext.Date.format(new Date(), 'Ym'),
  212. width: 110,
  213. hidden: true
  214. }, {
  215. text: '资金账户ID',
  216. dataIndex: 'rd_bankid',
  217. editor: {
  218. xtype: 'numberfield'
  219. },
  220. hidden: true
  221. }, {
  222. text: '资金账户编号',
  223. dataIndex: 'rd_bankcode',
  224. editor: {
  225. xtype: 'textfield'
  226. },
  227. hidden: true
  228. }, {
  229. text: '资金账户',
  230. dataIndex: 'rd_bankname',
  231. allowBlank: false,
  232. width: 200,
  233. editor: {
  234. xtype: 'bandinfoDbfindTrigger'
  235. }
  236. }, {
  237. text: "收款金额(元)",
  238. xtype: 'numbercolumn',
  239. dataIndex: "rd_amount",
  240. width: 110.0,
  241. allowBlank: false,
  242. editor: {
  243. xtype: "numberfield",
  244. decimalPrecision: 2
  245. },
  246. renderer: function(v, m, r) {
  247. return saas.util.BaseUtil.numberFormat(v, 2, true);
  248. },
  249. summaryType: 'sum',
  250. summaryRenderer: function(v, d, f, m) {
  251. return saas.util.BaseUtil.numberFormat(v, 2, true);
  252. }
  253. }, {
  254. text: "结算方式",
  255. dataIndex: "rd_paymethod",
  256. width: 150.0,
  257. editor: {
  258. xtype: 'combo',
  259. queryMode: 'local',
  260. displayField: 'display',
  261. valueField: 'value',
  262. store: Ext.create('Ext.data.Store', {
  263. fields: ['value', 'display'],
  264. data: [{
  265. value: "信用卡",
  266. display: "信用卡"
  267. }, {
  268. value: "支票",
  269. display: "支票"
  270. }, {
  271. value: "汇票",
  272. display: "汇票"
  273. }, {
  274. value: "现金",
  275. display: "现金"
  276. }, {
  277. value: "银行转账",
  278. display: "银行转账"
  279. }, {
  280. value: "支付宝转账",
  281. display: "支付宝转账"
  282. }, {
  283. value: "微信转账",
  284. display: "微信转账"
  285. }]
  286. })
  287. }
  288. }, {
  289. text: "结算号",
  290. dataIndex: "rd_paycode",
  291. editor: {
  292. xtype: 'textfield'
  293. }
  294. }, {
  295. text: "备注",
  296. dataIndex: "rd_remark",
  297. width: 250,
  298. editor: {
  299. xtype: 'textfield'
  300. }
  301. }, {
  302. dataIndex: "rd_text1",
  303. text: "自定义字段1",
  304. width: 100,
  305. hidden: true,
  306. initHidden: false,
  307. editor: {
  308. xtype: "textfield"
  309. },
  310. }, {
  311. dataIndex: "rd_text2",
  312. text: "自定义字段2",
  313. width: 100,
  314. hidden: true,
  315. initHidden: false,
  316. editor: {
  317. xtype: "textfield"
  318. },
  319. }, {
  320. dataIndex: "rd_text3",
  321. text: "自定义字段3",
  322. width: 100,
  323. hidden: true,
  324. initHidden: false,
  325. editor: {
  326. xtype: "textfield"
  327. },
  328. }, {
  329. dataIndex: "rd_text4",
  330. text: "自定义字段4",
  331. width: 100,
  332. hidden: true,
  333. initHidden: false,
  334. editor: {
  335. xtype: "textfield"
  336. },
  337. }, {
  338. dataIndex: "rd_text5",
  339. text: "自定义字段5",
  340. width: 100,
  341. hidden: true,
  342. initHidden: false,
  343. editor: {
  344. xtype: "textfield"
  345. },
  346. }]
  347. }, {
  348. xtype: "detailGridField",
  349. name: 'detail2',
  350. storeModel: 'saas.model.money.RecBalance2',
  351. detnoColumn: 'rbd_detno',
  352. allowEmpty: true,
  353. deleteDetailUrl: '/api/money/recbalance/deleteDetail2',
  354. columns: [{
  355. text: 'ID',
  356. dataIndex: 'id',
  357. hidden: true
  358. }, {
  359. text: '期间',
  360. dataIndex: 'rbd_ym',
  361. editor: {
  362. xtype: 'numberfield'
  363. },
  364. hidden: true
  365. }, {
  366. text: '来源ID',
  367. dataIndex: 'rbd_slid',
  368. editor: {
  369. xtype: 'numberfield'
  370. },
  371. hidden: true
  372. }, {
  373. text: '来源单号',
  374. dataIndex: 'rbd_slcode',
  375. width: 200,
  376. editor: {
  377. displayField: "display",
  378. editable: true,
  379. format: "",
  380. hideTrigger: false,
  381. maxLength: 100.0,
  382. minValue: null,
  383. positiveNum: false,
  384. queryMode: "local",
  385. store: null,
  386. valueField: "value",
  387. xtype: "oriOrderMutiDbfindTrigger",
  388. listeners: {
  389. beforetriggerclick: 'custnamechange'
  390. }
  391. }
  392. }, {
  393. text: "业务类型",
  394. dataIndex: "rbd_slkind",
  395. width: 110
  396. }, {
  397. text: "单据日期",
  398. dataIndex: "rbd_sldate",
  399. xtype: 'datecolumn',
  400. width: 110
  401. }, {
  402. text: "单据金额(元)",
  403. xtype: 'numbercolumn',
  404. dataIndex: "rbd_amount",
  405. width: 110,
  406. renderer: function(v, m, r) {
  407. return saas.util.BaseUtil.numberFormat(v, 2, true);
  408. },
  409. summaryType: 'sum',
  410. summaryRenderer: function(v, d, f, m) {
  411. return saas.util.BaseUtil.numberFormat(v, 2, true);
  412. }
  413. }, {
  414. text: "已核销金额(元)",
  415. xtype: 'numbercolumn',
  416. dataIndex: "sl_yamount",
  417. width: 120,
  418. ignore: true,
  419. renderer: function(v, m, r) {
  420. return saas.util.BaseUtil.numberFormat(v, 2, true);
  421. },
  422. summaryType: 'sum',
  423. summaryRenderer: function(v, d, f, m) {
  424. return saas.util.BaseUtil.numberFormat(v, 2, true);
  425. }
  426. }, {
  427. text: "未核销金额(元)",
  428. xtype: 'numbercolumn',
  429. dataIndex: "sl_namount",
  430. width: 120,
  431. ignore: true,
  432. renderer: function(v, m, r) {
  433. return saas.util.BaseUtil.numberFormat(v, 2, true);
  434. },
  435. summaryType: 'sum',
  436. summaryRenderer: function(v, d, f, m) {
  437. return saas.util.BaseUtil.numberFormat(v, 2, true);
  438. }
  439. }, {
  440. text: "本次核销金额(元)",
  441. xtype: 'numbercolumn',
  442. dataIndex: "rbd_nowbalance",
  443. width: 140,
  444. editor: {
  445. xtype: "numberfield",
  446. decimalPrecision: 2
  447. },
  448. allowBlank: false,
  449. renderer: function(v, m, r) {
  450. return saas.util.BaseUtil.numberFormat(v, 2, true);
  451. },
  452. summaryType: 'sum',
  453. summaryRenderer: function(v, d, f, m) {
  454. return saas.util.BaseUtil.numberFormat(v, 2, true);
  455. }
  456. }, {
  457. dataIndex: "rbd_text1",
  458. text: "自定义字段1",
  459. width: 100,
  460. hidden: true,
  461. initHidden: false,
  462. editor: {
  463. xtype: "textfield"
  464. },
  465. }, {
  466. dataIndex: "rbd_text2",
  467. text: "自定义字段2",
  468. width: 100,
  469. hidden: true,
  470. initHidden: false,
  471. editor: {
  472. xtype: "textfield"
  473. },
  474. }, {
  475. dataIndex: "rbd_text3",
  476. text: "自定义字段3",
  477. width: 100,
  478. hidden: true,
  479. initHidden: false,
  480. editor: {
  481. xtype: "textfield"
  482. },
  483. }, {
  484. dataIndex: "rbd_text4",
  485. text: "自定义字段4",
  486. width: 100,
  487. hidden: true,
  488. initHidden: false,
  489. editor: {
  490. xtype: "textfield"
  491. },
  492. }, {
  493. dataIndex: "rbd_text5",
  494. text: "自定义字段5",
  495. width: 100,
  496. hidden: true,
  497. initHidden: false,
  498. editor: {
  499. xtype: "textfield"
  500. },
  501. }]
  502. }, {
  503. xtype: 'textfield',
  504. name: 'rb_remark',
  505. fieldLabel: '备注',
  506. columnWidth: 1
  507. }, {
  508. xtype: "hidden",
  509. name: "creatorId",
  510. fieldLabel: "录入人ID",
  511. readOnly: true
  512. }, {
  513. xtype: "textfield",
  514. name: "creatorName",
  515. fieldLabel: "录入人",
  516. readOnly: true
  517. }, {
  518. xtype: "datefield",
  519. name: "createTime",
  520. fieldLabel: "录入日期",
  521. readOnly: true,
  522. defaultValue: new Date()
  523. }, {
  524. xtype: "hidden",
  525. name: "updaterId",
  526. fieldLabel: "更新人ID",
  527. readOnly: true
  528. }, {
  529. xtype: "hidden",
  530. name: "updaterName",
  531. fieldLabel: "更新人",
  532. readOnly: true
  533. }, {
  534. xtype: "hidden",
  535. name: "updateTime",
  536. fieldLabel: "更新日期",
  537. readOnly: true,
  538. defaultValue: new Date()
  539. }, {
  540. xtype: 'textfield',
  541. name: 'rb_auditman',
  542. fieldLabel: '审核人',
  543. readOnly: true
  544. }, {
  545. xtype: "datefield",
  546. name: "rb_auditdate",
  547. fieldLabel: "审核日期",
  548. readOnly: true
  549. }, {
  550. xtype: "textfield",
  551. name: "rb_text1",
  552. fieldLabel: "自定义字段1",
  553. hidden: true,
  554. initHidden: false
  555. }, {
  556. xtype: "textfield",
  557. name: "rb_text2",
  558. fieldLabel: "自定义字段2",
  559. hidden: true,
  560. initHidden: false
  561. }, {
  562. xtype: "textfield",
  563. name: "rb_text3",
  564. fieldLabel: "自定义字段3",
  565. hidden: true,
  566. initHidden: false
  567. }, {
  568. xtype: "textfield",
  569. name: "rb_text4",
  570. fieldLabel: "自定义字段4",
  571. hidden: true,
  572. initHidden: false
  573. }, {
  574. xtype: "textfield",
  575. name: "rb_text5",
  576. fieldLabel: "自定义字段5",
  577. hidden: true,
  578. initHidden: false
  579. }],
  580. });
  581. this.callParent(arguments);
  582. },
  583. beforeAudit: function () {
  584. var form = this,
  585. idField = form._idField,
  586. controller = form.getController(),
  587. viewModel = form.getViewModel(),
  588. id = viewModel.get(idField);
  589. store1 = viewModel.get('detail0').detailStore,
  590. store2 = viewModel.get('detail1').detailStore;
  591. // 已保存过的单据不进行此项校验
  592. if (id) {
  593. return true;
  594. }
  595. var sum_rd_amount = store1.sum('rd_amount'); // 付款金额合计
  596. var rb_discounts = viewModel.get('rb_discounts'); // 折扣金额
  597. var sum_rbd_nowbalance = store2.sum('rbd_nowbalance'); // 本次核销金额合计
  598. var flag = sum_rd_amount + rb_discounts - sum_rbd_nowbalance;
  599. viewModel.set("rb_preamount", flag);
  600. viewModel.set("rb_rbdamount",sum_rbd_nowbalance);
  601. viewModel.set("rb_rdamount",sum_rd_amount);
  602. viewModel.set("rb_preamount",sum_rd_amount-sum_rbd_nowbalance);
  603. if (flag != 0) {
  604. var t = flag > 0 ? '大' : '小';
  605. saas.util.BaseUtil.showConfirm('提示', '付款金额' + t + '于本次核销金额,是否仍要保存并审核?')
  606. .then(function (y) {
  607. if (y == 'yes') {
  608. controller.audit();
  609. }
  610. });
  611. } else {
  612. controller.audit();
  613. }
  614. return false;
  615. }
  616. });