FormPanel.js 14 KB

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