前端表单提交多条数据,将需要提交的数据集合序列化为json对象传递都后台进行保存到数据库

最近项目中需要使用表单提交多条数据,将数据传递到后台保存到数据库当中``,经过自身测试此方法不适合表格合并,合并后序列化后,后台接收到的集合数据就会错乱,需要合并的需要根据自己的需求进行处理。

<cui:form id="formId_gb_save" heightStyle="fill" style="height: 825px;">
        <table style="width: 2440px;">
            <caption text-align="center" style="border: 0px;height: 68px;"><b><font size="+3">每日基本情况工作表</font></b></caption>
            <tr>
                <td colspan="4" style="border: 0px;height: 32px;text-align: left;">记录人:${bbbs.userName}</td>
                <td colspan="34" style="border: 0px;text-align: right;">记录时间:${time}</td>
            </tr>
            <tr>
                <td rowspan="3"></td>
                <td colspan="6">值班情况</td>
                <td colspan="7">民警情况</td>
                <td colspan="3">报送人</td>
            </tr>
            <tr>
                <td colspan="4">监所领导</td>
                <td colspan="2">指挥中心指挥长</td>
                <td colspan="3">在岗</td>
                <td colspan="3">值班</td>
                <td rowspan="2">备勤警力</td>
                <td rowspan="2">姓名</td>
                <td rowspan="2" width="160px">日期时间</td>
                <td rowspan="2">备注</td>
            </tr>
            <tr>
                <td>姓名</td>
                <td>联系电话</td>
                <td>姓名</td>
                <td>联系电话</td>
                <td>姓名</td>
                <td>联系电话</td>
                <td>总数</td>
                <td>机关</td>
                <td>监(住)区</td>
                <td>总数</td>
                <td>机关</td>
                <td>监(住)区</td>
            </tr>
                
            <tr id="xktr" height="70px">
                <td width="150px">市局总值班长</td>
                <input type="text" style="display: none;"  name="userId" value="${bbbs.userId}" />
                <input type="text" style="display: none;"  name="userName" value="${bbbs.userName}" />
                <input type="text" style="display: none;"  name="deptId" value="${bbbs.deptId}" />
                <input type="text" style="display: none;"  name="deptName" value="${bbbs.deptName}" />
                <input type="text" style="display: none;"  name="unitId" value="${bbbs.unitId}" />
                <input type="text" style="display: none;"  name="unitName" value="市局总值班长" />
                <input type="text" style="display: none;"  name="toUnitId" value="${bbbs.toUnitId}" />
                <input type="text" style="display: none;"  name="toUnitName" value="${bbbs.toUnitName}" />
                <input type="text" style="display: none;"  name="content" value="${bbbs.content}" />
                <input type="text" style="display: none;"  name="state" value="" />
                <td ><input style="width: 100%" type="text" name="onePositionLeader" id="onePositionLeader1"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="onePositionPhone" id="onePositionPhone1"/></td>
                <td ><input style="width: 100%" type="text" name="twoPositionLeader" id="twoPositionLeader1"/></td>
                <td ><input style="width: 100%" type="text" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="twoPositionPhone" id="twoPositionPhone1"/></td>
                <td ><input style="width: 100%" type="text" name="zhzXm" id="zhzXm1"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zhzPhone" id="zhzPhone1"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjZs" id="zggjZs1"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJg" id="zggjJg1"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJq" id="zggjJq1"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjZs" id="zbgjZs1"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJg" id="zbgjJg1"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJq" id="zbgjJq1"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="bqJl" id="bqJl1"/></td>
                
                <td rowspan="6"><input type="text" readonly="readonly" name="reportPerson" value="${bbbs.userName}" style="width: 100%" /></td>
                <td rowspan="6"><input type="text" readonly="readonly" name="reportTime" value="${time}" style="width: 100%" /></td>
                <td rowspan="6"><input type="text" name="remark" id="remark" style="width: 100%" /></td>
            </tr>
            <tr height="70px">
                <td >市局一办值班长一</td>
                <input type="text" style="display: none;"  name="userId" value="${bbbs.userId}" />
                <input type="text" style="display: none;"  name="userName" value="${bbbs.userName}" />
                <input type="text" style="display: none;"  name="deptId" value="${bbbs.deptId}" />
                <input type="text" style="display: none;"  name="deptName" value="${bbbs.deptName}" />
                <input type="text" style="display: none;"  name="unitId" value="${bbbs.unitId}" />
                <input type="text" style="display: none;"  name="unitName" value="市局一办值班长一" />
                <input type="text" style="display: none;"  name="toUnitId" value="${bbbs.toUnitId}" />
                <input type="text" style="display: none;"  name="toUnitName" value="${bbbs.toUnitName}" />
                <input type="text" style="display: none;"  name="content" value="${bbbs.content}" />
                <input type="text" style="display: none;"  name="state" value="" />
                <td ><input style="width: 100%" type="text" name="onePositionLeader" id="onePositionLeader2"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="onePositionPhone" id="onePositionPhone2"/></td>
                <td ><input style="width: 100%" type="text" name="twoPositionLeader" id="twoPositionLeader2"/></td>
                <td ><input style="width: 100%" type="text" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="twoPositionPhone" id="twoPositionPhone2"/></td>
                <td ><input style="width: 100%" type="text" name="zhzXm" id="zhzXm2"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zhzPhone" id="zhzPhone2"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjZs" id="zggjZs2"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJg" id="zggjJg2"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJq" id="zggjJq2"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjZs" id="zbgjZs2"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJg" id="zbgjJg2"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJq" id="zbgjJq2"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="bqJl" id="bqJl2"/></td>
                <input type="text" readonly="readonly" name="reportPerson" value="${bbbs.userName}" style="width: 100%;display: none;" />
                <input type="text" readonly="readonly" name="reportTime" value="${time}" style="width: 100%;display: none;" />
                <input type="text" name="remark"  style="width: 100%;display: none;" />
                

            </tr>
            <tr height="70px">

                <td >市局一办值班长二</td>
                <input type="text" style="display: none;"  name="userId" value="${bbbs.userId}"/>
                <input type="text" style="display: none;"  name="userName" value="${bbbs.userName}"/>
                <input type="text" style="display: none;"  name="deptId" value="${bbbs.deptId}" />
                <input type="text" style="display: none;"  name="deptName" value="${bbbs.deptName}"/>
                <input type="text" style="display: none;"  name="unitId" value="${bbbs.unitId}" />
                <input type="text" style="display: none;"  name="unitName" value="市局一办值班长二"/>
                <input type="text" style="display: none;"  name="toUnitId" value="${bbbs.toUnitId}"/>
                <input type="text" style="display: none;"  name="toUnitName" value="${bbbs.toUnitName}"/>
                <input type="text" style="display: none;"  name="content" value="${bbbs.content}"/>
                <input type="text" style="display: none;"  name="state" value="" />
                <td ><input style="width: 100%" type="text" name="onePositionLeader" id="onePositionLeader3"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="onePositionPhone" id="onePositionPhone3"/></td>
                <td ><input style="width: 100%" type="text" name="twoPositionLeader" id="twoPositionLeader3"/></td>
                <td ><input style="width: 100%" type="text" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="twoPositionPhone" id="twoPositionPhone3"/></td>
                <td ><input style="width: 100%" type="text" name="zhzXm" id="zhzXm3"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zhzPhone" id="zhzPhone3"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjZs" id="zggjZs3"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJg" id="zggjJg3"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJq" id="zggjJq3"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjZs" id="zbgjZs3"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJg" id="zbgjJg3"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJq" id="zbgjJq3"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="bqJl" id="bqJl3"/></td>
                <input type="text" readonly="readonly" name="reportPerson" value="${bbbs.userName}" style="width: 100%;display: none;" />
                <input type="text" readonly="readonly" name="reportTime" value="${time}" style="width: 100%;display: none;" />
                <input type="text" name="remark"  style="width: 100%;display: none;" />

            </tr>
            <tr height="70px">

                <td >市局一办值班长三</td>
                <input type="text" style="display: none;"  name="userId" value="${bbbs.userId}" />
                <input type="text" style="display: none;"  name="userName" value="${bbbs.userName}" />
                <input type="text" style="display: none;"  name="deptId" value="${bbbs.deptId}" />
                <input type="text" style="display: none;"  name="deptName" value="${bbbs.deptName}" />
                <input type="text" style="display: none;"  name="unitId" value="${bbbs.unitId}" />
                <input type="text" style="display: none;"  name="unitName" value="市局一办值班长三" />
                <input type="text" style="display: none;"  name="toUnitId" value="${bbbs.toUnitId}" />
                <input type="text" style="display: none;"  name="toUnitName" value="${bbbs.toUnitName}" />
                <input type="text" style="display: none;"  name="content" value="${bbbs.content}" />
                <input type="text" style="display: none;"  name="state" value="" />
                <td ><input style="width: 100%" type="text" name="onePositionLeader" id="onePositionLeader4"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="onePositionPhone" id="onePositionPhone4"/></td>
                <td ><input style="width: 100%" type="text" name="twoPositionLeader" id="twoPositionLeader4"/></td>
                <td ><input style="width: 100%" type="text" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="twoPositionPhone" id="twoPositionPhone4"/></td>
                <td ><input style="width: 100%" type="text" name="zhzXm" id="zhzXm4"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zhzPhone" id="zhzPhone4"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjZs" id="zggjZs4"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJg" id="zggjJg4"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJq" id="zggjJq4"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjZs" id="zbgjZs4"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJg" id="zbgjJg4"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJq" id="zbgjJq4"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="bqJl" id="bqJl4"/></td>
                <input type="text" readonly="readonly" name="reportPerson" value="${bbbs.userName}" style="width: 100%;display: none;" />
                <input type="text" readonly="readonly" name="reportTime" value="${time}" style="width: 100%;display: none;" />
                <input type="text" name="remark"  style="width: 100%;display: none;" />
               

            </tr>

            <tr height="70px">

                <td width="">市局二办值班长一</td>
                <input type="text" style="display: none;"  name="userId" value="${bbbs.userId}" />
                <input type="text" style="display: none;"  name="userName" value="${bbbs.userName}" />
                <input type="text" style="display: none;"  name="deptId" value="${bbbs.deptId}" />
                <input type="text" style="display: none;"  name="deptName" value="${bbbs.deptName}" />
                <input type="text" style="display: none;"  name="unitId" value="${bbbs.unitId}" />
                <input type="text" style="display: none;"  name="unitName" value="市局二办值班长一" />
                <input type="text" style="display: none;"  name="toUnitId" value="${bbbs.toUnitId}" />
                <input type="text" style="display: none;"  name="toUnitName" value="${bbbs.toUnitName}" />
                <input type="text" style="display: none;"  name="content" value="${bbbs.content}" />
                <input type="text" style="display: none;"  name="state" value="" />
                <td ><input style="width: 100%" type="text" name="onePositionLeader" id="onePositionLeader5"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="onePositionPhone" id="onePositionPhone5"/></td>
                <td ><input style="width: 100%" type="text" name="twoPositionLeader" id="twoPositionLeader5"/></td>
                <td ><input style="width: 100%" type="text" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="twoPositionPhone" id="twoPositionPhone5"/></td>
                <td ><input style="width: 100%" type="text" name="zhzXm" id="zhzXm5"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zhzPhone" id="zhzPhone5"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjZs" id="zggjZs5"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJg" id="zggjJg5"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJq" id="zggjJq5"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjZs" id="zbgjZs5"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJg" id="zbgjJg5"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJq" id="zbgjJq5"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="bqJl" id="bqJl5"/></td>
                <input type="text" readonly="readonly" name="reportPerson" value="${bbbs.userName}" style="width: 100%;display: none;" />
                <input type="text" readonly="readonly" name="reportTime" value="${time}" style="width: 100%;display: none;" />
                <input type="text" name="remark"  style="width: 100%;display: none;" />

            </tr>

            <tr height="70px">

                <td width="">市局二办值班长二</td>
                <input type="text" style="display: none;"  name="userId" value="${bbbs.userId}" />
                <input type="text" style="display: none;"  name="userName" value="${bbbs.userName}" />
                <input type="text" style="display: none;"  name="deptId" value="${bbbs.deptId}" />
                <input type="text" style="display: none;"  name="deptName" value="${bbbs.deptName}" />
                <input type="text" style="display: none;"  name="unitId" value="${bbbs.unitId}" />
                <input type="text" style="display: none;"  name="unitName" value="市局二办值班长二" />
                <input type="text" style="display: none;"  name="toUnitId" value="${bbbs.toUnitId}" />
                <input type="text" style="display: none;"  name="toUnitName" value="${bbbs.toUnitName}" />
                <input type="text" style="display: none;"  name="content" value="${bbbs.content}" />
                <input type="text" style="display: none;"  name="state" value="" />
                <td ><input style="width: 100%" type="text" name="onePositionLeader" id="onePositionLeader6"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="onePositionPhone" id="onePositionPhone6"/></td>
                <td ><input style="width: 100%" type="text" name="twoPositionLeader" id="twoPositionLeader6"/></td>
                <td ><input style="width: 100%" type="text" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="twoPositionPhone" id="twoPositionPhone6"/></td>
                <td ><input style="width: 100%" type="text" name="zhzXm" id="zhzXm6"/></td>
                <td ><input style="width: 100%" type="text"  onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zhzPhone" id="zhzPhone6"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjZs" id="zggjZs6"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJg" id="zggjJg6"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zggjJq" id="zggjJq6"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjZs" id="zbgjZs6"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJg" id="zbgjJg6"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="zbgjJq" id="zbgjJq6"/></td>
                <td ><input style="width: 100%" type="text" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" name="bqJl" id="bqJl6"/></td>
                <input type="text" readonly="readonly" name="reportPerson"  value="${bbbs.userName}" style="width: 100%;display: none;" />
                <input type="text" readonly="readonly" name="reportTime" value="${time}" style="width: 100%;display: none;" />
                <input type="text" name="remark"  style="width: 100%;display: none;" />
                
            </tr>

            <tr >
                <td colspan="28"  style="border:0px;border-top:1px;height:96px;">
                    <a href="javascript:void(0);" onclick="saveBsbb('1')" style="background: #0b6aff; color: #ffffff;padding: 10px;">&nbsp;&nbsp;&nbsp;</a>
                    &nbsp;&nbsp;<a href="javascript:void(0);" onclick="saveBsbb('2')" style="background: #0b6aff; color: #ffffff;padding: 10px;">&nbsp;&nbsp;&nbsp;</a>
                    &nbsp;&nbsp;<a href="javascript:void(0);" onclick="reset()" style="background: #e1e1e1; padding: 10px;">&nbsp;&nbsp;&nbsp;</a> </td>
            </tr>

        </table>
    </cui:form>
//将表单序列化成json格式的数据(但不适用于含有控件的表单,例如复选框、多选的select)
    (function($){
        $.fn.serializeJson = function(){
            var jsonData1 = {};
            var serializeArray = this.serializeArray();
            // 先转换成{"id": ["12","14"], "name": ["aaa","bbb"], "pwd":["pwd1","pwd2"]}这种形式
            $(serializeArray).each(function () {
                if (jsonData1[this.name]) {
                    if ($.isArray(jsonData1[this.name])) {
                        jsonData1[this.name].push(this.value);
                    } else {
                        jsonData1[this.name] = [jsonData1[this.name], this.value];
                    }
                } else {
                    jsonData1[this.name] = this.value;
                }
            });
            // 再转成[{"id": "12", "name": "aaa", "pwd":"pwd1"},{"id": "14", "name": "bb", "pwd":"pwd2"}]的形式
            var vCount = 0;
            // 计算json内部的数组最大长度
            for(var item in jsonData1){
                var tmp = $.isArray(jsonData1[item]) ? jsonData1[item].length : 1;
                vCount = (tmp > vCount) ? tmp : vCount;
            }

            if(vCount > 1) {
                var jsonData2 = new Array();
                for(var i = 0; i < vCount; i++){
                    var jsonObj = {};
                    for(var item in jsonData1) {
                        jsonObj[item] = jsonData1[item][i];
                    }
                    jsonData2.push(jsonObj);
                }
                return JSON.stringify(jsonData2);
            }else{
                return "[" + JSON.stringify(jsonData1) + "]";
            }
        };
    })(jQuery);
//保存
function saveBsbb(bbbsState) {
            var jsonStr = $("#formId_gb_save").serializeJson();
            $.ajax({
                url: "${ctx}/worksheet/saveAll?state="+bbbsState,
                type: "POST",
                contentType : 'application/json;charset=utf-8', //设置请求头信息
                dataType:"json",
                data: jsonStr,
                success: function(data){
                    
                },
                error: function(res){
                    $.messageQueue({ message : "请确认输入是否正确!", cls : "warning", iframePanel : true, type : "info" });
                }
            });
        }
@ResponseBody
@RequestMapping(value = "/saveAll")
@Logger(action = "保存", logger = "保存监所每日工作表",model="报表报送")
public AjaxMessage saveAll(@RequestBody List<DailyBasicWorksheet> entities ,@RequestParam("state") String state) {
        AjaxMessage ajaxMessage = new AjaxMessage();
        boolean flag = false;
        Object obj = null;
        List<String> stringList=new ArrayList<>();
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String sTime = sdf.format(new Date());
            String eTime = sTime;
            UserBean userBean = AuthSystemFacade.getLoginUserInfo();
            if(entities.size()!=0){
                for(DailyBasicWorksheet entity :entities){
                    entity.setState(state);
                    entity.setReportTime(new Date());
                    entity.setReportPerson(userBean.getRealName());
                    if(!"".equals(entity.getId()) && entity.getId()!=null){
                        if(entity.getState().equals("2")){
                            List<DailyBasicWorksheet> dailyBasicWorksheets = dailyBasicWorksheetService.listTodayReportData(entity.getUnitId(), entity.getUnitName(), "2", sTime, eTime);
                            if(dailyBasicWorksheets.size()>0){
                                flag = false;
                                obj = "当天已存在上报记录,不能再上报!";
                            }else {
                                dailyBasicWorksheetService.update(entity);
                                flag = true;
                                obj = "保存成功";
                                String entityId=entity.getId();
                                stringList.add(entityId);
                                /*//消息提醒
                                this.generalMessage(entity);*/
                            }
                        }else {
                            dailyBasicWorksheetService.update(entity);
                            flag = true;
                            obj = "保存成功";
                        }
                    }else {
                        if(entity.getState().equals("2")){
                            List<DailyBasicWorksheet> dailyBasicWorksheets = dailyBasicWorksheetService.listTodayReportData(entity.getUnitId(), entity.getUnitName(), "2", sTime, eTime);
                            if(dailyBasicWorksheets.size()>0){
                                flag = false;
                                obj = "当天已存在上报记录,不能再上报!";
                            }else {
                                dailyBasicWorksheetService.insert(entity);
                                flag = true;
                                obj = "保存成功";
                                String entityId=entity.getId();
                                stringList.add(entityId);
                                /*//消息提醒
                                this.generalMessage(entity);*/
                            }
                        }else {
                            dailyBasicWorksheetService.insert(entity);
                            flag = true;
                            obj = "保存成功";
                        }
                    }
                }
            }
        } catch (Exception e) {
            flag = false;
            obj = "保存报送报表发生异常!";
        }
        ajaxMessage.setMsg((String) obj);
        ajaxMessage.setSuccess(flag);
        ajaxMessage.setObj(stringList);
        return ajaxMessage;
    }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值