layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect','laydate'], function () { let $ = layui.jquery, form = layui.form, table = layui.table, layer = layui.layer, xmSelect = layui.xmSelect, laydate = layui.laydate, miniTab = layui.miniTab; /**** index begin ***/ //index页面 if ($('.location-index-page').length > 0) { miniTab.listen(); // 渲染表格 let listUrl = $('#table-container').data('url'); let insTb = table.render({ elem: '#table-container', toolbar: '#toolbar-tpl', defaultToolbar: [ { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可 title: '搜索' , layEvent: 'search' , icon: 'layui-icon-search' }], url: listUrl, method: 'post', even: true, limits: [10,20,50,100,200,500,1000], request: { pageName: 'page', limitName: 'size', }, parseData: function (res) { return { "code": res.code, //解析接口状态 "msg": res.msg, //解析提示文本 "count": res.data.total, //解析数据长度 "data": res.data.list //解析数据列表 }; }, page: true, cols: [[ // {type: 'checkbox'}, {field: 'id' , width: 80, title: 'ID'}, {field: 'name', title: '名称'}, {templet:function(d){ if( d.business != undefined ){ return d.business.business_name!=null?d.business.business_name:'' } return d.business_name; }, title: '所属商家'}, {templet:function(d){ if( d.business != undefined ){ return d.business.business_subtitle!=null?d.business.business_subtitle:'' } return ''; }, title: '商家简称'}, {field: 'agency_text', title: '渠道商名称'}, {field: 'money', title: '金额'}, {field: 'deduction_money', title: '扣费'}, {field: 'start_time', title: '开始时间'}, {field: 'end_time', title: '结束时间'}, {templet: '#row-on_shelf', title: '上架状态'}, {field: 'state_text', title: '状态'}, {field: 'create_time', title: '创建时间'}, {templet: '#row-operate', field: 'right', align: 'center', title: '操作', fixed: 'right'} ]], done: function () { Tools.setInsTb(insTb); } }); // 监听搜索操作 form.on('submit(data-search-btn)', function (data) { //执行搜索重载 table.reload('table-container', { page: {curr: 1} , where: data.field }, 'data'); return false; }); //日期时间选择器 laydate.render({ elem: '#start_time' ,type: 'date' }); //日期时间选择器 laydate.render({ elem: '#end_time' ,type: 'date' }); //监听工具条 table.on('tool(table-container)', function (obj) { let data = obj.data; let layEvent = obj.event; let url = $($(this).context).data('href'); let title = $($(this).context).data('title'); let width = $($(this).context).data('width') ? $($(this).context).data('width') : '100%'; let height = $($(this).context).data('height') ? $($(this).context).data('height') : '100%'; let insTb = Tools.getInsTb(); if (layEvent === 'shelf') { $.post(url, null, function (res) { layer.msg(res.msg) if (res.code === 0) { insTb.reload(); } }) return false; } if (layEvent === 'info') { openLayer(url, title, width, height); return false; } }); } /*** index end ***/ if ($('.location-operate-page').length > 0){ //日期时间选择器 laydate.render({ elem: '#start_time' ,type: 'date' }); //日期时间选择器 laydate.render({ elem: '#end_time' ,type: 'date' }); } });