FormPanel.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. Ext.define('saas.view.money.verification.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. // extend: 'Ext.panel.Panel',
  4. xtype: 'money-verification-formpanel',
  5. controller: 'money-verification-formpanel',
  6. viewModel: 'money-verification-formpanel',
  7. viewName: 'money-verification-formpanel',
  8. caller: 'Verification',
  9. //字段属性
  10. _title: '核销单',
  11. _idField: 'id',
  12. _codeField: 'vc_code',
  13. _statusField: 'vc_status',
  14. _statusCodeField: 'vc_statuscode',
  15. _auditmanField: 'vc_auditman',
  16. _auditdateField:'vc_auditdate',
  17. _readUrl: '/api/money/verification/read',
  18. _saveUrl: '/api/money/verification/save',
  19. _auditUrl: '/api/money/verification/audit',
  20. _unAuditUrl: '/api/money/verification/unAudit',
  21. _deleteUrl: '/api/money/verification/delete',
  22. defatulType: 'receipts_offset_receivable',
  23. etc: {
  24. /**
  25. * 预收:receipts
  26. * 预付:prepaid
  27. * 应收:receivable
  28. * 应付:payable
  29. */
  30. // base
  31. base: [{
  32. xtype: 'combo',
  33. name: 'vc_kind',
  34. fieldLabel: '业务类型',
  35. editable: false,
  36. store: [
  37. ['receipts_offset_receivable', '预收冲应收'],
  38. ['prepaid_offset_payable', '预付冲应付'],
  39. ['receivable_offset_payable', '应收冲应付'],
  40. ['receivable_to_receivable', '应收转应收'],
  41. ['payable_to_payable', '应付转应付']
  42. ],
  43. listeners:{
  44. beforerender:function(f){
  45. f.firstLoad = true;
  46. if(f.ownerCt.initId!=0){
  47. f.setReadOnly(true);
  48. f.setDisabled(true);
  49. }
  50. }
  51. }
  52. }],
  53. detail1: {
  54. xtype: "detailGridField",
  55. storeModel: 'saas.model.money.Verification1',
  56. detnoColumn: 'vd_detno',
  57. deleteDetailUrl: '/api/money/verification/deleteDetail1',
  58. columnWidth: 1,
  59. columns: [{
  60. text: 'ID',
  61. dataIndex: 'id',
  62. hidden: true
  63. }, {
  64. text: '来源ID',
  65. dataIndex: 'vd_slid',
  66. hidden: true
  67. }, {
  68. text: '来源单号',
  69. dataIndex: 'vd_slcode',
  70. width: 150,
  71. allowBlank:false,
  72. editor:{
  73. displayField : "display",
  74. editable : true,
  75. format : "",
  76. hideTrigger : false,
  77. maxLength : 100.0,
  78. minValue : null,
  79. positiveNum : false,
  80. queryMode : "local",
  81. store : null,
  82. valueField : "value",
  83. xtype : "oriOrderMutiDbfindTrigger"
  84. }
  85. }, {
  86. text: '业务类型',
  87. dataIndex: "vd_slkind",
  88. width: 110
  89. }, {
  90. text: "单据日期",
  91. dataIndex: "vd_sldate",
  92. xtype: 'datecolumn',
  93. width: 110
  94. }, {
  95. text: "单据金额",
  96. xtype: 'numbercolumn',
  97. dataIndex: "vd_amount",
  98. width: 110,
  99. renderer : function(v) {
  100. return saas.util.BaseUtil.numberFormat(v, 2, true);
  101. },
  102. summaryType: 'sum',
  103. summaryRenderer: function(v) {
  104. return saas.util.BaseUtil.numberFormat(v, 2, true);
  105. }
  106. }, {
  107. text: "已核销金额",
  108. xtype: 'numbercolumn',
  109. dataIndex: "sl_yamount",
  110. width: 110,
  111. ignore:true,
  112. renderer : function(v) {
  113. return saas.util.BaseUtil.numberFormat(v, 2, true);
  114. },
  115. summaryType: 'sum',
  116. summaryRenderer: function(v) {
  117. return saas.util.BaseUtil.numberFormat(v, 2, true);
  118. }
  119. }, {
  120. text: "未核销金额",
  121. xtype: 'numbercolumn',
  122. dataIndex: "sl_namount",
  123. width: 110,
  124. ignore:true,
  125. renderer : function(v) {
  126. return saas.util.BaseUtil.numberFormat(v, 2, true);
  127. },
  128. summaryType: 'sum',
  129. summaryRenderer: function(v) {
  130. return saas.util.BaseUtil.numberFormat(v, 2, true);
  131. }
  132. }, {
  133. text: "本次核销金额",
  134. xtype: 'numbercolumn',
  135. dataIndex: "vd_nowbalance",
  136. width: 150,
  137. editor : {
  138. xtype : "numberfield",
  139. decimalPrecision: 2
  140. },
  141. allowBlank : false,
  142. renderer : function(v) {
  143. return saas.util.BaseUtil.numberFormat(v, 2, true);
  144. },
  145. summaryType: 'sum',
  146. summaryRenderer: function(v) {
  147. return saas.util.BaseUtil.numberFormat(v, 2, true);
  148. }
  149. }]
  150. },
  151. detail2: {
  152. xtype: "detailGridField",
  153. storeModel: 'saas.model.money.Verification2',
  154. detnoColumn: 'vcd_detno',
  155. deleteDetailUrl: '/api/money/verification/deleteDetail2',
  156. columnWidth: 1,
  157. columns: [{
  158. text: 'ID',
  159. dataIndex: 'id',
  160. hidden: true
  161. }, {
  162. text: '来源ID',
  163. dataIndex: 'vcd_slid',
  164. hidden: true
  165. }, {
  166. text: '来源单号',
  167. dataIndex: 'vcd_slcode',
  168. width: 150,
  169. allowBlank:false,
  170. editor:{
  171. displayField : "display",
  172. editable : true,
  173. format : "",
  174. hideTrigger : false,
  175. maxLength : 100.0,
  176. minValue : null,
  177. positiveNum : false,
  178. queryMode : "local",
  179. store : null,
  180. valueField : "value",
  181. xtype : "oriOrderMutiDbfindTrigger"
  182. }
  183. }, {
  184. text: '业务类型',
  185. dataIndex: "vcd_slkind",
  186. width: 110
  187. }, {
  188. text: "单据日期",
  189. dataIndex: "vcd_sldate",
  190. xtype: 'datecolumn',
  191. width: 110
  192. }, {
  193. text: "单据金额",
  194. xtype: 'numbercolumn',
  195. dataIndex: "vcd_amount",
  196. width: 110,
  197. renderer : function(v) {
  198. return saas.util.BaseUtil.numberFormat(v, 2, true);
  199. },
  200. summaryType: 'sum',
  201. summaryRenderer: function(v) {
  202. return saas.util.BaseUtil.numberFormat(v, 2, true);
  203. }
  204. }, {
  205. text: "已核销金额",
  206. xtype: 'numbercolumn',
  207. dataIndex: "sl_yamount",
  208. width: 110,
  209. ignore:true,
  210. renderer : function(v) {
  211. return saas.util.BaseUtil.numberFormat(v, 2, true);
  212. },
  213. summaryType: 'sum',
  214. summaryRenderer: function(v) {
  215. return saas.util.BaseUtil.numberFormat(v, 2, true);
  216. }
  217. }, {
  218. text: "未核销金额",
  219. xtype: 'numbercolumn',
  220. dataIndex: "sl_namount",
  221. width: 110,
  222. ignore:true,
  223. renderer : function(v) {
  224. return saas.util.BaseUtil.numberFormat(v, 2, true);
  225. },
  226. summaryType: 'sum',
  227. summaryRenderer: function(v) {
  228. return saas.util.BaseUtil.numberFormat(v, 2, true);
  229. }
  230. }, {
  231. text: "本次核销金额",
  232. dataIndex: "vcd_nowbalance",
  233. xtype: 'numbercolumn',
  234. width: 150,
  235. allowBlank : false,
  236. editor : {
  237. xtype : "numberfield",
  238. decimalPrecision: 2
  239. },
  240. renderer : function(v) {
  241. return saas.util.BaseUtil.numberFormat(v, 2, true);
  242. },
  243. summaryType: 'sum',
  244. summaryRenderer: function(v) {
  245. return saas.util.BaseUtil.numberFormat(v, 2, true);
  246. }
  247. }]
  248. },
  249. other: [{
  250. xtype: 'textfield',
  251. name: 'vc_remark',
  252. columnWidth: 1,
  253. fieldLabel: '备注'
  254. }, {
  255. xtype : "hidden",
  256. name : "creatorId",
  257. fieldLabel : "录入人ID",
  258. readOnly:true
  259. },
  260. {
  261. xtype : "textfield",
  262. name : "creatorName",
  263. fieldLabel : "录入人",
  264. readOnly:true
  265. }, {
  266. xtype : "datefield",
  267. name : "createTime",
  268. fieldLabel : "录入日期",
  269. readOnly:true,
  270. defaultValue: new Date()
  271. },{
  272. xtype : "hidden",
  273. name : "updaterId",
  274. fieldLabel : "更新人ID",
  275. readOnly:true
  276. },{
  277. xtype : "hidden",
  278. name : "updaterName",
  279. fieldLabel : "更新人",
  280. readOnly:true
  281. }, {
  282. xtype : "hidden",
  283. name : "updateTime",
  284. fieldLabel : "更新日期",
  285. readOnly:true,
  286. defaultValue: new Date()
  287. },{
  288. xtype: 'textfield',
  289. name: 'vc_auditman',
  290. fieldLabel: '审核人',
  291. readOnly: true
  292. },{
  293. xtype: "datefield",
  294. name: "vc_auditdate",
  295. fieldLabel: "审核日期",
  296. readOnly: true
  297. }],
  298. // 预收冲应收
  299. receipts_offset_receivable : {
  300. main: [{
  301. xtype: 'hidden',
  302. fieldLabel: '客户名称',
  303. name: 'vc_custid',
  304. allowBlank : false,
  305. listeners: {
  306. change: 'clearDetails'
  307. }
  308. }, {
  309. fieldLabel: '客户编号',
  310. xtype: 'hidden',
  311. name: 'vc_custcode',
  312. }, {
  313. fieldLabel: '客户名称',
  314. xtype: 'customerDbfindTrigger',
  315. name: 'vc_custname',
  316. allowBlank : false
  317. }, {
  318. fieldLabel: '日期',
  319. xtype: 'datefield',
  320. defaultValue: new Date(),
  321. allowBlank : false,
  322. name: 'vc_date'
  323. }, {
  324. xtype: 'hidden',
  325. name: 'vc_amount1',
  326. fieldLabel: '核销金额(元)'
  327. }, {
  328. xtype: "hidden",
  329. name: "vc_amount2",
  330. fieldLabel: "未核销金额"
  331. }],
  332. details: ['detail1', 'detail2'],
  333. other: ['other']
  334. },
  335. // 预付冲应付
  336. prepaid_offset_payable: {
  337. main: [{
  338. xtype: 'hidden',
  339. name: 'vc_vendid',
  340. fieldLabel: '供应商名称',
  341. allowBlank : false,
  342. listeners: {
  343. change: 'clearDetails'
  344. }
  345. }, {
  346. xtype: "hidden",
  347. name: "vc_vendcode",
  348. fieldLabel: "供应商编号"
  349. }, {
  350. xtype: "vendorDbfindTrigger",
  351. name: "vc_vendname",
  352. fieldLabel: "供应商名称",
  353. allowBlank : false
  354. }, {
  355. fieldLabel: '日期',
  356. xtype: 'datefield',
  357. defaultValue: new Date(),
  358. allowBlank : false,
  359. name: 'vc_date'
  360. }, {
  361. xtype: 'hidden',
  362. name: 'vc_amount1',
  363. fieldLabel: '核销金额(元)'
  364. }, {
  365. xtype: "hidden",
  366. name: "vc_amount2",
  367. fieldLabel: "未核销金额"
  368. }],
  369. details: ['detail1', 'detail2'],
  370. other: ['other']
  371. },
  372. // 应收冲应付
  373. receivable_offset_payable: {
  374. main: [{
  375. fieldLabel: '客户名称',
  376. xtype: 'textfield',
  377. name: 'vc_custid',
  378. hidden: true,
  379. listeners: {
  380. change: 'clearDetail0'
  381. }
  382. }, {
  383. fieldLabel: '客户编号',
  384. xtype: 'textfield',
  385. name: 'vc_custcode',
  386. hidden: true
  387. }, {
  388. fieldLabel: '客户名称',
  389. xtype: 'customerDbfindTrigger',
  390. name: 'vc_custname',
  391. allowBlank : false,
  392. }, {
  393. xtype: 'hidden',
  394. name: 'vc_vendid',
  395. fieldLabel: '供应商ID',
  396. listeners: {
  397. change: 'clearDetail1'
  398. }
  399. }, {
  400. xtype: "hidden",
  401. name: "vc_vendcode",
  402. fieldLabel: "供应商编号"
  403. }, {
  404. xtype: "vendorDbfindTrigger",
  405. name: "vc_vendname",
  406. fieldLabel: "供应商名称",
  407. allowBlank : false
  408. }, {
  409. fieldLabel: '日期',
  410. xtype: 'datefield',
  411. defaultValue: new Date(),
  412. allowBlank : false,
  413. name: 'vc_date'
  414. }, {
  415. xtype: 'hidden',
  416. name: 'vc_amount1',
  417. fieldLabel: '核销金额(元)'
  418. }, {
  419. xtype: "hidden",
  420. name: "vc_amount2",
  421. fieldLabel: "未核销金额"
  422. }],
  423. details: ['detail1', 'detail2'],
  424. other: ['other']
  425. },
  426. // 应收转应收
  427. receivable_to_receivable: {
  428. main: [{
  429. fieldLabel: '转出客户',
  430. xtype: 'textfield',
  431. name: 'vc_custid',
  432. hidden: true,
  433. listeners: {
  434. change: 'clearDetail0'
  435. }
  436. }, {
  437. fieldLabel: '转出客户编号',
  438. xtype: 'textfield',
  439. name: 'vc_custcode',
  440. hidden: true
  441. }, {
  442. fieldLabel: '转出客户',
  443. xtype: 'customerDbfindTrigger',
  444. name: 'vc_custname',
  445. allowBlank : false,
  446. }, {
  447. fieldLabel: '转入客户id',
  448. xtype: 'textfield',
  449. name: 'vc_turncustid',
  450. hidden: true
  451. }, {
  452. fieldLabel: '转入客户编号',
  453. xtype: 'textfield',
  454. name: 'vc_turncustcode',
  455. hidden: true
  456. }, {
  457. fieldLabel: '转入客户',
  458. xtype: 'customerDbfindTrigger',
  459. name: 'vc_turncustname',
  460. allowBlank : false,
  461. }, {
  462. fieldLabel: '日期',
  463. xtype: 'datefield',
  464. defaultValue: new Date(),
  465. allowBlank : false,
  466. name: 'vc_date'
  467. }, {
  468. xtype: 'hidden',
  469. name: 'vc_amount1',
  470. fieldLabel: '核销金额(元)'
  471. }, {
  472. xtype: "hidden",
  473. name: "vc_amount2",
  474. fieldLabel: "未核销金额"
  475. }],
  476. details: ['detail1'],
  477. other: ['other']
  478. },
  479. // 应付转应付
  480. payable_to_payable: {
  481. main: [{
  482. fieldLabel: '转出供应商',
  483. xtype: 'textfield',
  484. name: 'vc_vendid',
  485. hidden: true,
  486. listeners: {
  487. change: 'clearDetail0'
  488. }
  489. }, {
  490. fieldLabel: '转出供应商编号',
  491. xtype: 'textfield',
  492. name: 'vc_vendcode',
  493. hidden: true
  494. }, {
  495. fieldLabel: '转出供应商',
  496. xtype: 'vendorDbfindTrigger',
  497. name: 'vc_vendname',
  498. allowBlank : false,
  499. }, {
  500. fieldLabel: '转入供应商id',
  501. xtype: 'textfield',
  502. name: 'vc_turnvendid',
  503. hidden: true
  504. }, {
  505. fieldLabel: '转入供应商编号',
  506. xtype: 'textfield',
  507. name: 'vc_turnvendcode',
  508. hidden: true
  509. }, {
  510. fieldLabel: '转入供应商',
  511. xtype: 'vendorDbfindTrigger',
  512. name: 'vc_turnvendname',
  513. allowBlank : false,
  514. }, {
  515. fieldLabel: '日期',
  516. xtype: 'datefield',
  517. defaultValue: new Date(),
  518. allowBlank : false,
  519. name: 'vc_date'
  520. }, {
  521. xtype: 'hidden',
  522. name: 'vc_amount1',
  523. fieldLabel: '核销金额(元)'
  524. }, {
  525. xtype: "hidden",
  526. name: "vc_amount2",
  527. fieldLabel: "未核销金额"
  528. }],
  529. details: ['detail1'],
  530. other: ['other']
  531. },
  532. defaultConditions: {
  533. receipts_offset_receivable: ['ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)<>0 and ifnull(sl_namount,0)<>0 ' +
  534. ' and ((sl_kind=\'收款单\') or (sl_kind=\'期初余额\' and sl_ym=' +
  535. '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))',
  536. 'ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 ' +
  537. ' and (sl_kind in (\'出货单\',\'销售退货单\') or (sl_kind in (\'期初余额\') and sl_ym=' +
  538. '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))'],
  539. prepaid_offset_payable: ['ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)<>0 and ifnull(sl_namount,0)<>0 ' +
  540. ' and ((sl_kind=\'付款单\') or (sl_kind=\'期初余额\' and sl_ym=' +
  541. '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))',
  542. 'ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0' +
  543. ' and (sl_kind in (\'采购验收单\',\'采购验退单\') or (sl_kind in (\'期初余额\') and sl_ym=' +
  544. '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))'],
  545. receivable_offset_payable: ['ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 ' +
  546. ' and ((sl_kind in (\'出货单\',\'销售退货单\')) or (sl_kind=\'期初余额\' and sl_ym=' +
  547. '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))',
  548. 'ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0' +
  549. ' and (sl_kind in (\'采购验收单\',\'采购验退单\') or (sl_kind in (\'期初余额\') and sl_ym=' +
  550. '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))'],
  551. receivable_to_receivable: ['ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 ' +
  552. ' and ((sl_kind in (\'出货单\',\'销售退货单\')) or (sl_kind=\'期初余额\' and sl_ym=' +
  553. '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))'],
  554. payable_to_payable: ['ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0' +
  555. ' and (sl_kind in (\'采购验收单\',\'采购验退单\') or (sl_kind in (\'期初余额\') and sl_ym=' +
  556. '(select min(pd_detno) from periodsdetail where pd_status=0 and periodsdetail.companyid=subledger.companyid)))']
  557. }
  558. },
  559. // initComponent: function() {
  560. // this.callParent(arguments);
  561. // },
  562. initFormItems: function() {
  563. var me = this,
  564. cusItems = me.cusItems,
  565. defaultItems = me.getAcitveItems(),
  566. FormUtil = saas.util.FormUtil;
  567. me.detailCount = 0;
  568. if(cusItems) {
  569. var items = defaultItems || [];
  570. Ext.Array.each(cusItems, function(cusItem) {
  571. var item = items.find(function(item) {
  572. return item.name == cusItem.name;
  573. });
  574. Ext.apply(item, cusItem);
  575. });
  576. items = FormUtil.applyDefaultItems(me, items);
  577. me.removeAll();
  578. me.addItems(items);
  579. FormUtil.loadData(me);
  580. }else {
  581. FormUtil.applyCusItemConfig(me)
  582. .then(function(res) {
  583. if(res.success) {
  584. var config = res.data || true, items = defaultItems || [];
  585. if(config) {
  586. cusItems = config.items || [];
  587. me.cusItems = cusItems;
  588. Ext.Array.each(cusItems, function(cusItem) {
  589. var item = items.find(function(item) {
  590. return item.name == cusItem.name;
  591. });
  592. Ext.apply(item, cusItem);
  593. });
  594. items = FormUtil.applyDefaultItems(me, items);
  595. }
  596. me.removeAll();
  597. return me.addItems(items);
  598. }
  599. })
  600. .then(function(items) {
  601. me.fireEvent('afterSetItems', me, items);
  602. })
  603. .then(function() {
  604. FormUtil.loadData(me);
  605. })
  606. .catch(function(response) {
  607. saas.util.BaseUtil.showErrorToast('错误:' + response.message);
  608. console.error(response);
  609. });
  610. }
  611. },
  612. getAcitveItems: function() {
  613. var me = this,
  614. acitveType = me.acitveType || me.defatulType,
  615. etc = me.etc,
  616. acitveEtc = etc[acitveType],
  617. mainItems = acitveEtc.main,
  618. details = acitveEtc.details,
  619. base = etc.base,
  620. detail1 = etc.detail1,
  621. detail2 = etc.detail2,
  622. other = etc.other,
  623. items = [];
  624. base[0].defaultValue = acitveType;
  625. items = Ext.Array.merge(base, mainItems, (details[0] ? [detail1] : []), (details[1] ? [detail2] : []), other );
  626. return items;
  627. },
  628. });