FormPanel.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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. toolBtns: [{
  25. xtype: 'button',
  26. text: '转采购验退单',
  27. hidden: true,
  28. bind: {
  29. hidden: '{turnHidden}'
  30. },
  31. handler: 'turnOut'
  32. }],
  33. defaultItems: [{
  34. xtype: 'hidden',
  35. name: 'id',
  36. fieldLabel: 'id',
  37. allowBlank: true,
  38. columnWidth: 0
  39. }, {
  40. xtype: "hidden",
  41. name: "pi_class",
  42. fieldLabel: "单据类型",
  43. readOnly: true,
  44. allowBlank: true,
  45. columnWidth: 0.25
  46. }, {
  47. xtype: "hidden",
  48. name: "pi_vendid",
  49. fieldLabel: "供应商ID",
  50. allowBlank: true,
  51. columnWidth: 0.0
  52. }, {
  53. xtype: 'hidden',
  54. name: 'pi_vendcode',
  55. fieldLabel: '供应商编号'
  56. }, {
  57. xtype: 'vendorDbfindTrigger',
  58. name: 'pi_vendname',
  59. fieldLabel: '供应商名称',
  60. allowBlank: false,
  61. }, {
  62. xtype: "datefield",
  63. name: "pi_date",
  64. fieldLabel: "单据日期",
  65. allowBlank: false,
  66. columnWidth: 0.25,
  67. defaultValue: new Date()
  68. }, {
  69. xtype: "textfield",
  70. name: "pi_total",
  71. fieldLabel: "总额",
  72. allowBlank: true,
  73. readOnly: true,
  74. columnWidth: 0.25
  75. }, {
  76. xtype: "hidden",
  77. name: "pi_puid",
  78. fieldLabel: "采购单id",
  79. allowBlank: true,
  80. columnWidth: 0.25
  81. }, {
  82. xtype: "hidden",
  83. name: "pi_pucode",
  84. fieldLabel: "采购单号",
  85. allowBlank: true,
  86. columnWidth: 0.25
  87. }, {
  88. name: "detailGridField",
  89. xtype: "detailGridField",
  90. storeModel: 'saas.model.purchase.ProdInDetail',
  91. deleteDetailUrl: '/api/purchase/prodinout/deleteDetail',
  92. detnoColumn: 'pd_pdno',
  93. columns: [{
  94. text: "id",
  95. dataIndex: "id",
  96. xtype: "numbercolumn",
  97. hidden: true
  98. }, {
  99. text: "物料id",
  100. dataIndex: "pd_prodid",
  101. xtype: "numbercolumn",
  102. hidden: true
  103. }, {
  104. text: "物料编号",
  105. width: 150.0,
  106. dataIndex: "pd_prodcode",
  107. xtype: "",
  108. items: null,
  109. allowBlank: false,
  110. editor: {
  111. displayField: "display",
  112. editable: true,
  113. format: "",
  114. hideTrigger: false,
  115. maxLength: 100.0,
  116. minValue: null,
  117. positiveNum: false,
  118. queryMode: "local",
  119. store: null,
  120. valueField: "value",
  121. xtype: "productMultiDbfindTrigger"
  122. }
  123. }, {
  124. text: "品牌",
  125. width: 150.0,
  126. dataIndex: "pr_brand",
  127. ignore: true,
  128. renderer: function (v, m, r) {
  129. if (!v) {
  130. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  131. }
  132. return v;
  133. }
  134. }, {
  135. text: "名称",
  136. width: 200.0,
  137. dataIndex: "pr_detail",
  138. ignore: true,
  139. renderer: function (v, m, r) {
  140. if (!v) {
  141. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  142. }
  143. return v;
  144. }
  145. }, {
  146. text: "型号",
  147. width: 200.0,
  148. dataIndex: "pr_orispeccode",
  149. ignore: true,
  150. renderer: function (v, m, r) {
  151. if (!v) {
  152. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  153. }
  154. return v;
  155. }
  156. }, {
  157. text: "规格",
  158. width: 150,
  159. dataIndex: "pr_spec",
  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: 'model映射需要',
  169. dataIndex: 'productDTO',
  170. hidden: true,
  171. }, {
  172. text: "数量",
  173. dataIndex: "pd_inqty",
  174. xtype: 'numbercolumn',
  175. width: 110.0,
  176. allowBlank: false,
  177. editor: {
  178. xtype: "numberfield",
  179. decimalPrecision: 3,
  180. minValue: 0
  181. },
  182. renderer: function (v) {
  183. var arr = (v + '.').split('.');
  184. var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
  185. var format = '0.' + xr.join('');
  186. return Ext.util.Format.number(v, format);
  187. },
  188. summaryType: 'sum',
  189. summaryRenderer: function (v) {
  190. var arr = (v + '.').split('.');
  191. var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
  192. var format = '0.' + xr.join('');
  193. return Ext.util.Format.number(v, format);
  194. }
  195. }, {
  196. text: "单位",
  197. width: 80.0,
  198. dataIndex: "pr_unit",
  199. ignore: true,
  200. renderer: function (v, m, r) {
  201. if (!v) {
  202. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  203. }
  204. return v;
  205. }
  206. }, {
  207. text: "单价(元)",
  208. xtype: 'numbercolumn',
  209. width: 120,
  210. editor: {
  211. xtype: "numberfield",
  212. decimalPrecision: 4,
  213. minValue: 0
  214. },
  215. dataIndex: "pd_netprice",
  216. width: 120.0,
  217. renderer: function (v) {
  218. var arr = (v + '.').split('.');
  219. var xr = (new Array(arr[1].length > 4 ? 4 : arr[1].length)).fill('0');
  220. var format = '0,000.' + xr.join('');
  221. return Ext.util.Format.number(v, format);
  222. },
  223. }, {
  224. text: "含税单价(元)",
  225. xtype: 'numbercolumn',
  226. width: 120,
  227. editor: {
  228. xtype: "numberfield",
  229. decimalPrecision: 4,
  230. minValue: 0
  231. },
  232. dataIndex: "pd_orderprice",
  233. width: 120.0,
  234. renderer: function (v) {
  235. var arr = (v + '.').split('.');
  236. var xr = (new Array(arr[1].length > 4 ? 4 : arr[1].length)).fill('0');
  237. var format = '0,000.' + xr.join('');
  238. return Ext.util.Format.number(v, format);
  239. },
  240. listeners: {
  241. edit: function (value, grid) {
  242. var r = grid.getSelection()[0],
  243. pd_taxrate = r.get('pd_taxrate');
  244. r.set('pd_netprice', value / (1 + pd_taxrate / 100));
  245. }
  246. }
  247. }, {
  248. text: "金额",
  249. xtype: 'numbercolumn',
  250. dataIndex: "pd_nettotal",
  251. width: 120,
  252. renderer: function (v) {
  253. var arr = (v + '.').split('.');
  254. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  255. var format = '0,000.' + xr.join('');
  256. return Ext.util.Format.number(v, format);
  257. },
  258. summaryType: 'sum',
  259. summaryRenderer: function (v) {
  260. var arr = (v + '.').split('.');
  261. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  262. var format = '0,000.' + xr.join('');
  263. return Ext.util.Format.number(v, format);
  264. }
  265. }, {
  266. xtype: 'numbercolumn',
  267. text: "税率",
  268. dataIndex: "pd_taxrate",
  269. width: 80,
  270. editor: {
  271. xtype: "numberfield",
  272. decimalPrecision: 0,
  273. minValue: 0,
  274. maxValue: 100
  275. },
  276. renderer: function (v) {
  277. return Ext.util.Format.number(v, '0');
  278. },
  279. }, {
  280. text: "税额",
  281. xtype: 'numbercolumn',
  282. dataIndex: "pd_taxamount",
  283. width: 120,
  284. renderer: function (v) {
  285. var arr = (v + '.').split('.');
  286. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  287. var format = '0,000.' + xr.join('');
  288. return Ext.util.Format.number(v, format);
  289. },
  290. summaryType: 'sum',
  291. summaryRenderer: function (v) {
  292. var arr = (v + '.').split('.');
  293. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  294. var format = '0,000.' + xr.join('');
  295. return Ext.util.Format.number(v, format);
  296. }
  297. }, {
  298. text: "价税合计",
  299. xtype: 'numbercolumn',
  300. dataIndex: "pd_ordertotal",
  301. width: 120,
  302. renderer: function (v) {
  303. var arr = (v + '.').split('.');
  304. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  305. var format = '0,000.' + xr.join('');
  306. return Ext.util.Format.number(v, format);
  307. },
  308. summaryType: 'sum',
  309. summaryRenderer: function (v) {
  310. var arr = (v + '.').split('.');
  311. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  312. var format = '0,000.' + xr.join('');
  313. return Ext.util.Format.number(v, format);
  314. }
  315. }, {
  316. text: "仓库id",
  317. dataIndex: "pd_whid",
  318. xtype: "numbercolumn",
  319. hidden: true
  320. }, {
  321. text: "仓库编号",
  322. dataIndex: "pd_whcode",
  323. hidden: true
  324. }, {
  325. text: "仓库",
  326. dataIndex: "pd_whname",
  327. width: 150.0,
  328. allowBlank: false,
  329. editor: {
  330. displayField: "display",
  331. editable: true,
  332. format: "",
  333. hideTrigger: false,
  334. maxLength: 100.0,
  335. minValue: null,
  336. positiveNum: false,
  337. queryMode: "local",
  338. store: null,
  339. valueField: "value",
  340. xtype: "warehouseDbfindTrigger"
  341. }
  342. }, {
  343. text: "采购单明细id",
  344. dataIndex: "pd_orderid",
  345. ignore: true,
  346. hidden: true
  347. }, {
  348. text: "采购单号",
  349. dataIndex: "pd_ordercode",
  350. width: 150.0,
  351. ignore: true,
  352. }, {
  353. text: "采购序号",
  354. dataIndex: "pd_orderdetno",
  355. xtype: "numbercolumn",
  356. width: 110.0,
  357. format: '0',
  358. ignore: true,
  359. renderer: function (v) {
  360. if (v) {
  361. return Ext.util.Format.number(v, '0');
  362. } else {
  363. return null;
  364. }
  365. }
  366. }, {
  367. text: "备注",
  368. dataIndex: "pd_remark",
  369. width: 250,
  370. items: null,
  371. editor: {
  372. xtype: "textfield"
  373. },
  374. }]
  375. }, {
  376. xtype: "textfield",
  377. name: "pi_remark",
  378. fieldLabel: "备注",
  379. columnWidth: 1
  380. }, {
  381. xtype: "hidden",
  382. name: "creatorId",
  383. fieldLabel: "录入人ID",
  384. readOnly: true
  385. }, {
  386. xtype: "textfield",
  387. name: "creatorName",
  388. fieldLabel: "录入人",
  389. readOnly: true
  390. }, {
  391. xtype: "datefield",
  392. name: "createTime",
  393. fieldLabel: "录入日期",
  394. readOnly: true,
  395. defaultValue: new Date()
  396. }, {
  397. xtype: "hidden",
  398. name: "updaterId",
  399. fieldLabel: "更新人ID",
  400. readOnly: true
  401. }, {
  402. xtype: "hidden",
  403. name: "updaterName",
  404. fieldLabel: "更新人",
  405. readOnly: true
  406. }, {
  407. xtype: "hidden",
  408. name: "updateTime",
  409. fieldLabel: "更新日期",
  410. readOnly: true,
  411. defaultValue: new Date()
  412. }, {
  413. xtype: "textfield",
  414. name: "pi_auditman",
  415. fieldLabel: "审核人",
  416. readOnly: true
  417. }, {
  418. xtype: "datefield",
  419. name: "pi_auditdate",
  420. fieldLabel: "审核日期",
  421. readOnly: true
  422. }],
  423. beforeAudit: function () {
  424. var me = this,
  425. viewModel = me.getViewModel(),
  426. grid = me.down('detailGridField'),
  427. data = grid.getTrueData();
  428. Ext.Array.each(data, function (item) {
  429. if (item.pd_orderprice == 0) {
  430. saas.util.BaseUtil.showErrorToast(item.pd_pdno + '行' + item.pd_prodcode + '物料单价为0');
  431. }
  432. });
  433. return true;
  434. }
  435. });