FormPanel.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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_prodorispec",
  67. fieldLabel : "产品型号",
  68. readOnly:true,
  69. columnWidth: 0.25,
  70. },{
  71. xtype : "textfield",
  72. name : "ma_prodspec",
  73. fieldLabel : "产品规格",
  74. readOnly:true,
  75. columnWidth: 0.25,
  76. },{
  77. xtype : "textfield",
  78. name : "ma_produnit",
  79. fieldLabel : "单位",
  80. readOnly:true,
  81. columnWidth: 0.25
  82. },{
  83. xtype : "textfield",
  84. name : "ma_version",
  85. fieldLabel : "版本号",
  86. readOnly:true,
  87. columnWidth: 0.25
  88. },
  89. {
  90. xtype : "numberfield",
  91. name : "ma_qty",
  92. fieldLabel : "数量",
  93. columnWidth: 0.25,
  94. allowBlank : false,
  95. decimalPrecision:3,
  96. vtype: 'positiveNumber',
  97. },{
  98. xtype : "hidden",
  99. name : "ma_whid",
  100. fieldLabel : "仓库id"
  101. },{
  102. xtype : "hidden",
  103. name : "ma_whcode",
  104. fieldLabel : "仓库编号"
  105. },{
  106. xtype : "warehouseDbfindTrigger",
  107. name : "ma_whname",
  108. fieldLabel : "仓库名称",
  109. allowBlank : false,
  110. columnWidth: 0.25
  111. },{
  112. xtype : "numberfield",
  113. name : "ma_price",
  114. fieldLabel : "单价(元)",
  115. readOnly:true,
  116. editable:false,
  117. decimalPrecision:4,
  118. columnWidth: 0.25
  119. },{
  120. xtype : "numberfield",
  121. name : "ma_total",
  122. readOnly:true,
  123. editable:false,
  124. fieldLabel : "金额",
  125. decimalPrecision:2,
  126. columnWidth: 0.25
  127. },
  128. {
  129. name : "detailGridField",
  130. xtype : "detailGridField",
  131. storeModel:'saas.model.stock.Makematerial',
  132. detnoColumn: 'mm_detno',
  133. deleteDetailUrl:'/api/storage/make/deleteDetail',
  134. columns : [
  135. {
  136. text : "id",
  137. dataIndex : "id",
  138. xtype : "numbercolumn",
  139. hidden:true
  140. }, {
  141. text : "mm_prodidid",
  142. dataIndex : "mm_prodid",
  143. xtype : "numbercolumn",
  144. hidden:true
  145. }, {
  146. text : "物料编号",
  147. width : 150.0,
  148. dataIndex : "mm_prodcode",
  149. allowBlank : false,
  150. xtype : "",
  151. items : null,
  152. editor : {
  153. displayField : "display",
  154. editable : true,
  155. format : "",
  156. hideTrigger : false,
  157. maxLength : 100.0,
  158. minValue : null,
  159. positiveNum : false,
  160. queryMode : "local",
  161. store : null,
  162. valueField : "value",
  163. xtype : "productMultiDbfindTrigger"
  164. }
  165. }, {
  166. text: 'model映射需要',
  167. dataIndex: 'productDTO',
  168. hidden: true,
  169. }, {
  170. text : "品牌",
  171. width : 100.0,
  172. dataIndex : "pr_brand",
  173. ignore:true,
  174. renderer: function (v, m, r) {
  175. if(!v){
  176. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  177. }
  178. return v;
  179. }
  180. }, {
  181. text : "物料名称",
  182. width : 200.0,
  183. dataIndex : "pr_detail",
  184. ignore:true,
  185. renderer: function (v, m, r) {
  186. if(!v){
  187. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  188. }
  189. return v;
  190. }
  191. }, {
  192. text : "型号",
  193. width : 200.0,
  194. dataIndex : "pr_orispeccode",
  195. ignore:true,
  196. renderer: function (v, m, r) {
  197. if(!v){
  198. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  199. }
  200. return v;
  201. }
  202. },{
  203. text : "规格",
  204. width : 200,
  205. dataIndex : "pr_spec",
  206. ignore:true,
  207. renderer: function (v, m, r) {
  208. if(!v){
  209. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  210. }
  211. return v;
  212. }
  213. },{
  214. text : "需求数量",
  215. xtype: 'numbercolumn',
  216. dataIndex : "mm_qty",
  217. width : 110.0,
  218. editor : {
  219. xtype : "numberfield",
  220. decimalPrecision: 3,
  221. minValue:0
  222. },
  223. renderer : function(v) {
  224. return saas.util.BaseUtil.numberFormat(v, 3, false);
  225. },
  226. summaryType: 'sum',
  227. summaryRenderer: function(v) {
  228. return saas.util.BaseUtil.numberFormat(v, 3, false);
  229. }
  230. }, {
  231. text : "单位用量",
  232. xtype: 'numbercolumn',
  233. dataIndex : "mm_oneuseqty",
  234. hidden:true,
  235. renderer : function(v) {
  236. return saas.util.BaseUtil.numberFormat(v, 3, false);
  237. },
  238. }, {
  239. text : "单位",
  240. dataIndex : "pr_unit",
  241. width : 65.0,
  242. ignore:true,
  243. renderer: function (v, m, r) {
  244. if(!v){
  245. return r.data["productDTO"]?r.data["productDTO"][m.column.dataIndex]:null;
  246. }
  247. return v;
  248. }
  249. }, {
  250. text : "仓库id",
  251. dataIndex : "mm_whid",
  252. xtype : "numbercolumn",
  253. hidden:true
  254. }, {
  255. text : "仓库编号",
  256. dataIndex : "mm_whcode",
  257. hidden:true
  258. }, {
  259. text : "仓库",
  260. dataIndex : "mm_whname",
  261. width : 80.0,
  262. items : null,
  263. allowBlank : false,
  264. editor : {
  265. displayField : "display",
  266. editable : true,
  267. format : "",
  268. hideTrigger : false,
  269. maxLength : 100.0,
  270. minValue : null,
  271. positiveNum : false,
  272. queryMode : "local",
  273. store : null,
  274. valueField : "value",
  275. xtype : "warehouseDbfindTrigger"
  276. }
  277. }, {
  278. text : "成本单价(元)",
  279. dataIndex : "mm_price",
  280. xtype: 'numbercolumn',
  281. width : 120.0,
  282. editor : {
  283. xtype : "numberfield",
  284. decimalPrecision: 4,
  285. minValue:0
  286. },
  287. listeners:{
  288. edit:'price_change'
  289. },
  290. renderer : function(v) {
  291. return saas.util.BaseUtil.numberFormat(v, 4, true);
  292. }
  293. }, {
  294. text : "成本金额(元)",
  295. xtype: 'numbercolumn',
  296. dataIndex : "mm_amount",
  297. width : 120.0,
  298. editor : {
  299. xtype : "numberfield",
  300. decimalPrecision: 2,
  301. editable : false
  302. },
  303. renderer : function(v) {
  304. return saas.util.BaseUtil.numberFormat(v, 2, true);
  305. },
  306. summaryType: 'sum',
  307. summaryRenderer: function(v) {
  308. return saas.util.BaseUtil.numberFormat(v, 2, true);
  309. }
  310. }, {
  311. text : "备注",
  312. dataIndex : "mm_remark",
  313. width : 250,
  314. editor : {
  315. xtype : "textfield"
  316. },
  317. }]
  318. },{
  319. xtype : "hidden",
  320. name : "creatorId",
  321. fieldLabel : "录入人ID",
  322. readOnly:true
  323. },
  324. {
  325. xtype : "textfield",
  326. name : "creatorName",
  327. fieldLabel : "录入人",
  328. readOnly:true
  329. }, {
  330. xtype : "datefield",
  331. name : "createTime",
  332. fieldLabel : "录入日期",
  333. readOnly:true,
  334. defaultValue: new Date()
  335. },{
  336. xtype : "hidden",
  337. name : "updaterId",
  338. fieldLabel : "更新人ID",
  339. readOnly:true
  340. },{
  341. xtype : "hidden",
  342. name : "updaterName",
  343. fieldLabel : "更新人",
  344. readOnly:true
  345. }, {
  346. xtype : "hidden",
  347. name : "updateTime",
  348. fieldLabel : "更新日期",
  349. readOnly:true,
  350. defaultValue: new Date()
  351. }, {
  352. xtype : "textfield",
  353. name : "ma_auditman",
  354. fieldLabel : "审核人",
  355. readOnly:true
  356. }, {
  357. xtype : "datefield",
  358. name : "ma_auditdate",
  359. fieldLabel : "审核日期",
  360. readOnly:true
  361. }],
  362. beforeAudit:function(){
  363. var me = this,
  364. controller = me.getController(),
  365. viewModel = me.getViewModel(),
  366. grid = me.down('detailGridField'),
  367. data = grid.getTrueData(),
  368. str='',
  369. type = viewModel.get('ma_type');
  370. if ('拆件' == type) {
  371. Ext.Array.each(data,function(item){
  372. if(item.mm_price==0){
  373. str=str+item.mm_detno+'行'+item.mm_prodcode+'物料成本单价为0!'+'<br>'
  374. }
  375. });
  376. }
  377. if(str!=''){
  378. saas.util.BaseUtil.showConfirm('提示',str)
  379. .then(function(y) {
  380. if(y == 'yes') {
  381. controller.audit();
  382. }
  383. });
  384. }else{
  385. controller.audit();
  386. }
  387. return false;
  388. }
  389. });