JS对象封装例子

//封装模板
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("保存失败");
        }
    });
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值