标签:
$().ready(function () {
var indx_target;
var indx_ID;
var indx_kcsl;
var grid = document.all.grdTest;
var myJSON = {
value1: ‘‘,
value2: ‘‘,
value3: ‘‘,
load: function () {
},
serialize: function () {
var json = "";
for (var key in this) {
if (typeof this[key] != ‘function‘) {
json += (json != "" ? "," : "") + key + ":‘" + this[key] + "‘";
}
}
//json = ‘[{‘ + json + ‘}]‘;
json = ‘{‘ + json + ‘}‘;
return json;
}
}
$("#grdTest th").each(function(index) {
if ( $(this).html().indexOf("实发数量") > 0 ) {
indx_target = index;
}
});
$("#grdTest th").each(function(index) {
if ( $(this).html().indexOf("库存数量") > 0 ) {
indx_kcsl = index;
}
});
$("#grdTest th").each(function(index) {
if ($(this).html().indexOf("流水号") > 0) {
indx_ID = index;
}
});
$("#grdTest tr").find("td:eq(" + indx_target + ")").change(function (e){
var rowIndex = $(this).parent().parent().find("tr").index($(this).parent()[0]);
var strPK = grid.rows[rowIndex*1].cells[indx_ID*1].innerText;
var strSFSL= grid.rows[rowIndex*1].cells[indx_target*1].childNodes[0].value;
var strKCSL = grid.rows[rowIndex*1].cells[indx_kcsl*1].innerText;
if (_urlInfo.CS2 == ‘审核‘) {
alert(‘审核状态不能修改‘);
return false;
}
if (strSFSL * 1 == null) {
alert(‘数量不能为空‘);
grid.rows[rowIndex*1].cells[indx_target*1].childNodes[0].value= null;
strSFSL= null;
return false;
}
if (strSFSL * 1 <= 0) {
alert(‘数量不能为0或负数‘);
grid.rows[rowIndex*1].cells[indx_target*1].childNodes[0].value= null;
strSFSL= null;
return false;
}
if (parseInt(strKCSL) < parseInt(strSFSL)) {
alert(‘库存数量不能小于实发数量‘);
grid.rows[rowIndex*1].cells[indx_target*1].childNodes[0].value= null;
strSFSL= null;
return false;
}
if (typeof(myJSON) != ‘undefined‘) {
myJSON.value1 = strSFSL;//(strSFSL*1>0)?strSFSL:null;
myJSON.value2 = strPK;
myJSON.value3 = 13;
//var data = myJSON.serialize();
}
$.ajax({
type: "POST",
contentType: "application/json",
url: "LYR.aspx/GetWish",
data:myJSON.serialize(),
dataType: ‘json‘,
success: function (result) {
var json = eval(result.d);
if (json == "1") {
grid.rows[rowIndex*1].cells[indx_target*1].childNodes[0].value= strSFSL; }
if (json == "0") {
alert(‘数量没有添加成功‘);
}
return false;
} //success: function(result)
}); //$.ajax
return false;
});
});
标签:
原文地址:http://www.cnblogs.com/nuaaydh/p/4354420.html