CeramicProject/newyt/Js/ypdjajx.js

232 lines
9.3 KiB
JavaScript
Raw Normal View History

2024-05-18 15:28:29 +08:00
var jtnr;
function add_scylxx() {
//给每行的id 赋值上一行的id 加1 不会重复的id;
var hcount = parseFloat($("#scylxxtb tbody").children().eq($("#scylxxtb tbody").children().length - 1).attr("id")) + 1;
$("#scylxxtb").append("<tr id='" + hcount + "' name='0'><td width='25px'> <img src='../Images_Folder/Button/tjljh.png' onclick='jianhang(this)' width='25px' height='25px' /></td>"
+ " <td><input type='text' id='wuliao" + hcount + "' Class='inpittxt' onclick='selectscwuliao(this)' /></td><td><input type='text' onkeyup='doubleshuru(this)' id='yongl" + hcount + "' Class='inpittxt' /></td><td><input type='text' id='beizhu" + hcount + "' Class='inpittxt' /> </td>"
+ " <td><input type='text' id='wuliaoy" + hcount + "' Class='inpittxt' onclick='selectscwuliao(this)' /></td><td><input type='text' onkeyup='doubleshuru(this)' id='yongly" + hcount + "' Class='inpittxt' /></td><td><input type='text' id='beizhuy" + hcount + "' Class='inpittxt' /> </td>"
+ " <td><input type='text' id='wuliaoe" + hcount + "' Class='inpittxt' onclick='selectscwuliao(this)' /></td><td><input type='text' onkeyup='doubleshuru(this)' id='yongle" + hcount + "' Class='inpittxt' /></td><td><input type='text' id='beizhue" + hcount + "' Class='inpittxt' /> </td>"
+"</tr>");
}
function setgj() {
if ($("#kfh").val() == "") {
$("#z_error").html("开发号不能为空!");
return false;
} else if ($("#huohao").val() == "") {
$("#z_error").html("货号不能为空!");
return false;
} else if ($("#cpmc").val() == "") {
$("#z_error").html("产品名称不能为空!");
return false;
} else if ($("#zdysj").val() == "") {
$("#z_error").html("自定义时间不能为空!");
return false;
} else if ($("#xgsj").val() == "") {
$("#z_error").html("修改时间不能为空!");
return false;
} else if ($("#ypcc").val() == "") {
$("#z_error").html("样品尺寸不能为空!");
return false;
} else if ($("#zhongliang").val() == "") {
$("#z_error").html("重量不能为空!");
return false;
} else if ($("#rongliang").val() == "") {
$("#z_error").html("容量不能为空!");
return false;
} else if ($("#banci").val() == "") {
$("#z_error").html("版次不能为空!");
return false;
}
var jsonStr2 = "";
var ci = 0
jsonStr2 += "[";
$("#qdgjtb td").each(function () {
if ($(this).children('input').length > 0) {
jsonStr2 += "{";
jsonStr2 += "\"ypdid\":\"0\",";
jsonStr2 += "\"gjmc\":\"" + $(this).find('input').attr("name") + "\",";
jsonStr2 += "\"gjjg\":\"" + $(this).find('input').val() + "\",";
jsonStr2 += "\"jieduan\":\"" + "前段工价" + "\"";
jsonStr2 += "},";
}
});
$("#zdgjtb td").each(function () {
if ($(this).children('input').length > 0) {
jsonStr2 += "{";
jsonStr2 += "\"ypdid\":\"0\",";
jsonStr2 += "\"gjmc\":\"" + $(this).find('input').attr("name") + "\",";
jsonStr2 += "\"gjjg\":\"" + $(this).find('input').val() + "\",";
jsonStr2 += "\"jieduan\":\"" + "中段工价" + "\"";
jsonStr2 += "},";
}
});
$("#hdgjtb td").each(function () {
if ($(this).children('input').length > 0) {
jsonStr2 += "{";
jsonStr2 += "\"ypdid\":\"0\",";
jsonStr2 += "\"gjmc\":\"" + $(this).find('input').attr("name") + "\",";
jsonStr2 += "\"gjjg\":\"" + $(this).find('input').val() + "\",";
jsonStr2 += "\"jieduan\":\"" + "后段工价" + "\"";
jsonStr2 += "},";
}
});
jsonStr2 = jsonStr2.substring(0, jsonStr2.length - 1);
jsonStr2 += "]";
document.getElementById("gjxxhd").value = jsonStr2;
jsonStr2 = "";
jsonStr2 += "[";
var tdzhi = 0;
$("#qdxmtb td").each(function () {
if ($(this).children('input').length > 0) {
tdzhi = tdzhi * 1 + 1;
var tdyushu = tdzhi % 2;
if (tdyushu > 0) {
jsonStr2 += "{";
jsonStr2 += "\"xmmc\":\"" + $(this).find('input').attr("tag") + "\",";
jsonStr2 += "\"wlbh\":\"" + $(this).find('input').attr("name") + "\",";
}
else {
if ($(this).find('input').val()=="")
{
jsonStr2 += "\"wlyl\":\"0\",";
}else{
jsonStr2 += "\"wlyl\":\"" + $(this).find('input').val() + "\",";
}
jsonStr2 += "\"jieduan\":\"" + "前段项目" + "\"";
jsonStr2 += "},";
}
}
});
tdzhi = 0;
$("#zdxmtb td").each(function () {
if ($(this).children('input').length > 0) {
tdzhi = tdzhi * 1 + 1;
var tdyushu = tdzhi % 2;
if (tdyushu > 0) {
jsonStr2 += "{";
jsonStr2 += "\"xmmc\":\"" + $(this).find('input').attr("tag") + "\",";
jsonStr2 += "\"wlbh\":\"" + $(this).find('input').attr("name") + "\",";
}
else {
if ($(this).find('input').val() == "") {
jsonStr2 += "\"wlyl\":\"0\",";
} else {
jsonStr2 += "\"wlyl\":\"" + $(this).find('input').val() + "\",";
}
jsonStr2 += "\"jieduan\":\"" + "中段项目" + "\"";
jsonStr2 += "},";
}
}
});
tdzhi = 0;
$("#hdxmtb td").each(function () {
if ($(this).children('input').length > 0) {
tdzhi = tdzhi * 1 + 1;
var tdyushu = tdzhi % 2;
if (tdyushu > 0) {
jsonStr2 += "{";
jsonStr2 += "\"xmmc\":\"" + $(this).find('input').attr("tag") + "\",";
jsonStr2 += "\"wlbh\":\"" + $(this).find('input').attr("name") + "\",";
}
else {
if ($(this).find('input').val() == "") {
jsonStr2 += "\"wlyl\":\"0\",";
} else {
jsonStr2 += "\"wlyl\":\"" + $(this).find('input').val() + "\",";
}
jsonStr2 += "\"jieduan\":\"" + "后段项目" + "\"";
jsonStr2 += "},";
}
}
});
jsonStr2 = jsonStr2.substring(0, jsonStr2.length - 1);
jsonStr2 += "]";
document.getElementById("xmxxhd").value = jsonStr2;
jsonStr2 = "[";
$("#ypxgfytd td").each(function () {
if ($(this).children('input').length > 0) {
jsonStr2 += "{";
jsonStr2 += "\"fymc\":\"" + $(this).find('input').attr("name") + "\",";
jsonStr2 += "\"fyje\":\"" + $(this).find('input').val() + "\"";
jsonStr2 += "},";
}
});
jsonStr2 = jsonStr2.substring(0, jsonStr2.length - 1);
jsonStr2 += "]";
document.getElementById("xhfyhd").value = jsonStr2;
jsonStr2 = "";
//获取数据行的行数
var hang = $("#scylxxtb tr").length - 1;
//当数据行大于0时
if (hang > 0) {
//开始给变量赋值
jsonStr2 += "[";
//循环获取行id,拼接
for (var x = 1; x <= hang; x++) {
//获取当前每行的参数值
var trid = $("#scylxxtb").find("tr").eq(x).attr("id");
var scylid = "wuliao" + trid;
var yonglid = "yongl" + trid;
var beizhuid = "beizhu" + trid;
var scylyid = "wuliaoy" + trid;
var yonglyid = "yongly" + trid;
var beizhuyid = "beizhuy" + trid;
var wuliaoeid = "wuliaoe" + trid;
var yongleid = "yongle" + trid;
var beizhueid = "beizhue" + trid;
jsonStr2 += "{";
jsonStr2 += "\"scwlbh\":\"" + document.getElementById(scylid).name + "\",";
if (document.getElementById(yonglid).value == "") {
jsonStr2 += "\"scyl\":\"0\",";
} else {
jsonStr2 += "\"scyl\":\"" + document.getElementById(yonglid).value + "\",";
}
jsonStr2 += "\"beizhu\":\"" + document.getElementById(beizhuid).value + "\"";
jsonStr2 += "},";
jsonStr2 += "{";
jsonStr2 += "\"scwlbh\":\"" + document.getElementById(scylyid).name + "\",";
if (document.getElementById(yonglyid).value == "") {
jsonStr2 += "\"scyl\":\"0\",";
} else {
jsonStr2 += "\"scyl\":\"" + document.getElementById(yonglyid).value + "\",";
}
jsonStr2 += "\"beizhu\":\"" + document.getElementById(beizhuyid).value + "\"";
jsonStr2 += "},";
jsonStr2 += "{";
jsonStr2 += "\"scwlbh\":\"" + document.getElementById(wuliaoeid).name + "\",";
if (document.getElementById(yongleid).value == "") {
jsonStr2 += "\"scyl\":\"0\",";
} else {
jsonStr2 += "\"scyl\":\"" + document.getElementById(yongleid).value + "\",";
}
jsonStr2 += "\"beizhu\":\"" + document.getElementById(beizhueid).value + "\"";
jsonStr2 += "},";
}
//截取最后的,
jsonStr2 = jsonStr2.substring(0, jsonStr2.length - 1);
jsonStr2 += "]";
document.getElementById("scylhd").value = jsonStr2;
}
}