FormPanel.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. Ext.define('make.view.make.bom.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: ['make-bom-formpanel', 'bom-formpanel'],
  4. controller: 'make-bom-formpanel',
  5. viewModel: 'make-bom-formpanel',
  6. viewName: 'make-bom-formpanel',
  7. caller: 'Bom',
  8. //字段属性
  9. _title: 'BOM',
  10. _idField: 'id',
  11. _codeField: 'bo_code',
  12. _statusField: 'bo_status',
  13. _statusCodeField: 'bo_statuscode',
  14. _auditmanField: 'bo_auditman',
  15. _auditdateField: 'bo_auditdate',
  16. _relationColumn: 'bd_boid',
  17. _readUrl: '/api/make/bom/read',
  18. _saveUrl: '/api/make/bom/save',
  19. _auditUrl: '/api/make/bom/audit',
  20. _unAuditUrl: '/api/make/bom/unAudit',
  21. _deleteUrl: '/api/make/bom/delete',
  22. initId: 0,
  23. initComponent: function () {
  24. var me = this;
  25. Ext.apply(this, {
  26. toolBtns: [{
  27. xtype: 'button',
  28. text: '展开',
  29. hidden: true,
  30. bind: {
  31. hidden: '{bo_statuscode == "UNAUDITED"}'
  32. },
  33. handler: 'bomStruct'
  34. }, {
  35. xtype: 'button',
  36. text: 'BOM变更',
  37. handler:'modifyBomDetail',
  38. bind: {
  39. hidden: '{bo_statuscode != "AUDITED"}'
  40. }
  41. },{
  42. xtype: 'button',
  43. text: '变更记录',
  44. bind: {
  45. hidden: '{bo_statuscode != "AUDITED"}'
  46. },
  47. handler: function(){
  48. var bomStructDialog = me.add(
  49. Ext.widget('make-bom-bomecndetailwin', {
  50. height: '65%',
  51. width: '70%',
  52. title: 'BOM变更',
  53. closable: true,
  54. modal: true,
  55. resizable:false,
  56. initId: this.ownerCt.ownerCt.initId
  57. })
  58. )
  59. bomStructDialog.show();
  60. }
  61. }],
  62. defaultItems: [{
  63. xtype: 'hidden',
  64. name: 'id',
  65. fieldLabel: 'id',
  66. allowBlank: true,
  67. columnWidth: 0
  68. }, {
  69. xtype: "productMDbfindTrigger",
  70. name: "bo_mothercode",
  71. fieldLabel: "产品编号",
  72. allowBlank: false,
  73. },{
  74. xtype: "hidden",
  75. name: "bo_motherid",
  76. fieldLabel: "产品ID",
  77. },{
  78. xtype: "textfield",
  79. name: "bo_mothername",
  80. fieldLabel: "产品名称",
  81. readOnly:true
  82. },{
  83. xtype: 'tipTextfield',
  84. name: "pr_orispeccode",
  85. fieldLabel: "产品型号",
  86. editable: false,
  87. ignore: true,
  88. bind:{
  89. otherInfoTip:'厂家/品牌:{pr_brand}<br>产品规格:{pr_spec}'
  90. }
  91. },{
  92. xtype: "textfield",
  93. name: "pr_unit",
  94. fieldLabel: "单位",
  95. readOnly:true,
  96. ignore: true
  97. },{
  98. xtype: "textfield",
  99. name: "pr_spec",
  100. fieldLabel: "规格",
  101. readOnly:true,
  102. hidden:true,
  103. ignore: true,
  104. maxLength: 200,
  105. },{
  106. xtype: "textfield",
  107. name: "pr_brand",
  108. fieldLabel: "厂家/品牌",
  109. readOnly:true,
  110. hidden:true,
  111. ignore: true
  112. },{
  113. xtype: "textfield",
  114. name: "bo_version",
  115. fieldLabel: "版本号"
  116. },{
  117. xtype: 'remotecombo',
  118. storeUrl: '/api/document/workcenter/getCombo',
  119. name: "bo_wcname",
  120. fieldLabel: "工作中心",
  121. allowBlank: false,
  122. addHandler: function (b) {
  123. var form = this.ownerCmp.ownerCt;
  124. this.dialog = form.add({
  125. xtype: 'document-workcenter-window',
  126. bind: {
  127. title: '新增工作中心'
  128. },
  129. dataKind: 'workcenter',
  130. _parent: form,
  131. _combo: this.ownerCmp,
  132. record: null,
  133. session: true
  134. });
  135. this.dialog.show();
  136. },
  137. editHandler:function(btn,type){
  138. saas.util.BaseUtil.openTab('document-workcenter-datalist', '工作中心','maintab--document-workcenter-datalist');
  139. var combo = btn.ownerCt.up('remotecombo');
  140. if(combo){
  141. combo.collapse();
  142. }
  143. }
  144. },{
  145. name: "detailGridField",
  146. xtype: "detailGridField",
  147. storeModel: 'make.model.make.BomDetail',
  148. deleteDetailUrl: '/api/make/bom/deleteDetail',
  149. /*relativeBinds:{
  150. refFields:['bd_sonid'],
  151. fields:['bd_soncode','pr_detail','pr_unit','pr_spec','pr_brand','pr_orispeccode']
  152. },*/
  153. detnoColumn: 'bd_detno',
  154. columns: [{
  155. text: "id",
  156. dataIndex: "id",
  157. xtype: "numbercolumn",
  158. hidden: true
  159. }, {
  160. text: "物料id",
  161. dataIndex: "bd_sonid",
  162. xtype: "numbercolumn",
  163. hidden: true
  164. },{
  165. text: "物料编号",
  166. xtype: 'buttoncolumn',
  167. tdCls: 'report-item',
  168. width: 150,
  169. dataIndex: "bd_soncode",
  170. items: null,
  171. allowBlank: false,
  172. editor: {
  173. displayField: "display",
  174. editable: true,
  175. format: "",
  176. hideTrigger: false,
  177. maxLength: 100,
  178. minValue: null,
  179. positiveNum: false,
  180. queryMode: "local",
  181. store: null,
  182. valueField: "value",
  183. xtype: "productMultiDbfindTrigger"
  184. },
  185. renderer: function (value, meta, record) {
  186. var view = this.up('[viewName="make-bom-formpanel"]'),
  187. vm = view.getViewModel();
  188. if(vm && vm.get('bo_statuscode') == 'AUDITED'){
  189. return `<div class="report-item-action"><span>${value}</span><span class="x-fa fa-edit fa-fw"></span></div>`;
  190. }
  191. return value;
  192. },
  193. handler: 'modifyBomDetail2',
  194. }, {
  195. text: "物料名称",
  196. width: 150.0,
  197. dataIndex: "pr_detail",
  198. ignore: true,
  199. editor: {
  200. displayField: "display",
  201. editable: true,
  202. format: "",
  203. hideTrigger: false,
  204. maxLength: 100.0,
  205. minValue: null,
  206. positiveNum: false,
  207. queryMode: "local",
  208. store: null,
  209. valueField: "value",
  210. xtype: "productMultiDbfindTrigger"
  211. },
  212. renderer: function (v, m, r) {
  213. if (!v) {
  214. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  215. }
  216. return v;
  217. }
  218. }, {
  219. text: "厂家/品牌",
  220. hidden:true,
  221. width: 100.0,
  222. dataIndex: "pr_brand",
  223. ignore: true,
  224. renderer: function (v, m, r) {
  225. if (!v) {
  226. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  227. }
  228. return v;
  229. }
  230. }, {
  231. text: "型号",
  232. width: 200,
  233. dataIndex: "pr_orispeccode",
  234. ignore: true,
  235. renderer: saas.util.RenderUtil['renderer_prod']
  236. }, {
  237. text: "单位",
  238. width: 65.0,
  239. dataIndex: "pr_unit",
  240. ignore: true,
  241. renderer: function (v, m, r) {
  242. if (!v) {
  243. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  244. }
  245. return v;
  246. }
  247. },{
  248. text: "标准用量",
  249. dataIndex: "bd_baseqty",
  250. xtype: 'numbercolumn',
  251. width: 110.0,
  252. allowBlank: false,
  253. editor: {
  254. xtype: "numberfield",
  255. decimalPrecision: 6,
  256. minValue: 0
  257. },
  258. renderer: function(v, m, r) {
  259. return saas.util.BaseUtil.numberFormat(v, 6, true);
  260. }
  261. }, {
  262. text: "位号",
  263. dataIndex: "bd_location",
  264. editor: {
  265. xtype: "textfield"
  266. },
  267. width: 250,
  268. },{
  269. text: "备注",
  270. dataIndex: "bd_remark",
  271. editor: {
  272. xtype: "textfield"
  273. },
  274. width: 250,
  275. },{
  276. text: "规格",
  277. hidden:true,
  278. width: 200,
  279. dataIndex: "pr_spec",
  280. ignore: true,
  281. renderer: function (v, m, r) {
  282. if (!v) {
  283. return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
  284. }
  285. return v;
  286. }
  287. },{
  288. text: '标准损耗(%)',
  289. dataIndex: 'pr_lossrate',
  290. width: 100,
  291. ignore: true,
  292. xtype: 'numbercolumn',
  293. renderer : function(v, m, r) {
  294. return saas.util.BaseUtil.numberFormat(v, 2, true);
  295. },
  296. },{
  297. text: 'model映射需要',
  298. dataIndex: 'productDTO',
  299. hidden: true,
  300. }]
  301. }, {
  302. xtype: "textfield",
  303. name: "bo_remark",
  304. fieldLabel: "备注",
  305. columnWidth: 1
  306. },{
  307. xtype: "hidden",
  308. name: "creatorId",
  309. fieldLabel: "录入人ID",
  310. readOnly: true
  311. }, {
  312. xtype: "textfield",
  313. name: "creatorName",
  314. fieldLabel: "录入人",
  315. readOnly: true,
  316. }, {
  317. xtype: "datefield",
  318. name: "createTime",
  319. fieldLabel: "单据日期",
  320. readOnly: true,
  321. defaultValue: new Date()
  322. }, {
  323. xtype: "hidden",
  324. name: "updaterId",
  325. fieldLabel: "更新人ID",
  326. readOnly: true
  327. }, {
  328. xtype: "hidden",
  329. name: "updaterName",
  330. fieldLabel: "更新人",
  331. readOnly: true
  332. }, {
  333. xtype: "hidden",
  334. name: "updateTime",
  335. fieldLabel: "更新日期",
  336. readOnly: true,
  337. defaultValue: new Date()
  338. }, {
  339. xtype: "textfield",
  340. name: "bo_auditman",
  341. fieldLabel: "审核人",
  342. readOnly: true
  343. }, {
  344. xtype: "hidden",
  345. name: "bo_auditdate",
  346. fieldLabel: "审核日期",
  347. readOnly: true
  348. }],
  349. });
  350. this.callParent(arguments);
  351. },
  352. beforeAudit: function () {
  353. var me = this,
  354. viewModel = me.getViewModel(),
  355. grid = me.down('detailGridField'),
  356. data = grid.getTrueData();
  357. Ext.Array.each(data, function (item) {
  358. if (item.pd_orderprice == 0) {
  359. // saas.util.BaseUtil.showErrorToast(item.pd_pdno + '行' + item.pd_prodcode + '物料单价为0');
  360. }
  361. });
  362. return true;
  363. }
  364. });