FormPanel.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. Ext.define('saas.view.money.recBalance.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: 'money-recbalance-formpanel',
  4. controller: 'money-recbalance-formpanel',
  5. viewModel: 'money-recbalance-formpanel',
  6. viewName: 'money-recbalance-formpanel',
  7. caller: 'RecBalance',
  8. //字段属性
  9. _title: '收款单',
  10. _idField: 'id',
  11. _codeField: 'rb_code',
  12. _statusField: 'rb_status',
  13. _statusCodeField: 'rb_statuscode',
  14. _auditmanField: 'rb_auditman',
  15. _auditdateField: 'rb_auditdate',
  16. _readUrl: '/api/money/recbalance/read',
  17. _saveUrl: '/api/money/recbalance/save',
  18. _auditUrl: '/api/money/recbalance/audit',
  19. _unAuditUrl: '/api/money/recbalance/unAudit',
  20. _deleteUrl: '/api/money/recbalance/delete',
  21. initId: 0,
  22. initComponent: function () {
  23. Ext.apply(this, {
  24. defaultItems: [{
  25. xtype: 'hidden',
  26. name: 'id',
  27. fieldLabel: 'id'
  28. }, {
  29. xtype: 'hidden',
  30. name: 'rb_custid',
  31. fieldLabel: '客户ID'
  32. }, {
  33. xtype: 'hidden',
  34. name: 'rb_kind',
  35. fieldLabel: '单据类型',
  36. defaultValue: '收款单',
  37. readOnly: true
  38. }, {
  39. xtype: 'hidden',
  40. name: 'rb_custcode',
  41. fieldLabel: '客户编号'
  42. }, {
  43. xtype: "customerDbfindTrigger",
  44. name: "rb_custname",
  45. fieldLabel: "客户名称",
  46. allowBlank: false,
  47. columnWidth: 0.5,
  48. listeners: {
  49. change: 'clearDetails'
  50. }
  51. }, {
  52. xtype: 'condbfindtrigger',
  53. fieldLabel: '币别汇率',
  54. allowBlank: false,
  55. dbType: 'currencyDbfindTrigger',
  56. dbfinds: [{
  57. from: 'cr_name', to: 'rb_currency'
  58. }, {
  59. from: 'cr_rate', to: 'rb_rate'
  60. }],
  61. listeners: {
  62. change: 'clearDetails'
  63. },
  64. supFieldConfig: {
  65. xtype: 'numberfield',
  66. readOnly: false,
  67. defaultReadOnly: false,
  68. decimalPrecision: 6,
  69. vtype: 'positiveNumber',
  70. listeners: {
  71. change: function(f, v) {
  72. var defaultCurrency = Ext.getCmp('mainView').getViewModel().get('defaultCurrency');
  73. f.setReadOnly(f.ownerCt.items.items[0].value == defaultCurrency);
  74. }
  75. }
  76. }
  77. },{
  78. xtype: "datefield",
  79. name: "rb_date",
  80. fieldLabel: "日期",
  81. defaultValue: new Date(),
  82. allowBlank: false
  83. }, {
  84. xtype: "textfield",
  85. name: "rb_manname",
  86. fieldLabel: "收款人",
  87. defaultValue: saas.util.BaseUtil.getCurrentUser().realname
  88. }, {
  89. xtype: "numberfield",
  90. name: "cu_leftamount",
  91. fieldLabel: "总欠款(元)",
  92. thousandSeparator: ',',
  93. ignore: true,
  94. readOnly: true
  95. }, {
  96. xtype: 'hidden',
  97. name: 'rb_rbdamount',
  98. fieldLabel: '本次核销金额(元)',
  99. thousandSeparator: ',',
  100. hidden: true
  101. }, {
  102. xtype: 'hidden',
  103. name: 'rb_rdamount',
  104. fieldLabel: '本次付款金额(元)',
  105. thousandSeparator: ',',
  106. hidden: true
  107. }, {
  108. xtype: "numberfield",
  109. name: "rb_discounts",
  110. fieldLabel: "整单折扣",
  111. hidden: true
  112. }, {
  113. xtype: 'numberfield',
  114. name: 'rb_preamount',
  115. fieldLabel: '本次预收(元)',
  116. thousandSeparator: ',',
  117. readOnly: true
  118. }, {
  119. xtype: 'numberfield',
  120. name: 'rb_havebalance',
  121. fieldLabel: '已核销金额(元)',
  122. hidden: true
  123. }, {
  124. xtype: "detailGridField",
  125. name: 'detail1',
  126. storeModel: 'saas.model.money.RecBalance1',
  127. detnoColumn: 'rd_detno',
  128. deleteDetailUrl: '/api/money/recbalance/deleteDetail1',
  129. columns: [{
  130. text: 'ID',
  131. dataIndex: 'id',
  132. hidden: true
  133. }, {
  134. text: '期间',
  135. dataIndex: 'rd_ym',
  136. defaultValue: Ext.Date.format(new Date(), 'Ym'),
  137. width: 110,
  138. hidden: true
  139. }, {
  140. text: '资金账户ID',
  141. dataIndex: 'rd_bankid',
  142. editor: {
  143. xtype: 'numberfield'
  144. },
  145. hidden: true
  146. }, {
  147. text: '资金账户编号',
  148. dataIndex: 'rd_bankcode',
  149. editor: {
  150. xtype: 'textfield'
  151. },
  152. hidden: true
  153. }, {
  154. text: '资金账户',
  155. dataIndex: 'rd_bankname',
  156. allowBlank: false,
  157. width: 200,
  158. editor: {
  159. xtype: 'bandinfoDbfindTrigger'
  160. }
  161. }, {
  162. text: "收款金额(元)",
  163. xtype: 'numbercolumn',
  164. dataIndex: "rd_amount",
  165. width: 110.0,
  166. allowBlank: false,
  167. editor: {
  168. xtype: "numberfield",
  169. decimalPrecision: 2
  170. },
  171. renderer: function(v, m, r) {
  172. return saas.util.BaseUtil.numberFormat(v, 2, true);
  173. },
  174. summaryType: 'sum',
  175. summaryRenderer: function(v, d, f, m) {
  176. return saas.util.BaseUtil.numberFormat(v, 2, true);
  177. }
  178. }, {
  179. text: "结算方式",
  180. dataIndex: "rd_paymethod",
  181. width: 150.0,
  182. editor: {
  183. xtype: 'combo',
  184. queryMode: 'local',
  185. displayField: 'display',
  186. valueField: 'value',
  187. store: Ext.create('Ext.data.Store', {
  188. fields: ['value', 'display'],
  189. data: [{
  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. value: "支付宝转账",
  206. display: "支付宝转账"
  207. }, {
  208. value: "微信转账",
  209. display: "微信转账"
  210. }]
  211. })
  212. }
  213. }, {
  214. text: "结算号",
  215. dataIndex: "rd_paycode",
  216. editor: {
  217. xtype: 'textfield'
  218. }
  219. }, {
  220. text: "备注",
  221. dataIndex: "rd_remark",
  222. width: 250,
  223. editor: {
  224. xtype: 'textfield'
  225. }
  226. }, {
  227. dataIndex: "rd_text1",
  228. text: "自定义字段1",
  229. width: 100,
  230. hidden: true,
  231. initHidden: false,
  232. editor: {
  233. xtype: "textfield"
  234. },
  235. }, {
  236. dataIndex: "rd_text2",
  237. text: "自定义字段2",
  238. width: 100,
  239. hidden: true,
  240. initHidden: false,
  241. editor: {
  242. xtype: "textfield"
  243. },
  244. }, {
  245. dataIndex: "rd_text3",
  246. text: "自定义字段3",
  247. width: 100,
  248. hidden: true,
  249. initHidden: false,
  250. editor: {
  251. xtype: "textfield"
  252. },
  253. }, {
  254. dataIndex: "rd_text4",
  255. text: "自定义字段4",
  256. width: 100,
  257. hidden: true,
  258. initHidden: false,
  259. editor: {
  260. xtype: "textfield"
  261. },
  262. }, {
  263. dataIndex: "rd_text5",
  264. text: "自定义字段5",
  265. width: 100,
  266. hidden: true,
  267. initHidden: false,
  268. editor: {
  269. xtype: "textfield"
  270. },
  271. }]
  272. }, {
  273. xtype: "detailGridField",
  274. name: 'detail2',
  275. storeModel: 'saas.model.money.RecBalance2',
  276. detnoColumn: 'rbd_detno',
  277. allowEmpty: true,
  278. deleteDetailUrl: '/api/money/recbalance/deleteDetail2',
  279. columns: [{
  280. text: 'ID',
  281. dataIndex: 'id',
  282. hidden: true
  283. }, {
  284. text: '期间',
  285. dataIndex: 'rbd_ym',
  286. editor: {
  287. xtype: 'numberfield'
  288. },
  289. hidden: true
  290. }, {
  291. text: '来源ID',
  292. dataIndex: 'rbd_slid',
  293. editor: {
  294. xtype: 'numberfield'
  295. },
  296. hidden: true
  297. }, {
  298. text: '来源单号',
  299. dataIndex: 'rbd_slcode',
  300. width: 200,
  301. editor: {
  302. displayField: "display",
  303. editable: true,
  304. format: "",
  305. hideTrigger: false,
  306. maxLength: 100.0,
  307. minValue: null,
  308. positiveNum: false,
  309. queryMode: "local",
  310. store: null,
  311. valueField: "value",
  312. xtype: "oriOrderMutiDbfindTrigger",
  313. listeners: {
  314. beforetriggerclick: 'custnamechange'
  315. }
  316. }
  317. }, {
  318. text: "业务类型",
  319. dataIndex: "rbd_slkind",
  320. width: 110
  321. }, {
  322. text: "单据日期",
  323. dataIndex: "rbd_sldate",
  324. xtype: 'datecolumn',
  325. width: 110
  326. }, {
  327. text: "单据金额(元)",
  328. xtype: 'numbercolumn',
  329. dataIndex: "rbd_amount",
  330. width: 110,
  331. renderer: function(v, m, r) {
  332. return saas.util.BaseUtil.numberFormat(v, 2, true);
  333. },
  334. summaryType: 'sum',
  335. summaryRenderer: function(v, d, f, m) {
  336. return saas.util.BaseUtil.numberFormat(v, 2, true);
  337. }
  338. }, {
  339. text: "已核销金额(元)",
  340. xtype: 'numbercolumn',
  341. dataIndex: "sl_yamount",
  342. width: 120,
  343. ignore: true,
  344. renderer: function(v, m, r) {
  345. return saas.util.BaseUtil.numberFormat(v, 2, true);
  346. },
  347. summaryType: 'sum',
  348. summaryRenderer: function(v, d, f, m) {
  349. return saas.util.BaseUtil.numberFormat(v, 2, true);
  350. }
  351. }, {
  352. text: "未核销金额(元)",
  353. xtype: 'numbercolumn',
  354. dataIndex: "sl_namount",
  355. width: 120,
  356. ignore: true,
  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. xtype: 'numbercolumn',
  367. dataIndex: "rbd_nowbalance",
  368. width: 140,
  369. editor: {
  370. xtype: "numberfield",
  371. decimalPrecision: 2
  372. },
  373. allowBlank: false,
  374. renderer: function(v, m, r) {
  375. return saas.util.BaseUtil.numberFormat(v, 2, true);
  376. },
  377. summaryType: 'sum',
  378. summaryRenderer: function(v, d, f, m) {
  379. return saas.util.BaseUtil.numberFormat(v, 2, true);
  380. }
  381. }, {
  382. dataIndex: "rbd_text1",
  383. text: "自定义字段1",
  384. width: 100,
  385. hidden: true,
  386. initHidden: false,
  387. editor: {
  388. xtype: "textfield"
  389. },
  390. }, {
  391. dataIndex: "rbd_text2",
  392. text: "自定义字段2",
  393. width: 100,
  394. hidden: true,
  395. initHidden: false,
  396. editor: {
  397. xtype: "textfield"
  398. },
  399. }, {
  400. dataIndex: "rbd_text3",
  401. text: "自定义字段3",
  402. width: 100,
  403. hidden: true,
  404. initHidden: false,
  405. editor: {
  406. xtype: "textfield"
  407. },
  408. }, {
  409. dataIndex: "rbd_text4",
  410. text: "自定义字段4",
  411. width: 100,
  412. hidden: true,
  413. initHidden: false,
  414. editor: {
  415. xtype: "textfield"
  416. },
  417. }, {
  418. dataIndex: "rbd_text5",
  419. text: "自定义字段5",
  420. width: 100,
  421. hidden: true,
  422. initHidden: false,
  423. editor: {
  424. xtype: "textfield"
  425. },
  426. }]
  427. }, {
  428. xtype: 'textfield',
  429. name: 'rb_remark',
  430. fieldLabel: '备注',
  431. columnWidth: 1
  432. }, {
  433. xtype: "hidden",
  434. name: "creatorId",
  435. fieldLabel: "录入人ID",
  436. readOnly: true
  437. }, {
  438. xtype: "textfield",
  439. name: "creatorName",
  440. fieldLabel: "录入人",
  441. readOnly: true
  442. }, {
  443. xtype: "datefield",
  444. name: "createTime",
  445. fieldLabel: "录入日期",
  446. readOnly: true,
  447. defaultValue: new Date()
  448. }, {
  449. xtype: "hidden",
  450. name: "updaterId",
  451. fieldLabel: "更新人ID",
  452. readOnly: true
  453. }, {
  454. xtype: "hidden",
  455. name: "updaterName",
  456. fieldLabel: "更新人",
  457. readOnly: true
  458. }, {
  459. xtype: "hidden",
  460. name: "updateTime",
  461. fieldLabel: "更新日期",
  462. readOnly: true,
  463. defaultValue: new Date()
  464. }, {
  465. xtype: 'textfield',
  466. name: 'rb_auditman',
  467. fieldLabel: '审核人',
  468. readOnly: true
  469. }, {
  470. xtype: "datefield",
  471. name: "rb_auditdate",
  472. fieldLabel: "审核日期",
  473. readOnly: true
  474. }, {
  475. xtype: "textfield",
  476. name: "rb_text1",
  477. fieldLabel: "自定义字段1",
  478. hidden: true,
  479. initHidden: false
  480. }, {
  481. xtype: "textfield",
  482. name: "rb_text2",
  483. fieldLabel: "自定义字段2",
  484. hidden: true,
  485. initHidden: false
  486. }, {
  487. xtype: "textfield",
  488. name: "rb_text3",
  489. fieldLabel: "自定义字段3",
  490. hidden: true,
  491. initHidden: false
  492. }, {
  493. xtype: "textfield",
  494. name: "rb_text4",
  495. fieldLabel: "自定义字段4",
  496. hidden: true,
  497. initHidden: false
  498. }, {
  499. xtype: "textfield",
  500. name: "rb_text5",
  501. fieldLabel: "自定义字段5",
  502. hidden: true,
  503. initHidden: false
  504. }],
  505. });
  506. this.callParent(arguments);
  507. },
  508. beforeAudit: function () {
  509. var form = this,
  510. idField = form._idField,
  511. controller = form.getController(),
  512. viewModel = form.getViewModel(),
  513. id = viewModel.get(idField);
  514. store1 = viewModel.get('detail0').detailStore,
  515. store2 = viewModel.get('detail1').detailStore;
  516. // 已保存过的单据不进行此项校验
  517. if (id) {
  518. return true;
  519. }
  520. var sum_rd_amount = store1.sum('rd_amount'); // 付款金额合计
  521. var rb_discounts = viewModel.get('rb_discounts'); // 折扣金额
  522. var sum_rbd_nowbalance = store2.sum('rbd_nowbalance'); // 本次核销金额合计
  523. var flag = sum_rd_amount + rb_discounts - sum_rbd_nowbalance;
  524. viewModel.set("rb_preamount", flag);
  525. if (flag != 0) {
  526. var t = flag > 0 ? '大' : '小';
  527. saas.util.BaseUtil.showConfirm('提示', '付款金额' + t + '于本次核销金额,是否仍要保存并审核?')
  528. .then(function (y) {
  529. if (y == 'yes') {
  530. controller.audit();
  531. }
  532. });
  533. } else {
  534. controller.audit();
  535. }
  536. return false;
  537. }
  538. });