FormPanel.js 18 KB

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