| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.bom.ProdFeature', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'core.form.Panel','pm.bom.ProdFeature','core.grid.Panel2','core.toolbar.Toolbar',
- 'core.button.Save','core.button.Add','core.button.Upload','core.form.YnField',
- 'core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.grid.YnColumn','core.trigger.MultiDbfindTrigger'
- ],
- init:function(){
- var me = this;
- this.control({
- 'erpGridPanel2': {
- itemclick: function(selModel, record){
- this.onGridItemClick(selModel, record);
- },
- afterrender:function(grid){
- grid.setReadOnly(false);
- }
- },
- 'erpSaveButton': {
- afterrender:function(btn){
- btn.ownerCt.insert(2,{
- text: $I18N.common.button.erpCloseButton,
- iconCls: 'x-button-icon-close',
- cls: 'x-btn-gray',
- width: 60,
- style: {
- marginLeft: '10px'
- },
- handler:function(){
- var win=Ext.getCmp('win');
- if(win) win.close();
- }
- });
- var form=Ext.getCmp('form');
- data=form.getValues();
- Ext.getCmp('pf_prodcode').setValue(data.pr_code);
- Ext.getCmp('pf_prid').setValue(data.pr_id);
- },
- click:function(btn){
- var form=btn.ownerCt.ownerCt;
- r=form.getValues();
- var params = new Object();
- params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
- var me = this;
- Ext.Ajax.request({
- url : basePath + form.saveUrl,
- params : params,
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- saveSuccess(function(){
- var grid=Ext.getCmp('grid');
- var param={
- caller:caller,
- condition:'pf_prid='+r.pf_prid
- };
- btn.ownerCt.ownerCt.ownerCt.close();
- grid.GridUtil.loadNewStore(grid,param);
- });
- } else if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
- str = str.replace('AFTERSUCCESS', '');
- saveSuccess(function(){
- //add成功后刷新页面进入可编辑的页面
- var value = r[form.keyField];
- var formCondition = form.keyField + "IS" + value ;
- var gridCondition = '';
- var grid = Ext.getCmp('grid');
- if(grid && grid.mainField){
- gridCondition = grid.mainField + "IS" + value;
- }
- if(me.contains(window.location.href, '?', true)){
- window.location.href = window.location.href + '&formCondition=' +
- formCondition + '&gridCondition=' + gridCondition;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition + '&gridCondition=' + gridCondition;
- }
- });
- showError(str);
- } else {
- showError(str);
- return;
- }
- } else{
- saveFailure();//@i18n/i18n.js
- }
- }
-
- });
- }
- },
- 'erpDeleteButton' : {
- afterrender: function(btn){
- if(Ext.getCmp('pr_id').value != null && Ext.getCmp('pr_id').value != ''){
- btn.show();
- } else {
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('pr_id').value);
- }
- },
- 'erpUpdateButton': {
- afterrender: function(btn){
- if(Ext.getCmp('pr_id').value != null && Ext.getCmp('pr_id').value != ''){
- btn.show();
- } else {
- btn.hide();
- }
- /*if(Ext.getCmp('pr_statuscode').value!='ENTERING'){
- btn.hide();
- }*/
- },
- click: function(btn){
- if(Ext.getCmp('pr_statuscode').value!='ENTERING'){
- showError('只能修改在录入物料的特征');
- return;
- }
- var grid = Ext.getCmp('grid');
- Ext.each(grid.store.data.items, function(item){
- if(item.dirty == true){
- item.set('pf_prodcode', Ext.getCmp('pr_code').value);
- }
- });
- me.GridUtil.onUpdate(Ext.getCmp('grid'));
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addProdFeature', '新增BOM物料位号', 'jsps/pm/bom/ProdFeature.jsp');
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- /*me.FormUtil.beforeClose(me);*/
- }
- },
- 'button[id=addFeatrue]':{
- click:function(btn){
- var value=Ext.getCmp('pr_id').getValue();
- if(!value) {
- showError('请先选择需要添加的物料');
- return;
- }
- var win=new Ext.window.Window({
- id : 'win',
- title: "新增特征明细",
- height: "50%",
- width: "40%",
- maximizable : false,
- layout: 'anchor',
- items: { // Let's put an empty grid in just to illustrate fit layout
- xtype:'erpFormPanel',
- id:'baseform',
- _noc: 1,
- params:{
- caller:'AddProdFeature',
- condition:'',
- _noc:1
- },
- anchor:'100% 100%',
- saveUrl:'pm/feature/addProdFeature.action?_noc=1'
- }
- });
- win.show();
- }
- },
- 'dbfindtrigger[name=fe_valuecode]':{
- afterrender:function(t){
- var value=Ext.getCmp('pf_fecode').getValue();
- if(value){
- t.dbBaseCondition="fd_code like '%"+value+"'%";
- }
- }
-
- },
- 'multidbfindtrigger[name=fe_valuecode]':{
- afterrender:function(t){
- var value=Ext.getCmp('pf_fecode').getValue();
- if(value){
- t.dbBaseCondition="fd_code like '%"+value+"'%";
- }
- }
-
- },
-
- // 'dbfindtrigger[name=bd_sonid]': {
- // afterrender: function(t){
- // t.dbKey = "bd_bomid";
- // t.mappingKey = "bd_bomid";
- // t.dbMessage = "请先选择BOMID!";
- // }
- // },
- 'field[name=pr_id]': {
- change: function(f){
- if(f.value != null && f.value != ''){
- // me.GridUtil.loadNewStore(Ext.getCmp('grid'), {
- // caller: caller,
- // condition: 'pf_prid=' + f.value
- // });
- // Ext.getCmp('deletebutton').show();
- // Ext.getCmp('updatebutton').show();
- // //Ext.getCmp('save').hide();
- window.location.href = window.location.href.toString().split('?')[0] + '?formCondition=pr_id='+f.value+'&gridCondition=pf_prid='+f.value;
- } else {
- Ext.getCmp('deletebutton').hide();
- Ext.getCmp('updatebutton').hide();
- //Ext.getCmp('save').show();
- }
- }
-
- }
- });
- },
- onGridItemClick: function(selModel, record){//grid行选择
- this.GridUtil.onGridItemClick(selModel, record);
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- }
- });
|