FormPanel.js 24 KB

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