FormPanel.js 19 KB

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