1 //上傳文件 2 uploadModel: function() { 3 4 if(Ext.getCmp('exup').getForm().isValid()) { 5 6 var ssn = this.upPanel.getCmpByName('ssn').getValue(); 7 var ssy = this.upPanel.getCmpByName('ssy').getValue(); 8 var pzid = this.upPanel.getCmpByName('pzid').getValue(); 9 10 //判斷導入數據是否重復 11 Ext.Ajax.request({ 12 13 url : __ctxPath + '/gzt/sameDataGztDrLog.do', 14 params : { 15 ssn : ssn, 16 ssy : ssy, 17 pzid : pzid 18 }, 19 async:false, 20 method : 'POST', 21 scope:this, 22 success : function(response, options) { 23 var json = Ext.util.JSON.decode(response.responseText); 24 // alert(response.responseText); 25 if(json.success){ 26 var msg = json.message; 27 if(msg == 'same'){ 28 Ext.Msg.confirm('提示', '發現重復記錄,繼續導入將覆蓋舊數據,確認繼續導入嗎?', function(btn) { 29 if (btn == 'yes') { 30 this.zxdr1(); 31 } 32 },this); 33 }else{ 34 this.zxdr1(); 35 36 } 37 }else{ 38 Ext.ux.Toast.msg('操作信息', json.message); 39 } 40 }, 41 failure : function(response, options) { 42 Ext.ux.Toast.msg('操作信息', '操作出錯,請聯系管理員!'); 43 } 44 45 46 }); 47 48 49 } 50 51 52 }
extjs3 ajax 本身沒有同步方法,需要引入ext-basex.js
confirm(String title,
String msg,
Function fn,
Object scope
) : Ext.MessageBox提示框,與alert不同,為異步方法,要點確認按鈕后才執行的方法需要寫在其回調函數中,
如果要調用其他方法,注意作用域參數 scope 的使用,是confirm的參數,而不是回調函數的