诗词
class="layui-input" placeholder="请输入诗词关键字">
内容
class="layui-input" placeholder="请选择内容关键词">
查询
导出
// 自定义模块
layui.config({
base: 'ext/', // 模块目录
version: 'v1.5.16'
}).extend({ // 模块别名
soulTable: 'soulTable'
});
layui.use(['form', 'table','soulTable'], function () {
var table = layui.table,
soulTable = layui.soulTable,
form = layui.form,
$ = layui.$;
var myTable = table.render({
elem: '#myTable'
,url: 'data.json'
,height: $(document).height() - $('#myTable').offset().top - 20
,totalRow: true
,page: false
,cols: [[
{type: 'checkbox', fixed: 'left'},
{field: 'title', title: '诗词', width: 165 , fixed:'left', totalRowText: '合计', sort: true, filter: true},
{field: 'dynasty', title: '朝代', width: 165 , sort: true, filter: true, excel:function (d) {
var colors = {'清代':'01AAED', '唐代':'FFB800', '宋代':'FF5722','明代':'5FB878'};
return {
color: colors[d.dynasty]?'FFFFFF':'000000',
bgColor: colors[d.dynasty]
}
}},
{field: 'author', title: '作者', width: 165 , filter: true},
{field: 'type', title: '类型', width: 112, filter: {split:','}, sort:true},
{field: 'content', title: '内容', width: 823, filter: true},
{field: 'heat', title: '点赞数', width: 112, totalRow: true, filter: true, sort:true, excel:{cellType: 'n'}},
{field: 'createTime', title: '录入时间', width: 165, filter: {type: 'date[yyyy-MM-dd HH:mm:ss]'}, sort:true, excel:{cellType: 'd'}},
{title: '操作', width: 156, fixed: 'right', templet: '#bar'}
]]
,done: function () {
soulTable.render(this)
}
});
form.on('submit(search)', function (data) {
myTable.reload({
where: data.field
})
})
form.on('submit(export)', function () {
soulTable.export(myTable);
})
})
一键复制
编辑
Web IDE
原始数据
按行查看
历史