138 lines
6.6 KiB
Plaintext
138 lines
6.6 KiB
Plaintext
@{
|
|
ViewBag.Title = "Excel数据导出";
|
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
|
}
|
|
<style>
|
|
/* .layui-form input[type="checkbox"] {
|
|
display: inline;
|
|
}*/
|
|
.layui-input-block {
|
|
margin-left: unset;
|
|
}
|
|
</style>
|
|
<div class="x-body">
|
|
<form class="layui-form">
|
|
<div class="checkList">
|
|
<div class="layui-form-item" pane="">
|
|
<div class="layui-input-block">
|
|
<div class="layui-input-block" id="blockinput">
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="downLoadExcle" class="downLoad">
|
|
<iframe id='ifExcel' width='0' height='0'></iframe>
|
|
</div>
|
|
<button class="layui-btn" lay-submit lay-filter="save">确定</button>
|
|
<input class="layui-btn" id="btnCheckAll" type="button" ischecked="checked" value="全选" />
|
|
<span id="spMessage" style="top:5px; position:relative;left:30px;"></span>
|
|
</form>
|
|
</div>
|
|
<!--<div class="formContent">
|
|
<div class="checkList">
|
|
<ul id="checkboxList"></ul>
|
|
</div>
|
|
</div>
|
|
<div class="mvctool bgb">
|
|
<a id="btnSave" style="float: left;" class="l-btn l-btn-plain"><span class="l-btn-left"><span class="l-btn-text icon-save" style="padding-left: 20px;">确定</span></span></a>
|
|
<a id="btnCheckAll" ischecked="checked" style="float: left;" class="l-btn l-btn-plain"><span class="l-btn-left"><span class="l-btn-text icon-ok" style="padding-left: 20px;">全选</span></span></a>-->
|
|
<!--</div>-->
|
|
<script type="text/javascript">
|
|
|
|
$(function () {
|
|
var columns = window.parent.getDataGridHeader();
|
|
var checkboxhtml = "";
|
|
$.each(columns, function (i, ex) {
|
|
checkboxhtml += '<input type="checkbox" name="ckb' + ex.field + '" lay-skin="primary" title="' + ex.title + '" nvalue="' + ex.field + '" checked >';
|
|
//$("#checkboxList").append("<li class='checkLi'><input lay-skin='primary' type='checkbox' id='ckb" + ex.field + "' title='" + ex.title + "' name='ckb" + ex.field + "' checked value='" + ex.field + "' /><label for='ckb" + ex.field + "'>" + ex.title + "</label></li>")
|
|
});
|
|
$("#blockinput").html(checkboxhtml);
|
|
var form;
|
|
layui.use(['form', 'layer'], function () {
|
|
form= layui.form;
|
|
form.render("checkbox");
|
|
form.on('submit(save)', function (data) {
|
|
console.log("导出");
|
|
console.log(data.field);
|
|
var checkedFilds = "";//被选中的字段
|
|
var checkedTitles = "";//被选中的字段中文名称
|
|
$.each($("#blockinput input"), function (i, ex) {
|
|
if ($(ex).is(':checked')) {
|
|
checkedFilds += "[" + $(ex).attr("nvalue") + "]";
|
|
checkedTitles += $(ex).attr("title") + ",";
|
|
}
|
|
});
|
|
if (checkedTitles.length > 0)
|
|
checkedTitles = checkedTitles.substr(0, checkedTitles.length - 1);
|
|
//if (sys == "firefox")//火狐支持Loading效果
|
|
//alert(checkedTitles.length+checkedTitles);
|
|
//alert(checkedTitles.length);
|
|
if (checkedTitles.length > 180)
|
|
$("#ifExcel").attr("src", "@Html.Raw(ViewBag.Query)&excelGuid=" + GetGuid() + "&checkedTitles=&checkedFilds=" + encodeURIComponent(checkedFilds));
|
|
else
|
|
$("#ifExcel").attr("src", "@Html.Raw(ViewBag.Query)&excelGuid=" + GetGuid() + "&checkedTitles=" + encodeURIComponent(checkedTitles) + "&checkedFilds=" + encodeURIComponent(checkedFilds));
|
|
$("#btnSave").addClass("l-btn-disabled").unbind();
|
|
$("#spMessage").html("正在导出.......");
|
|
var funct = window.setInterval(function () {
|
|
$("#spMessage").html("");
|
|
clearInterval(funct);
|
|
}, 1000 * 5);
|
|
return false;
|
|
});
|
|
});
|
|
$("#btnCheckAll").click(function () {
|
|
if ($(this).attr("ischecked") == "checked") {
|
|
$(this).attr("ischecked", "noChecked");
|
|
$("#blockinput").find("input[type='checkbox']").prop("checked", false);
|
|
//$("input[type='checkbox']").removeAttr("checked");
|
|
form.render("checkbox");
|
|
//$("input[type='checkbox']").removeAttr("checked");
|
|
//$(".checkLi").removeClass("checkLi").addClass("uncheckLi");
|
|
}
|
|
else {
|
|
$(this).attr("ischecked", "checked");
|
|
//$("input[type='checkbox']").attr("checked", "checked");
|
|
//$(".uncheckLi").removeClass("uncheckLi").addClass("checkLi");
|
|
$("#blockinput").find("input[type='checkbox']").prop("checked", true);
|
|
form.render("checkbox");
|
|
}
|
|
|
|
});
|
|
//$("#checkboxList li").live("click", function () {
|
|
// if ($(this).find("input").attr("checked") == null)
|
|
// $(this).removeClass("checkLi").addClass("uncheckLi");
|
|
// else
|
|
// $(this).removeClass("uncheckLi").addClass("checkLi");
|
|
//});
|
|
//$("#btnSave").click(function () {
|
|
// var checkedFilds = "";//被选中的字段
|
|
// var checkedTitles = "";//被选中的字段中文名称
|
|
// $.each($("#checkboxList li input"), function (i, ex) {
|
|
// if ($(ex).attr("checked") == "checked") {
|
|
// checkedFilds += "[" + $(ex).val() + "]";
|
|
// checkedTitles += $(ex).attr("title") + ",";
|
|
// }
|
|
// });
|
|
// if (checkedTitles.length > 0)
|
|
// checkedTitles = checkedTitles.substr(0, checkedTitles.length - 1);
|
|
// //if (sys == "firefox")//火狐支持Loading效果
|
|
// //alert(checkedTitles.length+checkedTitles);
|
|
// //alert(checkedTitles.length);
|
|
// if (checkedTitles.length > 180)
|
|
// $("#ifExcel").attr("src", "@Html.Raw(ViewBag.Query)&excelGuid=" + GetGuid() + "&checkedTitles=&checkedFilds=" + encodeURIComponent(checkedFilds));
|
|
// else
|
|
// $("#ifExcel").attr("src", "@Html.Raw(ViewBag.Query)&excelGuid=" + GetGuid() + "&checkedTitles=" + encodeURIComponent(checkedTitles) + "&checkedFilds=" + encodeURIComponent(checkedFilds));
|
|
// $("#btnSave").addClass("l-btn-disabled").unbind();
|
|
// $("#spMessage").html("正在导出.......");
|
|
// var funct = window.setInterval(function () {
|
|
// $("#spMessage").html("");
|
|
// clearInterval(funct);
|
|
// }, 1000 * 5);
|
|
|
|
|
|
//});
|
|
});
|
|
var i = 0;
|
|
</script>
|