...
|
...
|
@@ -17,33 +17,88 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin |
|
|
|
|
|
var table = $("#table");
|
|
|
|
|
|
//导出功能
|
|
|
$(document).on("click", ".btn-export", function () {
|
|
|
var ids = Table.api.selectedids(table);
|
|
|
var page = table.bootstrapTable('getData');
|
|
|
var all = table.bootstrapTable('getOptions').totalRows;
|
|
|
console.log(ids, page, all);
|
|
|
Layer.confirm("请选择导出的选项<form action='" + Fast.api.fixurl("study/export") + "' method='post' target='_blank'><input type='hidden' name='ids' value='' /><input type='hidden' name='filter' ><input type='hidden' name='op'><input type='hidden' name='search'><input type='hidden' name='columns'></form>", {
|
|
|
title: '导出数据',
|
|
|
btn: ["选中项(" + ids.length + "条)", "本页(" + page.length + "条)", "全部(" + all + "条)"],
|
|
|
success: function (layero, index) {
|
|
|
$(".layui-layer-btn a", layero).addClass("layui-layer-btn0");
|
|
|
}
|
|
|
, yes: function (index, layero) {
|
|
|
submitForm(ids.join(","), layero);
|
|
|
return false;
|
|
|
}
|
|
|
,
|
|
|
btn2: function (index, layero) {
|
|
|
var ids = [];
|
|
|
$.each(page, function (i, j) {
|
|
|
ids.push(j.id);
|
|
|
});
|
|
|
submitForm(ids.join(","), layero);
|
|
|
return false;
|
|
|
}
|
|
|
,
|
|
|
btn3: function (index, layero) {
|
|
|
submitForm("all", layero);
|
|
|
return false;
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
var submitForm = function (ids, layero) {
|
|
|
var options = table.bootstrapTable('getOptions');
|
|
|
console.log(options);
|
|
|
var columns = [];
|
|
|
$.each(options.columns[0], function (i, j) {
|
|
|
if (j.field && !j.checkbox && j.visible && j.field != 'operate') {
|
|
|
columns.push(j.field);
|
|
|
}
|
|
|
});
|
|
|
var search = options.queryParams({});
|
|
|
$("input[name=search]", layero).val(options.searchText);
|
|
|
$("input[name=ids]", layero).val(ids);
|
|
|
$("input[name=filter]", layero).val(search.filter);
|
|
|
$("input[name=op]", layero).val(search.op);
|
|
|
$("input[name=columns]", layero).val(columns.join(','));
|
|
|
$("form", layero).submit();
|
|
|
};
|
|
|
|
|
|
// 初始化表格
|
|
|
table.bootstrapTable({
|
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
|
pk: 'id',
|
|
|
sortName: 'id',
|
|
|
showToggle: false,//浏览模式功能关闭
|
|
|
showColumns: false,//显示隐藏列功能关闭
|
|
|
//commonSearch: false, //关闭通用搜索按钮
|
|
|
showExport: false,//导出功能关闭
|
|
|
clickToSelect: false, //是否启用点击选中
|
|
|
dblClickToEdit: false, //是否启用双击编辑
|
|
|
fixedColumns: true,
|
|
|
fixedRightNumber: 1,
|
|
|
columns: [
|
|
|
[
|
|
|
{checkbox: true},
|
|
|
{field: 'id', title: __('Id')},
|
|
|
{field: 'user_id', title: __('User_id')},
|
|
|
{field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
|
|
|
{field: 'name', title: __('Name'), operate: 'LIKE'},
|
|
|
{field: 'gender', title: __('Gender'), searchList: {"0":__('Gender 0'),"1":__('Gender 1')}, formatter: Table.api.formatter.normal},
|
|
|
{field: 'birth', title: __('Birth'), operate: 'LIKE'},
|
|
|
{field: 'avatar', title: __('Avatar'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
|
|
{field: 'phone', title: __('Phone'), operate: 'LIKE'},
|
|
|
{field: 'team.title', title: __('Team.title'), operate: 'LIKE'},
|
|
|
{field: 'birthday', title: __('Birthday'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,datetimeFormat: "YYYY-MM-DD"},
|
|
|
{field: 'grade', title: __('Grade'), operate: 'LIKE'},
|
|
|
{field: 'school', title: __('School'), operate: 'LIKE'},
|
|
|
{field: 'unique', title: __('Unique')},
|
|
|
{field: 'sno', title: __('Sno'), operate: 'LIKE'},
|
|
|
{field: 'team_id', title: __('Team_id')},
|
|
|
{field: 'earn_score', title: __('Earn_score'), operate:'BETWEEN'},
|
|
|
{field: 'qrcode', title: __('Qrcode'), operate: 'LIKE'},
|
|
|
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
|
|
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
|
|
{field: 'team.title', title: __('Team.title'), operate: 'LIKE'},
|
|
|
{field: 'user.username', title: __('User.username'), operate: 'LIKE'},
|
|
|
// {field: 'team_id', title: __('Team_id')},
|
|
|
{field: 'earn_score', title: __('Earn_score'), operate:false},
|
|
|
{field: 'unique', title: __('Unique'), operate:false},
|
|
|
{field: 'barcode', title: __('Barcode'), operate:false},
|
|
|
// {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
|
|
// {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
|
|
]
|
|
|
]
|
...
|
...
|
|