FormPanel.js 18 KB

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