BOM.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.bom.BOM', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. GridUtil: Ext.create('erp.util.GridUtil'),
  7. views:[
  8. 'pm.bom.BOM','core.form.Panel','core.grid.Panel2','core.toolbar.Toolbar','core.button.BomCopy',
  9. 'core.button.Add','core.button.Save','core.button.Close','core.button.DeleteDetail',
  10. 'core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.ResAudit',
  11. 'core.button.Update','core.button.Delete','core.form.YnField','core.grid.YnColumn','core.button.Flow','core.button.Print',
  12. 'core.button.SonBOM','core.button.Location','core.button.Replace','core.button.FeatureDefinition',
  13. 'core.button.Banned','core.button.ResBanned','core.form.FileField','core.button.Sync','core.button.FeatureQuery',
  14. 'core.button.LoadRelation',
  15. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.MultiField','core.button.BOMTurn','core.button.BomUpdatePast'
  16. //,'core.button.ScanFeatureSet'
  17. ],
  18. init:function(){
  19. var me = this;
  20. this.control({
  21. 'textfield[name=bo_ispast]':{
  22. beforerender: function(field){
  23. field.readOnly=false;
  24. }
  25. },
  26. 'erpGridPanel2': {
  27. itemclick: function(selModel, record){
  28. Ext.getCmp('sonbom').setDisabled(false);
  29. Ext.getCmp('replace').setDisabled(false);
  30. Ext.getCmp('location').setDisabled(false);
  31. Ext.getCmp('featuredefinition').setDisabled(false);
  32. Ext.getCmp('FeatureQuery').setDisabled(false);
  33. this.GridUtil.onGridItemClick(selModel, record);
  34. }
  35. },
  36. 'erpDeleteDetailButton': {
  37. afterrender: function(btn){
  38. btn.ownerCt.add({
  39. xtype: 'erpSonBOMButton'
  40. });
  41. btn.ownerCt.add({
  42. xtype: 'erpReplaceButton'
  43. });
  44. btn.ownerCt.add({
  45. xtype: 'erpLocationButton'
  46. });
  47. btn.ownerCt.add({
  48. xtype: 'erpFeatureDefinitionButton'
  49. });
  50. btn.ownerCt.add({
  51. xtype: 'erpFeatureQueryButton'
  52. });
  53. }
  54. },
  55. 'erpBomTurnButton':{
  56. afterrender:function(btn){
  57. var statuscode=Ext.getCmp('bo_statuscode').getValue();
  58. if(statuscode&&statuscode!='AUDITED'){
  59. btn.hide();
  60. }
  61. }
  62. },
  63. 'erpBomCopyButton':{
  64. /* afterrender:function(btn){
  65. var statuscode=Ext.getCmp('bo_statuscode').getValue();
  66. if(statuscode&&statuscode!='AUDITED'){
  67. btn.hide();
  68. }
  69. }, */
  70. click:function(btn){
  71. Ext.create('Ext.window.Window', {
  72. title: '指定节点处理人',
  73. height: 200,
  74. width: 400,
  75. layout: 'column',
  76. id:'win',
  77. buttonAlign:'center',
  78. defaults:{
  79. fieldStyle:'background:#FFFAFA;color:#515151;',
  80. columnWidth:1
  81. },
  82. allowDrag:false,
  83. items: [{
  84. xtype:'dbfindtrigger',
  85. fieldLabel:'父件编号',
  86. name:'mothercode',
  87. id:'mothercode',
  88. fieldStyle:'background:#fffac0;color:#515151;',
  89. allowBlank:false
  90. },{
  91. xtype:'textfield',
  92. fieldLabel:'父件名称',
  93. name:'motherdetail',
  94. id:'motherdetail',
  95. allowBlank:true
  96. },{
  97. xtype:'textfield',
  98. fieldLabel:'规格',
  99. name:'motherspec',
  100. id:'motherspec',
  101. allowBlank:true
  102. },{
  103. xtype:'hidden',
  104. name:'motherid',
  105. id:'motherid'
  106. }],
  107. buttons:[{
  108. text:$I18N.common.button.erpConfirmButton,
  109. xtype:'button',
  110. formBind: true,
  111. handler:function(){
  112. var id=Ext.getCmp('motherid').getValue();
  113. var form=Ext.getCmp('form');
  114. var r=form.getValues();
  115. var keys = Ext.Object.getKeys(r), f;
  116. var reg = /[!@#$%^&*()'":,\/?]/;
  117. Ext.each(keys, function(k){
  118. f = form.down('#' + k);
  119. if(f && f.logic == 'ignore') {
  120. delete r[k];
  121. }
  122. //codeField值强制大写,自动过滤特殊字符
  123. if(k == form.codeField && !Ext.isEmpty(r[k])) {
  124. r[k] = r[k].trim().toUpperCase().replace(reg, '');
  125. }
  126. if(contains(k, 'ext-', true)){
  127. delete r[k];
  128. }
  129. });
  130. var grid = Ext.getCmp('grid');
  131. var jsonGridData = new Array();
  132. var form = Ext.getCmp('form');
  133. var s = grid.getStore().data.items;//获取store里面的数据
  134. var dd;
  135. for(var i=0;i<s.length;i++){//将grid里面各行的数据获取并拼成jsonGridData
  136. var data = s[i].data;
  137. dd = new Object();
  138. Ext.each(grid.columns, function(c){
  139. if((!c.isCheckerHd)&&(c.logic != 'ignore')){//只需显示,无需后台操作的字段,自动略去
  140. if(c.xtype == 'datecolumn'){
  141. c.format = c.format || 'Y-m-d';
  142. if(Ext.isDate(data[c.dataIndex])){
  143. dd[c.dataIndex] = Ext.Date.format(data[c.dataIndex], c.format);
  144. } else {
  145. if(c.editor){
  146. dd[c.dataIndex] = Ext.Date.format(new Date(), c.format);//如果用户没输入日期,或输入有误,就给个默认日期,
  147. }
  148. }
  149. } else if(c.xtype == 'datetimecolumn'){
  150. if(Ext.isDate(data[c.dataIndex])){
  151. dd[c.dataIndex] = Ext.Date.format(data[c.dataIndex], 'Y-m-d H:i:s');//在这里把GMT日期转化成Y-m-d H:i:s格式日期
  152. } else {
  153. if(c.editor){
  154. dd[c.dataIndex] = Ext.Date.format(new Date(), 'Y-m-d H:i:s');//默认日期,
  155. }
  156. }
  157. } else if(c.xtype == 'numbercolumn'){//赋个默认值0吧,不然不好保存
  158. if(data[c.dataIndex] == null || data[c.dataIndex] == ''){
  159. dd[c.dataIndex] = '0';//也可以从data里面去掉这些字段
  160. } else {
  161. dd[c.dataIndex] = s[i].data[c.dataIndex];
  162. }
  163. } else {
  164. dd[c.dataIndex] = s[i].data[c.dataIndex];
  165. }
  166. }
  167. });
  168. if(grid.mainField && form && form.keyField){//例如,将pu_id的值赋给pd_puid
  169. dd[grid.mainField] = Ext.getCmp(form.keyField).value;
  170. }
  171. jsonGridData.push(Ext.JSON.encode(dd));
  172. }
  173. var params=new Object();
  174. params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
  175. params.param = unescape(jsonGridData.toString().replace(/\\/g,"%"));
  176. params.id=id;
  177. Ext.Ajax.request({
  178. url : basePath +'pm/bom/bomcopy.action',
  179. params:params,
  180. method : 'post',
  181. callback : function(options,success,response){
  182. var res = new Ext.decode(response.responseText);
  183. if(res.exceptionInfo != null){
  184. showError(res.exceptionInfo);return;
  185. }else {
  186. Ext.Msg.alert('提示','赋值失败');
  187. }
  188. }
  189. });
  190. }
  191. },{
  192. text:$I18N.common.button.erpCancelButton,
  193. handler:function(){
  194. Ext.getCmp('win').close();
  195. }
  196. }]
  197. }).show();
  198. }
  199. },
  200. 'erpSonBOMButton': {
  201. click: function(btn){
  202. var grid = btn.ownerCt.ownerCt;
  203. var record = grid.selModel.lastSelected;
  204. Ext.Ajax.request({
  205. url : basePath + "pm/bom/getDescription.action",
  206. params: {
  207. tablename: 'BOM',
  208. field: 'bo_id',
  209. condition: "bo_mothercode='" + record.data['bd_soncode'] + "'"
  210. },
  211. method : 'post',
  212. async: false,
  213. callback : function(options,success,response){
  214. var res = new Ext.decode(response.responseText);
  215. if(res.exceptionInfo){
  216. showError(res.exceptionInfo);return;
  217. }
  218. if(res.success){
  219. sonid = res.description;
  220. }
  221. }
  222. });
  223. if(sonid != null && id != '' && sonid != 0 && sonid != '0'){
  224. me.FormUtil.onAdd(null, '下级BOM资料', 'jsps/pm/bom/BOM.jsp?formCondition=bo_id=' + sonid +
  225. "&gridCondition=bd_bomid=" + sonid + "&_noc=1");
  226. }
  227. }
  228. },
  229. 'erpLocationButton': {
  230. click: function(btn){
  231. var grid = btn.ownerCt.ownerCt;
  232. var record = grid.selModel.lastSelected;
  233. var id = record.data['bd_id'];
  234. if(id != null && id != '' && id != 0 && id != '0'){
  235. me.FormUtil.onAdd('locationBOM' + id, '位置维护', 'jsps/pm/bom/BOMDetailLocation.jsp?formCondition=bd_id=' + id +
  236. "&gridCondition=bdl_bdid=" + id + "&_noc=1");
  237. }
  238. }
  239. },
  240. 'erpReplaceButton': {
  241. click: function(btn){
  242. var grid = btn.ownerCt.ownerCt;
  243. var record = grid.selModel.lastSelected;
  244. var id = record.data['bd_id'];
  245. var bomid=record.data['bd_bomid'];
  246. var main = parent.Ext.getCmp("content-panel");
  247. var panelId=main.getActiveTab().id;
  248. main.getActiveTab().currentGrid=Ext.getCmp('grid');
  249. if(id != null && id != '' && id != 0 && id != '0'){
  250. me.FormUtil.onAdd('replaceBOM' + id, '替代关系维护', 'jsps/pm/bom/prodReplace.jsp?formCondition=bd_id=' + id +
  251. "&gridCondition=pre_bdid=" + id + "&_noc=1&panelId="+panelId+"&bomid="+bomid);
  252. }
  253. }
  254. },
  255. 'erpSaveButton': {
  256. click: function(btn){
  257. var form = btn.ownerCt.ownerCt;
  258. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  259. me.BaseUtil.getRandomNumber('BOM',1,'bo_code');//自动添加编号
  260. }
  261. //易方 根据分类走分支 研发BOM
  262. var flowstyle=Ext.getCmp('bo_flowstyle');
  263. if(flowstyle&&!flowstyle.value){
  264. showError('研发BOM分类必须填写!');
  265. }else {
  266. this.FormUtil.beforeSave(this);
  267. }
  268. }
  269. },
  270. 'erpCloseButton': {
  271. click: function(btn){
  272. this.FormUtil.beforeClose(this);
  273. }
  274. },
  275. 'erpUpdateButton': {
  276. afterrender: function(btn){
  277. if(Ext.getCmp('bo_id').value == null || Ext.getCmp('bo_id').value == ''){
  278. btn.hide();
  279. }
  280. },
  281. click: function(btn){
  282. this.FormUtil.onUpdate(this);
  283. }
  284. },
  285. 'erpDeleteButton': {
  286. afterrender: function(btn){
  287. if(Ext.getCmp('bo_id').value == null || Ext.getCmp('bo_id').value == ''){
  288. btn.hide();
  289. }
  290. },
  291. click: function(btn){
  292. me.FormUtil.onDelete(Ext.getCmp('bo_id').value);
  293. }
  294. },
  295. 'erpPrintButton': {
  296. click:function(btn){
  297. var reportName="SBOMList2";
  298. var condition='{Bom.bo_id}='+Ext.getCmp('bo_id').value+''+' and (isnull({BomDetail.bd_usestatus}) or {BomDetail.bd_usestatus}<>'+"'DISABLE')";
  299. var id=Ext.getCmp('bo_id').value;
  300. me.FormUtil.onwindowsPrint(id,reportName,condition);
  301. }
  302. },
  303. 'erpAddButton': {
  304. click: function(){
  305. me.FormUtil.onAdd('addBOM', '新增BOM资料', 'jsps/pm/bom/BOM.jsp');
  306. }
  307. },
  308. 'erpSubmitButton': {
  309. afterrender: function(btn){
  310. var status = Ext.getCmp('bo_statuscode');
  311. if((Ext.getCmp('bo_id').value == null || Ext.getCmp('bo_id').value == '')
  312. || (status && status.value != 'ENTERING')){
  313. btn.hide();
  314. }
  315. },
  316. click: function(btn){
  317. var grid = Ext.getCmp('grid');
  318. var items = grid.store.data.items;
  319. var bool = true;
  320. /*Ext.each(items, function(item){
  321. if(item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ''){
  322. if(item.data['bd_baseqty'] == null || item.data['bd_baseqty'] == 0){
  323. bool = false;
  324. showError("明细第" + item.data['bd_detno'] + "行未填写单位用量,不能提交!");return;
  325. }
  326. }
  327. });*/
  328. if(bool){
  329. //wanlida bom明细有为空的情况。
  330. me.FormUtil.onSubmit(Ext.getCmp('bo_id').value,true);
  331. }
  332. }
  333. },
  334. 'erpBannedButton':{
  335. afterrender:function(btn){
  336. var statuscode=Ext.getCmp('bo_statuscode').getValue();
  337. if(statuscode&&statuscode=='DISABLE'){
  338. btn.hide();
  339. }
  340. if(statuscode && statuscode != 'AUDITED'){
  341. btn.hide();
  342. }
  343. },
  344. click:function(btn){
  345. //bom 禁用
  346. me.changeBOM("Banned","禁用");
  347. }
  348. },
  349. 'erpResBannedButton':{
  350. afterrender:function(btn){
  351. var statuscode=Ext.getCmp('bo_statuscode').getValue();
  352. if(statuscode&&statuscode!='DISABLE'){
  353. btn.hide();
  354. }
  355. },
  356. click:function(btn){
  357. //bom 反禁用
  358. me.changeBOM("ResBanned",'反禁用');
  359. }
  360. },
  361. 'erpFeatureDefinitionButton':{
  362. click: function(btn){
  363. var grid = Ext.getCmp('grid');
  364. var record = grid.selModel.lastSelected;
  365. if(record.data.bd_soncode != null){
  366. Ext.Ajax.request({//拿到grid的columns
  367. url : basePath + "pm/bom/getDescription.action",
  368. params: {
  369. tablename: 'Product',
  370. field: 'pr_specvalue',
  371. condition: "pr_code='" + record.data.bd_soncode + "'"
  372. },
  373. method : 'post',
  374. async: false,
  375. callback : function(options,success,response){
  376. var res = new Ext.decode(response.responseText);
  377. if(res.exceptionInfo){
  378. showError(res.exceptionInfo);return;
  379. }
  380. if(res.success){
  381. if(res.description != '' && res.description != null && res.description == 'NOTSPECIFIC'){
  382. var formCondition="pr_code='"+record.data.bd_soncode+"'";
  383. var gridCondition="pf_prodcode='"+record.data.bd_soncode+"'";
  384. var win = new Ext.window.Window({
  385. id : 'win',
  386. title: '物料特征项设置',
  387. height: "90%",
  388. width: "70%",
  389. maximizable : true,
  390. buttonAlign : 'center',
  391. layout : 'anchor',
  392. items: [{
  393. tag : 'iframe',
  394. frame : true,
  395. anchor : '100% 100%',
  396. layout : 'fit',
  397. html : '<iframe id="iframe_' + record.data.bd_soncode + '" src="' + basePath +
  398. 'jsps/pm/bom/ProdFeature.jsp?formCondition='+formCondition+'&&gridCondition='+gridCondition+'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  399. }]
  400. });
  401. win.show();
  402. } else {
  403. showError('物料特征必须为虚拟特征件');return;
  404. }
  405. }
  406. }
  407. });
  408. }
  409. }
  410. },
  411. 'erpFeatureQueryButton':{
  412. click: function(btn){
  413. var grid = Ext.getCmp('grid');
  414. var record = grid.selModel.lastSelected;
  415. if(record.data.bd_soncode != null){
  416. Ext.Ajax.request({//拿到grid的columns
  417. url : basePath + "pm/bom/getDescription.action",
  418. params: {
  419. tablename: 'Product',
  420. field: 'pr_specvalue',
  421. condition: "pr_code='" + record.data.bd_soncode + "'"
  422. },
  423. method : 'post',
  424. async: false,
  425. callback : function(options,success,response){
  426. var res = new Ext.decode(response.responseText);
  427. if(res.exceptionInfo){
  428. showError(res.exceptionInfo);
  429. return;
  430. }
  431. if(res.success){
  432. if(res.description != '' && res.description != null && res.description == 'NOTSPECIFIC'){
  433. var win = new Ext.window.Window({
  434. id : 'win',
  435. title: '生成特征料号',
  436. height: "90%",
  437. width: "90%",
  438. maximizable : true,
  439. buttonAlign : 'center',
  440. layout : 'anchor',
  441. items: [{
  442. tag : 'iframe',
  443. frame : true,
  444. anchor : '100% 100%',
  445. layout : 'fit',
  446. html : '<iframe id="iframe_' + record.data.sd_id + '" src="' + basePath +
  447. "jsps/common/datalist.jsp?whoami=BomFeatureQuery&_noc=1&urlcondition=fp_refno='" + record.data.bd_soncode +"'"+'" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>'
  448. }]
  449. });
  450. win.show();
  451. } else {
  452. showError('物料特征必须为虚拟特征件');return;
  453. }
  454. }
  455. }
  456. });
  457. }
  458. }
  459. },
  460. 'erpResSubmitButton': {
  461. afterrender: function(btn){
  462. var status = Ext.getCmp('bo_statuscode');
  463. if(status && status.value != 'COMMITED'){
  464. btn.hide();
  465. }
  466. },
  467. click: function(btn){
  468. me.FormUtil.onResSubmit(Ext.getCmp('bo_id').value);
  469. }
  470. },
  471. 'erpAuditButton': {
  472. afterrender: function(btn){
  473. var status = Ext.getCmp('bo_statuscode');
  474. if(status && status.value != 'COMMITED'){
  475. btn.hide();
  476. }
  477. },
  478. click: function(btn){
  479. me.FormUtil.onAudit(Ext.getCmp('bo_id').value);
  480. }
  481. },
  482. 'erpResAuditButton': {
  483. afterrender: function(btn){
  484. var status = Ext.getCmp('bo_statuscode');
  485. if(status && status.value != 'AUDITED'){
  486. btn.hide();
  487. }
  488. },
  489. click: function(btn){
  490. me.FormUtil.onResAudit(Ext.getCmp('bo_id').value);
  491. }
  492. },
  493. 'erpBomUpdatePastButton': {
  494. afterrender:function(btn){
  495. if(!Ext.getCmp('bo_id').getValue()>0){
  496. btn.hide();
  497. }
  498. },
  499. click: function(btn){
  500. Ext.Ajax.request({//拿到grid的columns
  501. url : basePath + "pm/bom/updateBOMPast.action",
  502. params: {
  503. bo_id:Ext.getCmp('bo_id').value,
  504. value:Ext.getCmp('bo_ispast').value
  505. },
  506. method : 'post',
  507. async: false,
  508. callback : function(options,success,response){
  509. var res = new Ext.decode(response.responseText);
  510. if(res.exceptionInfo){
  511. showError(res.exceptionInfo);
  512. return;
  513. }else{
  514. Ext.Msg.alert('提示','更新成功');
  515. return;
  516. }
  517. }
  518. });
  519. }
  520. },
  521. 'field[name=bo_id]': {
  522. change: function(f){
  523. if(f.value != null){
  524. formCondition = 'bo_idIS' + f.value;
  525. gridCondition = 'bd_boidIS' + f.value;
  526. me.changeButtons(Ext.getCmp('bo_statuscode').value);
  527. }
  528. }
  529. },
  530. 'field[name=bo_statuscode]': {
  531. change: function(f){
  532. if(f.value != null){
  533. me.changeButtons(f.value);
  534. }
  535. }
  536. },
  537. 'dbfindtrigger[name=bo_mothercode]': {
  538. aftertrigger: function(f){
  539. me.FormUtil.loadNewStore(f.ownerCt, {caller: caller, condition: "bo_mothercode='" + f.value + "'"});
  540. var grid = Ext.getCmp('grid');
  541. grid.GridUtil.loadNewStore(grid, {caller: caller, condition: "bd_mothercode='" + f.value + "'"});
  542. }
  543. },
  544. 'dbfindtrigger[name=bd_soncode]': {
  545. focus: function(t){
  546. t.autoDbfind = false;
  547. var grid = Ext.getCmp('grid');
  548. var p = Ext.getCmp('bo_mothercode').value;
  549. if(p != null && p!= ''){
  550. var c = "(pr_code<>'" + p + "'";
  551. Ext.each(grid.store.data.items, function(item){
  552. if(item.data['bd_soncode'] != null && item.data['bd_soncode'] != ''){
  553. if(t.value != item.data['bd_soncode'])
  554. c += " and pr_code<>'" + item.data['bd_soncode'] + "'";
  555. }
  556. });
  557. t.dbBaseCondition = c + ")";
  558. } else {
  559. showError('未选择父件');return;
  560. }
  561. },
  562. /* change: function(t){
  563. },*/
  564. aftertrigger: function(t){
  565. var grid = Ext.getCmp('grid');
  566. t.setHideTrigger(false);
  567. t.setReadOnly(false);
  568. var record = grid.selModel.lastSelected;
  569. Ext.each(grid.store.data.items, function(item){
  570. if(item.data['bd_soncode'] != null && item.data['bd_soncode'] != ''){
  571. if(item.data['bd_detno'] != record.data['bd_detno'] && t.value == item.data['bd_soncode']){
  572. t.setHideTrigger(true);
  573. t.setReadOnly(true);
  574. t.setValue('');
  575. showError('请不要重复选择料号 ' + t.value);return;
  576. }
  577. }
  578. });
  579. me.FormUtil.getFieldsValue('BOM', 'bo_id', "bo_mothercode='" + t.value + "'", 'bd_sonbomid', grid.selModel.lastSelected);
  580. }
  581. }
  582. });
  583. },
  584. getForm: function(btn){
  585. return btn.ownerCt.ownerCt;
  586. },
  587. changeButtons: function(value){
  588. switch(value){
  589. case 'ENTERING':
  590. if(Ext.getCmp('bo_id').value != null){
  591. Ext.getCmp('save').hide();
  592. Ext.getCmp('updatebutton').show();
  593. Ext.getCmp('deletebutton').show();
  594. Ext.getCmp('submit').show();
  595. } else {
  596. Ext.getCmp('save').show();
  597. Ext.getCmp('updatebutton').hide();
  598. Ext.getCmp('submit').hide();
  599. Ext.getCmp('deletebutton').hide();
  600. }
  601. Ext.getCmp('resSubmit').hide();
  602. Ext.getCmp('auditbutton').hide();
  603. Ext.getCmp('resAudit').hide();
  604. break;
  605. case 'COMMITED':
  606. Ext.getCmp('save').hide();
  607. Ext.getCmp('updatebutton').hide();
  608. Ext.getCmp('submit').hide();
  609. Ext.getCmp('resSubmit').show();
  610. Ext.getCmp('auditbutton').show();
  611. Ext.getCmp('resAudit').hide();
  612. Ext.getCmp('deletebutton').hide();
  613. break;
  614. case 'AUDITED':
  615. Ext.getCmp('save').hide();
  616. Ext.getCmp('updatebutton').hide();
  617. Ext.getCmp('submit').hide();
  618. Ext.getCmp('resSubmit').hide();
  619. Ext.getCmp('auditbutton').hide();
  620. Ext.getCmp('resAudit').show();
  621. Ext.getCmp('deletebutton').hide();
  622. break;
  623. }
  624. },
  625. changeBOM:function(type,title){
  626. Ext.create('Ext.window.Window',{
  627. width:350,
  628. height:185,
  629. id:'win',
  630. title:'<h1>'+title+'BOM</h1>',
  631. layout:'column',
  632. items:[{
  633. xtype:'textarea',
  634. columnWidth:1,
  635. fieldLabel:title+'原因',
  636. name:'remark',
  637. editable:true,
  638. id:'remark',
  639. fieldStyle:'background:#fffac0;color:#515151;'
  640. }],
  641. buttonAlign:'center',
  642. buttons:[{
  643. xtype:'button',
  644. columnWidth:0.12,
  645. text:'保存',
  646. width:60,
  647. iconCls: 'x-button-icon-save',
  648. handler:function(btn){
  649. var remark=Ext.getCmp('remark').getValue();
  650. var boid=Ext.getCmp('bo_id').getValue();
  651. alert(remark);
  652. if(!remark){
  653. showError('请先填写相应的'+title+'原因!') ;
  654. return;
  655. }else{
  656. var dd=new Object();
  657. dd['botype']=type;
  658. dd['boid']=boid;
  659. dd['remark']=remark;
  660. Ext.Ajax.request({
  661. url : basePath +'pm/bom/handleBOM.action',
  662. params :{
  663. data:unescape(Ext.JSON.encode(dd)),
  664. caller:caller
  665. },
  666. method : 'post',
  667. callback : function(options,success,response){
  668. var localJson = new Ext.decode(response.responseText);
  669. if(localJson.success){
  670. Ext.Msg.alert('提示','更新成功!',function(){
  671. Ext.getCmp('win').close();
  672. window.location.reload();
  673. });
  674. } else if(localJson.exceptionInfo){
  675. var str = localJson.exceptionInfo;
  676. showError(str);
  677. return;
  678. } else{
  679. saveFailure();
  680. }
  681. }
  682. });
  683. }
  684. }
  685. },{
  686. xtype:'button',
  687. columnWidth:0.1,
  688. text:'关闭',
  689. width:60,
  690. iconCls: 'x-button-icon-close',
  691. margin:'0 0 0 10',
  692. handler:function(btn){
  693. Ext.getCmp('win').close();
  694. }
  695. }]
  696. }).show();
  697. }
  698. });