FormPanel.js 18 KB

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