从一个页面的表格列表(用Extjs的gridPanel组件)中获取n行数据,在执行跳转命令后,在另一个页面取到这些数据,并执行关联操作,操作完成后返回开始页面
1去数据,将数组数据转化为json数据
getJsonStr : function () {
var me = this;
var entity = me.getEntity();
var result = {
items : []
};
for (var i = 0; i < entity.length; i++) {
result.items.push({
goods_id : entity[i].get("goods_id"),
goods_count : entity[i].get("goodsCount"),
goods_money : entity[i].get("goodsMoney"),
goods_price : entity[i].get("goodsPrice"),
pobilldetail_id : entity[i].get("id"),
pobill_id : entity[i].get("pobill_id"),
show_order : entity[i].get("show_order"),
// "poship_id" : data.id,
// "tracking_no" : data.tracking_no
})
}
var jsonstr =Ext.JSON.encode(result);
return jsonstr;
},
onAdd : function() {
var me = this;
var timestamp=new Date().getTime();
var jsonstr = me.getJsonStr();
//设置cookie用当前时间戳
Ext.util.Cookies.set("PSI_purchase_logistics"+timestamp,jsonstr);
window.location.href=PSI.Const.BASE_URL+"Home/Purchase/wbillIndex/?openAdd=0&temp="+timestamp;
me.wnd.close();
}
onOK: function () {
var me = this;
Ext.getBody().mask(myproject.Message.Saving);
Ext.Ajax.request({
url: PSI.Const.BASE_URL + "Home/Purchase/editWBill",
method: "POST",
params: {
jsonStr: me.getSaveData()
},
callback: function (options, success, response) {
Ext.getBody().unmask();
if (success) {
var data = Ext.JSON.decode(response.responseText);
if (data.success) {
var temp = me.GetQueryString("temp");
if (temp!=null && temp.toString().length>1){
//拿到时间戳
var temps = Ext.util.Cookies.get("PSI_purchase_logistics"+temp);
if (temps !=null &&temps.length >1){
//正确可以关联
//清除cookie
Ext.util.Cookies.clear("PSI_purchase_logistics"+temp);
var shippingcode = Ext.getCmp("editShippingCode").getValue();
Ext.Ajax.request({
url : PSI.Const.BASE_URL+"Home/Purchase/batchConnect",
params : {
shippingcode : shippingcode,
"jsonstr" : temps,
},
// traditional: true,//这里设置为true
method : "POST",
callback : function (opt,success,response) {
if (success) {
var data = Ext.JSON.decode(response.responseText);
if (data.success) {
PSI.MsgBox.tip(myproject.Message.Connect_Success);
// me.parentForm.refreshDetailGrid();
window.location.href=PSI.Const.BASE_URL+"Home/Purchase/pobillIndex";
} else {
PSI.MsgBox.showInfo(data.msg);
}
}
},
scope : this,
});
}
}
PSI.MsgBox.tip(myproject.Message.Data_Save_Success);
me.parentForm.getMainGrid().store.reload();
me.close();
} else {
PSI.MsgBox.showInfo(data.msg);
}
}
}
});
},
GetQueryString : function (name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
},