FormPanel.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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. defaultItems: [{
  23. xtype: 'hidden',
  24. name: 'id',
  25. fieldLabel: 'id'
  26. }, {
  27. xtype: 'hidden',
  28. name: 'rb_custid',
  29. fieldLabel: '客户ID'
  30. }, {
  31. xtype: 'hidden',
  32. name: 'rb_kind',
  33. fieldLabel: '单据类型',
  34. defaultValue: '收款单',
  35. readOnly: true
  36. }, {
  37. xtype: 'hidden',
  38. name: 'rb_custcode',
  39. fieldLabel: '客户编号'
  40. }, {
  41. xtype: "customerDbfindTrigger",
  42. name: "rb_custname",
  43. fieldLabel: "客户名称",
  44. allowBlank : false,
  45. listeners: {
  46. change: 'clearDetails'
  47. }
  48. }, {
  49. xtype: "numberfield",
  50. name: "cu_leftamount",
  51. fieldLabel: "总欠款",
  52. ignore: true,
  53. readOnly: true
  54. }, {
  55. xtype: 'hidden',
  56. name: 'rb_rbdamount',
  57. fieldLabel: '本次核销金额(元)'
  58. },{
  59. xtype: 'hidden',
  60. name: 'rb_rdamount',
  61. fieldLabel: '本次付款金额(元)',
  62. }, {
  63. xtype: "datefield",
  64. name: "rb_date",
  65. fieldLabel: "日期",
  66. defaultValue: new Date(),
  67. allowBlank : false
  68. }, {
  69. xtype: "textfield",
  70. name: "rb_manname",
  71. fieldLabel: "收款人",
  72. defaultValue: saas.util.BaseUtil.getCurrentUser().realname
  73. }, {
  74. xtype: "numberfield",
  75. name: "rb_discounts",
  76. fieldLabel: "整单折扣",
  77. hidden: true
  78. }, {
  79. xtype: 'numberfield',
  80. name: 'rb_preamount',
  81. fieldLabel : '本次预收款',
  82. readOnly: true
  83. }, {
  84. xtype: 'hidden',
  85. name: 'rb_havebalance',
  86. fieldLabel: '已核销金额(元)'
  87. }, {
  88. xtype: "detailGridField",
  89. storeModel: 'saas.model.money.RecBalance1',
  90. detnoColumn: 'rd_detno',
  91. deleteDetailUrl: '/api/money/recbalance/deleteDetail1',
  92. columns: [{
  93. text: 'ID',
  94. dataIndex: 'id',
  95. hidden: true
  96. }, {
  97. text: '期间',
  98. dataIndex: 'rd_ym',
  99. defaultValue: Ext.Date.format(new Date(), 'Ym'),
  100. width : 110,
  101. hidden: true
  102. }, {
  103. text: '资金账户ID',
  104. dataIndex: 'rd_bankid',
  105. editor: {
  106. xtype: 'numberfield'
  107. },
  108. hidden: true
  109. }, {
  110. text: '资金账户编号',
  111. dataIndex: 'rd_bankcode',
  112. editor: {
  113. xtype: 'textfield'
  114. },
  115. hidden: true
  116. }, {
  117. text: '资金账户',
  118. dataIndex: 'rd_bankname',
  119. allowBlank : false,
  120. width: 200,
  121. editor:{
  122. xtype:'bandinfoDbfindTrigger'
  123. }
  124. }, {
  125. text: "收款金额(元)",
  126. xtype: 'numbercolumn',
  127. dataIndex: "rd_amount",
  128. width : 110.0,
  129. allowBlank : false,
  130. editor : {
  131. xtype : "numberfield",
  132. decimalPrecision: 2
  133. },
  134. renderer : function(v) {
  135. return saas.util.BaseUtil.numberFormat(v, 2, true);
  136. },
  137. summaryType: 'sum',
  138. summaryRenderer: function(v) {
  139. return saas.util.BaseUtil.numberFormat(v, 2, true);
  140. }
  141. }, {
  142. text: "结算方式",
  143. dataIndex: "rd_paymethod",
  144. width : 150.0,
  145. editor : {
  146. xtype:'combo',
  147. queryMode: 'local',
  148. displayField: 'display',
  149. valueField: 'value',
  150. store:Ext.create('Ext.data.Store', {
  151. fields: ['value', 'display'],
  152. data : [
  153. {value:"信用卡", display:"信用卡"},
  154. {value:"支票", display:"支票"},
  155. {value:"汇票", display:"汇票"},
  156. {value:"现金", display:"现金"},
  157. {value:"银行转账", display:"银行转账"},
  158. {value:"支付宝转账", display:"支付宝转账"},
  159. {value:"微信转账", display:"微信转账"}
  160. ]
  161. })
  162. }
  163. }, {
  164. text: "结算号",
  165. dataIndex: "rd_paycode",
  166. editor: {
  167. xtype: 'textfield'
  168. }
  169. }, {
  170. text: "备注",
  171. dataIndex: "rd_remark",
  172. width: 250,
  173. editor: {
  174. xtype: 'textfield'
  175. }
  176. }]
  177. },{
  178. xtype: "detailGridField",
  179. storeModel: 'saas.model.money.RecBalance2',
  180. detnoColumn: 'rbd_detno',
  181. allowEmpty: true,
  182. deleteDetailUrl: '/api/money/recbalance/deleteDetail2',
  183. columns: [{
  184. text: 'ID',
  185. dataIndex: 'id',
  186. hidden: true
  187. }, {
  188. text: '期间',
  189. dataIndex: 'rbd_ym',
  190. editor: {
  191. xtype: 'numberfield'
  192. },
  193. hidden: true
  194. }, {
  195. text: '来源ID',
  196. dataIndex: 'rbd_slid',
  197. editor: {
  198. xtype: 'numberfield'
  199. },
  200. hidden: true
  201. }, {
  202. text: '来源单号',
  203. dataIndex: 'rbd_slcode',
  204. width: 200,
  205. editor:{
  206. displayField : "display",
  207. editable : true,
  208. format : "",
  209. hideTrigger : false,
  210. maxLength : 100.0,
  211. minValue : null,
  212. positiveNum : false,
  213. queryMode : "local",
  214. store : null,
  215. valueField : "value",
  216. xtype : "oriOrderMutiDbfindTrigger",
  217. listeners:{
  218. beforetriggerclick:'custnamechange'
  219. }
  220. }
  221. }, {
  222. text: "业务类型",
  223. dataIndex: "rbd_slkind",
  224. width:110
  225. }, {
  226. text: "单据日期",
  227. dataIndex: "rbd_sldate",
  228. xtype: 'datecolumn',
  229. width:110
  230. }, {
  231. text: "单据金额(元)",
  232. xtype: 'numbercolumn',
  233. dataIndex: "rbd_amount",
  234. width:110,
  235. renderer : function(v) {
  236. return saas.util.BaseUtil.numberFormat(v, 2, true);
  237. },
  238. summaryType: 'sum',
  239. summaryRenderer: function(v) {
  240. return saas.util.BaseUtil.numberFormat(v, 2, true);
  241. }
  242. }, {
  243. text: "已核销金额(元)",
  244. xtype: 'numbercolumn',
  245. dataIndex: "sl_yamount",
  246. width:120,
  247. ignore:true,
  248. renderer : function(v) {
  249. return saas.util.BaseUtil.numberFormat(v, 2, true);
  250. },
  251. summaryType: 'sum',
  252. summaryRenderer: function(v) {
  253. return saas.util.BaseUtil.numberFormat(v, 2, true);
  254. }
  255. }, {
  256. text: "未核销金额(元)",
  257. xtype: 'numbercolumn',
  258. dataIndex: "sl_namount",
  259. width:120,
  260. ignore:true,
  261. renderer : function(v) {
  262. return saas.util.BaseUtil.numberFormat(v, 2, true);
  263. },
  264. summaryType: 'sum',
  265. summaryRenderer: function(v) {
  266. return saas.util.BaseUtil.numberFormat(v, 2, true);
  267. }
  268. }, {
  269. text: "本次核销金额(元)",
  270. xtype: 'numbercolumn',
  271. dataIndex: "rbd_nowbalance",
  272. width:140,
  273. editor : {
  274. xtype : "numberfield",
  275. decimalPrecision: 2
  276. },
  277. allowBlank : false,
  278. renderer : function(v) {
  279. return saas.util.BaseUtil.numberFormat(v, 2, true);
  280. },
  281. summaryType: 'sum',
  282. summaryRenderer: function(v) {
  283. return saas.util.BaseUtil.numberFormat(v, 2, true);
  284. }
  285. }]
  286. }, {
  287. xtype: 'textfield',
  288. name: 'rb_remark',
  289. fieldLabel: '备注',
  290. columnWidth: 1
  291. },{
  292. xtype : "hidden",
  293. name : "creatorId",
  294. fieldLabel : "录入人ID",
  295. readOnly:true
  296. },
  297. {
  298. xtype : "textfield",
  299. name : "creatorName",
  300. fieldLabel : "录入人",
  301. readOnly:true
  302. }, {
  303. xtype : "datefield",
  304. name : "createTime",
  305. fieldLabel : "录入日期",
  306. readOnly:true,
  307. defaultValue: new Date()
  308. },{
  309. xtype : "hidden",
  310. name : "updaterId",
  311. fieldLabel : "更新人ID",
  312. readOnly:true
  313. },{
  314. xtype : "hidden",
  315. name : "updaterName",
  316. fieldLabel : "更新人",
  317. readOnly:true
  318. }, {
  319. xtype : "hidden",
  320. name : "updateTime",
  321. fieldLabel : "更新日期",
  322. readOnly:true,
  323. defaultValue: new Date()
  324. }, {
  325. xtype: 'textfield',
  326. name: 'rb_auditman',
  327. fieldLabel: '审核人',
  328. readOnly: true
  329. },{
  330. xtype: "datefield",
  331. name: "rb_auditdate",
  332. fieldLabel: "审核日期",
  333. readOnly: true
  334. }],
  335. beforeAudit: function() {
  336. var form = this,
  337. idField = form._idField,
  338. controller = form.getController(),
  339. viewModel = form.getViewModel(),
  340. id = viewModel.get(idField);
  341. store1 = viewModel.get('detail0').detailStore,
  342. store2 = viewModel.get('detail1').detailStore;
  343. // 已保存过的单据不进行此项校验
  344. if(id) {
  345. return true;
  346. }
  347. var sum_rd_amount = store1.sum('rd_amount'); // 付款金额合计
  348. var rb_discounts = viewModel.get('rb_discounts'); // 折扣金额
  349. var sum_rbd_nowbalance = store2.sum('rbd_nowbalance'); // 本次核销金额合计
  350. var flag = sum_rd_amount + rb_discounts - sum_rbd_nowbalance;
  351. viewModel.set("rb_preamount",flag);
  352. if(flag != 0) {
  353. var t = flag > 0 ? '大' : '小';
  354. saas.util.BaseUtil.showConfirm('提示', '付款金额' + t + '于本次核销金额,是否仍要保存并审核?')
  355. .then(function(y) {
  356. if(y == 'yes') {
  357. controller.audit();
  358. }
  359. });
  360. }else {
  361. controller.audit();
  362. }
  363. return false;
  364. }
  365. });