FormPanel.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. Ext.define('saas.view.sale.saleout.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: 'sale-saleout-formpanel',
  4. controller: 'sale-saleout-formpanel',
  5. viewModel: 'sale-saleout-formpanel',
  6. viewName: 'sale-saleout-formpanel',
  7. caller: 'SaleOut',
  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/sale/prodinout/read',
  18. _saveUrl: '/api/sale/prodinout/save',
  19. _auditUrl: '/api/sale/prodinout/audit',
  20. _unAuditUrl: '/api/sale/prodinout/unAudit',
  21. _deleteUrl: '/api/sale/prodinout/delete',
  22. _turnInUrl: '/api/sale/prodinout/turnProdIn',
  23. initId: 0,
  24. initComponent: function () {
  25. Ext.apply(this, {
  26. toolBtns: [{
  27. xtype: 'button',
  28. text: '转销售退货',
  29. handler: 'turnProdIn',
  30. hidden: true,
  31. bind: {
  32. hidden: '{pi_statuscode!="AUDITED"}'
  33. }
  34. }],
  35. defaultItems: [{
  36. xtype: 'hidden',
  37. name: 'id',
  38. fieldLabel: 'id'
  39. }, {
  40. xtype: "hidden",
  41. name: "pi_class",
  42. fieldLabel: "单据类型",
  43. readOnly: true,
  44. allowBlank: false,
  45. defaultValue: '出货单'
  46. }, {
  47. xtype: "hidden",
  48. name: "pi_custid",
  49. fieldLabel: "客户ID"
  50. }, {
  51. xtype: "hidden",
  52. name: "pi_custcode",
  53. fieldLabel: "客户编号"
  54. }, {
  55. xtype: "customerDbfindTrigger",
  56. name: "pi_custname",
  57. fieldLabel: "客户名称",
  58. allowBlank: false,
  59. columnWidth: 0.5,
  60. setValue: function (value) {
  61. var me = this,
  62. bind, valueBind;
  63. var form = me.ownerCt;
  64. var c = form.down('[name=pi_address]');
  65. if (value && value != '') {
  66. c.setDisabled(false);
  67. } else {
  68. c.setDisabled(true);
  69. }
  70. if (me.hasFocus) {
  71. bind = me.getBind();
  72. valueBind = bind && bind.value;
  73. if (valueBind && valueBind.syncing) {
  74. if ((Ext.isEmpty(value) && Ext.isEmpty(me.value)) || value === me.value) {
  75. return me;
  76. } else if (Ext.isArray(value) && Ext.isArray(me.value) && Ext.Array.equals(value, me.value)) {
  77. return me;
  78. }
  79. }
  80. } else {
  81. me.lastSelectedRecords = null;
  82. }
  83. if (value != null) {
  84. me.doSetValue(value);
  85. } else {
  86. me.suspendEvent('select');
  87. me.valueCollection.beginUpdate();
  88. me.pickerSelectionModel.deselectAll();
  89. me.valueCollection.endUpdate();
  90. me.resumeEvent('select');
  91. }
  92. return me;
  93. }
  94. }, {
  95. xtype: "datefield",
  96. name: "pi_date",
  97. fieldLabel: "单据日期",
  98. allowBlank: false,
  99. columnWidth: 0.25,
  100. defaultValue: new Date()
  101. }, {
  102. xtype: 'condbfindtrigger',
  103. fieldLabel: '币别汇率',
  104. allowBlank: false,
  105. dbType: 'currencyDbfindTrigger',
  106. dbfinds: [{
  107. from: 'cr_name', to: 'pi_currency'
  108. }, {
  109. from: 'cr_rate', to: 'pi_rate'
  110. }],
  111. // defaultValue: {
  112. // pi_currency: this.getViewModel().get('defaultCurrency'),
  113. // pi_rate: 1
  114. // },
  115. supFieldConfig: {
  116. xtype: 'numberfield',
  117. readOnly: false,
  118. defaultReadOnly: false,
  119. defaultValue: 1,
  120. decimalPrecision: 6,
  121. vtype: 'positiveNumber',
  122. listeners: {
  123. change: function(f, v) {
  124. var defaultCurrency = Ext.getCmp('mainView').getViewModel().get('defaultCurrency');
  125. f.setReadOnly(f.ownerCt.items.items[0].value == defaultCurrency);
  126. }
  127. }
  128. }
  129. }, {
  130. columnWidth: 0.5,
  131. name: "pi_address",
  132. xtype: "remotecombo",
  133. fieldLabel: "交货地址",
  134. editable: false,
  135. allowBlank: false,
  136. storeUrl: '/api/document/customer/getAddressCombo',
  137. hiddenBtn: true, //true 则会关闭新增按钮功能
  138. }, {
  139. name: "detailGridField",
  140. xtype: "detailGridField",
  141. detnoColumn: 'pd_pdno',
  142. storeModel: 'saas.model.sale.SaleOutDetail',
  143. deleteDetailUrl: '/api/sale/prodinout/deleteDetail',
  144. columns: [{
  145. text: "id",
  146. dataIndex: "id",
  147. xtype: "numbercolumn",
  148. hidden: true
  149. }, {
  150. text: "物料id",
  151. dataIndex: "pd_prodid",
  152. hidden: true
  153. }, {
  154. text: "物料编号",
  155. width: 150.0,
  156. dataIndex: "pd_prodcode",
  157. xtype: "",
  158. items: null,
  159. allowBlank: false,
  160. editor: {
  161. displayField: "display",
  162. editable: true,
  163. format: "",
  164. hideTrigger: false,
  165. maxLength: 100.0,
  166. minValue: null,
  167. positiveNum: false,
  168. queryMode: "local",
  169. store: null,
  170. valueField: "value",
  171. xtype: "productMultiDbfindTrigger"
  172. }
  173. }, {
  174. text: 'model映射需要',
  175. dataIndex: 'productDTO',
  176. hidden: true,
  177. }, {
  178. text: "品牌",
  179. width: 100.0,
  180. dataIndex: "pr_brand",
  181. ignore: true,
  182. renderer: function (v, m, r) {
  183. if (!v) {
  184. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  185. }
  186. return v;
  187. }
  188. }, {
  189. text: "物料名称",
  190. width: 150.0,
  191. dataIndex: "pr_detail",
  192. ignore: true,
  193. renderer: function (v, m, r) {
  194. if (!v) {
  195. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  196. }
  197. return v;
  198. }
  199. }, {
  200. text: "型号",
  201. width: 200.0,
  202. dataIndex: "pr_orispeccode",
  203. ignore: true,
  204. renderer: function (v, m, r) {
  205. if (!v) {
  206. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  207. }
  208. return v;
  209. }
  210. }, {
  211. text: "规格",
  212. width: 200,
  213. dataIndex: "pr_spec",
  214. ignore: true,
  215. renderer: function (v, m, r) {
  216. if (!v) {
  217. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  218. }
  219. return v;
  220. }
  221. }, {
  222. text: "仓库ID",
  223. dataIndex: "pd_whid",
  224. hidden: true
  225. }, {
  226. text: "仓库编号",
  227. dataIndex: "pd_whcode",
  228. hidden: true
  229. }, {
  230. text: "仓库",
  231. dataIndex: "pd_whname",
  232. width: 110.0,
  233. items: null,
  234. allowBlank: false,
  235. editor: {
  236. displayField: "display",
  237. editable: true,
  238. format: "",
  239. hideTrigger: false,
  240. maxLength: 100.0,
  241. minValue: null,
  242. positiveNum: false,
  243. queryMode: "local",
  244. store: null,
  245. valueField: "value",
  246. xtype: "warehouseDbfindTrigger"
  247. }
  248. }, {
  249. text: "数量",
  250. xtype: 'numbercolumn',
  251. dataIndex: "pd_outqty",
  252. width: 110.0,
  253. allowBlank: false,
  254. editor: {
  255. xtype: "numberfield",
  256. decimalPrecision: 3,
  257. minValue: 0
  258. },
  259. renderer: function(v, m, r) {
  260. return saas.util.BaseUtil.numberFormat(v, 3, false);
  261. },
  262. summaryType: 'sum',
  263. summaryRenderer: function(v, d, f, m) {
  264. return saas.util.BaseUtil.numberFormat(v, 3, false);
  265. }
  266. }, {
  267. text: "单位",
  268. width: 65.0,
  269. dataIndex: "pr_unit",
  270. ignore: true,
  271. renderer: function (v, m, r) {
  272. if (!v) {
  273. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  274. }
  275. return v;
  276. }
  277. }, {
  278. text: "单价(元)",
  279. xtype: 'numbercolumn',
  280. dataIndex: "pd_netprice",
  281. width: 120,
  282. editor: {
  283. xtype: "numberfield",
  284. decimalPrecision: 4,
  285. minValue: 0
  286. },
  287. renderer: function(v, m, r) {
  288. return saas.util.BaseUtil.numberFormat(v, 4, true);
  289. },
  290. }, {
  291. text: "含税单价(元)",
  292. xtype: 'numbercolumn',
  293. dataIndex: "pd_sendprice",
  294. width: 120,
  295. editor: {
  296. xtype: "numberfield",
  297. decimalPrecision: 4,
  298. minValue: 0
  299. },
  300. renderer: function(v, m, r) {
  301. return saas.util.BaseUtil.numberFormat(v, 4, true);
  302. },
  303. listeners: {
  304. edit: function (value, grid) {
  305. var r = grid.getSelection()[0],
  306. pd_taxrate = r.get('pd_taxrate');
  307. var v = value / (1 + pd_taxrate / 100);
  308. r.set('pd_netprice', Number(saas.util.BaseUtil.numberFormat(v, 4, false)));
  309. }
  310. }
  311. }, {
  312. text: "金额(元)",
  313. xtype: 'numbercolumn',
  314. dataIndex: "pd_nettotal",
  315. width: 120,
  316. renderer: function(v, m, r) {
  317. return saas.util.BaseUtil.numberFormat(v, 2, true);
  318. },
  319. summaryType: 'sum',
  320. summaryRenderer: function(v, d, f, m) {
  321. return saas.util.BaseUtil.numberFormat(v, 2, true);
  322. }
  323. }, {
  324. text: "税率(%)",
  325. xtype: 'numbercolumn',
  326. dataIndex: "pd_taxrate",
  327. width: 80,
  328. editor: {
  329. xtype: "numberfield",
  330. decimalPrecision: 0,
  331. minValue: 0,
  332. maxValue: 100
  333. },
  334. renderer: function(v, m, r) {
  335. return saas.util.BaseUtil.numberFormat(v, 2, false);
  336. }
  337. }, {
  338. text: "税额(元)",
  339. xtype: 'numbercolumn',
  340. dataIndex: "pd_taxamount",
  341. width: 120,
  342. renderer: function(v, m, r) {
  343. return saas.util.BaseUtil.numberFormat(v, 2, true);
  344. },
  345. summaryType: 'sum',
  346. summaryRenderer: function(v, d, f, m) {
  347. return saas.util.BaseUtil.numberFormat(v, 2, true);
  348. }
  349. }, {
  350. text: "价税合计(元)",
  351. xtype: 'numbercolumn',
  352. dataIndex: "pd_ordertotal",
  353. width: 120,
  354. renderer: function(v, m, r) {
  355. return saas.util.BaseUtil.numberFormat(v, 2, true);
  356. },
  357. summaryType: 'sum',
  358. summaryRenderer: function (v) {
  359. return saas.util.BaseUtil.numberFormat(v, 2, true);
  360. }
  361. }, {
  362. text: "关联销售单号",
  363. dataIndex: "pd_ordercode",
  364. width: 150.0,
  365. ignore: true
  366. }, {
  367. text: "备注",
  368. dataIndex: "pd_remark",
  369. width: 250,
  370. items: null,
  371. editor: {
  372. xtype: "textfield"
  373. },
  374. }, {
  375. dataIndex: "pd_text1",
  376. text: "自定义字段1",
  377. width: 100,
  378. hidden: true,
  379. initHidden: false,
  380. editor: {
  381. xtype: "textfield"
  382. },
  383. }, {
  384. dataIndex: "pd_text2",
  385. text: "自定义字段2",
  386. width: 100,
  387. hidden: true,
  388. initHidden: false,
  389. editor: {
  390. xtype: "textfield"
  391. },
  392. }, {
  393. dataIndex: "pd_text3",
  394. text: "自定义字段3",
  395. width: 100,
  396. hidden: true,
  397. initHidden: false,
  398. editor: {
  399. xtype: "textfield"
  400. },
  401. }, {
  402. dataIndex: "pd_text4",
  403. text: "自定义字段4",
  404. width: 100,
  405. hidden: true,
  406. initHidden: false,
  407. editor: {
  408. xtype: "textfield"
  409. },
  410. }, {
  411. dataIndex: "pd_text5",
  412. text: "自定义字段5",
  413. width: 100,
  414. hidden: true,
  415. initHidden: false,
  416. editor: {
  417. xtype: "textfield"
  418. },
  419. }]
  420. }, {
  421. xtype: "textfield",
  422. name: "pi_remark",
  423. fieldLabel: "备注",
  424. columnWidth: 1
  425. }, {
  426. xtype: "numberfield",
  427. name: "pi_nettotal",
  428. fieldLabel: "金额(元)",
  429. readOnly: true,
  430. thousandSeparator: ','
  431. }, {
  432. xtype: "numberfield",
  433. name: "pi_total",
  434. fieldLabel: "价税合计(元)",
  435. readOnly: true,
  436. thousandSeparator: ','
  437. }, {
  438. xtype: "employeeDbfindTrigger",
  439. name: "pi_seller",
  440. fieldLabel: "业务员"
  441. }, {
  442. xtype: "hidden",
  443. name: "pi_sellerid",
  444. fieldLabel: "业务员ID"
  445. }, {
  446. xtype: "hidden",
  447. name: "pi_sellercode",
  448. fieldLabel: "业务员编号",
  449. }, {
  450. xtype: "hidden",
  451. name: "creatorId",
  452. fieldLabel: "录入人ID",
  453. readOnly: true
  454. }, {
  455. xtype: "textfield",
  456. name: "creatorName",
  457. fieldLabel: "录入人",
  458. readOnly: true
  459. }, {
  460. xtype: "datefield",
  461. name: "createTime",
  462. fieldLabel: "录入日期",
  463. readOnly: true,
  464. defaultValue: new Date()
  465. }, {
  466. xtype: "hidden",
  467. name: "updaterId",
  468. fieldLabel: "更新人ID",
  469. readOnly: true
  470. }, {
  471. xtype: "hidden",
  472. name: "updaterName",
  473. fieldLabel: "更新人",
  474. readOnly: true
  475. }, {
  476. xtype: "hidden",
  477. name: "updateTime",
  478. fieldLabel: "更新日期",
  479. readOnly: true,
  480. defaultValue: new Date()
  481. }, {
  482. xtype: "textfield",
  483. name: "pi_auditman",
  484. fieldLabel: "审核人",
  485. readOnly: true
  486. }, {
  487. xtype: "datefield",
  488. name: "pi_auditdate",
  489. fieldLabel: "审核日期",
  490. readOnly: true
  491. }, {
  492. xtype: "textfield",
  493. name: "pi_text1",
  494. fieldLabel: "自定义字段1",
  495. hidden: true,
  496. initHidden: false
  497. }, {
  498. xtype: "textfield",
  499. name: "pi_text2",
  500. fieldLabel: "自定义字段2",
  501. hidden: true,
  502. initHidden: false
  503. }, {
  504. xtype: "textfield",
  505. name: "pi_text3",
  506. fieldLabel: "自定义字段3",
  507. hidden: true,
  508. initHidden: false
  509. }, {
  510. xtype: "textfield",
  511. name: "pi_text4",
  512. fieldLabel: "自定义字段4",
  513. hidden: true,
  514. initHidden: false
  515. }, {
  516. xtype: "textfield",
  517. name: "pi_text5",
  518. fieldLabel: "自定义字段5",
  519. hidden: true,
  520. initHidden: false
  521. }]
  522. });
  523. this.callParent(arguments);
  524. },
  525. });