• 循环表单的提交 双层表格的处理


    <table class="table table-condensed table-hover  table-text " id="grouptable">
                       <thead>
                        <tr class="tabth" style="border-top:none;" >
                          <th rowspan =2 style=" text-align: center;">党员姓名</th>
                          <th rowspan =2 style=" text-align: center;">工资收入总额</th>
                          <th rowspan =2 style=" text-align: center;">应缴党费比例</th>
                          <th colspan=12 style=" text-align: center;">缴纳党费金额(元)</th>
                          <th rowspan =2 style=" text-align: center;">合计</th>
                        </tr>
                        
                
                           <tr><th style="40px">一月</th>
                           <th style="40px">二月</th>
                           <th style="40px">三月</th>
                           <th style="40px">四月 </th>
                           <th style="40px"> 五月</th>
                           <th style="40px"> 六月</th>
                           <th style="40px"> 七月</th>
                           <th style="40px"> 八月</th>
                           <th style="40px"> 九月</th>
                           <th style="40px"> 十月</th>
                           <th style="40px"> 十一月</th>
                           <th style="40px"> 十二月</th>
                           </tr>
                       </thead>
                         <tbody>
                         <c:forEach items="${dueslist }" var="list" varStatus="s">
                        <tr class="foreachtr">
                          <td >${list.pmname }</td>
                          <td >${list.monthnum}</td>
                          <td >${list.shouldproportion }</td>
                          <td ><input type="text" name="janNum" value="${list.janNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')">
                          <input type="hidden" name="duesid" value="${list.id }">                                 //离开焦点事件,只能输入数字,否则置空
                          <input type="hidden" name="pmid" value="${list.pmId }"></td>
                          <td ><input type="text" name="febNum" value="${list.febNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td ><input type="text" name="marNum" value="${list.marNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td ><input type="text" name="aprNum" value="${list.aprNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td ><input type="text" name="mayNum" value="${list.mayNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td ><input type="text" name="juneNum" value="${list.juneNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td ><input type="text" name="julyNum" value="${list.julyNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td ><input type="text" name="augNum" value="${list.augNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td ><input type="text" name="septNum" value="${list.septNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td ><input type="text" name="octNum" value="${list.octNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td ><input type="text" name="novNum" value="${list.novNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td ><input type="text" name="decNum" value="${list.decNum }" style="40px" onblur="this.value=this.value.replace(/D/g,'')"></td>
                          <td >${list.yearNum }</td>
                        </tr >
                       </c:forEach>   
                      </tbody>
                      </table>

    ---------------------------------------------------------------------------------------------------------------------------------

    function savememberinfo(){
        var orgid=$("#orgid").val();
        var payyear =$("#payyear").val();
        var str='[';
        $(".foreachtr").each(function(i,dom){
        //console.log($(this).html());
        //基本信息
        var duesid =$(this).find("input[name='duesid']").val();
        var pmid =$(this).find("input[name='pmid']").val();
        //console.log("----"+$(this).find("input[name='pmid']").val());  //循环表单取当前对象用$(this)  find查找后代
        var janNum =$(this).find("input[name='janNum']").val();
        var febNum =$(this).find("input[name='febNum']").val();
        var marNum =$(this).find("input[name='marNum']").val();
        var aprNum =$(this).find("input[name='aprNum']").val();
        var mayNum =$(this).find("input[name='mayNum']").val();
        var juneNum =$(this).find("input[name='juneNum']").val();
        var julyNum =$(this).find("input[name='julyNum']").val();
        var augNum =$(this).find("input[name='augNum']").val();
        var septNum =$(this).find("input[name='septNum']").val();
        var octNum =$(this).find("input[name='octNum']").val();
        var novNum =$(this).find("input[name='novNum']").val();
        var decNum =$(this).find("input[name='decNum']").val();
        str += '{"id":"' + duesid
                    + '","payYear":"' + payyear
                    + '","pmId":"' + pmid
                    + '","janNum":"' + janNum
                    + '","febNum":"' + febNum
                    + '","marNum":"' + marNum
                    + '","aprNum":"' + aprNum
                    + '","mayNum":"' + mayNum
                    + '","juneNum":"' + juneNum
                    + '","julyNum":"' + julyNum
                    + '","augNum":"' + augNum
                    + '","septNum":"' + septNum
                    + '","octNum":"' + octNum
                    + '","novNum":"' + novNum
                    + '","decNum":"' + decNum+'"}';
                    if(i<$(".foreachtr").length-1){
                    str+=",";
                    }  //判断循环是否到达最后一个
      });
        str+="]";
            $.ajax({    
            url:'${ctx}/memberdues/addmemberdues',     
            type:'post',
            cache:false,
            data:{
          str : str,
            },
            error:function(){
               layer.msg('请按照提示正确填写!');      
            },     
            success:function(){    
            window.parent.loaddiv("${ctx}/memberdues/payduesplus?orgid="+orgid);
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);
            }
        });
    }

    -----------------------------------------------------------------------------------------------------------------------------------------------------------

    //新增党费
        @RequestMapping("/addmemberdues")
        public String addmemberdues(
                @RequestParam(value = "str", required = false) String str,
                Model model, HttpServletRequest request, HttpSession session)
                throws JsonParseException, JsonMappingException, IOException {
            // 特殊字符处理
            str = Tools.stringToJson(str);
            ObjectMapper mapper = new ObjectMapper();
            // 允许出现特殊字符和转义符
            mapper.configure(Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
            // 允许出现单引号
            mapper.configure(Feature.ALLOW_SINGLE_QUOTES, true);
            List<MemberDues> list = mapper.readValue(str,
                    new TypeReference<List<MemberDues>>() {
                    });     //接收list        json对象
            for(MemberDues md :list){
                /*Float yearNum =md.getAprNum()+md.getAugNum()+md.getDecNum()+md.getFebNum()+md.getJanNum()+md.getJulyNum()+md.getJuneNum()+md.getMarNum()
                        +md.getMayNum()+md.getNovNum()+md.getOctNum()+md.getSeptNum();
                md.setYearNum(yearNum);*/
                if(md.getId()==null){
                    memberduesservice.insertMemberDues(md);
                }else{
                    memberduesservice.updateMemberDues(md);
                }
            }
            return "member/addmemberdues";
        }

    当能力支撑不了野心时,就该静下心来学习!
  • 相关阅读:
    React 生命周期及setState原理分析
    React Vue Angular 对比
    盒模型(一)
    CSS尺寸 rem与em原理与区别(二)
    HTTP 状态码
    React渲染机制
    HTTP三次握手四次挥手
    Java常见算法
    SharedPreferences存储数据
    解决ListView滑动上下出现阴影
  • 原文地址:https://www.cnblogs.com/1234cjq/p/6936340.html
Copyright © 2020-2023  润新知