在做系统的时候,往往查询条件是被严格指定的,大量的查询条件,一两个页面还可以通过dom去一个一个获取,再构建参数对象,请求后台接口。
这里给大家讲一个批量获取前端参数,构建参数对象。
<form name="@ViewData["title"]_FormId" id="@ViewData["title"]_FormId">
<table class="custom_Table" style="width:100%;">
<tr>
<td class="custom_td_Tip">收票人:</td>
<td>
<input name="TakerID" id="@ViewData["title"]_TakerID" style="width: 265px;" />
</td>
<td class="custom_td_Tip">用途:</td>
<td>
<input name="Purpose" id="@ViewData["title"]_Purpose" style="width:120px;" />
</td>
<td class="custom_td_Tip">项目号:</td>
<td>
<input class="easyui-textbox" name="ProjectNumber" id="@ViewData["title"]_ProjectNumber" style="width:120px;" />
</td>
<td class="custom_td_Tip">NO:</td>
<td>
<input class="easyui-textbox" name="PeWeNO" id="@ViewData["title"]_PeWeNO" style="width:120px;" />
</td>
</tr>
<tr>
<td class="custom_td_Tip">申请日期:</td>
<td>
<input name="CreateTime_Str" id="@ViewData["title"]_CreateTime_Str" type="text" class="easyui-datebox" data-options="editable:false" style="width:125px;">
-
<input name="CreateTime_End" id="@ViewData["title"]_CreateTime_End" type="text" class="easyui-datebox" data-options="editable:false" style="width:125px;">
</td>
<td class="custom_td_Tip">订单号:</td>
<td>
<input class="easyui-textbox" name="DBSOrderID" id="@ViewData["title"]_DBSOrderID" style="width:120px;" />
</td> <td class="custom_td_Tip">发票号:</td>
<td>
<input class="easyui-textbox" name="VatBill" id="@ViewData["title"]_VatBill" style="width:120px;" />
</td>
<td class="custom_td_Tip"> 单号:</td>
<td>
<input class="easyui-textbox" name="DBSWorkID" id="@ViewData["title"]_DBSWorkID" style="width:120px;" />
</td>
</tr>
<tr>
<td class="custom_td_Tip">汇票到期日:</td>
<td>
<input name="AcceptToDate_Str" id="@ViewData["title"]_AcceptToDate_Str" type="text" class="easyui-datebox" data-options="editable:false" style="width:125px;">
-
<input name="AcceptToDate_End" id="@ViewData["title"]_AcceptToDate_End" type="text" class="easyui-datebox" data-options="editable:false" style="width:125px;">
</td>
<td class="custom_td_Tip">客户名:</td>
<td>
<input class="easyui-textbox" name="CustomerName" id="@ViewData["title"]_CustomerName" style="width: 120px;" />
</td>
<td class="custom_td_Tip">对应部门:</td>
<td colspan="3">
<input name="Department" id="@ViewData["title"]_Department" style="width:355px;" />
</td>
</tr>
</table>
</form>
var RequestObj=$('#**_FormId').serializeObject() $.fn.serializeObject = function () {
var obj = {};
var formArray = this.serializeArray();
$.each(formArray, function () {
if (obj[this.name] !== undefined) {
if (!obj[this.name].push) {
obj[this.name] = [obj[this.name]];
}
obj[this.name].push(this.value || '');
} else {
obj[this.name] = this.value || '';
}
});
return obj;
}