FormPanel.js 19 KB

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