FormPanel.js 13 KB

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