FormPanel.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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.applyIf(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. storeModel: 'saas.model.money.PayBalance1',
  98. detnoColumn: 'pd_detno',
  99. deleteDetailUrl: '/api/money/paybalance/deleteDetail1',
  100. columns: [{
  101. text: 'ID',
  102. dataIndex: 'id',
  103. hidden: true
  104. }, {
  105. text: '期间',
  106. dataIndex: 'pd_ym',
  107. hidden: true,
  108. defaultValue: Ext.Date.format(new Date(), 'Ym'),
  109. width: 110.0
  110. }, {
  111. text: '结算账户ID',
  112. dataIndex: 'pd_bankid',
  113. hidden: true
  114. }, {
  115. text: '资金账户',
  116. dataIndex: 'pd_bankname',
  117. width: 200.0,
  118. allowBlank: false,
  119. editor: {
  120. xtype: 'bandinfoDbfindTrigger'
  121. }
  122. }, {
  123. text: '资金账户编号',
  124. dataIndex: 'pd_bankcode',
  125. hidden: true
  126. }, {
  127. text: "付款金额(元)",
  128. xtype: 'numbercolumn',
  129. dataIndex: "pd_amount",
  130. width: 110.0,
  131. allowBlank: false,
  132. editor: {
  133. xtype: "numberfield",
  134. decimalPrecision: 2,
  135. thousandSeparator: ','
  136. },
  137. renderer: function (v) {
  138. return saas.util.BaseUtil.numberFormat(v, 2, true);
  139. },
  140. summaryType: 'sum',
  141. summaryRenderer: function (v) {
  142. return saas.util.BaseUtil.numberFormat(v, 2, true);
  143. }
  144. }, {
  145. text: "结算方式",
  146. dataIndex: "pd_paymethod",
  147. width: 200.0,
  148. editor: {
  149. xtype: 'combo',
  150. queryMode: 'local',
  151. displayField: 'display',
  152. valueField: 'value',
  153. store: Ext.create('Ext.data.Store', {
  154. fields: ['value', 'display'],
  155. data: [{
  156. value: "信用卡",
  157. display: "信用卡"
  158. }, {
  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. })
  178. }
  179. }, {
  180. text: "结算号",
  181. dataIndex: "pd_paycode",
  182. width: 150.0,
  183. editor: {
  184. xtype: 'textfield'
  185. }
  186. }, {
  187. text: "备注",
  188. dataIndex: "pd_remark",
  189. width: 250,
  190. editor: {
  191. xtype: 'textfield'
  192. }
  193. }]
  194. }, {
  195. xtype: "detailGridField",
  196. storeModel: 'saas.model.money.PayBalance2',
  197. detnoColumn: 'pbd_detno',
  198. allowEmpty: true,
  199. deleteDetailUrl: '/api/money/paybalance/deleteDetail2',
  200. columns: [{
  201. text: 'ID',
  202. dataIndex: 'id',
  203. hidden: true
  204. }, {
  205. text: '期间',
  206. dataIndex: 'pbd_ym',
  207. hidden: true
  208. }, {
  209. text: '来源ID',
  210. dataIndex: 'pbd_slid',
  211. hidden: true
  212. }, {
  213. text: '来源单号',
  214. dataIndex: 'pbd_slcode',
  215. width: 150,
  216. editor: {
  217. displayField: "display",
  218. editable: true,
  219. format: "",
  220. hideTrigger: false,
  221. maxLength: 100.0,
  222. minValue: null,
  223. positiveNum: false,
  224. queryMode: "local",
  225. store: null,
  226. valueField: "value",
  227. xtype: "oriOrderMutiDbfindTrigger",
  228. listeners: {
  229. beforetriggerclick: 'vendnamechange'
  230. }
  231. },
  232. }, {
  233. text: "业务类型",
  234. dataIndex: "pbd_slkind",
  235. width: 110
  236. }, {
  237. text: "单据日期",
  238. dataIndex: "pbd_sldate",
  239. xtype: 'datecolumn',
  240. width: 110
  241. }, {
  242. text: "单据金额(元)",
  243. xtype: 'numbercolumn',
  244. dataIndex: "pbd_amount",
  245. width: 110,
  246. renderer: function (v) {
  247. return saas.util.BaseUtil.numberFormat(v, 2, true);
  248. },
  249. summaryType: 'sum',
  250. summaryRenderer: function (v) {
  251. return saas.util.BaseUtil.numberFormat(v, 2, true);
  252. }
  253. }, {
  254. text: "已核销金额(元)",
  255. xtype: 'numbercolumn',
  256. dataIndex: "sl_yamount",
  257. width: 120,
  258. ignore: true,
  259. renderer: function (v) {
  260. return saas.util.BaseUtil.numberFormat(v, 2, true);
  261. },
  262. summaryType: 'sum',
  263. summaryRenderer: function (v) {
  264. return saas.util.BaseUtil.numberFormat(v, 2, true);
  265. }
  266. }, {
  267. text: "未核销金额(元)",
  268. xtype: 'numbercolumn',
  269. dataIndex: "sl_namount",
  270. ignore: true,
  271. width: 120,
  272. renderer: function (v) {
  273. return saas.util.BaseUtil.numberFormat(v, 2, true);
  274. },
  275. summaryType: 'sum',
  276. summaryRenderer: function (v) {
  277. return saas.util.BaseUtil.numberFormat(v, 2, true);
  278. }
  279. }, {
  280. text: "本次核销金额(元)",
  281. xtype: 'numbercolumn',
  282. dataIndex: "pbd_nowbalance",
  283. width: 140,
  284. editor: {
  285. xtype: "numberfield",
  286. decimalPrecision: 2
  287. },
  288. allowBlank: false,
  289. renderer: function (v) {
  290. return saas.util.BaseUtil.numberFormat(v, 2, true);
  291. },
  292. summaryType: 'sum',
  293. summaryRenderer: function (v) {
  294. return saas.util.BaseUtil.numberFormat(v, 2, true);
  295. }
  296. }, {
  297. text: '备注',
  298. dataIndex: 'pbd_remark',
  299. width: 250,
  300. hidden: true
  301. }]
  302. }, {
  303. xtype: 'textfield',
  304. name: 'pb_remark',
  305. columnWidth: 1,
  306. fieldLabel: '备注'
  307. }, {
  308. xtype: "hidden",
  309. name: "creatorId",
  310. fieldLabel: "录入人ID",
  311. readOnly: true
  312. }, {
  313. xtype: "textfield",
  314. name: "creatorName",
  315. fieldLabel: "录入人",
  316. readOnly: true
  317. }, {
  318. xtype: "datefield",
  319. name: "createTime",
  320. fieldLabel: "录入日期",
  321. readOnly: true,
  322. defaultValue: new Date()
  323. }, {
  324. xtype: "hidden",
  325. name: "updaterId",
  326. fieldLabel: "更新人ID",
  327. readOnly: true
  328. }, {
  329. xtype: "hidden",
  330. name: "updaterName",
  331. fieldLabel: "更新人",
  332. readOnly: true
  333. }, {
  334. xtype: "hidden",
  335. name: "updateTime",
  336. fieldLabel: "更新日期",
  337. readOnly: true,
  338. defaultValue: new Date()
  339. }, {
  340. xtype: 'textfield',
  341. name: 'pb_auditman',
  342. fieldLabel: '审核人',
  343. readOnly: true
  344. }, {
  345. xtype: "datefield",
  346. name: "pb_auditdate",
  347. fieldLabel: "审核日期",
  348. readOnly: true
  349. }, {
  350. xtype: 'hidden',
  351. name: 'pb_text1',
  352. fieldLabel: '自定义字段1'
  353. }, {
  354. xtype: 'hidden',
  355. name: 'pb_text2',
  356. fieldLabel: '自定义字段2'
  357. }, {
  358. xtype: 'hidden',
  359. name: 'pb_text3',
  360. fieldLabel: '自定义字段3'
  361. }, {
  362. xtype: 'hidden',
  363. name: 'pb_text4',
  364. fieldLabel: '自定义字段4'
  365. }, {
  366. xtype: 'hidden',
  367. name: 'pb_text5',
  368. fieldLabel: '自定义字段5'
  369. }],
  370. });
  371. this.callParent(arguments);
  372. },
  373. beforeAudit: function () {
  374. var form = this,
  375. idField = form._idField,
  376. controller = form.getController(),
  377. viewModel = form.getViewModel(),
  378. id = viewModel.get(idField);
  379. store1 = viewModel.get('detail0').detailStore,
  380. store2 = viewModel.get('detail1').detailStore;
  381. // 已保存过的单据不进行此项校验
  382. if (id) {
  383. return true;
  384. }
  385. var sum_pd_amount = store1.sum('pd_amount'); // 付款金额合计
  386. var pb_discounts = viewModel.get('pb_discounts'); // 折扣金额
  387. var sum_pbd_nowbalance = store2.sum('pbd_nowbalance'); // 本次核销金额合计
  388. var flag = sum_pd_amount + pb_discounts - sum_pbd_nowbalance;
  389. viewModel.set("pb_preamount", flag);
  390. if (flag != 0) {
  391. var t = flag > 0 ? '大' : '小';
  392. saas.util.BaseUtil.showConfirm('提示', '付款金额' + t + '于本次核销金额,是否仍要保存并审核?')
  393. .then(function (y) {
  394. if (y == 'yes') {
  395. controller.audit();
  396. }
  397. });
  398. } else {
  399. controller.audit();
  400. }
  401. return false;
  402. }
  403. });