FormPanel.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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. }, {
  53. xtype: 'condbfindtrigger',
  54. fieldLabel: '币别汇率',
  55. allowBlank: false,
  56. dbType: 'currencyDbfindTrigger',
  57. dbfinds: [{
  58. from: 'cr_name', to: 'pb_currency'
  59. }, {
  60. from: 'cr_rate', to: 'pb_rate'
  61. }],
  62. listeners: {
  63. change: 'clearDetails'
  64. },
  65. supFieldConfig: {
  66. xtype: 'numberfield',
  67. readOnly: false,
  68. defaultReadOnly: false,
  69. decimalPrecision: 6,
  70. vtype: 'positiveNumber',
  71. listeners: {
  72. change: function(f, v) {
  73. var defaultCurrency = Ext.getCmp('mainView').getViewModel().get('defaultCurrency');
  74. f.setReadOnly(f.ownerCt.items.items[0].value == defaultCurrency);
  75. }
  76. }
  77. }
  78. },{
  79. xtype: "datefield",
  80. name: "pb_date",
  81. fieldLabel: "日期",
  82. defaultValue: new Date(),
  83. allowBlank: false
  84. }, {
  85. xtype: 'textfield',
  86. name: 'pb_manname',
  87. fieldLabel: '付款人',
  88. defaultValue: saas.util.BaseUtil.getCurrentUser().realname
  89. }, {
  90. xtype: "numberfield",
  91. name: "ve_leftamount",
  92. fieldLabel: "总欠款(元)",
  93. thousandSeparator: ',',
  94. ignore: true,
  95. readOnly: true
  96. }, {
  97. xtype: 'hidden',
  98. name: 'pb_pdamount',
  99. thousandSeparator: ',',
  100. fieldLabel: '付款金额(元)'
  101. }, {
  102. xtype: "hidden",
  103. name: "pb_pbdamount",
  104. thousandSeparator: ',',
  105. fieldLabel: "本次核销金额(元)"
  106. }, {
  107. xtype: "numberfield",
  108. name: "pb_preamount",
  109. fieldLabel: "本次预付(元)",
  110. thousandSeparator: ',',
  111. readOnly: true
  112. }, {
  113. xtype: 'hidden',
  114. name: 'pb_discounts',
  115. fieldLabel: '整单折扣(元)',
  116. hidden: true
  117. }, {
  118. xtype: 'hidden',
  119. name: 'pb_havebalance',
  120. thousandSeparator: ',',
  121. fieldLabel: '已核销金额(元)'
  122. }, {
  123. xtype: "detailGridField",
  124. name: 'detail1',
  125. storeModel: 'saas.model.money.PayBalance1',
  126. detnoColumn: 'pd_detno',
  127. deleteDetailUrl: '/api/money/paybalance/deleteDetail1',
  128. columns: [{
  129. text: 'ID',
  130. dataIndex: 'id',
  131. hidden: true
  132. }, {
  133. text: '期间',
  134. dataIndex: 'pd_ym',
  135. hidden: true,
  136. defaultValue: Ext.Date.format(new Date(), 'Ym'),
  137. width: 110.0
  138. }, {
  139. text: '结算账户ID',
  140. dataIndex: 'pd_bankid',
  141. hidden: true
  142. }, {
  143. text: '资金账户',
  144. dataIndex: 'pd_bankname',
  145. width: 200.0,
  146. allowBlank: false,
  147. editor: {
  148. xtype: 'bandinfoDbfindTrigger'
  149. }
  150. }, {
  151. text: '资金账户编号',
  152. dataIndex: 'pd_bankcode',
  153. hidden: true
  154. }, {
  155. text: "付款金额(元)",
  156. xtype: 'numbercolumn',
  157. dataIndex: "pd_amount",
  158. width: 110.0,
  159. allowBlank: false,
  160. editor: {
  161. xtype: "numberfield",
  162. decimalPrecision: 2,
  163. thousandSeparator: ','
  164. },
  165. renderer: function(v, m, r) {
  166. return saas.util.BaseUtil.numberFormat(v, 2, true);
  167. },
  168. summaryType: 'sum',
  169. summaryRenderer: function(v, d, f, m) {
  170. return saas.util.BaseUtil.numberFormat(v, 2, true);
  171. }
  172. }, {
  173. text: "结算方式",
  174. dataIndex: "pd_paymethod",
  175. width: 150.0,
  176. editor: {
  177. xtype: 'combo',
  178. queryMode: 'local',
  179. displayField: 'display',
  180. valueField: 'value',
  181. store: Ext.create('Ext.data.Store', {
  182. fields: ['value', 'display'],
  183. data: [{
  184. value: "信用卡",
  185. display: "信用卡"
  186. }, {
  187. value: "支票",
  188. display: "支票"
  189. }, {
  190. value: "汇票",
  191. display: "汇票"
  192. }, {
  193. value: "现金",
  194. display: "现金"
  195. }, {
  196. value: "银行转账",
  197. display: "银行转账"
  198. }, {
  199. value: "支付宝转账",
  200. display: "支付宝转账"
  201. }, {
  202. value: "微信转账",
  203. display: "微信转账"
  204. }]
  205. })
  206. }
  207. }, {
  208. text: "结算号",
  209. dataIndex: "pd_paycode",
  210. editor: {
  211. xtype: 'textfield'
  212. }
  213. }, {
  214. text: "备注",
  215. dataIndex: "pd_remark",
  216. width: 250,
  217. editor: {
  218. xtype: 'textfield'
  219. }
  220. }, {
  221. dataIndex: "pd_text1",
  222. text: "自定义字段1",
  223. width: 100,
  224. hidden: true,
  225. initHidden: false,
  226. editor: {
  227. xtype: "textfield"
  228. },
  229. }, {
  230. dataIndex: "pd_text2",
  231. text: "自定义字段2",
  232. width: 100,
  233. hidden: true,
  234. initHidden: false,
  235. editor: {
  236. xtype: "textfield"
  237. },
  238. }, {
  239. dataIndex: "pd_text3",
  240. text: "自定义字段3",
  241. width: 100,
  242. hidden: true,
  243. initHidden: false,
  244. editor: {
  245. xtype: "textfield"
  246. },
  247. }, {
  248. dataIndex: "pd_text4",
  249. text: "自定义字段4",
  250. width: 100,
  251. hidden: true,
  252. initHidden: false,
  253. editor: {
  254. xtype: "textfield"
  255. },
  256. }, {
  257. dataIndex: "pd_text5",
  258. text: "自定义字段5",
  259. width: 100,
  260. hidden: true,
  261. initHidden: false,
  262. editor: {
  263. xtype: "textfield"
  264. },
  265. }]
  266. }, {
  267. xtype: "detailGridField",
  268. name: 'detail2',
  269. storeModel: 'saas.model.money.PayBalance2',
  270. detnoColumn: 'pbd_detno',
  271. allowEmpty: true,
  272. deleteDetailUrl: '/api/money/paybalance/deleteDetail2',
  273. columns: [{
  274. text: 'ID',
  275. dataIndex: 'id',
  276. hidden: true
  277. }, {
  278. text: '期间',
  279. dataIndex: 'pbd_ym',
  280. hidden: true
  281. }, {
  282. text: '来源ID',
  283. dataIndex: 'pbd_slid',
  284. hidden: true
  285. }, {
  286. text: '来源单号',
  287. dataIndex: 'pbd_slcode',
  288. width: 150,
  289. editor: {
  290. displayField: "display",
  291. editable: true,
  292. format: "",
  293. hideTrigger: false,
  294. maxLength: 100.0,
  295. minValue: null,
  296. positiveNum: false,
  297. queryMode: "local",
  298. store: null,
  299. valueField: "value",
  300. xtype: "oriOrderMutiDbfindTrigger",
  301. // listeners: {
  302. // beforetriggerclick: 'vendnamechange'
  303. // }
  304. },
  305. }, {
  306. text: "业务类型",
  307. dataIndex: "pbd_slkind",
  308. width: 110
  309. }, {
  310. text: "单据日期",
  311. dataIndex: "pbd_sldate",
  312. xtype: 'datecolumn',
  313. width: 110
  314. }, {
  315. text: "单据金额(元)",
  316. xtype: 'numbercolumn',
  317. dataIndex: "pbd_amount",
  318. width: 110,
  319. renderer: function(v, m, r) {
  320. return saas.util.BaseUtil.numberFormat(v, 2, true);
  321. },
  322. summaryType: 'sum',
  323. summaryRenderer: function(v, d, f, m) {
  324. return saas.util.BaseUtil.numberFormat(v, 2, true);
  325. }
  326. }, {
  327. text: "已核销金额(元)",
  328. xtype: 'numbercolumn',
  329. dataIndex: "sl_yamount",
  330. width: 120,
  331. ignore: true,
  332. renderer: function(v, m, r) {
  333. return saas.util.BaseUtil.numberFormat(v, 2, true);
  334. },
  335. summaryType: 'sum',
  336. summaryRenderer: function(v, d, f, m) {
  337. return saas.util.BaseUtil.numberFormat(v, 2, true);
  338. }
  339. }, {
  340. text: "未核销金额(元)",
  341. xtype: 'numbercolumn',
  342. dataIndex: "sl_namount",
  343. ignore: true,
  344. width: 120,
  345. renderer: function(v, m, r) {
  346. return saas.util.BaseUtil.numberFormat(v, 2, true);
  347. },
  348. summaryType: 'sum',
  349. summaryRenderer: function(v, d, f, m) {
  350. return saas.util.BaseUtil.numberFormat(v, 2, true);
  351. }
  352. }, {
  353. text: "本次核销金额(元)",
  354. xtype: 'numbercolumn',
  355. dataIndex: "pbd_nowbalance",
  356. width: 140,
  357. editor: {
  358. xtype: "numberfield",
  359. decimalPrecision: 2
  360. },
  361. allowBlank: false,
  362. renderer: function(v, m, r) {
  363. return saas.util.BaseUtil.numberFormat(v, 2, true);
  364. },
  365. summaryType: 'sum',
  366. summaryRenderer: function(v, d, f, m) {
  367. return saas.util.BaseUtil.numberFormat(v, 2, true);
  368. }
  369. }, {
  370. text: '备注',
  371. dataIndex: 'pbd_remark',
  372. width: 250,
  373. hidden: true
  374. }, {
  375. dataIndex: "pbd_text1",
  376. text: "自定义字段1",
  377. width: 100,
  378. hidden: true,
  379. initHidden: false,
  380. editor: {
  381. xtype: "textfield"
  382. },
  383. }, {
  384. dataIndex: "pbd_text2",
  385. text: "自定义字段2",
  386. width: 100,
  387. hidden: true,
  388. initHidden: false,
  389. editor: {
  390. xtype: "textfield"
  391. },
  392. }, {
  393. dataIndex: "pbd_text3",
  394. text: "自定义字段3",
  395. width: 100,
  396. hidden: true,
  397. initHidden: false,
  398. editor: {
  399. xtype: "textfield"
  400. },
  401. }, {
  402. dataIndex: "pbd_text4",
  403. text: "自定义字段4",
  404. width: 100,
  405. hidden: true,
  406. initHidden: false,
  407. editor: {
  408. xtype: "textfield"
  409. },
  410. }, {
  411. dataIndex: "pbd_text5",
  412. text: "自定义字段5",
  413. width: 100,
  414. hidden: true,
  415. initHidden: false,
  416. editor: {
  417. xtype: "textfield"
  418. },
  419. }]
  420. }, {
  421. xtype: 'textfield',
  422. name: 'pb_remark',
  423. columnWidth: 1,
  424. fieldLabel: '备注'
  425. }, {
  426. xtype: "hidden",
  427. name: "creatorId",
  428. fieldLabel: "录入人ID",
  429. readOnly: true
  430. }, {
  431. xtype: "textfield",
  432. name: "creatorName",
  433. fieldLabel: "录入人",
  434. readOnly: true
  435. }, {
  436. xtype: "datefield",
  437. name: "createTime",
  438. fieldLabel: "录入日期",
  439. readOnly: true,
  440. defaultValue: new Date()
  441. }, {
  442. xtype: "hidden",
  443. name: "updaterId",
  444. fieldLabel: "更新人ID",
  445. readOnly: true
  446. }, {
  447. xtype: "hidden",
  448. name: "updaterName",
  449. fieldLabel: "更新人",
  450. readOnly: true
  451. }, {
  452. xtype: "hidden",
  453. name: "updateTime",
  454. fieldLabel: "更新日期",
  455. readOnly: true,
  456. defaultValue: new Date()
  457. }, {
  458. xtype: 'textfield',
  459. name: 'pb_auditman',
  460. fieldLabel: '审核人',
  461. readOnly: true
  462. }, {
  463. xtype: "datefield",
  464. name: "pb_auditdate",
  465. fieldLabel: "审核日期",
  466. readOnly: true
  467. }, {
  468. xtype: "textfield",
  469. name: "pb_text1",
  470. fieldLabel: "自定义字段1",
  471. hidden: true,
  472. initHidden: false
  473. }, {
  474. xtype: "textfield",
  475. name: "pb_text2",
  476. fieldLabel: "自定义字段2",
  477. hidden: true,
  478. initHidden: false
  479. }, {
  480. xtype: "textfield",
  481. name: "pb_text3",
  482. fieldLabel: "自定义字段3",
  483. hidden: true,
  484. initHidden: false
  485. }, {
  486. xtype: "textfield",
  487. name: "pb_text4",
  488. fieldLabel: "自定义字段4",
  489. hidden: true,
  490. initHidden: false
  491. }, {
  492. xtype: "textfield",
  493. name: "pb_text5",
  494. fieldLabel: "自定义字段5",
  495. hidden: true,
  496. initHidden: false
  497. }],
  498. });
  499. this.callParent(arguments);
  500. },
  501. beforeAudit: function () {
  502. var form = this,
  503. idField = form._idField,
  504. controller = form.getController(),
  505. viewModel = form.getViewModel(),
  506. id = viewModel.get(idField);
  507. store1 = viewModel.get('detail0').detailStore,
  508. store2 = viewModel.get('detail1').detailStore;
  509. // 已保存过的单据不进行此项校验
  510. if (id) {
  511. return true;
  512. }
  513. var sum_pd_amount = store1.sum('pd_amount'); // 付款金额合计
  514. var pb_discounts = viewModel.get('pb_discounts'); // 折扣金额
  515. var sum_pbd_nowbalance = store2.sum('pbd_nowbalance'); // 本次核销金额合计
  516. var flag = sum_pd_amount + pb_discounts - sum_pbd_nowbalance;
  517. viewModel.set("pb_preamount", flag);
  518. if (flag != 0) {
  519. var t = flag > 0 ? '大' : '小';
  520. saas.util.BaseUtil.showConfirm('提示', '付款金额' + t + '于本次核销金额,是否仍要保存并审核?')
  521. .then(function (y) {
  522. if (y == 'yes') {
  523. controller.audit();
  524. }
  525. });
  526. } else {
  527. controller.audit();
  528. }
  529. return false;
  530. }
  531. });