FormPanel.js 19 KB

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