FormPanel.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  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. }, {
  121. name: "detailGridField",
  122. xtype: "detailGridField",
  123. storeModel: 'saas.model.purchase.ProdInDetail',
  124. deleteDetailUrl: '/api/purchase/prodinout/deleteDetail',
  125. detnoColumn: 'pd_pdno',
  126. columns: [{
  127. text: "id",
  128. dataIndex: "id",
  129. xtype: "numbercolumn",
  130. hidden: true
  131. }, {
  132. text: "物料id",
  133. dataIndex: "pd_prodid",
  134. xtype: "numbercolumn",
  135. hidden: true
  136. }, {
  137. text: "物料编号",
  138. width: 150.0,
  139. dataIndex: "pd_prodcode",
  140. xtype: "",
  141. items: null,
  142. allowBlank: false,
  143. editor: {
  144. displayField: "display",
  145. editable: true,
  146. format: "",
  147. hideTrigger: false,
  148. maxLength: 100.0,
  149. minValue: null,
  150. positiveNum: false,
  151. queryMode: "local",
  152. store: null,
  153. valueField: "value",
  154. xtype: "productMultiDbfindTrigger"
  155. }
  156. }, {
  157. text: "品牌",
  158. width: 100.0,
  159. dataIndex: "pr_brand",
  160. ignore: true,
  161. renderer: function (v, m, r) {
  162. if (!v) {
  163. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  164. }
  165. return v;
  166. }
  167. }, {
  168. text: "物料名称",
  169. width: 150.0,
  170. dataIndex: "pr_detail",
  171. ignore: true,
  172. renderer: function (v, m, r) {
  173. if (!v) {
  174. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  175. }
  176. return v;
  177. }
  178. }, {
  179. text: "型号",
  180. width: 200.0,
  181. dataIndex: "pr_orispeccode",
  182. ignore: true,
  183. renderer: function (v, m, r) {
  184. if (!v) {
  185. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  186. }
  187. return v;
  188. }
  189. }, {
  190. text: "规格",
  191. width: 200,
  192. dataIndex: "pr_spec",
  193. ignore: true,
  194. renderer: function (v, m, r) {
  195. if (!v) {
  196. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  197. }
  198. return v;
  199. }
  200. }, {
  201. text: 'model映射需要',
  202. dataIndex: 'productDTO',
  203. hidden: true,
  204. }, {
  205. text: "仓库id",
  206. dataIndex: "pd_whid",
  207. xtype: "numbercolumn",
  208. hidden: true
  209. }, {
  210. text: "仓库编号",
  211. dataIndex: "pd_whcode",
  212. hidden: true
  213. }, {
  214. text: "仓库",
  215. dataIndex: "pd_whname",
  216. width: 110.0,
  217. allowBlank: false,
  218. editor: {
  219. displayField: "display",
  220. editable: true,
  221. format: "",
  222. hideTrigger: false,
  223. maxLength: 100.0,
  224. minValue: null,
  225. positiveNum: false,
  226. queryMode: "local",
  227. store: null,
  228. valueField: "value",
  229. xtype: "warehouseDbfindTrigger"
  230. }
  231. }, {
  232. text: "数量",
  233. dataIndex: "pd_inqty",
  234. xtype: 'numbercolumn',
  235. width: 110.0,
  236. allowBlank: false,
  237. editor: {
  238. xtype: "numberfield",
  239. decimalPrecision: 3,
  240. minValue: 0
  241. },
  242. renderer: function(v, m, r) {
  243. return saas.util.BaseUtil.numberFormat(v, 3, false);
  244. },
  245. summaryType: 'sum',
  246. summaryRenderer: function(v, d, f, m) {
  247. return saas.util.BaseUtil.numberFormat(v, 3, false);
  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. xtype: 'numbercolumn',
  263. width: 120,
  264. editor: {
  265. xtype: "numberfield",
  266. decimalPrecision: 4,
  267. minValue: 0
  268. },
  269. dataIndex: "pd_netprice",
  270. width: 120,
  271. renderer: function(v, m, r) {
  272. return saas.util.BaseUtil.numberFormat(v, 4, true);
  273. },
  274. }, {
  275. text: "含税单价(元)",
  276. xtype: 'numbercolumn',
  277. width: 120,
  278. editor: {
  279. xtype: "numberfield",
  280. decimalPrecision: 4,
  281. minValue: 0
  282. },
  283. dataIndex: "pd_orderprice",
  284. width: 120.0,
  285. renderer: function(v, m, r) {
  286. return saas.util.BaseUtil.numberFormat(v, 4, true);
  287. },
  288. listeners: {
  289. edit: function (value, grid) {
  290. var r = grid.getSelection()[0],
  291. pd_taxrate = r.get('pd_taxrate');
  292. var v = value / (1 + pd_taxrate / 100);
  293. r.set('pd_netprice', Number(saas.util.BaseUtil.numberFormat(v, 4, false)));
  294. }
  295. }
  296. }, {
  297. text: "金额(元)",
  298. xtype: 'numbercolumn',
  299. dataIndex: "pd_nettotal",
  300. width: 120,
  301. renderer: function(v, m, r) {
  302. return saas.util.BaseUtil.numberFormat(v, 2, true);
  303. },
  304. summaryType: 'sum',
  305. summaryRenderer: function(v, d, f, m) {
  306. return saas.util.BaseUtil.numberFormat(v, 2, true);
  307. }
  308. }, {
  309. xtype: 'numbercolumn',
  310. text: "税率(%)",
  311. dataIndex: "pd_taxrate",
  312. width: 80,
  313. editor: {
  314. xtype: "numberfield",
  315. decimalPrecision: 0,
  316. minValue: 0,
  317. maxValue: 100
  318. },
  319. renderer: function(v, m, r) {
  320. return saas.util.BaseUtil.numberFormat(v, 2, false);
  321. },
  322. }, {
  323. text: "税额(元)",
  324. xtype: 'numbercolumn',
  325. dataIndex: "pd_taxamount",
  326. width: 120,
  327. renderer: function(v, m, r) {
  328. return saas.util.BaseUtil.numberFormat(v, 2, true);
  329. },
  330. summaryType: 'sum',
  331. summaryRenderer: function(v, d, f, m) {
  332. return saas.util.BaseUtil.numberFormat(v, 2, true);
  333. }
  334. }, {
  335. text: "价税合计(元)",
  336. xtype: 'numbercolumn',
  337. dataIndex: "pd_ordertotal",
  338. width: 120,
  339. renderer: function(v, m, r) {
  340. return saas.util.BaseUtil.numberFormat(v, 2, true);
  341. },
  342. summaryType: 'sum',
  343. summaryRenderer: function(v, d, f, m) {
  344. return saas.util.BaseUtil.numberFormat(v, 2, true);
  345. }
  346. }, {
  347. text: "关联采购单号",
  348. dataIndex: "pd_ordercode",
  349. width: 150.0,
  350. ignore: true,
  351. }, {
  352. text: "备注",
  353. dataIndex: "pd_remark",
  354. width: 250,
  355. items: null,
  356. editor: {
  357. xtype: "textfield"
  358. }
  359. }, {
  360. dataIndex: "pd_text1",
  361. text: "自定义字段1",
  362. width: 100,
  363. hidden: true,
  364. initHidden: false,
  365. editor: {
  366. xtype: "textfield"
  367. },
  368. }, {
  369. dataIndex: "pd_text2",
  370. text: "自定义字段2",
  371. width: 100,
  372. hidden: true,
  373. initHidden: false,
  374. editor: {
  375. xtype: "textfield"
  376. },
  377. }, {
  378. dataIndex: "pd_text3",
  379. text: "自定义字段3",
  380. width: 100,
  381. hidden: true,
  382. initHidden: false,
  383. editor: {
  384. xtype: "textfield"
  385. },
  386. }, {
  387. dataIndex: "pd_text4",
  388. text: "自定义字段4",
  389. width: 100,
  390. hidden: true,
  391. initHidden: false,
  392. editor: {
  393. xtype: "textfield"
  394. },
  395. }, {
  396. dataIndex: "pd_text5",
  397. text: "自定义字段5",
  398. width: 100,
  399. hidden: true,
  400. initHidden: false,
  401. editor: {
  402. xtype: "textfield"
  403. },
  404. }]
  405. }, {
  406. xtype: "textfield",
  407. name: "pi_remark",
  408. fieldLabel: "备注",
  409. columnWidth: 1
  410. }, {
  411. xtype: "numberfield",
  412. name: "pi_nettotal",
  413. fieldLabel: "金额(元)",
  414. readOnly: true,
  415. thousandSeparator: ',',
  416. columnWidth: 0.25
  417. }, {
  418. xtype: "numberfield",
  419. name: "pi_total",
  420. fieldLabel: "价税合计(元)",
  421. readOnly: true,
  422. thousandSeparator: ',',
  423. columnWidth: 0.25
  424. }, {
  425. xtype: "hidden",
  426. name: "pi_buyercode",
  427. fieldLabel: "采购员编号"
  428. }, {
  429. xtype: "employeeDbfindTrigger",
  430. name: "pi_buyername",
  431. fieldLabel: "采购员",
  432. columnWidth: 0.25
  433. }, {
  434. xtype: "hidden",
  435. name: "pi_buyerid",
  436. fieldLabel: "采购员ID"
  437. }, {
  438. xtype: "hidden",
  439. name: "creatorId",
  440. fieldLabel: "录入人ID",
  441. readOnly: true
  442. }, {
  443. xtype: "textfield",
  444. name: "creatorName",
  445. fieldLabel: "录入人",
  446. readOnly: true
  447. }, {
  448. xtype: "datefield",
  449. name: "createTime",
  450. fieldLabel: "录入日期",
  451. readOnly: true,
  452. defaultValue: new Date()
  453. }, {
  454. xtype: "hidden",
  455. name: "updaterId",
  456. fieldLabel: "更新人ID",
  457. readOnly: true
  458. }, {
  459. xtype: "hidden",
  460. name: "updaterName",
  461. fieldLabel: "更新人",
  462. readOnly: true
  463. }, {
  464. xtype: "hidden",
  465. name: "updateTime",
  466. fieldLabel: "更新日期",
  467. readOnly: true,
  468. defaultValue: new Date()
  469. }, {
  470. xtype: "textfield",
  471. name: "pi_auditman",
  472. fieldLabel: "审核人",
  473. readOnly: true
  474. }, {
  475. xtype: "datefield",
  476. name: "pi_auditdate",
  477. fieldLabel: "审核日期",
  478. readOnly: true
  479. }, {
  480. xtype: "textfield",
  481. name: "pi_text1",
  482. fieldLabel: "自定义字段1",
  483. hidden: true,
  484. initHidden: false
  485. }, {
  486. xtype: "textfield",
  487. name: "pi_text2",
  488. fieldLabel: "自定义字段2",
  489. hidden: true,
  490. initHidden: false
  491. }, {
  492. xtype: "textfield",
  493. name: "pi_text3",
  494. fieldLabel: "自定义字段3",
  495. hidden: true,
  496. initHidden: false
  497. }, {
  498. xtype: "textfield",
  499. name: "pi_text4",
  500. fieldLabel: "自定义字段4",
  501. hidden: true,
  502. initHidden: false
  503. }, {
  504. xtype: "textfield",
  505. name: "pi_text5",
  506. fieldLabel: "自定义字段5",
  507. hidden: true,
  508. initHidden: false
  509. }],
  510. });
  511. this.callParent(arguments);
  512. },
  513. beforeAudit: function () {
  514. var me = this,
  515. viewModel = me.getViewModel(),
  516. grid = me.down('detailGridField'),
  517. data = grid.getTrueData();
  518. Ext.Array.each(data, function (item) {
  519. if (item.pd_orderprice == 0) {
  520. saas.util.BaseUtil.showErrorToast(item.pd_pdno + '行' + item.pd_prodcode + '物料单价为0');
  521. }
  522. });
  523. return true;
  524. }
  525. });