| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.make.MakeBase', {
- extend: 'Ext.app.Controller',
- requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
- views:[
- 'core.form.Panel','pm.make.MakeBase','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField','core.form.YnField',
- 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.PrintA4','core.button.Upload','core.button.ResAudit',
- 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail','core.button.ResSubmit',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.grid.YnColumn','core.button.Flow','core.button.Get',
- 'core.button.GetMaterial','core.button.DeleteMaterial','core.button.ChangeMaterial','core.button.GetCraft','core.button.HistoryProdIO',
- 'core.button.RefreshQty','core.button.MakeFlow','core.trigger.MultiDbfindTrigger','core.button.EnforceEnd',
- 'core.button.CalMake','core.button.Check','core.button.ResCheck', 'core.button.End', 'core.button.ResEnd','core.button.ModifyMaterial',
- 'core.button.SubRelation','core.button.TurnOSMake','core.button.GetOSVendor','core.button.UpdateRemark',
- 'core.button.UpdateTeamcode','core.button.GetPrice','core.button.OSInfoUpdate','core.button.UpdateMaterialWH',
- 'core.button.TurnOSToMake','core.button.BomUseMatch','erp.view.core.grid.HeaderFilter','core.button.UpdateMaStyle',
- 'core.button.ShiPAddressUpdate','core.button.MrpOpen','core.button.MrpClose'
- ],
- init:function(){
- var me = this;
- me.FormUtil = Ext.create('erp.util.FormUtil');
- me.GridUtil = Ext.create('erp.util.GridUtil');
- me.BaseUtil = Ext.create('erp.util.BaseUtil');
- this.control({
- '#ma_remark':{
- beforerender: function(field){
- field.readOnly=false;
- }
- },
- '#ma_teamcode':{
- beforerender: function(field){
- field.readOnly=false;
- }
- },
- '#ma_style':{
- beforerender: function(field){
- field.readOnly=false;
- }
- },
- 'erpGridPanel2': {
- afterrender: function(grid){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'ENTERING' ){
- grid.setReadOnly(true);
- }
- },
- reconfigure:function(grid){
- var items = grid.store.data.items;
- var totaluseqty = grid.store.getSum(items, 'mm_totaluseqty');
- var havegetqty = grid.store.getSum(items, 'mm_havegetqty');
- if( totaluseqty!=0 || havegetqty!=0){
- /*Ext.getCmp('resAudit').hide();
- Ext.getCmp('resCheck').hide();*/
- }
- },
- itemclick: function(view,record){
- me.itemclick(view,record,me);
- }
- },
- 'field[name=ma_currency]': {
- beforetrigger: function(field) {
- var value = Ext.getCmp('ma_date').value;
- if(value) {
- field.findConfig = 'cm_yearmonth=' + Ext.Date.format(value, 'Ym');
- }
- }
- },
- 'field[name=ma_tasktype]': {
- afterrender:function(field){
- if (field.value=='OS' && caller=='Make!Base'){
- window.location.href=window.location.href.replace('whoami=Make!Base','whoami=Make');
- }
- }
- },
- 'erpBomUseMatchButton':{
- afterrender:function(btn){
- btn.setDisabled(true);
- }
- },
- 'erpMakeFlowButton':{
- click: function(btn){
- var id=Ext.getCmp('ma_id').value;
- var formCondition="ma_idIS"+id;
- var gridCondition = "mf_maid="+Ext.getCmp('ma_id').value;
- var linkCaller='MakeFlow';
- var win = new Ext.window.Window(
- {
- id : 'win',
- height : '90%',
- width : '95%',
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items : [ {
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_'+linkCaller+'" src="'+basePath+'jsps/pm/make/makeflow.jsp?_noc=1&whoami='+linkCaller+'&gridCondition='+gridCondition+'&formCondition='+formCondition+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
- } ]
- });
- win.show();
- }
- },
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn), codeField = Ext.getCmp(form.codeField);
- if(codeField.value == null || codeField.value == ''){
- me.BaseUtil.getRandomNumber(caller);//自动添加编号
- var res = me.getLeadCode(Ext.getCmp('ma_kind').value);
- if(res != null && res != ''){
- codeField.setValue(res + codeField.getValue());
- }
- }
- this.FormUtil.beforeSave(this);
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- this.FormUtil.beforeClose(this);
- }
- },
- 'erpDeleteDetailButton': {
- afterrender: function(btn){
- btn.ownerCt.add({
- xtype: 'erpSubRelationButton'
- });
- btn.ownerCt.add({
- xtype: 'erpModifyMaterialButton'
- });
- btn.ownerCt.add({
- xtype: 'erpMrpOpenButton'
- });
- btn.ownerCt.add({
- xtype: 'erpMrpCloseButton'
- });
-
- }
-
- },
- 'erpUpdateButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'ENTERING' ){
- btn.hide();
- }
- },
- click: function(btn){
- var oldmaqty=0;
- if (Ext.getCmp('ma_id').value>0){
- oldmaqty=me.getFdValue('make','ma_qty','ma_id='+Ext.getCmp('ma_id').value);
- }
- this.FormUtil.onUpdate(this);
- if (oldmaqty-Ext.getCmp('ma_qty').value!=0){
- alert('工单需求数量已经被修改,请重新计算用料!');
- }
- }
- },
- 'erpDeleteButton': {
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('ma_id').value);
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addMakeBase', '新增单据', 'jsps/pm/make/makeBase.jsp?whoami=' + caller);
- }
- },
- 'erpSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- status = Ext.getCmp('ma_checkstatuscode');
- if(status && status.value != 'UNAPPROVED'){
- btn.hide();
- }
- },
- click: function(btn){
- /*var type = Ext.getCmp('ma_tasktype').getValue();
- if(type != 'MAKE'){// 委外工单 考虑加工单价
- var p = Ext.getCmp('ma_price');
- if(p && (Ext.isEmpty(p.value) || p.value == 0)){
- Ext.Msg.alert("提示","请先填写加工单价后再提交!");
- return;
- }
- }*/
- me.FormUtil.onSubmit(Ext.getCmp('ma_id').value);
- }
- },
- 'erpResSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_checkstatuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResSubmit(Ext.getCmp('ma_id').value);
- }
- },
- 'erpAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onAudit(Ext.getCmp('ma_id').value);
- }
- },
- 'erpResAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- var checkStatus = Ext.getCmp('ma_checkstatuscode');
- if(checkStatus && checkStatus.value == 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- if (!confirm('确定要反审核单据?')){
- return;
- }
- me.FormUtil.onResAudit(Ext.getCmp('ma_id').value);
- }
- },
- 'erpPrintButton':{
- click:function(btn){
- var maclass=Ext.getCmp('ma_tasktype').value;
- var reportName="";
- var condition="";
- if(maclass == "MAKE"){
- reportName="MAKE";
- condition='{Make.ma_id}='+Ext.getCmp('ma_id').value;
- //+' and (' + 'isnull({MAKEMATERIAL.MM_MATERIALSTATUS}) or {MAKEMATERIAL.MM_MATERIALSTATUS}=\' \')';
- } else {
- reportName="MAKEWW";
- condition='{Make.ma_id}='+Ext.getCmp('ma_id').value;
- //+' and (' + 'isnull({MAKEMATERIAL.MM_MATERIALSTATUS}) or {MAKEMATERIAL.MM_MATERIALSTATUS}=\' \')';
- }
-
- var id=Ext.getCmp('ma_id').value;
- me.FormUtil.onwindowsPrint2(id,reportName,condition);
- }
- },
- 'erpPrintA4Button':{
- click:function(btn){
- var maclass=Ext.getCmp('ma_tasktype').value;console.log(maclass);
- var reportName="";
- var condition="";
- if(maclass == "MAKE"){
- reportName="MAKE";
- condition='{MA_MAKEUSEPRE.ma_id}='+Ext.getCmp('ma_id').value;
- } else {
- reportName="MAKEWWA4";
- condition='{Make.ma_id}='+Ext.getCmp('ma_id').value;
- }
- //var condition='{MA_MAKEUSEPRE.ma_id}='+Ext.getCmp('ma_id').value;
- var id=Ext.getCmp('ma_id').value;
- me.FormUtil.onwindowsPrint(id,reportName,condition);
- }
- },
- 'erpGetMaterialButton':{
- afterrender: function(btn){
- btn.hide();//暂时不启用
- var status = Ext.getCmp('ma_chechkstatuscode');
- if(status && status.value != 'APPROVE'){
- btn.hide();
- }
- }
- },
- 'erpDeleteMaterialButton':{
- afterrender: function(btn){
- btn.hide();//暂时不启用
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- }
- },
- 'erpEnforceEndButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value == 'FINISH'){
- btn.hide();
- }
- },
- click: function(btn){
- warnMsg("确定要强制结案吗?", function(btn){
- if(btn == 'yes'){
- Ext.Ajax.request({
- url : basePath + 'pm/make/enforceEndMake.action',
- params: {
- id: Ext.getCmp('ma_id').value
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- Ext.Msg.alert("提示","操作成功!");
- window.location.reload();
- } else {
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
- str = str.replace('AFTERSUCCESS', '');
- showMessage('提示', str);
- window.location.reload();
- } else if(str == 'OK'){
- Ext.Msg.alert("提示","强制结案成功!");
- } else {
- showError(str);return;
- }
- }
- }
- }
- });
- }
- });
- }
- },
- 'erpGetOSVendorButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && (status.value == 'FINISH')){
- btn.hide();
- }
- var tasktype = Ext.getCmp('ma_tasktype');
- if(tasktype && (tasktype.value != 'OS')){
- btn.hide();
- }
- },
- click: function(btn){
- if (!confirm('确定要自动获取委外商和单价?')){
- return;
- }
- Ext.Ajax.request({
- url: basePath + '/scm/purchase/getMakeVendorPrice.action',
- params: {
- id: Ext.getCmp('ma_id').value
- },
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.exceptionInfo) {
- showError(rs.exceptionInfo);
- } else {
- Ext.Msg.alert("提示","获取成功!");
- window.location.reload();
- }
- }
- });
- }
- },
- 'erpGetCraftButton':{
- afterrender: function(btn){
- btn.hide();//暂时不启用
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- if(status && status.value != 'APPROVE'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResAudit(Ext.getCmp('ma_id').value);
- }
- },
- 'erpChangeMaterialButton': {
- afterrender: function(btn){
- btn.hide();//暂时不启用
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- }
- },
- 'erpGetPriceButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value == 'FINISH'){
- btn.hide();
- }
- status = Ext.getCmp('ma_checkstatuscode');
- if (status && status.value == 'APPROVE'){
- btn.hide();
- }
- },
- click: function(btn){
- Ext.Ajax.request({
- url: basePath + '/scm/purchase/getMakeVendorPrice.action',
- params: {
- id: Ext.getCmp('ma_id').value
- },
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.exceptionInfo) {
- showError(rs.exceptionInfo);
- } else {
- Ext.Msg.alert("提示","获取成功!");
- window.location.reload();
- }
- }
- });
- }
- },
- 'erpCalMakeButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'ENTERING' && status.value != 'AUDITED'){
- btn.hide();
- }
- } ,
- click: function(btn){
- if (!confirm('确定要计算用料?')){
- return;
- }
- var code = Ext.getCmp('ma_code').getValue();
- if (code) {
- Ext.Ajax.request({
- url : basePath + 'pm/make/setMakeMaterial.action',
- params: {
- caller: caller,
- code: code
- },
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- } else {
- window.location.reload();
- };
- }
- });
- }
- }
- },
- 'dbfindtrigger[name=ma_saledetno]': {
- afterrender: function(t){
- t.dbKey = "ma_salecode";
- t.mappingKey = "sd_code";
- t.dbMessage = "请先选择订单编号!";
- }
- },
- 'combo[name=ma_sourcekind]':{
- change:function(field,newValue){
- var codefield=Ext.getCmp('ma_salecode');
- var detnofield=Ext.getCmp('ma_saledetno');
- if(newValue=='Sale'){
- //销售预测
- codefield.dbCaller='Make!Base';
- detnofield.dbCaller='Make!Base';
- }else if(newValue=='SaleForeCast'){
- codefield.dbCaller='Make!Base!ForeCast';
- detnofield.dbCaller='Make!Base!ForeCast';
-
- }
- }
- },
- 'dbfindtrigger[name=mm_prodcode]': {
- /*focus: function(t){
- var grid = Ext.getCmp('grid');
- var c = null;
- Ext.each(grid.store.data.items, function(item){
- if(item.data['mm_prodcode'] != null && item.data['mm_prodcode'] != ''){
- if(c == null){
- c = "(pr_code<>'" + item.data['mm_prodcode'] + "'";
- } else {
- c += " and pr_code<>'" + item.data['mm_prodcode'] + "'";
- }
- }
- });
- if(c != null){
- t.dbBaseCondition = c + ")";
- }
- }*/
- },
- 'textfield[name=ma_wccode]': {
- change: function(field){
- if(field.value != null && field.value != ''){
- var grid = Ext.getCmp('grid');
- var d = field.value;
- Ext.Array.each(grid.getStore().data.items,function(item){
- if(item.data['mm_prodcode'] != null && item.data['mm_prodcode'] != '' ){
- if(item.data['mm_wccode'] == null ||item.data['mm_wccode'] == '' ){
- item.set('mm_wccode',d);
- }
- }
- });
- }
- }
- },
- 'datefield[name=ma_planenddate]':{
- change: function(f) {
- var c = Ext.getCmp('ma_planbegindate').getValue();
- var value = f.value;
- if( c != null && c != '' && value !=null && value != ''){
- if(c > value){
- Ext.getCmp('ma_planbegindate').setValue('');
- showError('计划完工日期不能早于计划开工日期');
- }
- }
- }
- },
-
- 'datefield[name=ma_planbegindate]':{
- change: function(f) {
- var c = Ext.getCmp('ma_planenddate').getValue();
- var value = f.value;
- if( value !=null && value != ''){
- var formatV = new Date(Ext.util.Format.date(value, 'Y-m-d'));
- var now = new Date(Ext.util.Format.date(new Date(),'Y-m-d'))
- if(now > formatV){
- Ext.getCmp('ma_planenddate').setValue('');
- showError('计划开工日期不能早于今天的日期');
- }
- if(c != null && c != '' ){
- if(value > c){
- Ext.getCmp('ma_planenddate').setValue('');
- showError('计划完工日期不能早于计划开工日期');
- }
- }
- }
- }
- },
- 'erpCheckButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_checkstatuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onCheck(Ext.getCmp('ma_id').value);
- }
- },
- 'erpResCheckButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_checkstatuscode');
- if(status && status.value != 'APPROVE' ){
- btn.hide();
- }
- /*if(status && status.value != 'APPROVE' || Ext.getCmp('ma_statuscode').value != 'AUDITED'){
- btn.hide();
- }*/
- },
- click: function(btn){
- me.FormUtil.onResCheck(Ext.getCmp('ma_id').value);
- }
- },
- 'erpEndButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onEnd(Ext.getCmp('ma_id').value);
- }
- },
- 'erpResEndButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'FINISH'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResEnd(Ext.getCmp('ma_id').value);
- }
- },
- 'erpSubRelationButton':{
- click:function(btn){
- var id=btn.ownerCt.ownerCt.ownerCt.items.items[1].selModel.selected.items[0].data["mm_id"];
- var formCondition="mm_id IS"+id;
- var gridCondition="mp_mmid IS"+id;
- var linkCaller='MakeBase!Sub';
- var win = new Ext.window.Window(
- {
- id : 'win',
- height : '90%',
- width : '95%',
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items : [ {
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_'+linkCaller+'" src="'+basePath+'jsps/pm/make/makeCommon.jsp?_noc=1&whoami='+linkCaller+'&gridCondition='+gridCondition+'&formCondition='+formCondition+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
- } ]
- });
- win.show();
- },
- afterrender:function(btn){
- btn.setDisabled(true);
- }
- },
- 'erpModifyMaterialButton':{
- click:function(btn){
- var id=btn.ownerCt.ownerCt.ownerCt.items.items[1].selModel.selected.items[0].data["mm_id"];
- var formCondition="mm_id IS"+id;
- var linkCaller='MakeMaterial!Modify';
- var win = new Ext.window.Window(
- {
- id : 'win',
- height : '90%',
- width : '95%',
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items : [ {
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_'+linkCaller+'" src="'+basePath+'jsps/pm/make/modifyForm.jsp?_noc=0&whoami='+linkCaller+'&formCondition='+formCondition+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
- } ],
- listeners:{
- 'beforeclose':function(view ,opt){
- var grid = Ext.getCmp('grid');
- var value = Ext.getCmp('ma_id').value;
- var gridCondition = grid.mainField + '=' + value,
- gridParam = {caller: caller, condition: gridCondition};
- me.GridUtil.loadNewStore(grid, gridParam);
- }
-
- }
- });
- win.show();
- },
- afterrender:function(btn){
- btn.setDisabled(true);
-
- }
-
- },
- 'erpBomUseMatchButton' :{
- click: function(btn){
-
- var ma_code = Ext.getCmp('ma_code').value;
- Ext.Ajax.request({
- url : basePath + 'pm/make/MakeMaterialCheck.action',
- params: {
- code:ma_code
- },
- async:false,
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- } else {
- // var grid = Ext.getCmp('grid');
- // var value = Ext.getCmp('ma_id').value;
- // var gridCondition = grid.mainField + '=' + value,
- // gridParam = {caller: caller, condition: gridCondition};
- // me.GridUtil.loadNewStore(grid, gridParam);
-
- var win = new Ext.window.Window(
- {
- id : 'winMatch',
- height : '90%',
- width : '95%',
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items : [ {
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_BomUseMatchWin'+ma_code+'" src="'+basePath+'jsps/common/datalist.jsp?_noc=1&whoami=BomUseMatchWin&urlcondition=mc_makecode=\''+ma_code+'\'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
- } ]
- });
- win.show();
- };
- }
- });
- },
- afterrender:function(btn){
- btn.setDisabled(false);
- }
-
- },
- 'erpHistoryProdIOButton':{
- click: function(){
- var macode = Ext.getCmp('ma_code').value;
- var record = Ext.getCmp('grid').selModel.lastSelected;
- if(record){
- var detno = record.data['mm_detno'],prod = record.data['mm_prodcode'];
- var win = Ext.getCmp('history-win');
- if(win == null){
- win = Ext.create('Ext.window.Window', {
- id: 'history-win',
- width: '80%',
- height: '100%',
- maximizable : true,
- layout: 'anchor',
- closeAction: 'hide',
- setMyTitle: function(code){//@param code 料号
- this.setTitle('物料编号:<font color=blue>' + code + '</font> 工单号:<font color=blue>' + macode + '</font> 的出入库明细 ');
- },
- reload: function(no, code){//@param code 料号
- var g = this.down('grid[id=history]');
- g.GridUtil.loadNewStore(g, {
- caller: g.caller,
- condition: "pd_ordercode ='" + macode + "' and pd_orderdetno="+ no + " order by pi_date desc"
- });
- g = this.down('grid[id=makescrap]');
- g.GridUtil.loadNewStore(g, {
- caller: g.caller,
- condition: "md_mmcode='" + macode + "' AND md_mmdetno=" + no
- });
- this.setMyTitle(code);
- }
- });
- win.setMyTitle(prod);
- win.show();
- win.add(Ext.create('erp.view.core.grid.Panel2', {
- id: 'history',
- anchor: '100% 60%',
- caller: 'ProdInOut!Make!History',
- condition: "pd_ordercode ='" + macode + "' and pd_orderdetno='"+ detno + "' order by pi_date desc",
- bbar: null,
- listeners: {
- reconfigure: function(){
- win.add(Ext.create('erp.view.core.grid.Panel2', {
- id: 'makescrap',
- title: '报废单',
- anchor: '100% 40%',
- caller: 'MakeScrap!JM',
- condition: "md_mmcode='" + macode + "' AND md_mmdetno=" + detno,
- bbar: null
- }));
- }
- }
- }));
- } else {
- win.reload(detno, prod);
- win.show();
- }
- } else {
- Ext.Msg.alert("提示","请先选择明细!");
- }
- }
- },
- 'erpRefreshQtyButton':{
- click: function(btn){
- var maid=Ext.getCmp('ma_id').value;
- Ext.Ajax.request({
- url : basePath + "pm/make/refreshqty.action",
- params:{
- id: maid
- },
- method:'post',
- callback:function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- Ext.Msg.alert("提示","刷新成功!");
- window.location.reload();
- } else {
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
- str = str.replace('AFTERSUCCESS', '');
- showError(str);
- } else {
- showError(str);return;
- }
- }
- }
- }
- });
- }
- },
- 'erpTurnOSMakeButton':{
- click: function(btn){
- if (!confirm('确定要转本单据为委外单?')){
- return;
- }
- var kind = Ext.getCmp('ma_kind'),
- bg = 'background:#fffac0;color:#515151;';
- Ext.create('Ext.window.Window',{
- width:300,
- height:120,
- id:'win',
- title:'<h1>请选择委外单工单类型</h1>',
- items:[{
- xtype:'dbfindtrigger',
- fieldLabel:'工单类型',
- name:'makind',
- editable:false,
- id:'makind',
- fieldStyle: kind.allowBlank ? '' : bg
- }],
- buttonAlign:'center',
- buttons:[{
- xtype:'button',
- columnWidth:0.12,
- text:'确认',
- width:60,
- iconCls: 'x-button-icon-save',
- handler:function(btn){
- var kind=Ext.getCmp('makind').getValue();
- var maid=Ext.getCmp('ma_id').value;
- if(kind == null ||kind == ''){
- showError("请选择工单类型");
- return ;
- }
- Ext.Ajax.request({
- url : basePath + "pm/make/turnOSMake.action",
- params:{
- id: maid,
- kind:kind,
- caller:caller
- },
- method:'post',
- callback:function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- Ext.Msg.alert("提示","已成功转委外单!");
- var main = parent.Ext.getCmp("content-panel");
- main.getActiveTab().close();
- } else {
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
- str = str.replace('AFTERSUCCESS', '');
- showError(str);
- } else {
- showError(str);return;
- }
- }
- }
- }
- });
-
- }
- },{
- xtype:'button',
- columnWidth:0.1,
- text:'关闭',
- width:60,
- iconCls: 'x-button-icon-close',
- margin:'0 0 0 10',
- handler:function(btn){
- Ext.getCmp('win').close();
- }
- }]
- }).show();
- }
- },
-
- 'erpTurnOSToMakeButton':{
- click: function(btn){
- if (!confirm('确定要转本单据为制造单?')){
- return;
- }
- var kind = Ext.getCmp('ma_kind'),
- bg = 'background:#fffac0;color:#515151;';
- Ext.create('Ext.window.Window',{
- width:300,
- height:120,
- id:'win',
- title:'<h1>请选择制造工单类型</h1>',
- items:[{
- xtype:'dbfindtrigger',
- fieldLabel:'工单类型',
- name:'makind',
- editable:false,
- id:'makind',
- fieldStyle: kind.allowBlank ? '' : bg
- }],
- buttonAlign:'center',
- buttons:[{
- xtype:'button',
- columnWidth:0.12,
- text:'确认',
- width:60,
- iconCls: 'x-button-icon-save',
- handler:function(btn){
- var kind=Ext.getCmp('makind').getValue();
- var maid=Ext.getCmp('ma_id').value;
- if(kind == null ||kind == ''){
- showError("请选择工单类型");
- return ;
- }
- Ext.Ajax.request({
- url : basePath + "pm/make/turnOSToMake.action",
- params:{
- id: maid,
- kind:kind,
- caller:caller
- },
- method:'post',
- callback:function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- Ext.Msg.alert("提示","已成功转制造单!");
- var main = parent.Ext.getCmp("content-panel");
- main.getActiveTab().close();
- } else {
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
- str = str.replace('AFTERSUCCESS', '');
- showError(str);
- } else {
- showError(str);return;
- }
- }
- }
- }
- });
- }
- },{
- xtype:'button',
- columnWidth:0.1,
- text:'关闭',
- width:60,
- iconCls: 'x-button-icon-close',
- margin:'0 0 0 10',
- handler:function(btn){
- Ext.getCmp('win').close();
- }
- }]
- }).show();
- }
- },
- 'erpMrpOpenButton':{
- click: function(btn){
- var grid = Ext.getCmp('grid');
- var record = grid.selModel.lastSelected;
- var id = record.data.mm_id;
- Ext.Ajax.request({
- url : basePath + "pm/make/openMrp.action",
- params: {
- id:id,
- caller:caller
- },
- method : 'post',
- async: false,
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);
- return;
- }
- Ext.Msg.alert('提示','打开Mrp成功!');
- var condition='mm_maid='+Ext.getCmp('ma_id').value;
- me.GridUtil.loadNewStore(grid,{caller:caller,condition:condition});
- }
- });
- },
- afterrender:function(btn){
- btn.setDisabled(true);
- }
- },
- 'erpMrpCloseButton': {
- click: function(btn){
- var grid = Ext.getCmp('grid');
- var record = grid.selModel.lastSelected;
- var id = record.data.mm_id;
- Ext.Ajax.request({
- url : basePath + "pm/make/CloseMrp.action",
- params: {
- id:id,
- caller:caller
- },
- method : 'post',
- async: false,
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);
- return;
- }
- Ext.Msg.alert('提示','关闭Mrp成功!');
- var condition='mm_maid='+Ext.getCmp('ma_id').value;
- me.GridUtil.loadNewStore(grid,{caller:caller,condition:condition});
- }
- });
- },
- afterrender:function(btn){
- btn.setDisabled(true);
- }
- },
- 'field[name=ma_prodcode]': {
- change: function(f){
- if(f.value != null && f.value != ''){
- me.FormUtil.getFieldValue('BOM', 'bo_id', "bo_mothercode='" + f.value + "'", 'ma_bomid');
- }
- }
- },
- 'field[name=ma_qty]': {
- /*
- change: function(f){
- if(f.value == null || f.value == ''){
- f.value = 0;
- }
- if(Ext.getCmp('ma_total')){
- Ext.getCmp('ma_total').setValue(f.value*Ext.getCmp('ma_price').value);
- }
- var grid = Ext.getCmp('grid');
- if(grid){
- var items = grid.store.data.items;
- Ext.each(items, function(item){//制单需求=制单套数*单位用量
- if(item.data['mm_oneuseqty'] != null && item.data['mm_oneuseqty'] != 0){
- item.set('mm_qty', item.data['mm_oneuseqty']*f.value);
- }
- });
- }
- }
- */
- },
- 'erpUpdateRemarkButton':{
- click:function(){
- var remark=Ext.getCmp('ma_remark');
- me.updateRemark(remark.value,Ext.getCmp('ma_id').value);
-
- }
- },
- 'erpUpdateTeamcodeButton':{
- click:function(){
- var teamcode=Ext.getCmp('ma_teamcode');
- me.updateTeamcode(teamcode.value,Ext.getCmp('ma_id').value);
-
- }
- },
- 'erpUpdateMaStyleButton':{//更新流程类型
- click:function(){
- var mastyle=Ext.getCmp('ma_style');
- me.updateMaStyle(mastyle.value,Ext.getCmp('ma_id').value);
- },
- afterrender:function(btn){
- var checkstatus = Ext.getCmp("ma_checkstatuscode");
- var status = Ext.getCmp("ma_statuscode");
- if((checkstatus && (checkstatus.value == 'APPROVE'||checkstatus.value == 'COMMITED'))||(status && status.valueOf() == 'ENTERING')){
- btn.hide();
- }
- }
- },
- 'field[name=ma_price]': {
- change: function(f){
- if(f.value == null || f.value == ''){
- f.value = 0;
- }
- if(Ext.getCmp('ma_total')){//字段存在赋值,不存在不赋值
- Ext.getCmp('ma_total').setValue(f.value*Ext.getCmp('ma_qty').value);
- }
- }
- },
- 'field[name=mm_oneuseqty]': {
- change: function(f){//制单需求=制单套数*单位用量
- if(f.value != null && f.value > 0 && Ext.getCmp('ma_qty') && Ext.getCmp('ma_qty').value > 0){
- var record = Ext.getCmp('grid').selModel.getLastSelected();
- if(record.data['mm_qty'] != f.value*Ext.getCmp('ma_qty').value){
- record.set('mm_qty', f.value*Ext.getCmp('ma_qty').value);
- }
- }
- }
- }
- });
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- itemclick:function(view,record,me){
- var show=0;
- me.GridUtil.onGridItemClick(view,record);
- var fieldValue=record.data["mm_prodcode"];
- if(fieldValue==undefined||fieldValue==""||fieldValue==null){
- show=1;
- return;
- }
- var status = Ext.getCmp('ma_statuscode').getValue();
- if(show==1 || status=='FINISH' ){
- Ext.getCmp('SubRelation').setDisabled(true);
- Ext.getCmp('ModifyMaterial').setDisabled(true);
- Ext.getCmp('MrpClose').setDisabled(true);
- Ext.getCmp('MrpOpen').setDisabled(true);
- }else {
- Ext.getCmp('SubRelation').setDisabled(false);
- Ext.getCmp('ModifyMaterial').setDisabled(false);
- Ext.getCmp('MrpClose').setDisabled(false);
- Ext.getCmp('MrpOpen').setDisabled(false);
- }
- },
- updateRemark:function(remark,id){
- Ext.Ajax.request({
- url : basePath + 'pm/make/updateRemark.action',
- params: {remark:remark,id:id},
- method : 'post',
- async:false,
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- }
- showMessage("提示", '更新成功!');
- window.location.reload();
- }
- });
- },
- updateTeamcode:function(value,id){
- Ext.Ajax.request({
- url : basePath + 'pm/make/updateTeamcode.action',
- params: {value:value,id:id},
- method : 'post',
- async:false,
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- }
- showMessage("提示", '更新成功!');
- window.location.reload();
- }
- });
- },
- updateMaStyle:function(value,id){
- Ext.Ajax.request({
- url : basePath + 'pm/make/updateMaStyle.action',
- params: {value:value,id:id},
- method : 'post',
- async:false,
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- }
- showMessage("提示", '更新成功!');
- window.location.reload();
- }
- });
- },
- getFdValue: function(tablename,field, condition){//根据特征项code和特征值码获取特征值
- var result = '';
- Ext.Ajax.request({
- url : basePath + "/common/getFieldData.action",
- params: {
- caller: tablename,
- field: field,
- condition: condition
- },
- method : 'post',
- async: false,
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- }
- if(res.success){
- result = res.data;
- }
- }
- });
- return result;
- },
- getRandomNumber: function(table, type, codeField){
- if(Ext.getCmp('ma_kind')){
- var form = Ext.getCmp('form');
- if(form){
- table = table == null ? form.tablename : table;
- }
- type = type == null ? 2 : type;
- codeField = codeField == null ? form.codeField : codeField;
- Ext.Ajax.request({
- url : basePath + 'pm/make/getCodeString.action',
- async: false,//同步ajax请求
- params: {
- caller: caller,//如果table==null,则根据caller去form表取对应table
- table: table,
- type: type,
- conKind:Ext.getCmp('ma_kind').getValue()
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.success){
- Ext.getCmp(codeField).setValue(localJson.code);
- }
- }
- });
- } else {
- this.BaseUtil.getRandomNumber(caller);//自动添加编号
- }
- },
- getLeadCode: function(type) {
- var result = null;
- Ext.Ajax.request({
- url : basePath + 'common/getFieldData.action',
- async: false,
- params: {
- caller: 'MakeKind',
- field: 'mk_excode',
- condition: 'mk_name=\'' + type + '\''
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);return;
- } else if(r.success){
- result = r.data;
- }
- }
- });
- return result;
- }
- });
|