FormPanel.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. Ext.define('saas.view.purchase.purchase.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: 'purchase-purchase-formpanel',
  4. controller: 'purchase-purchase-formpanel',
  5. viewModel: 'purchase-purchase-formpanel',
  6. viewName: 'purchase-purchase-formpanel',
  7. caller: 'Purchase',
  8. //字段属性
  9. _title: '采购订单',
  10. _idField: 'id',
  11. _codeField: 'pu_code',
  12. _statusField: 'pu_status',
  13. _statusCodeField: 'pu_statuscode',
  14. _auditmanField: 'pu_auditman',
  15. _auditdateField: 'pu_auditdate',
  16. _relationColumn: 'pd_puid',
  17. _readUrl: '/api/purchase/purchase/read',
  18. _saveUrl: '/api/purchase/purchase/save',
  19. _auditUrl: '/api/purchase/purchase/audit',
  20. _unAuditUrl: '/api/purchase/purchase/unAudit',
  21. _deleteUrl: '/api/purchase/purchase/delete',
  22. _turnInUrl: '/api/purchase/purchase/turnProdin',
  23. initId: 0,
  24. initComponent: function () {
  25. Ext.apply(this, {
  26. defaultItems: [{
  27. xtype: 'hidden',
  28. name: 'id',
  29. fieldLabel: 'id'
  30. }, {
  31. xtype: "hidden",
  32. name: "pu_vendid",
  33. fieldLabel: "供应商ID"
  34. }, {
  35. xtype: "hidden",
  36. name: "pu_vendcode",
  37. fieldLabel: "供应商编号"
  38. }, {
  39. xtype: "vendorDbfindTrigger",
  40. name: "pu_vendname",
  41. fieldLabel: "供应商名称",
  42. allowBlank: false,
  43. columnWidth: 0.5
  44. }, {
  45. xtype: 'condbfindtrigger',
  46. fieldLabel: '币别汇率',
  47. allowBlank: false,
  48. dbType: 'currencyDbfindTrigger',
  49. dbfinds: [{
  50. from: 'cr_name',
  51. to: 'pu_currency'
  52. }, {
  53. from: 'cr_rate',
  54. to: 'pu_rate'
  55. }],
  56. // defaultValue: {
  57. // pu_currency: 'RMB',
  58. // pu_rate: 1
  59. // },
  60. supFieldConfig: {
  61. xtype: 'numberfield',
  62. readOnly: false,
  63. defaultReadOnly: false,
  64. defaultValue: 1,
  65. decimalPrecision: 6,
  66. vtype: 'positiveNumber',
  67. listeners: {
  68. change: function (f, v) {
  69. var defaultCurrency = Ext.getCmp('mainView').getViewModel().get('defaultCurrency');
  70. f.setReadOnly(f.ownerCt.items.items[0].value == defaultCurrency);
  71. }
  72. }
  73. }
  74. }, {
  75. xtype: "datefield",
  76. name: "pu_delivery",
  77. fieldLabel: "需求日期",
  78. allowBlank: false,
  79. defaultValue: new Date(),
  80. columnWidth: 0.25,
  81. }, {
  82. name: "pu_shipaddresscode",
  83. editable: false,
  84. xtype: "remotecombo",
  85. storeUrl: '/api/document/address/getCombo',
  86. fieldLabel: "交货地址",
  87. allowBlank: false,
  88. columnWidth: 0.5,
  89. hiddenBtn: false, //true 则会关闭新增按钮功能
  90. addHandler: function (b) {
  91. var form = this.ownerCmp.ownerCt;
  92. this.dialog = form.add({
  93. xtype: 'document-address-window',
  94. bind: {
  95. title: '新增交货地址'
  96. },
  97. _parent: form,
  98. _combo: this.ownerCmp,
  99. record: null,
  100. session: true
  101. });
  102. this.dialog.show();
  103. }
  104. }, {
  105. xtype: 'textfield',
  106. name: 'ssstatus',
  107. fieldLabel: '上传状态',
  108. bind: {
  109. hidden: '{!enableB2B}'
  110. }
  111. }, {
  112. name: "detailGridField",
  113. xtype: "detailGridField",
  114. storeModel: 'saas.model.purchase.Purchasedetail',
  115. detnoColumn: 'pd_detno',
  116. deleteDetailUrl: '/api/purchase/purchase/deleteDetail',
  117. allowEmpty: false,
  118. columns: [{
  119. text: "id",
  120. dataIndex: "id",
  121. xtype: "numbercolumn",
  122. hidden: true
  123. }, {
  124. text: "物料id",
  125. dataIndex: "pd_prodid",
  126. xtype: "numbercolumn",
  127. hidden: true
  128. }, {
  129. text: "物料编号",
  130. width: 150.0,
  131. dataIndex: "pd_prodcode",
  132. allowBlank: false,
  133. editor: {
  134. xtype: "productMultiDbfindTrigger"
  135. }
  136. }, {
  137. text: "品牌",
  138. width: 100.0,
  139. dataIndex: "pr_brand",
  140. ignore: true,
  141. renderer: function (v, m, r) {
  142. if (!v) {
  143. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  144. }
  145. return v;
  146. }
  147. }, {
  148. text: "物料名称",
  149. width: 150.0,
  150. dataIndex: "pr_detail",
  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: 200.0,
  161. dataIndex: "pr_orispeccode",
  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: 'model映射需要',
  171. dataIndex: 'productDTO',
  172. hidden: true,
  173. }, {
  174. text: "规格",
  175. width: 200,
  176. dataIndex: "pr_spec",
  177. ignore: true,
  178. renderer: function (v, m, r) {
  179. if (!v) {
  180. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  181. }
  182. return v;
  183. }
  184. }, {
  185. text: "数量",
  186. dataIndex: "pd_qty",
  187. xtype: 'numbercolumn',
  188. width: 110.0,
  189. allowBlank: false,
  190. editor: {
  191. xtype: "numberfield",
  192. decimalPrecision: 3,
  193. minValue: 0
  194. },
  195. renderer: function (v, m, r) {
  196. return saas.util.BaseUtil.numberFormat(v, 3, false);
  197. },
  198. summaryType: 'sum',
  199. summaryRenderer: function (v, d, f, m) {
  200. return saas.util.BaseUtil.numberFormat(v, 3, false);
  201. }
  202. }, {
  203. text: "单位",
  204. width: 65.0,
  205. dataIndex: "pr_unit",
  206. ignore: true,
  207. renderer: function (v, m, r) {
  208. if (!v) {
  209. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  210. }
  211. return v;
  212. }
  213. }, {
  214. text: "单价(元)",
  215. xtype: 'numbercolumn',
  216. dataIndex: "pd_taxprice",
  217. width: 120,
  218. editor: {
  219. xtype: "numberfield",
  220. decimalPrecision: 4,
  221. minValue: 0
  222. },
  223. renderer: function (v, m, r) {
  224. return saas.util.BaseUtil.numberFormat(v, 4, true);
  225. }
  226. }, {
  227. text: "含税单价(元)",
  228. xtype: 'numbercolumn',
  229. dataIndex: "pd_price",
  230. width: 120,
  231. editor: {
  232. xtype: "numberfield",
  233. decimalPrecision: 4,
  234. minValue: 0
  235. },
  236. renderer: function (v, m, r) {
  237. return saas.util.BaseUtil.numberFormat(v, 4, true);
  238. },
  239. listeners: {
  240. edit: function (value, grid) {
  241. var r = grid.getSelection()[0],
  242. pd_taxrate = r.get('pd_taxrate');
  243. var v = value / (1 + pd_taxrate / 100);
  244. r.set('pd_taxprice', Number(saas.util.BaseUtil.numberFormat(v, 4, false)));
  245. }
  246. }
  247. }, {
  248. text: "金额(元)",
  249. xtype: 'numbercolumn',
  250. dataIndex: "pd_taxtotal",
  251. width: 120,
  252. renderer: function (v, m, r) {
  253. return saas.util.BaseUtil.numberFormat(v, 2, true);
  254. },
  255. summaryType: 'sum',
  256. summaryRenderer: function (v, d, f, m) {
  257. return saas.util.BaseUtil.numberFormat(v, 2, true);
  258. }
  259. }, {
  260. text: "税率(%)",
  261. xtype: 'numbercolumn',
  262. dataIndex: "pd_taxrate",
  263. width: 80,
  264. editor: {
  265. xtype: "numberfield",
  266. decimalPrecision: 0,
  267. minValue: 0,
  268. maxValue: 100
  269. },
  270. renderer: function (v, m, r) {
  271. return saas.util.BaseUtil.numberFormat(v, 2, false);
  272. }
  273. }, {
  274. text: "税额(元)",
  275. xtype: 'numbercolumn',
  276. dataIndex: "pd_taxamount",
  277. width: 120,
  278. renderer: function (v, m, r) {
  279. return saas.util.BaseUtil.numberFormat(v, 2, true);
  280. },
  281. summaryType: 'sum',
  282. summaryRenderer: function (v, d, f, m) {
  283. return saas.util.BaseUtil.numberFormat(v, 2, true);
  284. }
  285. }, {
  286. text: "价税合计(元)",
  287. xtype: 'numbercolumn',
  288. dataIndex: "pd_total",
  289. width: 120,
  290. renderer: function (v, m, r) {
  291. return saas.util.BaseUtil.numberFormat(v, 2, true);
  292. },
  293. summaryType: 'sum',
  294. summaryRenderer: function (v, d, f, m) {
  295. return saas.util.BaseUtil.numberFormat(v, 2, true);
  296. }
  297. }, {
  298. text: "需求日期",
  299. dataIndex: "pd_delivery",
  300. xtype: 'datecolumn',
  301. width: 110.0,
  302. editor: {
  303. xtype: "datefield",
  304. editable: false,
  305. hideTrigger: false
  306. }
  307. }, {
  308. text: "最小包装数",
  309. xtype: 'numbercolumn',
  310. dataIndex: "pr_zxbzs",
  311. width: 100.0,
  312. ignore: true,
  313. renderer: function (v, m, r) {
  314. if (!v) {
  315. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  316. }
  317. return v;
  318. }
  319. }, {
  320. text: "关联销售单号",
  321. dataIndex: "pd_salecode",
  322. width: 150.0,
  323. ignore: true,
  324. }, {
  325. text: "备注",
  326. dataIndex: "pd_remark",
  327. width: 250,
  328. items: null,
  329. editor: {
  330. xtype: "textfield"
  331. },
  332. }, {
  333. dataIndex: "pd_text1",
  334. text: "自定义字段1",
  335. width: 100,
  336. hidden: true,
  337. initHidden: false,
  338. editor: {
  339. xtype: "textfield"
  340. },
  341. }, {
  342. dataIndex: "pd_text2",
  343. text: "自定义字段2",
  344. width: 100,
  345. hidden: true,
  346. initHidden: false,
  347. editor: {
  348. xtype: "textfield"
  349. },
  350. }, {
  351. dataIndex: "pd_text3",
  352. text: "自定义字段3",
  353. width: 100,
  354. hidden: true,
  355. initHidden: false,
  356. editor: {
  357. xtype: "textfield"
  358. },
  359. }, {
  360. dataIndex: "pd_text4",
  361. text: "自定义字段4",
  362. width: 100,
  363. hidden: true,
  364. initHidden: false,
  365. editor: {
  366. xtype: "textfield"
  367. },
  368. }, {
  369. dataIndex: "pd_text5",
  370. text: "自定义字段5",
  371. width: 100,
  372. hidden: true,
  373. initHidden: false,
  374. editor: {
  375. xtype: "textfield"
  376. },
  377. }]
  378. }, {
  379. xtype: "textfield",
  380. name: "pu_remark",
  381. fieldLabel: "备注",
  382. columnWidth: 1
  383. }, {
  384. xtype: "datefield",
  385. name: "pu_date",
  386. fieldLabel: "单据日期",
  387. defaultValue: new Date()
  388. }, {
  389. xtype: "numberfield",
  390. name: "pu_total",
  391. fieldLabel: "价税合计(元)",
  392. readOnly: true,
  393. thousandSeparator: ',',
  394. columnWidth: 0.25,
  395. }, {
  396. xtype: "hidden",
  397. name: "pu_buyercode",
  398. fieldLabel: "采购员编号"
  399. }, {
  400. xtype: "employeeDbfindTrigger",
  401. name: "pu_buyername",
  402. fieldLabel: "采购员",
  403. columnWidth: 0.25
  404. }, {
  405. xtype: "hidden",
  406. name: "pu_buyerid",
  407. fieldLabel: "采购员ID"
  408. }, {
  409. xtype: "hidden",
  410. name: "creatorId",
  411. fieldLabel: "录入人ID",
  412. readOnly: true
  413. }, {
  414. xtype: "textfield",
  415. name: "creatorName",
  416. fieldLabel: "录入人",
  417. readOnly: true
  418. }, {
  419. xtype: "datefield",
  420. name: "createTime",
  421. fieldLabel: "录入日期",
  422. readOnly: true,
  423. defaultValue: new Date()
  424. }, {
  425. xtype: "hidden",
  426. name: "updaterId",
  427. fieldLabel: "更新人ID",
  428. readOnly: true
  429. }, {
  430. xtype: "hidden",
  431. name: "updaterName",
  432. fieldLabel: "更新人",
  433. readOnly: true
  434. }, {
  435. xtype: "hidden",
  436. name: "updateTime",
  437. fieldLabel: "更新日期",
  438. readOnly: true,
  439. defaultValue: new Date()
  440. }, {
  441. xtype: "textfield",
  442. name: "pu_auditman",
  443. fieldLabel: "审核人",
  444. readOnly: true
  445. }, {
  446. xtype: "datefield",
  447. name: "pu_auditdate",
  448. fieldLabel: "审核日期",
  449. readOnly: true
  450. }, {
  451. xtype: "textfield",
  452. name: "pu_text1",
  453. fieldLabel: "自定义字段1",
  454. hidden: true,
  455. initHidden: false
  456. }, {
  457. xtype: "textfield",
  458. name: "pu_text2",
  459. fieldLabel: "自定义字段2",
  460. hidden: true,
  461. initHidden: false
  462. }, {
  463. xtype: "textfield",
  464. name: "pu_text3",
  465. fieldLabel: "自定义字段3",
  466. hidden: true,
  467. initHidden: false
  468. }, {
  469. xtype: "textfield",
  470. name: "pu_text4",
  471. fieldLabel: "自定义字段4",
  472. hidden: true,
  473. initHidden: false
  474. }, {
  475. xtype: "textfield",
  476. name: "pu_text5",
  477. fieldLabel: "自定义字段5",
  478. hidden: true,
  479. initHidden: false
  480. }]
  481. });
  482. this.callParent();
  483. },
  484. toolBtns: [{
  485. xtype: 'button',
  486. text: '转采购验收单',
  487. hidden: true,
  488. bind: {
  489. hidden: '{turnHidden}'
  490. },
  491. handler: 'turnIn'
  492. }],
  493. initFormData: function (data) {
  494. var me = this;
  495. me.setFormData(data);
  496. if (data.main.pu_statuscode != 'AUDITED' && !data.main.pu_shipaddresscode) {
  497. //读取默认地址
  498. saas.util.BaseUtil.request({
  499. url: '/api/document/address/getDefault',
  500. method: 'GET',
  501. })
  502. .then(function (localJson) {
  503. var data = localJson.data;
  504. if (data && data.ad_address) {
  505. var f = me.down('[name=pu_shipaddresscode]');
  506. f.setValue(data.ad_address)
  507. } else {
  508. saas.util.BaseUtil.showErrorToast('未设置默认采购交货地址,维护后新增会自动给采购交货地址赋默认值');
  509. }
  510. })
  511. .catch(function (e) {
  512. saas.util.BaseUtil.showErrorToast('获取默认采购交货地址失败: ' + e.message);
  513. });
  514. }
  515. me.clearDirty();
  516. }
  517. });