FormPanel.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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. defaultItems: [{
  26. xtype: 'hidden',
  27. name: 'id',
  28. fieldLabel: 'id',
  29. columnWidth: 0
  30. },{
  31. xtype: 'combobox',
  32. name: 'ma_type',
  33. allowBlank : false,
  34. columnWidth: 0.25,
  35. fieldLabel: '类型',
  36. queryMode: 'local',
  37. displayField: 'name',
  38. valueField: 'value',
  39. editable:false,
  40. allowBlank : false,
  41. store: Ext.create('Ext.data.ArrayStore', {
  42. fields: ['name', 'value'],
  43. data: [
  44. ["拆件", "拆件"],
  45. ["组装", "组装"],
  46. ]
  47. })
  48. },{
  49. xtype: 'hidden',
  50. name: 'ma_prodid',
  51. fieldLabel: '产品id'
  52. },{
  53. xtype : "bomDbfindTrigger",
  54. name : "ma_prodcode",
  55. fieldLabel : "产品编号",
  56. allowBlank : false,
  57. columnWidth: 0.25
  58. },{
  59. xtype : "textfield",
  60. name : "ma_proddetail",
  61. fieldLabel : "产品名称",
  62. readOnly:true,
  63. columnWidth: 0.25
  64. },{
  65. xtype : "textfield",
  66. name : "ma_prodspec",
  67. fieldLabel : "产品规格",
  68. readOnly:true,
  69. columnWidth: 0.25,
  70. },{
  71. xtype : "textfield",
  72. name : "ma_produnit",
  73. fieldLabel : "单位",
  74. readOnly:true,
  75. columnWidth: 0.25
  76. },{
  77. xtype : "textfield",
  78. name : "ma_version",
  79. fieldLabel : "版本",
  80. readOnly:true,
  81. columnWidth: 0.25
  82. },
  83. {
  84. xtype : "numberfield",
  85. name : "ma_qty",
  86. fieldLabel : "数量",
  87. columnWidth: 0.25,
  88. allowBlank : false,
  89. minValue:1
  90. },{
  91. xtype : "hidden",
  92. name : "ma_whid",
  93. fieldLabel : "仓库id"
  94. },{
  95. xtype : "hidden",
  96. name : "ma_whcode",
  97. fieldLabel : "仓库编号"
  98. },{
  99. xtype : "warehouseDbfindTrigger",
  100. name : "ma_whname",
  101. fieldLabel : "仓库名称",
  102. allowBlank : false,
  103. columnWidth: 0.25
  104. },{
  105. xtype : "numberfield",
  106. name : "ma_price",
  107. fieldLabel : "单价(元)",
  108. readOnly:true,
  109. editable:false,
  110. decimalPrecision:4,
  111. columnWidth: 0.25,
  112. renderer : function(v) {
  113. var arr = (v + '.').split('.');
  114. var xr = (new Array(arr[1].length > 4 ? 4 : arr[1].length)).fill('0');
  115. var format = '0.' + xr.join('');
  116. return Ext.util.Format.number(v, format);
  117. }
  118. },{
  119. xtype : "numberfield",
  120. name : "ma_total",
  121. readOnly:true,
  122. editable:false,
  123. fieldLabel : "金额",
  124. decimalPrecision:2,
  125. columnWidth: 0.25
  126. },
  127. {
  128. name : "detailGridField",
  129. xtype : "detailGridField",
  130. storeModel:'saas.model.stock.Makematerial',
  131. detnoColumn: 'mm_detno',
  132. deleteDetailUrl:'/api/storage/make/deleteDetail',
  133. columns : [
  134. {
  135. text : "id",
  136. dataIndex : "id",
  137. xtype : "numbercolumn",
  138. hidden:true
  139. },
  140. {
  141. text : "mm_prodidid",
  142. dataIndex : "mm_prodid",
  143. xtype : "numbercolumn",
  144. hidden:true
  145. },
  146. {
  147. text : "物料编号",
  148. width : 150.0,
  149. dataIndex : "mm_prodcode",
  150. allowBlank : false,
  151. xtype : "",
  152. items : null,
  153. editor : {
  154. displayField : "display",
  155. editable : true,
  156. format : "",
  157. hideTrigger : false,
  158. maxLength : 100.0,
  159. minValue : null,
  160. positiveNum : false,
  161. queryMode : "local",
  162. store : null,
  163. valueField : "value",
  164. xtype : "productMultiDbfindTrigger"
  165. }
  166. },{
  167. text: 'model映射需要',
  168. dataIndex: 'productDTO',
  169. hidden: true,
  170. },
  171. {
  172. text : "品牌",
  173. width : 150.0,
  174. dataIndex : "pr_brand",
  175. ignore:true,
  176. renderer: function (v, m, r) {
  177. if(!v){
  178. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  179. }
  180. return v;
  181. }
  182. },
  183. {
  184. text : "名称",
  185. width : 200.0,
  186. dataIndex : "pr_detail",
  187. ignore:true,
  188. renderer: function (v, m, r) {
  189. if(!v){
  190. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  191. }
  192. return v;
  193. }
  194. },
  195. {
  196. text : "型号",
  197. width : 200.0,
  198. dataIndex : "pr_orispeccode",
  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. width : 150,
  209. dataIndex : "pr_spec",
  210. ignore:true,
  211. renderer: function (v, m, r) {
  212. if(!v){
  213. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  214. }
  215. return v;
  216. }
  217. },{
  218. text : "需求数量",
  219. xtype: 'numbercolumn',
  220. dataIndex : "mm_qty",
  221. width : 110.0,
  222. editor : {
  223. xtype : "numberfield",
  224. decimalPrecision: 3,
  225. minValue:0
  226. },
  227. renderer : function(v) {
  228. var arr = (v + '.').split('.');
  229. var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
  230. var format = '0.' + xr.join('');
  231. return Ext.util.Format.number(v, format);
  232. },
  233. summaryType: 'sum',
  234. summaryRenderer: function(v) {
  235. var arr = (v + '.').split('.');
  236. var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
  237. var format = '0.' + xr.join('');
  238. return Ext.util.Format.number(v, format);
  239. }
  240. },
  241. {
  242. text : "单位",
  243. dataIndex : "pr_unit",
  244. width : 80.0,
  245. ignore:true,
  246. renderer: function (v, m, r) {
  247. if(!v){
  248. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  249. }
  250. return v;
  251. }
  252. },{
  253. text : "成本单价(元)",
  254. dataIndex : "mm_price",
  255. xtype: 'numbercolumn',
  256. width : 110.0,
  257. editor : {
  258. xtype : "numberfield",
  259. decimalPrecision: 4,
  260. minValue:0
  261. },
  262. listeners:{
  263. edit:'price_change'
  264. },
  265. renderer : function(v) {
  266. var arr = (v + '.').split('.');
  267. var xr = (new Array(arr[1].length > 4 ? 4 : arr[1].length)).fill('0');
  268. var format = '0.' + xr.join('');
  269. return Ext.util.Format.number(v, format);
  270. }
  271. },
  272. {
  273. text : "单位用量",
  274. xtype: 'numbercolumn',
  275. dataIndex : "mm_oneuseqty",
  276. width : 110.0,
  277. hidden:true,
  278. editor : {
  279. xtype : "numberfield",
  280. decimalPrecision: 8,
  281. editable:false,
  282. minValue:0
  283. },
  284. renderer : function(v) {
  285. var arr = (v + '.').split('.');
  286. var xr = (new Array(arr[1].length)).fill('0');
  287. var format = '0.' + 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)).fill('0');
  294. var format = '0.' + xr.join('');
  295. return Ext.util.Format.number(v, format);
  296. }
  297. },
  298. {
  299. text : "仓库id",
  300. dataIndex : "mm_whid",
  301. xtype : "numbercolumn",
  302. hidden:true
  303. },
  304. {
  305. text : "仓库编号",
  306. dataIndex : "mm_whcode",
  307. hidden:true
  308. },
  309. {
  310. text : "仓库",
  311. dataIndex : "mm_whname",
  312. width : 150.0,
  313. items : null,
  314. allowBlank : false,
  315. editor : {
  316. displayField : "display",
  317. editable : true,
  318. format : "",
  319. hideTrigger : false,
  320. maxLength : 100.0,
  321. minValue : null,
  322. positiveNum : false,
  323. queryMode : "local",
  324. store : null,
  325. valueField : "value",
  326. xtype : "warehouseDbfindTrigger"
  327. }
  328. },{
  329. text : "成本金额",
  330. xtype: 'numbercolumn',
  331. dataIndex : "mm_amount",
  332. width : 110.0,
  333. editor : {
  334. xtype : "numberfield",
  335. decimalPrecision: 2,
  336. editable : false
  337. },
  338. renderer : function(v) {
  339. var arr = (v + '.').split('.');
  340. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  341. var format = '0,000.' + xr.join('');
  342. return Ext.util.Format.number(v, format);
  343. },
  344. summaryType: 'sum',
  345. summaryRenderer: function(v) {
  346. var arr = (v + '.').split('.');
  347. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  348. var format = '0,000.' + xr.join('');
  349. return Ext.util.Format.number(v, format);
  350. }
  351. },{
  352. text : "替代料",
  353. dataIndex : "mm_repprodcode",
  354. width : 0,
  355. editor : {
  356. xtype : "textfield"
  357. },
  358. }, {
  359. text : "备注",
  360. dataIndex : "mm_remark",
  361. width : 250,
  362. editor : {
  363. xtype : "textfield"
  364. },
  365. }]
  366. },{
  367. xtype : "hidden",
  368. name : "creatorId",
  369. fieldLabel : "录入人ID",
  370. readOnly:true
  371. },
  372. {
  373. xtype : "textfield",
  374. name : "creatorName",
  375. fieldLabel : "录入人",
  376. readOnly:true
  377. }, {
  378. xtype : "datefield",
  379. name : "createTime",
  380. fieldLabel : "录入日期",
  381. readOnly:true,
  382. defaultValue: new Date()
  383. },{
  384. xtype : "hidden",
  385. name : "updaterId",
  386. fieldLabel : "更新人ID",
  387. readOnly:true
  388. },{
  389. xtype : "hidden",
  390. name : "updaterName",
  391. fieldLabel : "更新人",
  392. readOnly:true
  393. }, {
  394. xtype : "hidden",
  395. name : "updateTime",
  396. fieldLabel : "更新日期",
  397. readOnly:true,
  398. defaultValue: new Date()
  399. }, {
  400. xtype : "textfield",
  401. name : "ma_auditman",
  402. fieldLabel : "审核人",
  403. readOnly:true
  404. }, {
  405. xtype : "datefield",
  406. name : "ma_auditdate",
  407. fieldLabel : "审核日期",
  408. readOnly:true
  409. }],
  410. beforeAudit:function(){
  411. var me = this,
  412. controller = me.getController(),
  413. viewModel = me.getViewModel(),
  414. grid = me.down('detailGridField'),
  415. data = grid.getTrueData(),
  416. str='',
  417. type = viewModel.get('ma_type');
  418. if ('拆件' == type) {
  419. Ext.Array.each(data,function(item){
  420. if(item.mm_price==0){
  421. str=str+item.mm_detno+'行'+item.mm_prodcode+'物料成本单价为0!'+'<br>'
  422. }
  423. });
  424. }
  425. if(str!=''){
  426. saas.util.BaseUtil.showConfirm('提示',str)
  427. .then(function(y) {
  428. if(y == 'yes') {
  429. controller.audit();
  430. }
  431. });
  432. }else{
  433. controller.audit();
  434. }
  435. return false;
  436. }
  437. });