layui.use(['element', 'table', 'laydate', 'form'], function () { var $ = layui.jquery; var table = layui.table; var laydate = layui.laydate; var element = layui.element; var form = layui.form; // 生成表格 table.render({ elem: '#informationTable', url: '../../../getInformations', toolbar: '#toolbarDemo', title: '用户表',// 导出文件名 id: 'informationTableAll', // 开启分页 // page : true, page: { layout: ['count', 'prev', 'page', 'next', 'skip', 'limit'] }, limits: [10, 30, 50, 80, 100, 999], /*request : { 'limitName' : 'pageSize' // 分页每页条数默认字段改为pageSize },*/ where: { type: '1',content: '' }, cellMinWidth: 80, // 全局定义常规单元格的最小宽度,layui 2.2.1 新增 cols: [[{ type: 'numbers', title: '序号', width: 50, fixed: "left" }, { field: 'content', title: '内容', }, { field: 'type', align: 'center', width: 150, title: '类型' }, { field: 'createBy', align: 'center', width: 150, title: '创建人' }, { field: 'createDate', title: '创建时间', width: 220, align: 'center', templet: function (d) { return d.createDate != null ? layui.util.toDateString(d.createDate, "yyyy-MM-dd HH:mm:ss") : ""; } }, { fixed: 'right', title: '操作', align: 'center', width: 150, toolbar: '#barDemo' }]], parseData: function (res) { //将原始数据解析成 table 组件所规定的数据 return { "code": 0, //解析接口状态 "msg": "", //解析提示文本 "count": res.data.list.total,//解析数据长度 "data": res.data.list.list//解析数据列表 }; } }); //点击查询按钮,重载表格 $('#searchBtn').on('click', function () { table.reload('informationTableAll', { method: 'get', where: { content: $("#content").val() }, page: { curr: 1 } }); return false; }); // 监听头部工作栏的 新增 table.on('toolbar(informationTable)', function (obj) { var checkStatus = table.checkStatus(obj.config.id); switch (obj.event) { case 'add': layer.open({ type: 2, title: "添加问题", fix: false, //不固定 maxmin: true, skin: 'layui-layer-molv', area: ['45%', '70%'], content: './addInformation.jsp', }); break; } ; }); function previewImage(textImage) { } // 监听 修改 table.on('tool(informationTable)', function (obj) { var data1 = obj.data; console.log(data1) if (obj.event === 'edit') { layer.open({ type: 2, title: "修改问题", area: ['45%', '70%'], skin: 'layui-layer-molv', content: './updateInformation.jsp', success: function (layero, index) { var body = layer.getChildFrame('body', index); var iframeWin = window[layero.find('iframe')[0]['name']]; // 得到iframe页的窗口对象 body.find('#id').val(data1.id); body.find('#contentUpdate').val(data1.content); body.find('#type').val(data1.type); body.find('#images').val(data1.attachment); let textImage = data1.attachment; if (textImage) { let textImageList = textImage == "" ? [] : textImage.split(","); let html = ""; textImageList.forEach((item, index) => { if (item != "" && (item.indexOf(".mp4") > -1 || item.indexOf(".MP4") > -1)) { html += "