FormPanel.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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:8,
  111. columnWidth: 0.25
  112. },{
  113. xtype : "numberfield",
  114. name : "ma_total",
  115. readOnly:true,
  116. editable:false,
  117. fieldLabel : "金额(元)",
  118. decimalPrecision:2,
  119. columnWidth: 0.25
  120. },
  121. {
  122. name : "detailGridField",
  123. xtype : "detailGridField",
  124. storeModel:'saas.model.stock.Makematerial',
  125. detnoColumn: 'mm_detno',
  126. deleteDetailUrl:'/api/storage/make/deleteDetail',
  127. columns : [
  128. {
  129. text : "id",
  130. dataIndex : "id",
  131. xtype : "numbercolumn",
  132. hidden:true
  133. },
  134. {
  135. text : "mm_prodidid",
  136. dataIndex : "mm_prodid",
  137. xtype : "numbercolumn",
  138. hidden:true
  139. },
  140. {
  141. text : "物料编号",
  142. width : 150.0,
  143. dataIndex : "mm_prodcode",
  144. allowBlank : false,
  145. xtype : "",
  146. items : null,
  147. editor : {
  148. displayField : "display",
  149. editable : true,
  150. format : "",
  151. hideTrigger : false,
  152. maxLength : 100.0,
  153. minValue : null,
  154. positiveNum : false,
  155. queryMode : "local",
  156. store : null,
  157. valueField : "value",
  158. xtype : "productMultiDbfindTrigger"
  159. }
  160. },{
  161. text: 'model映射需要',
  162. dataIndex: 'productDTO',
  163. hidden: true,
  164. },
  165. {
  166. text : "品牌",
  167. width : 150.0,
  168. dataIndex : "pr_brand",
  169. ignore:true,
  170. renderer: function (v, m, r) {
  171. if(!v){
  172. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  173. }
  174. return v;
  175. }
  176. },
  177. {
  178. text : "名称",
  179. width : 200.0,
  180. dataIndex : "pr_detail",
  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. {
  190. text : "型号",
  191. width : 200.0,
  192. dataIndex : "pr_orispeccode",
  193. ignore:true,
  194. renderer: function (v, m, r) {
  195. if(!v){
  196. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  197. }
  198. return v;
  199. }
  200. },
  201. {
  202. text : "需求数量",
  203. xtype: 'numbercolumn',
  204. dataIndex : "mm_qty",
  205. width : 110.0,
  206. editor : {
  207. xtype : "numberfield",
  208. decimalPrecision: 3,
  209. minValue:0
  210. },
  211. renderer : function(v) {
  212. var arr = (v + '.').split('.');
  213. var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
  214. var format = '0.' + xr.join('');
  215. return Ext.util.Format.number(v, format);
  216. },
  217. summaryType: 'sum',
  218. summaryRenderer: function(v) {
  219. var arr = (v + '.').split('.');
  220. var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
  221. var format = '0.' + xr.join('');
  222. return Ext.util.Format.number(v, format);
  223. }
  224. },
  225. {
  226. text : "单位",
  227. dataIndex : "pr_unit",
  228. width : 80.0,
  229. ignore:true,
  230. renderer: function (v, m, r) {
  231. if(!v){
  232. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  233. }
  234. return v;
  235. }
  236. },{
  237. text : "成本单价",
  238. dataIndex : "mm_price",
  239. xtype: 'numbercolumn',
  240. width : 110.0,
  241. editor : {
  242. xtype : "numberfield",
  243. decimalPrecision: 8,
  244. minValue:0
  245. },
  246. listeners:{
  247. edit:'price_change'
  248. },
  249. renderer : function(v) {
  250. var arr = (v + '.').split('.');
  251. var xr = (new Array(arr[1].length)).fill('0');
  252. var format = '0,000.' + xr.join('');
  253. return Ext.util.Format.number(v, format);
  254. }
  255. },
  256. {
  257. text : "单位用量",
  258. xtype: 'numbercolumn',
  259. dataIndex : "mm_oneuseqty",
  260. width : 110.0,
  261. hidden:true,
  262. editor : {
  263. xtype : "numberfield",
  264. decimalPrecision: 8,
  265. editable:false,
  266. minValue:0
  267. },
  268. renderer : function(v) {
  269. var arr = (v + '.').split('.');
  270. var xr = (new Array(arr[1].length)).fill('0');
  271. var format = '0.' + xr.join('');
  272. return Ext.util.Format.number(v, format);
  273. },
  274. summaryType: 'sum',
  275. summaryRenderer: function(v) {
  276. var arr = (v + '.').split('.');
  277. var xr = (new Array(arr[1].length)).fill('0');
  278. var format = '0.' + xr.join('');
  279. return Ext.util.Format.number(v, format);
  280. }
  281. },
  282. {
  283. text : "仓库id",
  284. dataIndex : "mm_whid",
  285. xtype : "numbercolumn",
  286. hidden:true
  287. },
  288. {
  289. text : "仓库编号",
  290. dataIndex : "mm_whcode",
  291. hidden:true
  292. },
  293. {
  294. text : "仓库",
  295. dataIndex : "mm_whname",
  296. width : 150.0,
  297. items : null,
  298. allowBlank : false,
  299. editor : {
  300. displayField : "display",
  301. editable : true,
  302. format : "",
  303. hideTrigger : false,
  304. maxLength : 100.0,
  305. minValue : null,
  306. positiveNum : false,
  307. queryMode : "local",
  308. store : null,
  309. valueField : "value",
  310. xtype : "warehouseDbfindTrigger"
  311. }
  312. },{
  313. text : "成本金额",
  314. xtype: 'numbercolumn',
  315. dataIndex : "mm_amount",
  316. width : 110.0,
  317. editor : {
  318. xtype : "numberfield",
  319. decimalPrecision: 2,
  320. editable : false
  321. },
  322. renderer : function(v) {
  323. var arr = (v + '.').split('.');
  324. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  325. var format = '0,000.' + xr.join('');
  326. return Ext.util.Format.number(v, format);
  327. },
  328. summaryType: 'sum',
  329. summaryRenderer: function(v) {
  330. var arr = (v + '.').split('.');
  331. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  332. var format = '0,000.' + xr.join('');
  333. return Ext.util.Format.number(v, format);
  334. }
  335. },{
  336. text : "替代料",
  337. dataIndex : "mm_repprodcode",
  338. width : 0,
  339. editor : {
  340. xtype : "textfield"
  341. },
  342. }, {
  343. text : "备注",
  344. dataIndex : "mm_remark",
  345. width : 250,
  346. editor : {
  347. xtype : "textfield"
  348. },
  349. }]
  350. },{
  351. xtype : "hidden",
  352. name : "creatorId",
  353. fieldLabel : "录入人ID",
  354. readOnly:true
  355. },
  356. {
  357. xtype : "textfield",
  358. name : "creatorName",
  359. fieldLabel : "录入人",
  360. readOnly:true
  361. }, {
  362. xtype : "datefield",
  363. name : "createTime",
  364. fieldLabel : "录入日期",
  365. readOnly:true,
  366. defaultValue: new Date()
  367. },{
  368. xtype : "hidden",
  369. name : "updaterId",
  370. fieldLabel : "更新人ID",
  371. readOnly:true
  372. },{
  373. xtype : "hidden",
  374. name : "updaterName",
  375. fieldLabel : "更新人",
  376. readOnly:true
  377. }, {
  378. xtype : "hidden",
  379. name : "updateTime",
  380. fieldLabel : "更新日期",
  381. readOnly:true,
  382. defaultValue: new Date()
  383. }, {
  384. xtype : "textfield",
  385. name : "ma_auditman",
  386. fieldLabel : "审核人",
  387. readOnly:true
  388. }, {
  389. xtype : "datefield",
  390. name : "ma_auditdate",
  391. fieldLabel : "审核日期",
  392. readOnly:true
  393. }],
  394. beforeAudit:function(){
  395. var me = this,
  396. controller = me.getController(),
  397. viewModel = me.getViewModel(),
  398. grid = me.down('detailGridField'),
  399. data = grid.getTrueData(),
  400. str='',
  401. type = viewModel.get('ma_type');
  402. if ('拆件' == type) {
  403. Ext.Array.each(data,function(item){
  404. if(item.mm_price==0){
  405. str=str+item.mm_detno+'行'+item.mm_prodcode+'物料成本单价为0!'+'<br>'
  406. }
  407. });
  408. }
  409. if(str!=''){
  410. saas.util.BaseUtil.showConfirm('提示',str)
  411. .then(function(y) {
  412. if(y == 'yes') {
  413. controller.audit();
  414. }
  415. });
  416. }else{
  417. controller.audit();
  418. }
  419. return false;
  420. }
  421. });