| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154 |
- 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.toolbar.Toolbar','core.form.MultiField','core.form.YnField',
- 'core.button.Save','core.button.MakeDownPut','core.button.Add','core.button.Submit','core.button.ResAudit',
- 'core.button.Audit','core.button.ResMakeDownPut','core.button.Close','core.button.Delete','core.button.Update','core.button.ResSubmit',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.grid.YnColumn','core.button.Flow','core.button.UpdateTeamcode',
- 'core.trigger.MultiDbfindTrigger','core.button.EnforceEnd','core.button.End', 'core.button.ResEnd','core.button.ModifyMaterial',
- 'core.button.SubRelation','core.button.UpdateRemark','erp.view.core.grid.HeaderFilter','core.button.MakeSNCode',
- 'core.button.MakeStop','core.button.MakeResStop','core.button.ModifyDetail','core.button.Modify','core.button.VindicateMake',
- 'core.button.CopyByConfigs','core.button.DecomSetting','core.button.UpdateMaCraft'
- ],
- 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_firstitemcheck':{
- change:function(f){
- if (f.value==-1) {
- Ext.getCmp('ma_allowpronum').setFieldStyle("color:#000000");
- Ext.getCmp('ma_allowpronum').allowBlank=false;
- }else {
- Ext.getCmp('ma_allowpronum').allowBlank=true;
- }
- }
- },*/
- '#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');
- }
- }
- },
- 'erpMakeSNCodeButton':{
- click: function(){
- var id = Ext.getCmp('ma_id').value;
- /*var url = "jsps/pm/make/makeIMEI.jsp?whoami=Make!MakeSN";*/
- var url = "jsps/common/import.jsp?whoami=Make!MakeSN";
- var panelId = caller + "ma_id_" + id + "ma_idIS"+id;
- var panel = Ext.getCmp(panelId);
- var main = parent.Ext.getCmp("content-panel");
- if(!main){
- main = parent.parent.Ext.getCmp("content-panel");
- }
- if(!panel){
- var title = "";
- panel = {
- title : '工单序列号导入',
- tag : 'iframe',
- tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'(ma_id"="' + id +')'},
- border : false,
- layout : 'fit',
- iconCls : 'x-tree-icon-tab-tab1',
- html : '<iframe id="iframe_maindetail_'+caller+"_"+id+'" src="' + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
- closable : true,
- listeners : {
- close : function(){
- if(!main){
- main = parent.parent.Ext.getCmp("content-panel");
- }
- main.setActiveTab(main.getActiveTab().id);
- }
- }
- };
- this.openTab(panel, panelId);
- }else{
- main.setActiveTab(panel);
- }
- }
- },
- 'erpDecomSettingButton':{
- afterrender: function(btn){
- var ma_kind = Ext.getCmp("ma_kind");
- if(ma_kind && ma_kind.value != '返工' ){
- btn.hide();
- }
- },
- click: function(btn){
- var ma_screcode = Ext.getCmp('ma_screcode').value;
- var grid = Ext.getCmp('grid');
- var caller = 'DecomSetting!Make';
- var id = Ext.getCmp('ma_id').value;
- var result = 0;
- if(ma_screcode != null && ma_screcode !=''){
- Ext.Ajax.request({
- url : basePath + 'common/getFieldData.action',
- async: false,
- params: {
- caller: 'reworkdetail left join rework on re_id = rd_reid',
- field: 'count(rd_sncode)',
- condition: "re_code= '" + ma_screcode +"'"
- },
- 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;
- }
- }
- });
- }else{
- showError("返工需求单号为空");return;
- }
- if(result > 0){
- var dbwin = new Ext.window.Window({
- id : 'dcswin',
- title: '拆解部件设定',
- height: "100%",
- width: "90%",
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items: [],
- listeners:{
- beforeclose: function(){
- window.location.reload();
- }
- }
- });
- dbwin.add({
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_DecomSetting!Make" src="'+basePath+'jsps/pm/make/decomSetting.jsp?whoami='+caller+'&formCondition=ma_idIS'+id+'&gridCondition=mm_maidIS'+id+'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
- });
- dbwin.show();
- }else{
- showError("不存在序列号");return;
- }
- /*var items = grid.getStore().data.items;//获取store里面的数据
- */
-
- }
- },
- 'erpMakeDownPutButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'AUDITED' ){
- btn.hide();
- }
- },
- click: function(btn){
- //var istrue =me.checkFirstItem();
- //if (!istrue) {
- // return false;
- //}
- warnMsg("确定要下放吗?", function(btn){
- if(btn == 'yes'){
- me.FormUtil.setLoading(true);
- Ext.Ajax.request({
- url : basePath + 'pm/make/MakeDownPut.action',
- params: {
- id: Ext.getCmp('ma_id').value,
- caller : caller
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- Ext.Msg.alert("提示","下放成功!",function(){
- 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;
- }
- }
- }
- }
- });
- }
- });
- }
- },
- 'erpVindicateMakeButton':{
- click: function(btn){
- var id = Ext.getCmp("ma_id").value;
- if(id != null && id != '' && id != 0 && id != '0'){
- me.FormUtil.onAdd('MakeMaterial' + id, '用料表维护', 'jsps/pm/make/makeMaterial.jsp?formCondition=ma_id=' + id +"&gridCondition=mm_maid=" + id);
- }
- }
- },
- 'erpResMakeDownPutButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'STARTED' ){
- btn.hide();
- }
- },
- click: function(btn){
- var me = this;
- me.FormUtil.setLoading(true);
- Ext.Ajax.request({
- url : basePath + 'pm/make/ResMakeDownPut.action',
- params: {
- id: Ext.getCmp('ma_id').value,
- caller : caller
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- Ext.Msg.alert("提示","取消下放成功!",function(){
- 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;
- }
- }
- }
- }
- });
- }
- },
- 'erpMakeStopButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'STARTED' ){
- btn.hide();
- }
- },
- click: function(btn){
- warnMsg("确定要暂停吗?", function(btn){
- if(btn == 'yes'){
- Ext.Ajax.request({
- url : basePath + 'pm/make/MakeStop.action',
- params: {
- id: Ext.getCmp('ma_id').value,
- caller : caller
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- Ext.Msg.alert("提示","暂停成功!",function(){
- 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;
- }
- }
- }
- }
- });
- }
- });
- }
- },
- 'erpMakeResStopButton':{
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'STOP' ){
- btn.hide();
- }
- },
- click: function(btn){
- Ext.Ajax.request({
- url : basePath + 'pm/make/ResMakeStop.action',
- params: {
- id: Ext.getCmp('ma_id').value,
- caller : caller
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- Ext.Msg.alert("提示","取消暂停成功!",function(){
- 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;
- }
- }
- }
- }
- });
- }
- },
- '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'
- });
- }
- },*/
- 'erpUpdateButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'ENTERING' ){
- btn.hide();
- }
- },
- click: function(btn){
- if (Ext.getCmp('ma_firstitemcheck').value!=-1) {
- Ext.getCmp('ma_allowpronum').allowBlank=true;
- }
- this.FormUtil.onUpdate(this);
- /*var oldmaqty=0;
- if (Ext.getCmp('ma_id').value>0){
- oldmaqty=me.getFdValue('make','ma_qty','ma_id='+Ext.getCmp('ma_id').value);
- }
- 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 != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- //var istrue =me.checkFirstItem();
- //if (!istrue) {
- // return false;
- //}
- /*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_statuscode');
- 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 != 'COMMITED'){
- 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);
- }
- },
- '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;
- }
- }
- }
- }
- });
- }
- });
- }
- },
- 'erpChangeMaterialButton': {
- afterrender: function(btn){
- btn.hide();//暂时不启用
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- }
- },
- '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;
- if(grid){
- 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'));
- if(c != null && c != '' ){
- if(value > c){
- Ext.getCmp('ma_planenddate').setValue('');
- showError('计划完工日期不能早于计划开工日期');
- }
- }
- }
- }
- },
- 'erpEndButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- Ext.MessageBox.show({
- title:'结案',
- msg:'请输入结案原因:',
- width:300,
- buttons:Ext.MessageBox.OKCANCEL,
- multiline:true,
- fn:function(btn,text){
- if(btn == 'ok'){
- me.onEnd(Ext.getCmp('ma_id').value,text);
- }
- }
- })
-
- }
- },
- '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);
-
- }
-
- },
- '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 linecode=Ext.getCmp('ma_linecode');
- me.updateTeamcode(linecode.value,Ext.getCmp('ma_id').value);
-
- }
- },
- '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);
- }
- }
- }
- },
- 'dbfindtrigger[name=ma_craftcode]': {
- beforetrigger: function(field) {
- var t = field.up('form').down('field[name=ma_prodcode]'),
- value = t.getValue();
- if(value) {
- field.findConfig = "cr_prodcode='" + value + "'";
- }
- }
- },
- 'dbfindtrigger[name=ma_bomversion]': {
- beforetrigger: function(field) {
- var value1 = Ext.getCmp('ma_prodcode').value;
- var value2 = Ext.getCmp('ma_craftcode').value;
- if(value1 && value2) {
- field.findConfig = "sb_prodcode='"+value1+"' and sb_craftcode = '"+value2+"'";
- }else if(value1){
- field.findConfig = "sb_prodcode='"+value1+"'";
- }else if(value2){
- field.findConfig = "sb_craftcode = '"+value2+"'";
- }
- }
- },
- 'erpUpdateMaCraftButton':{
- afterrender:function(btn){
- var status = Ext.getCmp("ma_statuscode");
- if((status && (status.value == 'ENTERING' || status.value == 'FINISH'))){
- btn.hide();
- }
- },
- click:function(){
- var me=this;
- var cr_code = Ext.getCmp('ma_craftcode'),
- bg = 'background:#fffac0;color:#515151;';
- var win = Ext.getCmp('cr_win');
- if(win == null){
- win = Ext.create('Ext.window.Window',{
- width:400,
- height:200,
- id:'cr_win',
- title:'<h1>请选择工单途程</h1>',
- layout : 'anchor',
- bodyStyle: 'background: #f1f1f1;',
- bodyPadding:5,
- layout: 'column',
- buttonAlign:'center',
- defaults:{
- columnWidth:0.8
- },
- items:[{
- xtype:'dbfindtrigger',
- fieldLabel:'途程编号',
- labelStyle:"color:red;",
- name:'macraftcode',
- editable:false,
- id:'macraftcode',
- fieldStyle: cr_code.allowBlank ? '' : bg,
- listeners:{
- beforetrigger: function(field) {
- var t = Ext.getCmp("ma_prodcode");
- if(t && t.value) {
- field.findConfig = "cr_prodcode='" + t.value + "'";
- }
- }
- }
- },{
- xtype:'textfield',
- fieldLabel:'途程名称',
- name:'macraftname',
- editable:false,
- id:'macraftname'
- },{
- xtype:'textfield',
- fieldLabel:'BOM版本',
- name:'mabomversion',
- editable:false,
- id:'mabomversion',
- value:Ext.getCmp("ma_bomversion")?Ext.getCmp("ma_bomversion").value:''
- }],
- buttonAlign:'center',
- buttons:[{
- xtype:'button',
- columnWidth:0.12,
- text:'确认',
- width:60,
- iconCls: 'x-button-icon-save',
- handler:function(btn){
- var macraftcode=Ext.getCmp('macraftcode').getValue();
- var maid=Ext.getCmp('ma_id').value;
- var mabomversion = Ext.getCmp('mabomversion').getValue();
- if(macraftcode == null ||macraftcode == ''){
- showError("请选择工单途程编号");
- return ;
- }else if(cr_code == macraftcode){
- showError("不允许修改成同一个途程编号!");
- return ;
- }
- me.updateMaCraft(macraftcode,maid,mabomversion);
- }
- },{
- xtype:'button',
- columnWidth:0.1,
- text:'关闭',
- width:60,
- iconCls: 'x-button-icon-close',
- margin:'0 0 0 10',
- handler:function(btn){
- Ext.getCmp('cr_win').close();
- }
- }]
- }).show();
- }else{
- win.show();
- }
- }
- }
- });
- },
- 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);
- }else {
- Ext.getCmp('SubRelation').setDisabled(false);
- Ext.getCmp('ModifyMaterial').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();
- }
- });
- },
- updateMaCraft:function(value,id,mabomversion){
- Ext.Ajax.request({
- url : basePath + 'pm/make/updateMaCraft.action',
- params: {
- caller:caller,
- id:id,
- cr_code:value,
- mabomversion:mabomversion
- },
- 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;
- },
- onEnd : function(id,text){
- var me = this;
- var form = Ext.getCmp('form');
- if(form.endUrl && !me.contains(form.endUrl, '?caller=', true)){
- form.endUrl = form.endUrl + "?caller=" + caller;
- }
- me.setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + form.endUrl,
- params: {
- id: id,
- remark: text
- },
- method : 'post',
- callback : function(options,success,response){
- me.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- endSuccess(function(){
- window.location.reload();
- });
- } else {
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
- str = str.replace('AFTERSUCCESS', '');
- showError(str);
- endSuccess(function(){
- window.location.reload();
- });
- } else {
- showError(str);return;
- }
- }
- }
- }
- });
- },
- /**
- * string:原始字符串
- * substr:子字符串
- * isIgnoreCase:忽略大小写
- */
- contains: function(string, substr, isIgnoreCase){
- if (string == null || substr == null) return false;
- if (isIgnoreCase === undefined || isIgnoreCase === true) {
- string = string.toLowerCase();
- substr = substr.toLowerCase();
- }
- return string.indexOf(substr) > -1;
- },
- setLoading : function(b) {// 原this.getActiveTab().setLoading()换成此方法,解决Window模式下无loading问题
- var mask = this.mask;
- if (!mask) {
- this.mask = mask = new Ext.LoadMask(Ext.getBody(), {
- msg : "处理中,请稍后...",
- msgCls : 'z-index:10000;'
- });
- }
- if (b)
- mask.show();
- else
- mask.hide();
- },
- openTab : function (panel,id){
- var o = (typeof panel == "string" ? panel : id || panel.id);
- var main = parent.Ext.getCmp("content-panel");
- /*var tab = main.getComponent(o); */
- if(!main) {
- main =parent.parent.Ext.getCmp("content-panel");
- }
- var tab = main.getComponent(o);
- if (tab) {
- main.setActiveTab(tab);
- } else if(typeof panel!="string"){
- panel.id = o;
- var p = main.add(panel);
- main.setActiveTab(p);
- }
- },
- checkFirstItem:function(f){
- if (Ext.getCmp('ma_firstitemcheck').value==-1) {
- Ext.getCmp('ma_allowpronum').allowBlank=false;
- if (Ext.getCmp('ma_allowpronum').value<0 || Ext.getCmp('ma_allowpronum').value>=Ext.getCmp('ma_qty').value) {
- showError("首件允生产个数必须大于等于0且小于工单数量!");
- return false;
- }
- }else {
- Ext.getCmp('ma_allowpronum').allowBlank=true;
- }
- return true;
- }
- });
|