//封装模板 function setTemplate() { var stage =[]; $("td>span[name=sNumber]").each(function(){ var sNumber = $(this).text(); var sName = $(this).parent().next().text(); var imgPath = $(this).parent().next().next().text(); var id = $(this).parent().next().next().next().next().next().text(); stage.push({id:id,name:sName,imagePath:imgPath,number:sNumber}); }); var datestage =[]; $("td>span[name=dsNumber]").each(function(){ var dsNumber = $(this).text(); var dsName = $(this).parent().next().text(); var day = $(this).parent().next().next().text(); var id = $(this).parent().next().next().next().next().text(); datestage.push({id:id,name:dsName,number:dsNumber,day:day}); }); // for(var i=0;i<$("p[name=dsName]").length;i++){ // var dsName =$("p[name=dsName]").eq(i).text(); // var day =$("p[name=day]").eq(i).text(); // datestage.push({name:dsName}); // days.push({day:day}); // } var att =[]; $("td>span[name=a1Name]").each(function(){ var aName = $(this).text(); var inputtype = $(this).parent().next().text(); var height = $(this).parent().next().next().text(); var width = $(this).parent().next().next().next().text(); var protype = $(this).parent().next().next().next().next().text(); var id = $(this).parent().next().next().next().next().next().next().text(); if(id==null){ var fileName =null; att.push({id:id,name:aName,proType:protype,inputtype:inputtype,width:width,height:height,fileName:fileName}); } else{ att.push({id:id,name:aName,proType:protype,inputtype:inputtype,width:width,height:height}); } }); $("td>span[name=a2Name]").each(function(){ var aName = $(this).text(); var protype = $(this).parent().next().text(); var id = $(this).parent().next().next().next().text(); att.push({id:id,name:aName,proType:protype}); }); $("td>span[name=a3Name]").each(function(){ var aName = $(this).text(); var protype = $(this).parent().next().text(); var id = $(this).parent().next().next().next().text(); att.push({id:id,name:aName,proType:protype}); }); var checkDate = $("#checkDate").val(); var checkTime = $("#checkTime").val(); var id = $("#temid").val(); var temName = $("#temName").val(); var vo = { id:id, name:temName, checkDate:checkDate, checkTime:checkTime, farmAtt:att, farmStage:stage, farmDatestage:datestage } var url = "/agrovideo/farmtemplate/save.do"; $.ajax({ url : url, type : 'post', contentType: "application/json", data :JSON.stringify(vo), success:function(){ $.MsgBox.Alert("保存成功"); setTimeout(function () { window.location.href ="/agrovideo/farmtemplate/list.do"; }, 1500); }, error:function(){ $.MsgBox.Alert("保存失败"); } }); }
JS对象封装例子
最新推荐文章于 2023-11-28 07:30:00 发布