FormPanel.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. Ext.define('saas.view.purchase.purchaseIn.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: 'purchase-purchasein-formpanel',
  4. controller: 'purchase-purchasein-formpanel',
  5. viewModel: 'purchase-purchasein-formpanel',
  6. viewName: 'purchase-purchasein-formpanel',
  7. caller: 'PurchaseIn',
  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/purchase/prodinout/read',
  18. _saveUrl: '/api/purchase/prodinout/save',
  19. _auditUrl: '/api/purchase/prodinout/audit',
  20. _unAuditUrl: '/api/purchase/prodinout/unAudit',
  21. _deleteUrl: '/api/purchase/prodinout/delete',
  22. _turnOutUrl: '/api/purchase/prodinout/turnProdOut',
  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: 'turnOut'
  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. columnWidth: 0.25
  48. }, {
  49. xtype: "hidden",
  50. name: "pi_vendid",
  51. fieldLabel: "供应商ID",
  52. allowBlank: true,
  53. columnWidth: 0.0
  54. }, {
  55. xtype: 'hidden',
  56. name: 'pi_vendcode',
  57. fieldLabel: '供应商编号'
  58. }, {
  59. xtype: 'vendorDbfindTrigger',
  60. name: 'pi_vendname',
  61. fieldLabel: '供应商名称',
  62. allowBlank: false,
  63. columnWidth: 0.5
  64. }, {
  65. xtype: 'condbfindtrigger',
  66. fieldLabel: '币别汇率',
  67. allowBlank: false,
  68. dbType: 'currencyDbfindTrigger',
  69. dbfinds: [{
  70. from: 'cr_name', to: 'pi_currency'
  71. }, {
  72. from: 'cr_rate', to: 'pi_rate'
  73. }],
  74. // defaultValue: {
  75. // pi_currency: this.getViewModel().get('defaultCurrency'),
  76. // pi_rate: 1
  77. // },
  78. supFieldConfig: {
  79. xtype: 'numberfield',
  80. readOnly: false,
  81. defaultReadOnly: false,
  82. defaultValue: 1,
  83. decimalPrecision: 6,
  84. vtype: 'positiveNumber',
  85. listeners: {
  86. change: function(f, v) {
  87. var defaultCurrency = Ext.getCmp('mainView').getViewModel().get('defaultCurrency');
  88. f.setReadOnly(f.ownerCt.items.items[0].value == defaultCurrency);
  89. }
  90. }
  91. },
  92. }, {
  93. xtype: "datefield",
  94. name: "pi_date",
  95. fieldLabel: "单据日期",
  96. allowBlank: false,
  97. columnWidth: 0.25,
  98. defaultValue: new Date()
  99. }, {
  100. xtype: "hidden",
  101. name: "pi_puid",
  102. fieldLabel: "采购单id",
  103. allowBlank: true,
  104. columnWidth: 0.25
  105. }, {
  106. xtype: "hidden",
  107. name: "pi_pucode",
  108. fieldLabel: "采购单号",
  109. allowBlank: true,
  110. columnWidth: 0.25
  111. // }, {
  112. // xtype: "textfield",
  113. // name: "b2bStatus",
  114. // fieldLabel: "上传状态",
  115. // columnWidth: 0.25,
  116. // readOnly: true,
  117. // bind: {
  118. // hidden: '{!enableB2B}'
  119. // },
  120. // defaultValue: '待上传'
  121. }, {
  122. name: "detailGridField",
  123. xtype: "detailGridField",
  124. storeModel: 'saas.model.purchase.ProdInDetail',
  125. deleteDetailUrl: '/api/purchase/prodinout/deleteDetail',
  126. detnoColumn: 'pd_pdno',
  127. columns: [{
  128. text: "id",
  129. dataIndex: "id",
  130. xtype: "numbercolumn",
  131. hidden: true
  132. }, {
  133. text: "物料id",
  134. dataIndex: "pd_prodid",
  135. xtype: "numbercolumn",
  136. hidden: true
  137. }, {
  138. text: "物料编号",
  139. width: 150.0,
  140. dataIndex: "pd_prodcode",
  141. xtype: "",
  142. items: null,
  143. allowBlank: false,
  144. editor: {
  145. displayField: "display",
  146. editable: true,
  147. format: "",
  148. hideTrigger: false,
  149. maxLength: 100.0,
  150. minValue: null,
  151. positiveNum: false,
  152. queryMode: "local",
  153. store: null,
  154. valueField: "value",
  155. xtype: "productMultiDbfindTrigger"
  156. }
  157. }, {
  158. text: "品牌",
  159. width: 100.0,
  160. dataIndex: "pr_brand",
  161. ignore: true,
  162. renderer: function (v, m, r) {
  163. if (!v) {
  164. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  165. }
  166. return v;
  167. }
  168. }, {
  169. text: "物料名称",
  170. width: 150.0,
  171. dataIndex: "pr_detail",
  172. ignore: true,
  173. renderer: function (v, m, r) {
  174. if (!v) {
  175. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  176. }
  177. return v;
  178. }
  179. }, {
  180. text: "型号",
  181. width: 200.0,
  182. dataIndex: "pr_orispeccode",
  183. ignore: true,
  184. renderer: function (v, m, r) {
  185. if (!v) {
  186. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  187. }
  188. return v;
  189. }
  190. }, {
  191. text: "规格",
  192. width: 200,
  193. dataIndex: "pr_spec",
  194. ignore: true,
  195. renderer: function (v, m, r) {
  196. if (!v) {
  197. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  198. }
  199. return v;
  200. }
  201. }, {
  202. text: 'model映射需要',
  203. dataIndex: 'productDTO',
  204. hidden: true,
  205. }, {
  206. text: "仓库id",
  207. dataIndex: "pd_whid",
  208. xtype: "numbercolumn",
  209. hidden: true
  210. }, {
  211. text: "仓库编号",
  212. dataIndex: "pd_whcode",
  213. hidden: true
  214. }, {
  215. text: "仓库",
  216. dataIndex: "pd_whname",
  217. width: 110.0,
  218. allowBlank: false,
  219. editor: {
  220. displayField: "display",
  221. editable: true,
  222. format: "",
  223. hideTrigger: false,
  224. maxLength: 100.0,
  225. minValue: null,
  226. positiveNum: false,
  227. queryMode: "local",
  228. store: null,
  229. valueField: "value",
  230. xtype: "warehouseDbfindTrigger"
  231. }
  232. }, {
  233. text: "数量",
  234. dataIndex: "pd_inqty",
  235. xtype: 'numbercolumn',
  236. width: 110.0,
  237. allowBlank: false,
  238. editor: {
  239. xtype: "numberfield",
  240. decimalPrecision: 3,
  241. minValue: 0
  242. },
  243. renderer: function(v, m, r) {
  244. return saas.util.BaseUtil.numberFormat(v, 3, false);
  245. },
  246. summaryType: 'sum',
  247. summaryRenderer: function(v, d, f, m) {
  248. return saas.util.BaseUtil.numberFormat(v, 3, false);
  249. }
  250. }, {
  251. text: "单位",
  252. width: 65.0,
  253. dataIndex: "pr_unit",
  254. ignore: true,
  255. renderer: function (v, m, r) {
  256. if (!v) {
  257. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  258. }
  259. return v;
  260. }
  261. }, {
  262. text: "单价(元)",
  263. xtype: 'numbercolumn',
  264. width: 120,
  265. editor: {
  266. xtype: "numberfield",
  267. decimalPrecision: 4,
  268. minValue: 0
  269. },
  270. dataIndex: "pd_netprice",
  271. width: 120,
  272. renderer: function(v, m, r) {
  273. return saas.util.BaseUtil.numberFormat(v, 4, true);
  274. },
  275. }, {
  276. text: "含税单价(元)",
  277. xtype: 'numbercolumn',
  278. width: 120,
  279. editor: {
  280. xtype: "numberfield",
  281. decimalPrecision: 4,
  282. minValue: 0
  283. },
  284. dataIndex: "pd_orderprice",
  285. width: 120.0,
  286. renderer: function(v, m, r) {
  287. return saas.util.BaseUtil.numberFormat(v, 4, true);
  288. },
  289. listeners: {
  290. edit: function (value, grid) {
  291. var r = grid.getSelection()[0],
  292. pd_taxrate = r.get('pd_taxrate');
  293. var v = value / (1 + pd_taxrate / 100);
  294. r.set('pd_netprice', Number(saas.util.BaseUtil.numberFormat(v, 4, false)));
  295. }
  296. }
  297. }, {
  298. text: "金额(元)",
  299. xtype: 'numbercolumn',
  300. dataIndex: "pd_nettotal",
  301. width: 120,
  302. renderer: function(v, m, r) {
  303. return saas.util.BaseUtil.numberFormat(v, 2, true);
  304. },
  305. summaryType: 'sum',
  306. summaryRenderer: function(v, d, f, m) {
  307. return saas.util.BaseUtil.numberFormat(v, 2, true);
  308. }
  309. }, {
  310. xtype: 'numbercolumn',
  311. text: "税率(%)",
  312. dataIndex: "pd_taxrate",
  313. width: 80,
  314. editor: {
  315. xtype: "numberfield",
  316. decimalPrecision: 0,
  317. minValue: 0,
  318. maxValue: 100
  319. },
  320. renderer: function(v, m, r) {
  321. return saas.util.BaseUtil.numberFormat(v, 2, false);
  322. },
  323. }, {
  324. text: "税额(元)",
  325. xtype: 'numbercolumn',
  326. dataIndex: "pd_taxamount",
  327. width: 120,
  328. renderer: function(v, m, r) {
  329. return saas.util.BaseUtil.numberFormat(v, 2, true);
  330. },
  331. summaryType: 'sum',
  332. summaryRenderer: function(v, d, f, m) {
  333. return saas.util.BaseUtil.numberFormat(v, 2, true);
  334. }
  335. }, {
  336. text: "价税合计(元)",
  337. xtype: 'numbercolumn',
  338. dataIndex: "pd_ordertotal",
  339. width: 120,
  340. renderer: function(v, m, r) {
  341. return saas.util.BaseUtil.numberFormat(v, 2, true);
  342. },
  343. summaryType: 'sum',
  344. summaryRenderer: function(v, d, f, m) {
  345. return saas.util.BaseUtil.numberFormat(v, 2, true);
  346. }
  347. }, {
  348. text: "关联采购单号",
  349. dataIndex: "pd_ordercode",
  350. width: 150.0,
  351. ignore: true,
  352. }, {
  353. text: "备注",
  354. dataIndex: "pd_remark",
  355. width: 250,
  356. items: null,
  357. editor: {
  358. xtype: "textfield"
  359. }
  360. }, {
  361. dataIndex: "pd_text1",
  362. text: "自定义字段1",
  363. width: 100,
  364. hidden: true,
  365. initHidden: false,
  366. editor: {
  367. xtype: "textfield"
  368. },
  369. }, {
  370. dataIndex: "pd_text2",
  371. text: "自定义字段2",
  372. width: 100,
  373. hidden: true,
  374. initHidden: false,
  375. editor: {
  376. xtype: "textfield"
  377. },
  378. }, {
  379. dataIndex: "pd_text3",
  380. text: "自定义字段3",
  381. width: 100,
  382. hidden: true,
  383. initHidden: false,
  384. editor: {
  385. xtype: "textfield"
  386. },
  387. }, {
  388. dataIndex: "pd_text4",
  389. text: "自定义字段4",
  390. width: 100,
  391. hidden: true,
  392. initHidden: false,
  393. editor: {
  394. xtype: "textfield"
  395. },
  396. }, {
  397. dataIndex: "pd_text5",
  398. text: "自定义字段5",
  399. width: 100,
  400. hidden: true,
  401. initHidden: false,
  402. editor: {
  403. xtype: "textfield"
  404. },
  405. }]
  406. }, {
  407. xtype: "textfield",
  408. name: "pi_remark",
  409. fieldLabel: "备注",
  410. columnWidth: 1
  411. }, {
  412. xtype: "numberfield",
  413. name: "pi_nettotal",
  414. fieldLabel: "金额(元)",
  415. readOnly: true,
  416. thousandSeparator: ',',
  417. columnWidth: 0.25
  418. }, {
  419. xtype: "numberfield",
  420. name: "pi_total",
  421. fieldLabel: "价税合计(元)",
  422. readOnly: true,
  423. thousandSeparator: ',',
  424. columnWidth: 0.25
  425. }, {
  426. xtype: "hidden",
  427. name: "pi_buyercode",
  428. fieldLabel: "采购员编号"
  429. }, {
  430. xtype: "employeeDbfindTrigger",
  431. name: "pi_buyername",
  432. fieldLabel: "采购员",
  433. columnWidth: 0.25
  434. }, {
  435. xtype: "hidden",
  436. name: "pi_buyerid",
  437. fieldLabel: "采购员ID"
  438. }, {
  439. xtype: "hidden",
  440. name: "creatorId",
  441. fieldLabel: "录入人ID",
  442. readOnly: true
  443. }, {
  444. xtype: "textfield",
  445. name: "creatorName",
  446. fieldLabel: "录入人",
  447. readOnly: true
  448. }, {
  449. xtype: "datefield",
  450. name: "createTime",
  451. fieldLabel: "录入日期",
  452. readOnly: true,
  453. defaultValue: new Date()
  454. }, {
  455. xtype: "hidden",
  456. name: "updaterId",
  457. fieldLabel: "更新人ID",
  458. readOnly: true
  459. }, {
  460. xtype: "hidden",
  461. name: "updaterName",
  462. fieldLabel: "更新人",
  463. readOnly: true
  464. }, {
  465. xtype: "hidden",
  466. name: "updateTime",
  467. fieldLabel: "更新日期",
  468. readOnly: true,
  469. defaultValue: new Date()
  470. }, {
  471. xtype: "textfield",
  472. name: "pi_auditman",
  473. fieldLabel: "审核人",
  474. readOnly: true
  475. }, {
  476. xtype: "datefield",
  477. name: "pi_auditdate",
  478. fieldLabel: "审核日期",
  479. readOnly: true
  480. }, {
  481. xtype: "textfield",
  482. name: "pi_text1",
  483. fieldLabel: "自定义字段1",
  484. hidden: true,
  485. initHidden: false
  486. }, {
  487. xtype: "textfield",
  488. name: "pi_text2",
  489. fieldLabel: "自定义字段2",
  490. hidden: true,
  491. initHidden: false
  492. }, {
  493. xtype: "textfield",
  494. name: "pi_text3",
  495. fieldLabel: "自定义字段3",
  496. hidden: true,
  497. initHidden: false
  498. }, {
  499. xtype: "textfield",
  500. name: "pi_text4",
  501. fieldLabel: "自定义字段4",
  502. hidden: true,
  503. initHidden: false
  504. }, {
  505. xtype: "textfield",
  506. name: "pi_text5",
  507. fieldLabel: "自定义字段5",
  508. hidden: true,
  509. initHidden: false
  510. }],
  511. });
  512. this.callParent(arguments);
  513. },
  514. beforeAudit: function () {
  515. var me = this,
  516. viewModel = me.getViewModel(),
  517. grid = me.down('detailGridField'),
  518. data = grid.getTrueData();
  519. Ext.Array.each(data, function (item) {
  520. if (item.pd_orderprice == 0) {
  521. saas.util.BaseUtil.showErrorToast(item.pd_pdno + '行' + item.pd_prodcode + '物料单价为0');
  522. }
  523. });
  524. return true;
  525. }
  526. });