FormPanel.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. Ext.define('saas.view.sale.sale.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: 'sale-sale-formpanel',
  4. controller: 'sale-sale-formpanel',
  5. viewModel: 'sale-sale-formpanel',
  6. viewName: 'sale-sale-formpanel',
  7. caller: 'Sale',
  8. //字段属性
  9. _title: '销售订单',
  10. _idField: 'id',
  11. _codeField: 'sa_code',
  12. _statusField: 'sa_status',
  13. _statusCodeField: 'sa_statuscode',
  14. _auditmanField: 'sa_auditman',
  15. _auditdateField: 'sa_auditdate',
  16. _relationColumn: 'sd_puid',
  17. _readUrl: '/api/sale/sale/read',
  18. _saveUrl: '/api/sale/sale/save',
  19. _auditUrl: '/api/sale/sale/audit',
  20. _unAuditUrl: '/api/sale/sale/unAudit',
  21. _deleteUrl: '/api/sale/sale/delete',
  22. _turnOutUrl: '/api/sale/sale/turnProdOut',
  23. _turnPurchase: '/api/sale/sale/saleTurnPurchase',
  24. initId: 0,
  25. initComponent: function () {
  26. Ext.applyIf(this, {
  27. defaultItems: [{
  28. xtype: 'hidden',
  29. name: 'id',
  30. fieldLabel: 'id'
  31. }, {
  32. xtype: 'hidden',
  33. name: 'sa_custid',
  34. fieldLabel: '客户ID'
  35. }, {
  36. xtype: 'hidden',
  37. name: 'sa_custcode',
  38. fieldLabel: '客户编号'
  39. }, {
  40. xtype: "customerDbfindTrigger",
  41. name: "sa_custname",
  42. fieldLabel: "客户名称",
  43. allowBlank: false,
  44. setValue: function (value) {
  45. var me = this,
  46. bind, valueBind;
  47. var form = me.ownerCt;
  48. var c = form.down('[name=sa_toplace]');
  49. if (value && value != '') {
  50. c.setDisabled(false);
  51. } else {
  52. c.setDisabled(true);
  53. }
  54. if (me.hasFocus) {
  55. bind = me.getBind();
  56. valueBind = bind && bind.value;
  57. if (valueBind && valueBind.syncing) {
  58. if ((Ext.isEmpty(value) && Ext.isEmpty(me.value)) || value === me.value) {
  59. return me;
  60. } else if (Ext.isArray(value) && Ext.isArray(me.value) && Ext.Array.equals(value, me.value)) {
  61. return me;
  62. }
  63. }
  64. } else {
  65. me.lastSelectedRecords = null;
  66. }
  67. if (value != null) {
  68. me.doSetValue(value);
  69. } else {
  70. me.suspendEvent('select');
  71. me.valueCollection.beginUpdate();
  72. me.pickerSelectionModel.deselectAll();
  73. me.valueCollection.endUpdate();
  74. me.resumeEvent('select');
  75. }
  76. return me;
  77. }
  78. }, {
  79. name: "sa_toplace",
  80. xtype: "remotecombo",
  81. fieldLabel: "交货地址",
  82. editable: false,
  83. allowBlank: false,
  84. columnWidth: 0.5,
  85. storeUrl: '/api/document/customer/getAddressCombo',
  86. hiddenBtn: true, //true 则会关闭新增按钮功能
  87. }, {
  88. name: "detailGridField",
  89. xtype: "detailGridField",
  90. detnoColumn: 'sd_detno',
  91. storeModel: 'saas.model.sale.Saledetail',
  92. deleteDetailUrl: '/api/sale/sale/deleteDetail',
  93. columns: [{
  94. text: "id",
  95. dataIndex: "id",
  96. xtype: "numbercolumn",
  97. hidden: true
  98. }, {
  99. text: "物料id",
  100. dataIndex: "sd_prodid",
  101. width: 0
  102. }, {
  103. text: "物料编号",
  104. width: 150.0,
  105. dataIndex: "sd_prodcode",
  106. xtype: "",
  107. items: null,
  108. allowBlank: false,
  109. editor: {
  110. displayField: "display",
  111. editable: true,
  112. format: "",
  113. hideTrigger: false,
  114. maxLength: 100.0,
  115. minValue: null,
  116. positiveNum: false,
  117. queryMode: "local",
  118. store: null,
  119. valueField: "value",
  120. xtype: "productMultiDbfindTrigger"
  121. }
  122. }, {
  123. text: 'model映射需要',
  124. dataIndex: 'productDTO',
  125. hidden: true,
  126. }, {
  127. text: "品牌",
  128. width: 100.0,
  129. dataIndex: "pr_brand",
  130. ignore: true,
  131. renderer: function (v, m, r) {
  132. if (!v) {
  133. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  134. }
  135. return v;
  136. }
  137. }, {
  138. text: "物料名称",
  139. width: 150.0,
  140. dataIndex: "pr_detail",
  141. ignore: true,
  142. renderer: function (v, m, r) {
  143. if (!v) {
  144. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  145. }
  146. return v;
  147. }
  148. }, {
  149. text: "型号",
  150. width: 200.0,
  151. dataIndex: "pr_orispeccode",
  152. ignore: true,
  153. renderer: function (v, m, r) {
  154. if (!v) {
  155. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  156. }
  157. return v;
  158. }
  159. }, {
  160. text: "规格",
  161. width: 200,
  162. dataIndex: "pr_spec",
  163. ignore: true,
  164. renderer: function (v, m, r) {
  165. if (!v) {
  166. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  167. }
  168. return v;
  169. }
  170. }, {
  171. text: "数量",
  172. dataIndex: "sd_qty",
  173. width: 110.0,
  174. xtype: 'numbercolumn',
  175. allowBlank: false,
  176. editor: {
  177. xtype: "numberfield",
  178. decimalPrecision: 3,
  179. minValue: 0
  180. },
  181. renderer: function (v) {
  182. return saas.util.BaseUtil.numberFormat(v, 3, true);
  183. },
  184. summaryType: 'sum',
  185. summaryRenderer: function (v) {
  186. return saas.util.BaseUtil.numberFormat(v, 3, true);
  187. }
  188. }, {
  189. text: "单位",
  190. width: 65.0,
  191. dataIndex: "pr_unit",
  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. xtype: 'numbercolumn',
  202. dataIndex: "sd_netprice",
  203. width: 120,
  204. editor: {
  205. xtype: "numberfield",
  206. decimalPrecision: 4,
  207. minValue: 0
  208. },
  209. renderer: function (v) {
  210. return saas.util.BaseUtil.numberFormat(v, 4, true);
  211. }
  212. }, {
  213. text: "含税单价(元)",
  214. xtype: 'numbercolumn',
  215. dataIndex: "sd_price",
  216. width: 120,
  217. editor: {
  218. xtype: "numberfield",
  219. decimalPrecision: 4,
  220. minValue: 0
  221. },
  222. renderer: function (v) {
  223. return saas.util.BaseUtil.numberFormat(v, 4, true);
  224. },
  225. listeners: {
  226. edit: function (value, grid) {
  227. var r = grid.getSelection()[0],
  228. sd_taxrate = r.get('sd_taxrate');
  229. var v = value / (1 + sd_taxrate / 100);
  230. r.set('sd_netprice', Number(saas.util.BaseUtil.numberFormat(v, 4, false)));
  231. }
  232. }
  233. }, {
  234. text: "金额(元)",
  235. xtype: 'numbercolumn',
  236. dataIndex: "sd_nettotal",
  237. width: 120,
  238. renderer: function (v) {
  239. return saas.util.BaseUtil.numberFormat(v, 2, true);
  240. },
  241. summaryType: 'sum',
  242. summaryRenderer: function (v) {
  243. return saas.util.BaseUtil.numberFormat(v, 2, true);
  244. }
  245. }, {
  246. text: "税率(%)",
  247. xtype: 'numbercolumn',
  248. dataIndex: "sd_taxrate",
  249. width: 80,
  250. editor: {
  251. xtype: "numberfield",
  252. decimalPrecision: 0,
  253. minValue: 0,
  254. maxValue: 100
  255. },
  256. renderer: function (v) {
  257. return Ext.util.Format.number(v, '0');
  258. }
  259. }, {
  260. text: "税额(元)",
  261. xtype: 'numbercolumn',
  262. dataIndex: "sd_taxamount",
  263. width: 120,
  264. renderer: function (v) {
  265. return saas.util.BaseUtil.numberFormat(v, 2, true);
  266. },
  267. summaryType: 'sum',
  268. summaryRenderer: function (v) {
  269. return saas.util.BaseUtil.numberFormat(v, 2, true);
  270. }
  271. }, {
  272. text: "价税合计(元)",
  273. xtype: 'numbercolumn',
  274. dataIndex: "sd_total",
  275. width: 120,
  276. renderer: function (v) {
  277. return saas.util.BaseUtil.numberFormat(v, 2, true);
  278. },
  279. summaryType: 'sum',
  280. summaryRenderer: function (v) {
  281. return saas.util.BaseUtil.numberFormat(v, 2, true);
  282. }
  283. }, {
  284. text: "交货日期",
  285. dataIndex: "sd_delivery",
  286. width: 110.0,
  287. xtype: 'datecolumn',
  288. editor: {
  289. xtype: "datefield",
  290. editable: true,
  291. hideTrigger: false
  292. }
  293. }, {
  294. text: "备注",
  295. dataIndex: "sd_remark",
  296. width: 250,
  297. items: null,
  298. editor: {
  299. xtype: "textfield"
  300. },
  301. }]
  302. }, {
  303. xtype: "textfield",
  304. name: "sa_remark",
  305. fieldLabel: "备注",
  306. columnWidth: 1
  307. }, {
  308. xtype: "datefield",
  309. name: "sa_date",
  310. fieldLabel: "单据日期",
  311. defaultValue: new Date()
  312. }, {
  313. xtype: "textfield",
  314. name: "sa_currency",
  315. fieldLabel: "币别",
  316. readOnly: true,
  317. defaultValue: 'RMB'
  318. }, {
  319. xtype: "textfield",
  320. name: "sa_nettotal",
  321. fieldLabel: "金额(元)",
  322. readOnly: true
  323. },{
  324. xtype: "textfield",
  325. name: "sa_total",
  326. fieldLabel: "价税合计(元)",
  327. readOnly: true
  328. }, {
  329. xtype: "employeeDbfindTrigger",
  330. name: "sa_seller",
  331. fieldLabel: "业务员"
  332. }, {
  333. xtype: "hidden",
  334. name: "sa_sellerid",
  335. fieldLabel: "业务员ID"
  336. }, {
  337. xtype: "hidden",
  338. name: "sa_sellercode",
  339. fieldLabel: "业务员编号",
  340. }, {
  341. xtype: 'textfield',
  342. name: 'sa_sendstatus',
  343. fieldLabel: '出货状态',
  344. hidden: true
  345. }, {
  346. xtype: "hidden",
  347. name: "creatorId",
  348. fieldLabel: "录入人ID",
  349. readOnly: true
  350. }, {
  351. xtype: "textfield",
  352. name: "creatorName",
  353. fieldLabel: "录入人",
  354. readOnly: true
  355. }, {
  356. xtype: "datefield",
  357. name: "createTime",
  358. fieldLabel: "录入日期",
  359. readOnly: true,
  360. defaultValue: new Date()
  361. }, {
  362. xtype: "hidden",
  363. name: "updaterId",
  364. fieldLabel: "更新人ID",
  365. readOnly: true
  366. }, {
  367. xtype: "hidden",
  368. name: "updaterName",
  369. fieldLabel: "更新人",
  370. readOnly: true
  371. }, {
  372. xtype: "hidden",
  373. name: "updateTime",
  374. fieldLabel: "更新日期",
  375. readOnly: true,
  376. defaultValue: new Date()
  377. }, {
  378. xtype: "textfield",
  379. name: "sa_auditman",
  380. fieldLabel: "审核人",
  381. readOnly: true
  382. }, {
  383. xtype: "datefield",
  384. name: "sa_auditdate",
  385. fieldLabel: "审核日期",
  386. readOnly: true
  387. }]
  388. });
  389. this.callParent();
  390. },
  391. toolBtns: [{
  392. xtype: 'button',
  393. text: '转出货单',
  394. hidden: true,
  395. handler: 'turnOut',
  396. bind: {
  397. hidden: '{sa_statuscode!="AUDITED"}'
  398. }
  399. }, {
  400. xtype: 'button',
  401. text: '转采购单',
  402. hidden: true,
  403. handler: 'turnPurchase',
  404. bind: {
  405. hidden: '{sa_statuscode!="AUDITED"}'
  406. }
  407. }]
  408. });