81,091
社区成员
发帖
与我相关
我的任务
分享
//临时保存
function saveParts(){//保存变量方法
var codestr = "";
var valuestr="";
var variablestr="";
if(!subflag){
alert("输入值有错误,请检查修改!");
return;
}
var f = document.mainForm; //得到表单对象
var hashMap=new HashMap();
for(var j=0;j<f.length;j++){
hashMap.put(f[j].id,f[j]);
}
var myDate = new Date();
var s = myDate.getTime();
for(var i=0;i<vcodes.length;i++){
var mView = document.mainForm.mname;
var m = document.mainForm.mname.value;
var eDiv = document.getElementById("div_"+vcodes[i]);
//将界面所有显示着的变量code拼成字符串
if(eDiv){
if(eDiv.style.display=='block'){
variablestr+=vcodes[i]+";";
}
}
if(vmodes[i]==m){
if(hashMap.get(vcodes[i]).type=="text"){//输入题或日期时间题或日期题或下拉列表题
if(hashMap.get(vcodes[i]).value!=""){//表单对象value有值
idstr+=vids[i]+";";//将变量id拼成字符串
codestr+=vcodes[i]+";";//将变量code拼成字符串
valuestr+=hashMap.get(vcodes[i]).value+";";//将变量value拼成字符串
}else{//表单对象value无值
if(mView.style.display!='none'){//20120330lyd模块div显示
if(eDiv){
if(eDiv.style.display=='block'){
alert(vcnames[i]+"\n不能为空");//20120408lyd新增
return;//20120408lyd新增
}
}
}
}
}else if(hashMap.get(vcodes[i]).type=="radio"){//单选题
if(mView.style.display!='none'){//20120330lyd
if(eDiv){
if(eDiv.style.display=='block'){
if(isRadio(hashMap.get(vcodes[i]).name)==""){//name为f[j].name的一组单选按钮全部没有选中
for(var h=0;h<tcodes.length;h++){
if(hashMap.get(vcodes[i]).name==tcodes[h]){
alert(tcnames[h]+"\n不能为空");//提示单选的文本题目不能为空
return;
}
}
}
}
}
}
if(hashMap.get(vcodes[i]).checked){ //单选选中
idstr+=vids[i]+";";//将变量id拼成字符串
codestr+=hashMap.get(vcodes[i]).name+";";//将变量code拼成字符串
valuestr+=hashMap.get(vcodes[i]).value+";";//将变量value拼成字符串
}
}else if(hashMap.get(vcodes[i]).type=="checkbox"){//多选题
if(mView.style.display!='none'){//20120330lyd
if(eDiv){
if(eDiv.style.display=='block'){
if(isCheckbox(hashMap.get(vcodes[i]).name)==""){//name为f[j].name的一组多选按钮全部没有选中
for(var h=0;h<tcodes.length;h++){
if(hashMap.get(vcodes[i]).name==tcodes[h]){
alert(tcnames[h]+"\n不能为空");//提示单选的文本题目不能为空
return;
}
}
}
}
}
}
if(hashMap.get(vcodes[i]).checked){ //多选选中
idstr+=vids[i]+";";//将变量id拼成字符串
codestr+=vcodes[i]+";";//将变量code拼成字符串
valuestr+=hashMap.get(vcodes[i]).value+";";//将变量value拼成字符串
}
}else if(hashMap.get(vcodes[i]).type=="select-one"){//下拉列表
if(hashMap.get(vcodes[i]).value!="-1"){//下拉列表的value不为空
idstr+=vids[i]+";";//将变量id拼成字符串
codestr+=vcodes[i]+";";//将变量code拼成字符串
valuestr+=hashMap.get(vcodes[i]).value+";";//将变量value拼成字符串
}else{
if(mView.style.display!='none'){//20120330lyd
if(eDiv){
if(eDiv.style.display=='block'){
alert(vcnames[i]+"\n不能为空");
return;
}
}
}
}
}
}
}
var user = "<%=user.getUname()%>";
if(user!="null"&&user!=""){
testMessageBox(event);
myDate = new Date();
var e = myDate.getTime();
if(idstr.lastIndexOf(";")!=-1){// 拼最后一个id时,idstr字符串最后一个字符为;
idstr = idstr.substring(0,idstr.lastIndexOf(";"));// 去掉最后的;字符
}
if(codestr.lastIndexOf(";")!=-1){//拼最后一个code时,codestr字符串最后一个字符为;
codestr = codestr.substring(0,codestr.lastIndexOf(";"));//去掉最后的;字符
}
if(valuestr.lastIndexOf(";")!=-1){//拼最后一个value时,valuestr字符串最后一个字符为;
valuestr = valuestr.substring(0,valuestr.lastIndexOf(";"));//去掉最后的;字符
}
if(variablestr.lastIndexOf(";")!=-1){// 拼最后一个显示的变量code时,variablestr字符串最后一个字符为;
variablestr = variablestr.substring(0,variablestr.lastIndexOf(";"));// 去掉最后的;字符
}
//alert(idstr);alert(codestr);alert(valuestr);
document.mainForm.vid.value=idstr;//将idstr字符串赋给name为vid的表单隐藏域
document.mainForm.vcode.value=codestr;//将codestr字符串赋给name为vcode的表单隐藏域
document.mainForm.vvalue.value=valuestr;//将valuestr字符串赋给name为vvalue的表单隐藏域
document.mainForm.variable.value=variablestr;//将valuestr字符串赋给name为vvalue的表单隐藏域
var tag = "<%=tag%>";//获得修改或查看的标志
var url;
//alert(variablestr);
if(tag=="up"){//up为修改;view为查看
//默认表单提交到添加,如果接收到tag参数为up,更改表单提交地址为修改地址
url="value.do?operate=doUpateValue&pid=<%=pid %>&mname="+m+"&vid="+idstr+"&vcode="+codestr+"&vvalue="+valuestr+"&variable="+variablestr;
}else{
url = "value.do?operate=doAddValue&pid=<%=pid %>&mname="+m+"&vid="+idstr+"&vcode="+codestr+"&vvalue="+valuestr+"&variable="+variablestr;
}
$.post(url, function(data){
var datas = data.split(',');
if(datas[0]=="1"){
//alert("保存成功!");
var content = document.getElementById("content");
content.innerHTML = "<div style='font-size:12px; text-align:center'>保存成功!</div><div style='font-size:12px; text-align:center; margin-top:10px;'><input type='button' value='确定' onclick='closeWindow()' style='width:60px;padding-top:5px;padding-bottom:3px;' />";
}else{
//alert("保存失败!");
content.innerHTML = "<div style='font-size:12px; text-align:center'>保存失败!</div><div style='font-size:12px; text-align:center; margin-top:10px;'><input type='button' value='确定' onclick='closeWindow()' style='width:60px;padding-top:5px;padding-bottom:3px;'/></div>";
}
showDiv(datas[1]);
},"html");
}else{
alert("登陆超时,请重新登录!");
window.navigate("login.jsp");
}
//document.mainForm.submit();//提交表单
}