FormPanel.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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.applyIf(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) {
  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) {
  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) {
  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) {
  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. }, {
  323. xtype: "textfield",
  324. name: "pi_remark",
  325. fieldLabel: "备注",
  326. columnWidth: 1
  327. }, {
  328. xtype: "textfield",
  329. name: "pi_currency",
  330. fieldLabel: "币别",
  331. readOnly: true,
  332. defaultValue: 'RMB'
  333. }, {
  334. xtype: "numberfield",
  335. name: "pi_nettotal",
  336. fieldLabel: "金额(元)",
  337. readOnly: true,
  338. thousandSeparator: ',',
  339. columnWidth: 0.25
  340. }, {
  341. xtype: "numberfield",
  342. name: "pi_total",
  343. fieldLabel: "价税合计(元)",
  344. readOnly: true,
  345. thousandSeparator: ',',
  346. columnWidth: 0.25
  347. }, {
  348. xtype: "hidden",
  349. name: "pi_buyercode",
  350. fieldLabel: "采购员编号"
  351. }, {
  352. xtype: "employeeDbfindTrigger",
  353. name: "pi_buyername",
  354. fieldLabel: "采购员",
  355. columnWidth: 0.25
  356. }, {
  357. xtype: "hidden",
  358. name: "pi_buyerid",
  359. fieldLabel: "采购员ID"
  360. }, {
  361. xtype: "hidden",
  362. name: "creatorId",
  363. fieldLabel: "录入人ID",
  364. readOnly: true
  365. }, {
  366. xtype: "textfield",
  367. name: "creatorName",
  368. fieldLabel: "录入人",
  369. readOnly: true
  370. }, {
  371. xtype: "datefield",
  372. name: "createTime",
  373. fieldLabel: "录入日期",
  374. readOnly: true,
  375. defaultValue: new Date()
  376. }, {
  377. xtype: "hidden",
  378. name: "updaterId",
  379. fieldLabel: "更新人ID",
  380. readOnly: true
  381. }, {
  382. xtype: "hidden",
  383. name: "updaterName",
  384. fieldLabel: "更新人",
  385. readOnly: true
  386. }, {
  387. xtype: "hidden",
  388. name: "updateTime",
  389. fieldLabel: "更新日期",
  390. readOnly: true,
  391. defaultValue: new Date()
  392. }, {
  393. xtype: "textfield",
  394. name: "pi_auditman",
  395. fieldLabel: "审核人",
  396. readOnly: true
  397. }, {
  398. xtype: "datefield",
  399. name: "pi_auditdate",
  400. fieldLabel: "审核日期",
  401. readOnly: true
  402. }],
  403. });
  404. this.callParent(arguments);
  405. },
  406. beforeAudit: function () {
  407. var me = this,
  408. viewModel = me.getViewModel(),
  409. grid = me.down('detailGridField'),
  410. data = grid.getTrueData();
  411. Ext.Array.each(data, function (item) {
  412. if (item.pd_orderprice == 0) {
  413. saas.util.BaseUtil.showErrorToast(item.pd_pdno + '行' + item.pd_prodcode + '物料单价为0');
  414. }
  415. });
  416. return true;
  417. }
  418. });