FormPanel.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. Ext.define('make.view.osmake.osMakeCheckIn.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: ['osmake-osmakecheckin-formpanel', 'osmakecheckin-formpanel'],
  4. controller: 'osmake-osmakecheckin-formpanel',
  5. viewModel: 'osmake-osmakecheckin-formpanel',
  6. viewName: 'osmake-osmakecheckin-formpanel',
  7. caller: 'OsMakeIn',
  8. //字段属性
  9. _title: '外协验收单',
  10. _idField: 'id',
  11. _codeField: 'pi_inoutno',
  12. _statusField: 'pi_status',
  13. _statusCodeField: 'pi_statuscode',
  14. _auditmanField: 'pi_auditman',
  15. _auditdateField: 'pi_auditdate',
  16. _relationColumn: 'pd_piid',
  17. _readUrl: '/api/make/prodinout/read',
  18. _saveUrl: '/api/make/prodinout/save',
  19. _auditUrl: '/api/make/prodinout/audit',
  20. _unAuditUrl: '/api/make/prodinout/unAudit',
  21. _deleteUrl: '/api/make/prodinout/delete',
  22. _turnOsMakeInBackUrl: '/api/make/prodinout/turnOsMakeInBack',
  23. initId: 0,
  24. initComponent: function () {
  25. Ext.apply(this, {
  26. toolBtns: [{
  27. xtype: 'button',
  28. text: '转验退',
  29. hidden: true,
  30. bind: {
  31. hidden: '{turnHidden}'
  32. },
  33. handler: 'turnOsMakeInBack'
  34. }],
  35. defaultItems: [{
  36. xtype: 'hidden',
  37. name: 'id',
  38. fieldLabel: 'id',
  39. allowBlank: true,
  40. columnWidth: 0
  41. }, {
  42. xtype: "hidden",
  43. name: "pi_class",
  44. fieldLabel: "单据类型",
  45. readOnly: true,
  46. allowBlank: true,
  47. defaultValue: 'OSMAKEIN',
  48. columnWidth: 0.25
  49. }, {
  50. xtype: "hidden",
  51. name: "pi_vendid",
  52. fieldLabel: "供应商ID",
  53. allowBlank: true,
  54. columnWidth: 0.0
  55. }, {
  56. xtype: 'hidden',
  57. name: 'pi_vendcode',
  58. fieldLabel: '供应商编号'
  59. }, {
  60. xtype: 'vendorDbfindTrigger',
  61. name: 'pi_vendname',
  62. fieldLabel: '外协厂商',
  63. allowBlank: false,
  64. columnWidth: 0.5,
  65. setValue: function (value) {
  66. var me = this,
  67. bind, valueBind;
  68. var form = me.ownerCt;
  69. var pi_contact = form.down('[name=pi_contact]');
  70. if (value && value != '') {
  71. pi_contact.setDisabled(false);
  72. } else {
  73. pi_contact.setDisabled(true);
  74. }
  75. if (me.hasFocus) {
  76. bind = me.getBind();
  77. valueBind = bind && bind.value;
  78. if (valueBind && valueBind.syncing) {
  79. if ((Ext.isEmpty(value) && Ext.isEmpty(me.value)) || value === me.value) {
  80. return me;
  81. } else if (Ext.isArray(value) && Ext.isArray(me.value) && Ext.Array.equals(value, me.value)) {
  82. return me;
  83. }
  84. }
  85. } else {
  86. me.lastSelectedRecords = null;
  87. }
  88. if (value != null) {
  89. me.doSetValue(value);
  90. } else {
  91. me.suspendEvent('select');
  92. me.valueCollection.beginUpdate();
  93. me.pickerSelectionModel.deselectAll();
  94. me.valueCollection.endUpdate();
  95. me.resumeEvent('select');
  96. }
  97. return me;
  98. }
  99. },{
  100. xtype: "remotecombo",
  101. name: "pi_contact",
  102. fieldLabel: "联系人",
  103. hiddenBtn: true,
  104. storeUrl: '/api/document/vendor/getContactCombo',
  105. columnWidth: 0.25
  106. },{
  107. xtype: "textfield",
  108. name: "pi_tel",
  109. fieldLabel: "联系电话",
  110. columnWidth: 0.25
  111. }, {
  112. xtype: 'hidden',
  113. name: 'pi_paymentsid',
  114. fieldLabel: '付款方式ID'
  115. }, {
  116. xtype: 'hidden',
  117. name: 'pi_paymentscode',
  118. fieldLabel: '付款方式编号'
  119. },{
  120. xtype: "remotecombo",
  121. name: "pi_payments",
  122. fieldLabel: "付款方式",
  123. storeUrl:'/api/document/paymentspay/list/enable',
  124. valueField:'pa_name',
  125. displayField: 'pa_name',
  126. allowBlank: false,
  127. columnWidth: 0.25,
  128. addHandler: function (b) {
  129. var document = Ext.create('saas.view.document.paymentspay.DataList', {});
  130. var form = this.ownerCmp.ownerCt;
  131. this.dialog = form.getController().getView().add({
  132. xtype: 'document-paymentspay-window',
  133. bind: {
  134. title: '新增付款方式'
  135. },
  136. dataKind: 'paymentspay',
  137. belong: document.etc['paymentspay'],
  138. _parent: form,
  139. _combo: this.ownerCmp,
  140. record: null,
  141. session: true
  142. });
  143. this.dialog.show();
  144. },
  145. editHandler:function(btn,type){
  146. saas.util.BaseUtil.openTab('document-paymentspay-datalist', '付款方式设置','maintab--document-paymentspay-datalist');
  147. var combo = btn.ownerCt.up('remotecombo');
  148. if(combo){
  149. combo.collapse();
  150. }
  151. },
  152. listeners:{
  153. select: function ( combo, record, eOpts ) {
  154. let form = combo.ownerCt;
  155. let paymentsid = form.down('[name=pi_paymentsid]'),
  156. paymentscode = form.down('[name=pi_paymentscode]');
  157. paymentsid.setValue(record.data['id']);
  158. paymentscode.setValue(record.data['pa_code']);
  159. }
  160. }
  161. }, {
  162. xtype: 'currencyCombo',
  163. name:'pi_currency',
  164. fieldLabel: '币种',
  165. allowBlank: false,
  166. rateField:'pi_rate',
  167. columnWidth: 0.25,
  168. }, {
  169. xtype: 'numberfield',
  170. fieldLabel: '税率',
  171. name:'pi_taxrate',
  172. allowBlank: true,
  173. defaultValue: saas.util.BaseUtil.getDefualtTaxRate()
  174. }, {
  175. name: "detailGridField",
  176. xtype: "detailGridField",
  177. storeModel: 'make.model.osmake.OsMakeCheckInDetail',
  178. deleteDetailUrl: '/api/make/prodinout/deleteDetail',
  179. relativeBinds:{
  180. refFields:['pd_orderid'],
  181. fields:['pd_prodcode','pr_detail']
  182. },
  183. detnoColumn: 'pd_pdno',
  184. columns: [{
  185. text: "id",
  186. dataIndex: "id",
  187. xtype: "numbercolumn",
  188. hidden: true
  189. },{
  190. text: "工单id",
  191. dataIndex: "pd_orderid",
  192. xtype: "numbercolumn",
  193. hidden: true
  194. }, {
  195. text: "订单id",
  196. dataIndex: "pd_maid",
  197. xtype: "numbercolumn",
  198. hidden: true
  199. }, {
  200. text: "物料id",
  201. dataIndex: "pd_prodid",
  202. xtype: "numbercolumn",
  203. hidden: true
  204. },{
  205. text: "外协单号",
  206. dataIndex: "pd_ordercode",
  207. width: 150.0,
  208. editor: {
  209. displayField: "display",
  210. editable: true,
  211. format: "",
  212. hideTrigger: false,
  213. maxLength: 100.0,
  214. minValue: null,
  215. positiveNum: false,
  216. store: null,
  217. valueField: "value",
  218. xtype: "osMakeMainMultiDbfindTrigger"
  219. }
  220. }, {
  221. text: "物料编号",
  222. width: 150.0,
  223. dataIndex: "pd_prodcode",
  224. items: null,
  225. allowBlank: false
  226. }, {
  227. text: "物料名称",
  228. width: 150.0,
  229. dataIndex: "pr_detail",
  230. ignore: true,
  231. renderer: function (v, m, r) {
  232. if (!v) {
  233. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  234. }
  235. return v;
  236. }
  237. }, {
  238. text: "规格",
  239. hidden:true,
  240. width: 200,
  241. dataIndex: "pr_spec",
  242. ignore: true,
  243. renderer: function (v, m, r) {
  244. if (!v) {
  245. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  246. }
  247. return v;
  248. }
  249. }, {
  250. text: "单位",
  251. width: 65.0,
  252. dataIndex: "pr_unit",
  253. ignore: true,
  254. renderer: function (v, m, r) {
  255. if (!v) {
  256. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  257. }
  258. return v;
  259. }
  260. },{
  261. text: "验收数量",
  262. dataIndex: "pd_inqty",
  263. xtype: 'numbercolumn',
  264. width: 110.0,
  265. allowBlank: false,
  266. editor: {
  267. xtype: "numberfield",
  268. decimalPrecision: 6,
  269. minValue: 0
  270. },
  271. renderer: function(v, m, r) {
  272. return saas.util.BaseUtil.numberFormat(v, 6, true);
  273. },
  274. summaryType: 'sum',
  275. summaryRenderer: function(v, d, f, m) {
  276. return saas.util.BaseUtil.numberFormat(v, 6, true);
  277. }
  278. }, {
  279. text: "仓库id",
  280. dataIndex: "pd_whid",
  281. xtype: "numbercolumn",
  282. hidden: true
  283. }, {
  284. text: "仓库编号",
  285. dataIndex: "pd_whcode",
  286. hidden: true
  287. }, {
  288. text: "仓库",
  289. dataIndex: "pd_whname",
  290. width: 110.0,
  291. allowBlank: false,
  292. editor: {
  293. displayField: "display",
  294. editable: true,
  295. format: "",
  296. hideTrigger: false,
  297. maxLength: 100.0,
  298. minValue: null,
  299. positiveNum: false,
  300. queryMode: "local",
  301. store: null,
  302. valueField: "value",
  303. xtype: "warehouseDbfindTrigger"
  304. }
  305. }, {
  306. text: "不含税单价(元)",
  307. xtype: 'numbercolumn',
  308. dataIndex: "pd_netprice",
  309. width: 120,
  310. hidden: true
  311. }, {
  312. text: "含税单价(元)",
  313. xtype: 'numbercolumn',
  314. width: 120,
  315. editor: {
  316. xtype: "numberfield",
  317. decimalPrecision: 8,
  318. minValue: 0
  319. },
  320. dataIndex: "pd_orderprice",
  321. width: 120.0,
  322. renderer: function(v, m, r) {
  323. return saas.util.BaseUtil.numberFormat(v, 8, true);
  324. },
  325. listeners: {
  326. edit: function (value, grid) {
  327. let me=this;
  328. var r = grid.getSelection()[0],
  329. pd_taxrate = r.get('pd_taxrate');
  330. if(value>0) {
  331. let form = me.up('form');
  332. let pi_taxrate = form.down('[name=pi_taxrate]');
  333. if(pi_taxrate && pi_taxrate.value>0){
  334. pd_taxrate=pi_taxrate.value;
  335. r.set('pd_taxrate',pd_taxrate);
  336. }
  337. var v = value / (1 + pd_taxrate / 100);
  338. r.set('pd_netprice', Number(saas.util.BaseUtil.numberFormat(v, 8, false)));
  339. }else{
  340. r.set('pd_netprice', 0);
  341. }
  342. if(r.modified && Object.assign(r.modified) && Object.keys(Object.assign(r.modified)).length==1 && Object.keys(Object.assign(r.modified))[0]=='pd_taxrate'){
  343. r.dirty=false;
  344. }
  345. }
  346. }
  347. }, {
  348. text: "税率(%)",
  349. xtype: 'numbercolumn',
  350. dataIndex: "pd_taxrate",
  351. width: 120,
  352. hidden: true
  353. }, {
  354. text: "不含税金额(元)",
  355. xtype: 'numbercolumn',
  356. dataIndex: "pd_nettotal",
  357. width: 120,
  358. hidden: true
  359. }, {
  360. text: "税额(元)",
  361. xtype: 'numbercolumn',
  362. dataIndex: "pd_taxamount",
  363. hidden: true,
  364. width: 120,
  365. renderer: function(v, m, r) {
  366. return saas.util.BaseUtil.numberFixFormat(v, 2, true);
  367. },
  368. summaryType: 'sum',
  369. summaryRenderer: function(v, d, f, m) {
  370. return saas.util.BaseUtil.numberFixFormat(v, 2, true);
  371. }
  372. }, {
  373. text: "价税合计(元)",
  374. xtype: 'numbercolumn',
  375. dataIndex: "pd_ordertotal",
  376. width: 120,
  377. hidden: true,
  378. renderer: function(v, m, r) {
  379. return saas.util.BaseUtil.numberFixFormat(v, 2, true);
  380. },
  381. summaryType: 'sum',
  382. summaryRenderer: function(v, d, f, m) {
  383. return saas.util.BaseUtil.numberFixFormat(v, 2, true);
  384. }
  385. }, {
  386. text: "厂家/品牌",
  387. hidden:true,
  388. width: 100.0,
  389. dataIndex: "pr_brand",
  390. ignore: true,
  391. renderer: function (v, m, r) {
  392. if (!v) {
  393. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  394. }
  395. return v;
  396. }
  397. }, {
  398. text: "型号",
  399. width: 200.0,
  400. dataIndex: "pr_orispeccode",
  401. ignore: true,
  402. renderer: function (v, m, r) {
  403. var str = '';
  404. if(r.data["productDTO"] ){
  405. if(r.data["productDTO"]['pr_brand']){
  406. str += '厂家/品牌:'+ r.data["productDTO"]['pr_brand'] + '<br>';
  407. }
  408. if(r.data["productDTO"]['pr_spec']){
  409. str += '规格:' + r.data["productDTO"]['pr_spec'];
  410. }
  411. if(str) m.tdAttr = 'data-qtip="'+ str +'"';
  412. if (!v) {
  413. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  414. }
  415. }
  416. return v;
  417. }
  418. }, {
  419. text: "开票数量",
  420. xtype: 'numbercolumn',
  421. dataIndex: "pd_auditbillqty",
  422. width: (saas.util.BaseUtil.getBillOutSource("BillOutARSource") == 'PRODIOAUTO')? 0.0:110.0,
  423. ignore: true,
  424. renderer: function(v, m, r) {
  425. return saas.util.BaseUtil.numberFormat(v, 6, true);
  426. },
  427. summaryType: 'sum',
  428. summaryRenderer: function(v, d, f, m) {
  429. return saas.util.BaseUtil.numberFormat(v, 6, true);
  430. }
  431. }, {
  432. text: "开票金额",
  433. xtype: 'numbercolumn',
  434. dataIndex: "pd_auditbillamount",
  435. width: (saas.util.BaseUtil.getBillOutSource("BillOutARSource") == 'PRODIOAUTO')? 0.0:110.0,
  436. ignore: true,
  437. renderer: function(v, m, r) {
  438. return saas.util.BaseUtil.numberFormat(v, 2, true);
  439. },
  440. summaryType: 'sum',
  441. summaryRenderer: function(v, d, f, m) {
  442. return saas.util.BaseUtil.numberFormat(v, 2, true);
  443. }
  444. }, {
  445. text: "备注",
  446. dataIndex: "pd_remark",
  447. width: 250,
  448. items: null,
  449. editor: {
  450. xtype: "textfield"
  451. }
  452. }, {
  453. text: "对账状态",
  454. dataIndex: "apcheckStatus",
  455. width: 100.0,
  456. hidden: true,
  457. ignore: true,
  458. }, {
  459. text: 'model映射需要',
  460. dataIndex: 'productDTO',
  461. hidden: true,
  462. }, {
  463. dataIndex: "pd_text1",
  464. text: "自定义字段1",
  465. width: 100,
  466. hidden: true,
  467. initHidden: false,
  468. editor: {
  469. xtype: "textfield"
  470. },
  471. }, {
  472. dataIndex: "pd_text2",
  473. text: "自定义字段2",
  474. width: 100,
  475. hidden: true,
  476. initHidden: false,
  477. editor: {
  478. xtype: "textfield"
  479. },
  480. }, {
  481. dataIndex: "pd_text3",
  482. text: "自定义字段3",
  483. width: 100,
  484. hidden: true,
  485. initHidden: false,
  486. editor: {
  487. xtype: "textfield"
  488. },
  489. }, {
  490. dataIndex: "pd_text4",
  491. text: "自定义字段4",
  492. width: 100,
  493. hidden: true,
  494. initHidden: false,
  495. editor: {
  496. xtype: "textfield"
  497. },
  498. }, {
  499. dataIndex: "pd_text5",
  500. text: "自定义字段5",
  501. width: 100,
  502. hidden: true,
  503. initHidden: false,
  504. editor: {
  505. xtype: "textfield"
  506. },
  507. }]
  508. }, {
  509. xtype: "textfield",
  510. name: "pi_remark",
  511. fieldLabel: "备注",
  512. columnWidth: 0.6
  513. }, {
  514. xtype: "displayfield",
  515. name: "pi_nettotal",
  516. fieldLabel: "不含税金额(元)",
  517. labelWidth:200,
  518. labelAlign : 'right',
  519. columnWidth: 0.4,
  520. thousandSeparator: ',',
  521. renderer: function (v){
  522. if(!v){
  523. v=0;
  524. }
  525. return '<p class="money-rtl"><B>'+saas.util.BaseUtil.numberFixFormat(v, 2, true)+''
  526. }
  527. }, {
  528. xtype: "datefield",
  529. name: "pi_date",
  530. fieldLabel: "单据日期",
  531. columnWidth: 0.6,
  532. defaultValue: new Date()
  533. }, {
  534. xtype: "displayfield",
  535. name: "pi_taxtotal",
  536. fieldLabel: "税额(元)",
  537. labelWidth:200,
  538. labelAlign : 'right',
  539. columnWidth: 0.4,
  540. thousandSeparator: ',',
  541. readOnly: true,
  542. renderer: function (v){
  543. if(!v){
  544. v=0;
  545. }
  546. return '<p class="money-rtl"><B>'+saas.util.BaseUtil.numberFixFormat(v, 2, true)+''
  547. }
  548. }, {
  549. xtype: "hidden",
  550. name: "creatorId",
  551. fieldLabel: "录入人ID",
  552. readOnly: true
  553. }, {
  554. xtype: "textfield",
  555. name: "creatorName",
  556. fieldLabel: "录入人",
  557. readOnly: true,
  558. columnWidth: 0.3
  559. }, {
  560. xtype: "hidden",
  561. name: "createTime",
  562. fieldLabel: "录入日期",
  563. readOnly: true,
  564. defaultValue: new Date()
  565. }, {
  566. xtype: "textfield",
  567. name: "pi_auditman",
  568. fieldLabel: "审核人",
  569. columnWidth: 0.3,
  570. readOnly: true
  571. }, {
  572. xtype: "hidden",
  573. name: "pi_auditdate",
  574. fieldLabel: "审核日期",
  575. readOnly: true
  576. }, {
  577. xtype: "displayfield",
  578. name: "pi_total",
  579. fieldLabel: "价税合计(元)",
  580. labelWidth:200,
  581. labelAlign : 'right',
  582. columnWidth: 0.4,
  583. thousandSeparator: ',',
  584. renderer: function (v){
  585. if(!v){
  586. v=0;
  587. }
  588. return '<p class="money-rtl"><font color="red"><B>'+saas.util.BaseUtil.numberFixFormat(v, 2, true)+'</font>'
  589. },
  590. readOnly: true
  591. }, {
  592. xtype: "textfield",
  593. name: "pi_billamount",
  594. fieldLabel: "开票金额",
  595. columnWidth: 0.3,
  596. readOnly: true,
  597. hidden:(saas.util.BaseUtil.getBillOutSource("BillOutARSource") == 'PRODIOAUTO')
  598. }, {
  599. xtype: "textfield",
  600. name: "pi_billstatus",
  601. fieldLabel: "开票状态",
  602. columnWidth: 0.3,
  603. readOnly: true,
  604. hidden:(saas.util.BaseUtil.getBillOutSource("BillOutARSource") == 'PRODIOAUTO')
  605. }, {
  606. xtype: "textfield",
  607. name: "pi_billstatuscode",
  608. fieldLabel: "开票状态码",
  609. columnWidth: 0.25,
  610. readOnly: true,
  611. hidden:true
  612. }, {
  613. xtype: "textfield",
  614. name: "pi_text1",
  615. fieldLabel: "自定义字段1",
  616. hidden: true,
  617. initHidden: false
  618. }, {
  619. xtype: "textfield",
  620. name: "pi_text2",
  621. fieldLabel: "自定义字段2",
  622. hidden: true,
  623. initHidden: false
  624. }, {
  625. xtype: "textfield",
  626. name: "pi_text3",
  627. fieldLabel: "自定义字段3",
  628. hidden: true,
  629. initHidden: false
  630. }, {
  631. xtype: "textfield",
  632. name: "pi_text4",
  633. fieldLabel: "自定义字段4",
  634. hidden: true,
  635. initHidden: false
  636. }, {
  637. xtype: "textfield",
  638. name: "pi_text5",
  639. fieldLabel: "自定义字段5",
  640. hidden: true,
  641. initHidden: false
  642. }],
  643. });
  644. this.callParent(arguments);
  645. },
  646. // beforeAudit: function () {
  647. // var me = this,
  648. // viewModel = me.getViewModel(),
  649. // grid = me.down('detailGridField'),
  650. // data = grid.getTrueData();
  651. // Ext.Array.each(data, function (item) {
  652. // if (item.pd_orderprice == 0) {
  653. // saas.util.BaseUtil.showErrorToast(item.pd_pdno + '行' + item.pd_prodcode + '物料单价为0');
  654. // }
  655. // });
  656. // return true;
  657. // }
  658. });