FormPanel.js 18 KB

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