FormPanel.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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. {
  208. text : "需求数量",
  209. xtype: 'numbercolumn',
  210. dataIndex : "mm_qty",
  211. width : 110.0,
  212. editor : {
  213. xtype : "numberfield",
  214. decimalPrecision: 3,
  215. minValue:0
  216. },
  217. renderer : function(v) {
  218. var arr = (v + '.').split('.');
  219. var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
  220. var format = '0.' + xr.join('');
  221. return Ext.util.Format.number(v, format);
  222. },
  223. summaryType: 'sum',
  224. summaryRenderer: function(v) {
  225. var arr = (v + '.').split('.');
  226. var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
  227. var format = '0.' + xr.join('');
  228. return Ext.util.Format.number(v, format);
  229. }
  230. },
  231. {
  232. text : "单位",
  233. dataIndex : "pr_unit",
  234. width : 80.0,
  235. ignore:true,
  236. renderer: function (v, m, r) {
  237. if(!v){
  238. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  239. }
  240. return v;
  241. }
  242. },{
  243. text : "成本单价(元)",
  244. dataIndex : "mm_price",
  245. xtype: 'numbercolumn',
  246. width : 110.0,
  247. editor : {
  248. xtype : "numberfield",
  249. decimalPrecision: 4,
  250. minValue:0
  251. },
  252. listeners:{
  253. edit:'price_change'
  254. },
  255. renderer : function(v) {
  256. var arr = (v + '.').split('.');
  257. var xr = (new Array(arr[1].length > 4 ? 4 : arr[1].length)).fill('0');
  258. var format = '0.' + xr.join('');
  259. return Ext.util.Format.number(v, format);
  260. }
  261. },
  262. {
  263. text : "单位用量",
  264. xtype: 'numbercolumn',
  265. dataIndex : "mm_oneuseqty",
  266. width : 110.0,
  267. hidden:true,
  268. editor : {
  269. xtype : "numberfield",
  270. decimalPrecision: 8,
  271. editable:false,
  272. minValue:0
  273. },
  274. renderer : function(v) {
  275. var arr = (v + '.').split('.');
  276. var xr = (new Array(arr[1].length)).fill('0');
  277. var format = '0.' + xr.join('');
  278. return Ext.util.Format.number(v, format);
  279. },
  280. summaryType: 'sum',
  281. summaryRenderer: function(v) {
  282. var arr = (v + '.').split('.');
  283. var xr = (new Array(arr[1].length)).fill('0');
  284. var format = '0.' + xr.join('');
  285. return Ext.util.Format.number(v, format);
  286. }
  287. },
  288. {
  289. text : "仓库id",
  290. dataIndex : "mm_whid",
  291. xtype : "numbercolumn",
  292. hidden:true
  293. },
  294. {
  295. text : "仓库编号",
  296. dataIndex : "mm_whcode",
  297. hidden:true
  298. },
  299. {
  300. text : "仓库",
  301. dataIndex : "mm_whname",
  302. width : 150.0,
  303. items : null,
  304. allowBlank : false,
  305. editor : {
  306. displayField : "display",
  307. editable : true,
  308. format : "",
  309. hideTrigger : false,
  310. maxLength : 100.0,
  311. minValue : null,
  312. positiveNum : false,
  313. queryMode : "local",
  314. store : null,
  315. valueField : "value",
  316. xtype : "warehouseDbfindTrigger"
  317. }
  318. },{
  319. text : "成本金额",
  320. xtype: 'numbercolumn',
  321. dataIndex : "mm_amount",
  322. width : 110.0,
  323. editor : {
  324. xtype : "numberfield",
  325. decimalPrecision: 2,
  326. editable : false
  327. },
  328. renderer : function(v) {
  329. var arr = (v + '.').split('.');
  330. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  331. var format = '0,000.' + xr.join('');
  332. return Ext.util.Format.number(v, format);
  333. },
  334. summaryType: 'sum',
  335. summaryRenderer: function(v) {
  336. var arr = (v + '.').split('.');
  337. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  338. var format = '0,000.' + xr.join('');
  339. return Ext.util.Format.number(v, format);
  340. }
  341. },{
  342. text : "替代料",
  343. dataIndex : "mm_repprodcode",
  344. width : 0,
  345. editor : {
  346. xtype : "textfield"
  347. },
  348. }, {
  349. text : "备注",
  350. dataIndex : "mm_remark",
  351. width : 250,
  352. editor : {
  353. xtype : "textfield"
  354. },
  355. }]
  356. },{
  357. xtype : "hidden",
  358. name : "creatorId",
  359. fieldLabel : "录入人ID",
  360. readOnly:true
  361. },
  362. {
  363. xtype : "textfield",
  364. name : "creatorName",
  365. fieldLabel : "录入人",
  366. readOnly:true
  367. }, {
  368. xtype : "datefield",
  369. name : "createTime",
  370. fieldLabel : "录入日期",
  371. readOnly:true,
  372. defaultValue: new Date()
  373. },{
  374. xtype : "hidden",
  375. name : "updaterId",
  376. fieldLabel : "更新人ID",
  377. readOnly:true
  378. },{
  379. xtype : "hidden",
  380. name : "updaterName",
  381. fieldLabel : "更新人",
  382. readOnly:true
  383. }, {
  384. xtype : "hidden",
  385. name : "updateTime",
  386. fieldLabel : "更新日期",
  387. readOnly:true,
  388. defaultValue: new Date()
  389. }, {
  390. xtype : "textfield",
  391. name : "ma_auditman",
  392. fieldLabel : "审核人",
  393. readOnly:true
  394. }, {
  395. xtype : "datefield",
  396. name : "ma_auditdate",
  397. fieldLabel : "审核日期",
  398. readOnly:true
  399. }],
  400. beforeAudit:function(){
  401. var me = this,
  402. controller = me.getController(),
  403. viewModel = me.getViewModel(),
  404. grid = me.down('detailGridField'),
  405. data = grid.getTrueData(),
  406. str='',
  407. type = viewModel.get('ma_type');
  408. if ('拆件' == type) {
  409. Ext.Array.each(data,function(item){
  410. if(item.mm_price==0){
  411. str=str+item.mm_detno+'行'+item.mm_prodcode+'物料成本单价为0!'+'<br>'
  412. }
  413. });
  414. }
  415. if(str!=''){
  416. saas.util.BaseUtil.showConfirm('提示',str)
  417. .then(function(y) {
  418. if(y == 'yes') {
  419. controller.audit();
  420. }
  421. });
  422. }else{
  423. controller.audit();
  424. }
  425. return false;
  426. }
  427. });