FormPanel.js 12 KB

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