FormPanel.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. Ext.define('saas.view.stock.make.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: 'stock-make-formpanel',
  4. controller: 'stock-make-formpanel',
  5. viewModel: 'stock-make-formpanel',
  6. viewName: 'stock-make-formpanel',
  7. caller: 'Make',
  8. //字段属性
  9. _title: '制造单',
  10. _idField: 'id',
  11. _codeField: 'ma_code',
  12. _statusField: 'ma_status',
  13. _statusCodeField: 'ma_statuscode',
  14. _auditmanField: 'ma_auditman',
  15. _auditdateField: 'ma_auditdate',
  16. _relationColumn: 'mm_maid',
  17. _readUrl: '/api/storage/make/read',
  18. _saveUrl: '/api/storage/make/save',
  19. _auditUrl: '/api/storage/make/audit',
  20. _unAuditUrl: '/api/storage/make/unAudit',
  21. _deleteUrl: '/api/storage/make/delete',
  22. _getBomUrl: '/api/document/bom/read',
  23. initId: 0,
  24. toolBtns: [],
  25. initComponent: function () {
  26. Ext.apply(this, {
  27. defaultItems: [{
  28. xtype: 'hidden',
  29. name: 'id',
  30. fieldLabel: 'id',
  31. columnWidth: 0
  32. }, {
  33. xtype: 'combobox',
  34. name: 'ma_type',
  35. allowBlank: false,
  36. columnWidth: 0.25,
  37. fieldLabel: '类型',
  38. queryMode: 'local',
  39. displayField: 'name',
  40. valueField: 'value',
  41. editable: false,
  42. allowBlank: false,
  43. store: Ext.create('Ext.data.ArrayStore', {
  44. fields: ['name', 'value'],
  45. data: [
  46. ["拆件", "拆件"],
  47. ["组装", "组装"],
  48. ]
  49. })
  50. }, {
  51. xtype: 'hidden',
  52. name: 'ma_prodid',
  53. fieldLabel: '产品id'
  54. }, {
  55. xtype: "bomDbfindTrigger",
  56. name: "ma_prodcode",
  57. fieldLabel: "产品编号",
  58. allowBlank: false,
  59. columnWidth: 0.25
  60. }, {
  61. xtype: "textfield",
  62. name: "ma_proddetail",
  63. fieldLabel: "产品名称",
  64. readOnly: true,
  65. columnWidth: 0.25
  66. }, {
  67. xtype: "textfield",
  68. name: "ma_prodorispec",
  69. fieldLabel: "产品型号",
  70. readOnly: true,
  71. columnWidth: 0.25,
  72. }, {
  73. xtype: "textfield",
  74. name: "ma_prodspec",
  75. fieldLabel: "产品规格",
  76. readOnly: true,
  77. columnWidth: 0.25,
  78. }, {
  79. xtype: "textfield",
  80. name: "ma_produnit",
  81. fieldLabel: "单位",
  82. readOnly: true,
  83. columnWidth: 0.25
  84. }, {
  85. xtype: "textfield",
  86. name: "ma_version",
  87. fieldLabel: "版本号",
  88. readOnly: true,
  89. columnWidth: 0.25
  90. }, {
  91. xtype: "numberfield",
  92. name: "ma_qty",
  93. fieldLabel: "数量",
  94. columnWidth: 0.25,
  95. allowBlank: false,
  96. decimalPrecision: 3,
  97. vtype: 'positiveNumber',
  98. }, {
  99. xtype: "hidden",
  100. name: "ma_whid",
  101. fieldLabel: "仓库id"
  102. }, {
  103. xtype: "hidden",
  104. name: "ma_whcode",
  105. fieldLabel: "仓库编号"
  106. }, {
  107. xtype: "warehouseDbfindTrigger",
  108. name: "ma_whname",
  109. fieldLabel: "仓库",
  110. allowBlank: false,
  111. columnWidth: 0.25
  112. }, {
  113. xtype: "numberfield",
  114. name: "ma_price",
  115. fieldLabel: "单价(元)",
  116. readOnly: true,
  117. editable: false,
  118. decimalPrecision: 4,
  119. columnWidth: 0.25
  120. }, {
  121. xtype: "numberfield",
  122. name: "ma_total",
  123. readOnly: true,
  124. editable: false,
  125. fieldLabel: "金额(元)",
  126. decimalPrecision: 2,
  127. thousandSeparator: ',',
  128. columnWidth: 0.25
  129. }, {
  130. name: "detailGridField",
  131. xtype: "detailGridField",
  132. storeModel: 'saas.model.stock.Makematerial',
  133. detnoColumn: 'mm_detno',
  134. deleteDetailUrl: '/api/storage/make/deleteDetail',
  135. columns: [{
  136. text: "id",
  137. dataIndex: "id",
  138. xtype: "numbercolumn",
  139. hidden: true
  140. }, {
  141. text: "mm_prodidid",
  142. dataIndex: "mm_prodid",
  143. xtype: "numbercolumn",
  144. hidden: true
  145. }, {
  146. text: "物料编号",
  147. width: 150.0,
  148. dataIndex: "mm_prodcode",
  149. allowBlank: false,
  150. xtype: "",
  151. items: null,
  152. editor: {
  153. displayField: "display",
  154. editable: true,
  155. format: "",
  156. hideTrigger: false,
  157. maxLength: 100.0,
  158. minValue: null,
  159. positiveNum: false,
  160. queryMode: "local",
  161. store: null,
  162. valueField: "value",
  163. xtype: "productMultiDbfindTrigger"
  164. }
  165. }, {
  166. text: 'model映射需要',
  167. dataIndex: 'productDTO',
  168. hidden: true,
  169. }, {
  170. text: "品牌",
  171. width: 100.0,
  172. dataIndex: "pr_brand",
  173. ignore: true,
  174. renderer: function (v, m, r) {
  175. if (!v) {
  176. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  177. }
  178. return v;
  179. }
  180. }, {
  181. text: "物料名称",
  182. width: 200.0,
  183. dataIndex: "pr_detail",
  184. ignore: true,
  185. renderer: function (v, m, r) {
  186. if (!v) {
  187. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  188. }
  189. return v;
  190. }
  191. }, {
  192. text: "型号",
  193. width: 200.0,
  194. dataIndex: "pr_orispeccode",
  195. ignore: true,
  196. renderer: function (v, m, r) {
  197. if (!v) {
  198. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  199. }
  200. return v;
  201. }
  202. }, {
  203. text: "规格",
  204. width: 200,
  205. dataIndex: "pr_spec",
  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: "mm_qty",
  217. width: 110.0,
  218. editor: {
  219. xtype: "numberfield",
  220. decimalPrecision: 3,
  221. minValue: 0
  222. },
  223. renderer: function (v) {
  224. return saas.util.BaseUtil.numberFormat(v, 3, false);
  225. },
  226. summaryType: 'sum',
  227. summaryRenderer: function(v, d, f, m) {
  228. return saas.util.BaseUtil.numberFormat(v, 3, false);
  229. }
  230. }, {
  231. text: "单位用量",
  232. xtype: 'numbercolumn',
  233. dataIndex: "mm_oneuseqty",
  234. hidden: true,
  235. renderer: function (v) {
  236. return saas.util.BaseUtil.numberFormat(v, 3, false);
  237. },
  238. }, {
  239. text: "单位",
  240. dataIndex: "pr_unit",
  241. width: 65.0,
  242. ignore: true,
  243. renderer: function (v, m, r) {
  244. if (!v) {
  245. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  246. }
  247. return v;
  248. }
  249. }, {
  250. text: "仓库id",
  251. dataIndex: "mm_whid",
  252. xtype: "numbercolumn",
  253. hidden: true
  254. }, {
  255. text: "仓库编号",
  256. dataIndex: "mm_whcode",
  257. hidden: true
  258. }, {
  259. text: "仓库",
  260. dataIndex: "mm_whname",
  261. width: 120.0,
  262. items: null,
  263. allowBlank: false,
  264. editor: {
  265. displayField: "display",
  266. editable: true,
  267. format: "",
  268. hideTrigger: false,
  269. maxLength: 100.0,
  270. minValue: null,
  271. positiveNum: false,
  272. queryMode: "local",
  273. store: null,
  274. valueField: "value",
  275. xtype: "warehouseDbfindTrigger"
  276. }
  277. }, {
  278. text: "成本单价(元)",
  279. dataIndex: "mm_price",
  280. xtype: 'numbercolumn',
  281. width: 120.0,
  282. editor: {
  283. xtype: "numberfield",
  284. decimalPrecision: 4,
  285. minValue: 0
  286. },
  287. listeners: {
  288. edit: 'price_change'
  289. },
  290. renderer: function (v) {
  291. return saas.util.BaseUtil.numberFormat(v, 4, true);
  292. }
  293. }, {
  294. text: "成本金额(元)",
  295. xtype: 'numbercolumn',
  296. dataIndex: "mm_amount",
  297. width: 120.0,
  298. editor: {
  299. xtype: "numberfield",
  300. decimalPrecision: 2,
  301. editable: false
  302. },
  303. renderer: function (v) {
  304. return saas.util.BaseUtil.numberFormat(v, 2, true);
  305. },
  306. summaryType: 'sum',
  307. summaryRenderer: function(v, d, f, m) {
  308. return saas.util.BaseUtil.numberFormat(v, 2, true);
  309. }
  310. }, {
  311. text: "备注",
  312. dataIndex: "mm_remark",
  313. width: 250,
  314. editor: {
  315. xtype: "textfield"
  316. },
  317. }, {
  318. dataIndex: "mm_text1",
  319. text: "自定义字段1",
  320. width: 100,
  321. hidden: true,
  322. initHidden: false,
  323. editor: {
  324. xtype: "textfield"
  325. },
  326. }, {
  327. dataIndex: "mm_text2",
  328. text: "自定义字段2",
  329. width: 100,
  330. hidden: true,
  331. initHidden: false,
  332. editor: {
  333. xtype: "textfield"
  334. },
  335. }, {
  336. dataIndex: "mm_text3",
  337. text: "自定义字段3",
  338. width: 100,
  339. hidden: true,
  340. initHidden: false,
  341. editor: {
  342. xtype: "textfield"
  343. },
  344. }, {
  345. dataIndex: "mm_text4",
  346. text: "自定义字段4",
  347. width: 100,
  348. hidden: true,
  349. initHidden: false,
  350. editor: {
  351. xtype: "textfield"
  352. },
  353. }, {
  354. dataIndex: "mm_text5",
  355. text: "自定义字段5",
  356. width: 100,
  357. hidden: true,
  358. initHidden: false,
  359. editor: {
  360. xtype: "textfield"
  361. },
  362. }]
  363. }, {
  364. xtype: "hidden",
  365. name: "creatorId",
  366. fieldLabel: "录入人ID",
  367. readOnly: true
  368. }, {
  369. xtype: "textfield",
  370. name: "creatorName",
  371. fieldLabel: "录入人",
  372. readOnly: true
  373. }, {
  374. xtype: "datefield",
  375. name: "createTime",
  376. fieldLabel: "录入日期",
  377. readOnly: true,
  378. defaultValue: new Date()
  379. }, {
  380. xtype: "hidden",
  381. name: "updaterId",
  382. fieldLabel: "更新人ID",
  383. readOnly: true
  384. }, {
  385. xtype: "hidden",
  386. name: "updaterName",
  387. fieldLabel: "更新人",
  388. readOnly: true
  389. }, {
  390. xtype: "hidden",
  391. name: "updateTime",
  392. fieldLabel: "更新日期",
  393. readOnly: true,
  394. defaultValue: new Date()
  395. }, {
  396. xtype: "textfield",
  397. name: "ma_auditman",
  398. fieldLabel: "审核人",
  399. readOnly: true
  400. }, {
  401. xtype: "datefield",
  402. name: "ma_auditdate",
  403. fieldLabel: "审核日期",
  404. readOnly: true
  405. }, {
  406. xtype: "textfield",
  407. name: "ma_text1",
  408. fieldLabel: "自定义字段1",
  409. hidden: true,
  410. initHidden: false
  411. }, {
  412. xtype: "textfield",
  413. name: "ma_text2",
  414. fieldLabel: "自定义字段2",
  415. hidden: true,
  416. initHidden: false
  417. }, {
  418. xtype: "textfield",
  419. name: "ma_text3",
  420. fieldLabel: "自定义字段3",
  421. hidden: true,
  422. initHidden: false
  423. }, {
  424. xtype: "textfield",
  425. name: "ma_text4",
  426. fieldLabel: "自定义字段4",
  427. hidden: true,
  428. initHidden: false
  429. }, {
  430. xtype: "textfield",
  431. name: "ma_text5",
  432. fieldLabel: "自定义字段5",
  433. hidden: true,
  434. initHidden: false
  435. }]
  436. });
  437. this.callParent(arguments);
  438. },
  439. beforeAudit: function () {
  440. var me = this,
  441. controller = me.getController(),
  442. viewModel = me.getViewModel(),
  443. grid = me.down('detailGridField'),
  444. data = grid.getTrueData(),
  445. str = '',
  446. type = viewModel.get('ma_type');
  447. if ('拆件' == type) {
  448. Ext.Array.each(data, function (item) {
  449. if (item.mm_price == 0) {
  450. str = str + item.mm_detno + '行' + item.mm_prodcode + '物料成本单价为0!' + '<br>'
  451. }
  452. });
  453. }
  454. if (str != '') {
  455. saas.util.BaseUtil.showConfirm('提示', str)
  456. .then(function (y) {
  457. if (y == 'yes') {
  458. controller.audit();
  459. }
  460. });
  461. } else {
  462. controller.audit();
  463. }
  464. return false;
  465. }
  466. });