查询优化

dep_wangsr
RuoYi 6 years ago committed by Limy
parent eb588e7a95
commit 85d5f32171

@ -51,11 +51,12 @@
}; };
}, },
// 搜索 // 搜索
search: function(form) { search: function(formId) {
var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
var params = $("#bootstrap-table").bootstrapTable('getOptions'); var params = $("#bootstrap-table").bootstrapTable('getOptions');
params.queryParams = function(params) { params.queryParams = function(params) {
var search = {}; var search = {};
$.each($("#" + form).serializeArray(), function(i, field) { $.each($("#" + currentId).serializeArray(), function(i, field) {
search[field.name] = field.value; search[field.name] = field.value;
}); });
search.pageSize = params.limit; search.pageSize = params.limit;
@ -68,9 +69,10 @@
$("#bootstrap-table").bootstrapTable('refresh', params); $("#bootstrap-table").bootstrapTable('refresh', params);
}, },
// 下载 // 下载
exportExcel: function(form) { exportExcel: function(formId) {
var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
$.modal.loading("正在导出数据,请稍后..."); $.modal.loading("正在导出数据,请稍后...");
$.post($.table._option.exportUrl, $("#" + form).serializeArray(), function(result) { $.post($.table._option.exportUrl, $("#" + currentId).serializeArray(), function(result) {
if (result.code == web_status.SUCCESS) { if (result.code == web_status.SUCCESS) {
window.location.href = ctx + "common/download?fileName=" + result.msg + "&delete=" + true; window.location.href = ctx + "common/download?fileName=" + result.msg + "&delete=" + true;
} else { } else {
@ -132,9 +134,10 @@
$.treeTable._treeTable = treeTable; $.treeTable._treeTable = treeTable;
}, },
// 条件查询 // 条件查询
search: function(form) { search: function(formId) {
var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
var params = {}; var params = {};
$.each($("#" + form).serializeArray(), function(i, field) { $.each($("#" + currentId).serializeArray(), function(i, field) {
params[field.name] = field.value; params[field.name] = field.value;
}); });
$.treeTable._treeTable.bootstrapTreeTable('refresh', params); $.treeTable._treeTable.bootstrapTreeTable('refresh', params);

File diff suppressed because one or more lines are too long

@ -24,8 +24,8 @@
</select> </select>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()"><i class="fa fa-download"></i>&nbsp;下载</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -30,8 +30,8 @@
<input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/> <input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()"><i class="fa fa-download"></i>&nbsp;下载</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -30,8 +30,8 @@
<input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/> <input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()"><i class="fa fa-download"></i>&nbsp;下载</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -18,7 +18,7 @@
操作人员:<input type="text" name="loginName"/> 操作人员:<input type="text" name="loginName"/>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -30,8 +30,8 @@
<input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/> <input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()"><i class="fa fa-download"></i>&nbsp;下载</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -29,8 +29,8 @@
<input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/> <input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()"><i class="fa fa-download"></i>&nbsp;下载</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -20,7 +20,7 @@
</select> </select>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -26,8 +26,8 @@
</select> </select>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()"><i class="fa fa-download"></i>&nbsp;下载</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -30,8 +30,8 @@
<input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/> <input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()"><i class="fa fa-download"></i>&nbsp;下载</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -20,7 +20,7 @@
</select> </select>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -23,7 +23,7 @@
</select> </select>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -24,8 +24,8 @@
</select> </select>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()"><i class="fa fa-download"></i>&nbsp;下载</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -30,8 +30,8 @@
<input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/> <input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()"><i class="fa fa-download"></i>&nbsp;下载</a>
</li> </li>
</ul> </ul>
</div> </div>

@ -55,8 +55,8 @@
<input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/> <input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel($('form').attr('id'))"><i class="fa fa-download"></i>&nbsp;下载</a> <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.exportExcel()"><i class="fa fa-download"></i>&nbsp;下载</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -170,7 +170,7 @@
tree.expandNode(treeNode); tree.expandNode(treeNode);
$("#deptId").val(treeNode.id); $("#deptId").val(treeNode.id);
$("#parentId").val(treeNode.pId); $("#parentId").val(treeNode.pId);
$.table.search($('form').attr('id')); $.table.search();
}} }}
}, tree, loadTree = function(){ }, tree, loadTree = function(){
$.get(ctx + "system/dept/treeData", function(data) { $.get(ctx + "system/dept/treeData", function(data) {

@ -23,7 +23,7 @@
<input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/> <input type="text" class="layui-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
</li> </li>
<li> <li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
</li> </li>
</ul> </ul>
</div> </div>

Loading…
Cancel
Save