2022年8月3日 星期三

V120103 - 判斷目前編輯的模式(1:新增, 2:編輯,0:瀏覽,..) buttonModel.modelType

1>TMSingleViewEdit.js

var buttonModel = function () {
    this.modelType = 0; //預設檢視模式
    this.getModelType = function () {
        return this.modelType;
    }
}

Ext.define('G_buttonModel', {
getModelType: function () {
return buttonModel.modelType;
},
setModelType: function (type_num) {
buttonModel.modelType = type_num;
}
});


2>V120103.js 

Ext.onReady(function () {
     var TMSingleViewEdit = Ext.create('TMSingleViewEdit');
     var gridstore = Ext.getCmp('grid_Single').store;
     var buttonModel = Ext.create('G_buttonModel'); 
                         :
               Ext.getCmp('btn_save').setFormValue = function () {
               //要判斷 buttonModel 的編輯模式時, 才即時去抓 modelType
               var modelType = buttonModel.getModelType();

               console.log("setFormValue modelType=", modelType);
               //若非[新增]模式,則不設定欄位值
               if (!(modelType == 1))    
                   return true;

        var isOk = true;
        var Tmp_MAX_ITM = "";       
        np = {};
        np["CLS"] = Ext.getCmp('CLS').getValue();        
        Ext.Ajax.request({
            method: "POST",
            url: '../../api/V120103API/GET_MAXITM',
            params: np,
            async: false,
            success: function (response, opts) {
                var Tmp_Obj = Ext.decode(response.responseText);       
                if (Tmp_Obj["success"]) {
                    Tmp_MAX_ITM = Tmp_Obj['MAX_ITM'];
                    Ext.getCmp("ITM").setValue(Tmp_MAX_ITM);
                }
            }, // end of  success 
            failure: function (response, opts) {
                isOk = false;
            }
        });  // end of Ext.Ajax               
       return isOk;

}

 

沒有留言:

張貼留言