FormPanel.js 19 KB

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