| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.make.ModifyForm', {
- extend: 'Ext.app.Controller',
- requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
- views:[
- 'core.form.Panel','pm.make.MakeCommon','core.grid.Panel2','core.toolbar.Toolbar','core.form.YnField',
- 'core.button.Save','core.button.Add','core.button.Close','core.button.Delete','core.button.Update',
- 'core.trigger.DbfindTrigger'
-
- ],
- 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({
- 'erpGridPanel2': {
- afterrender: function(grid){
- grid.setReadOnly(true);
- },
- itemclick:me.ItemClick
- },
- 'dbfindtrigger[name=mm_prodcode]': {
- beforerender:function(trigger){
- trigger.autoDbfind=false;
- }
- /*focus: function(t){
- var grid = parent.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 + ")";
- }
- }*/
- },
- 'erpSaveButton' :{
- click:function(btn){
- //this.FormUtil.beforeSave(this);
- var form=me.getForm(btn);
- var r = form.getValues();
- var keys = Ext.Object.getKeys(r), f;
- Ext.each(keys, function(k){
- f = form.down('#' + k);
- if(f && f.logic == 'ignore') {
- delete r[k];
- }
- });
- me.FormUtil.setLoading(true);
- Ext.Ajax.request({
- url : basePath + form.saveUrl,
- params : {
- formStore: unescape(Ext.JSON.encode(r).replace(/\\/g,"%")),
- _noc:1
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- saveSuccess(function(){
- //add成功后刷新页面进入可编辑的页面
- var value = localJson.Id;
- var formCondition = "mm_id IS" + value ;
- if(me.FormUtil.contains(window.location.href, '?', true)){
- var href=window.location.href;
- window.location.href = href.substring(0,href.lastIndexOf('&')) + '&whoami=&formCondition=' +
- formCondition;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition;
- }
- });
- } 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 ;
-
- if(me.contains(window.location.href, '?', true)){
- window.location.href = window.location.href + '&formCondition=' +
- formCondition ;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition;
- }
- });
- showError(str);
- } else {
- showError(str);
- return;
- }
- } else{
- saveFailure();//@i18n/i18n.js
- }
- }
-
- });
- }
- },
- 'erpDeleteButton': {
- click: function(btn){
- //me.GridUtil.deleteDetailForEditGrid(btn);
- var grid = parent.Ext.getCmp('grid');
- var records = grid.selModel.getSelection();
- Ext.Ajax.request({
- url : basePath + "pm/make/deleteModifyMaterial.action",
- params: {
- id: records[0].data[grid.keyField]
- },
- method : 'post',
- callback : function(options,success,response){
- grid.BaseUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- grid.store.remove(records[0]);
- delSuccess(function(){
- });//@i18n/i18n.js
- parent.Ext.getCmp('win').close();
- } else {
- delFailure();
- }
- }
- });
- },
- },
- 'erpCloseButton':{
- click:function(btn){
- parent.Ext.getCmp('win').close();
- }
- },
- 'erpAddButton': {
- click: function(btn){
- var form= me.getForm(btn);
- //form.getForm().reset(); 不行
- Ext.Array.each(form.items.items,function(item){
- if(item.name!='mm_maid'){
- item.setValue(null);
- }
- });
- }
- },
- 'field[name=mm_oneuseqty]': {
- change: function(f) {
- var v = f.value || 0,
- q = parent.Ext.getCmp('ma_qty');
- Ext.getCmp('mm_qty').setValue(v * q.value);
- }
- }
- });
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- ItemClick:function(view ,record){
- if(caller=='MakeBase!Sub'){
- Ext.getCmp('deletebutton').setDisabled(false);
- var form=view.ownerCt.ownerCt.items.items[0];
- form.getForm().setValues(record.data);
- }
- }
- });
|