FormPanel.js 19 KB

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