| <div class="layui-card"> |
| <div class="layui-card-header"> |
| <h2 class="header-title">访客记录</h2> |
| <span class="layui-breadcrumb pull-right"> |
| <a href="#">访客登记管理</a> |
| <a><cite>访客记录</cite></a> |
| </span> |
| </div> |
| <div class="layui-card-body"> |
| <div class="layui-form toolbar"> |
| 搜索: |
| <input id="visitor-search-value" class="layui-input search-input" type="text" placeholder="输入姓名"/>  |
| <select id="visitor-search-sex" class="layui-input search-input" type="" > |
| <option value="">性别</option> |
| <option value="1">男</option> |
| <option value="2">女</option> |
| </select>  |
| <input id="visitor-search-startdate" class="layui-input search-input" type="date" />  |
| <label>~ </label> |
| <input id="visitor-search-enddate" class="layui-input search-input" type="date" />  |
| <button id="customer-btn-search" class="layui-btn icon-btn" data-type="search"><i class="layui-icon"></i>搜索 |
| </button> |
| <!-- <button id="customer-btn-import" class="layui-btn icon-btn" ><i class="layui-icon"></i>批量导入</button>--> |
| <!-- <a id="customer-btn-export" href="javascript:void(0);" class="layui-btn layui-btn-primary" >导出</a>--> |
| </div> |
| <table class="layui-table" id="customer-table" lay-filter="customer-table"></table> |
| </div> |
| </div> |
| <input hidden th:value="${custtypelist}" id="custtypelist"> |
| <input hidden th:value="${deptlist}" id="deptlist"> |
| <script> |
| |
| var ctlist=$("#custtypelist").val(); |
| var custtypelist=JSON.parse(ctlist); |
| var dplist=$("#deptlist").val(); |
| var deptlist=JSON.parse(dplist); |
| layui.use(['form', 'table', 'layer', 'admin', 'element'], function () { |
| let form = layui.form; |
| let table = layui.table; |
| let admin = layui.admin; |
| |
| form.render('select'); |
| |
| // 渲染表格 |
| table.render({ |
| elem: '#customer-table', |
| url: '[[@{/visitor/checklist}]]', |
| page: true, |
| minWidth: 80, |
| cols: [ |
| [ |
| {field: 'visitorname', title: '姓名'}, |
| |
| |
| /*{ |
| field: 'checkstatus', title: '审核状态', align: 'center', width: 120, sort: true, templet: function (d) { |
| if ('uncheck' == d.checkstatus) { |
| return '<span class="layui-badge layui-bg-orange">待审核</span>' |
| } else if ('normal' == d.checkstatus) { |
| return '<span class="layui-badge layui-bg-green">成功</span>'; |
| } else if ('fail' == d.checkstatus) { |
| return '<span class="layui-badge layui-bg-gray">失败</span>'; |
| } else { |
| return d.checkstatus; |
| } |
| } |
| },*/ |
| { |
| field: 'sex', |
| title: '性别', |
| align: 'center', |
| templet: function (item) { |
| if(item.sex==1){ |
| return "男" |
| }else { |
| return "女" |
| } |
| } |
| }, |
| {field: 'phone', title: '联系方式'}, |
| |
| { |
| field: 'transdate', width:200, title: '日期',align: 'center', templet: function (item) { |
| return item.transdate.substring(0,4)+"-"+item.transdate.substring(4,6)+"-"+item.transdate.substring(6,8); |
| } |
| },{ |
| field: 'transtime', width:200, title: '时间', align: 'center',templet: function (item) { |
| return item.transtime.substring(0,2)+":"+item.transtime.substring(2,4)+":"+item.transtime.substring(4,6); |
| } |
| }, |
| {field: 'idno', align: 'center', title: '身份证号'}, |
| {field: 'company', align: 'center', title: '单位'}, |
| {field: 'custname', align: 'center', title: '受访人'}, |
| {field: 'deptname', align: 'center', title: '受访人部门'}, |
| {field: 'remarks', align: 'center', title: '备注'} |
| ] |
| ] |
| }); |
| $('#customer-btn-export').click(function () { |
| var url = '[[@{/customer/export}]]'; |
| /* $("#form").attr("action",url); |
| |
| $("#form").submit();*/ |
| |
| $("#customer-btn-export").attr("href", url ); |
| $("#customer-btn-export")[0].click(); |
| }); |
| // 搜索按钮点击事件 |
| $('#customer-btn-search').click(function () { |
| let key = $('#visitor-search-value').val().trim(); |
| let sex = $('#visitor-search-sex').val().trim(); |
| let startdate = $('#visitor-search-startdate').val().trim(); |
| let enddate = $('#visitor-search-enddate').val().trim(); |
| if(enddate!=null&&enddate!=""){ |
| if(startdate!=null&&startdate!=""){ |
| if(startdate>enddate){ |
| alert("请输入正确的日期") |
| return; |
| } |
| } |
| |
| } |
| table.reload('customer-table', {where: {searchkey: key,sex: sex,startdate:startdate,enddate:enddate }, page: {curr: 1}}); |
| }); |
| $('#customer-btn-add').click(function () { |
| showModel(); |
| }); |
| /* $('#customer-btn-import').click(function () { |
| showDownload(); |
| }); |
| let showDownload = function () { |
| let title ='导入'; |
| admin.popupCenter({ |
| title: title, |
| path: '[[@{/customer/loadimport}]]', |
| finish: function () { |
| table.reload('customer-table', {}); |
| } |
| }); |
| };*/ |
| let showModel = function (data) { |
| let title = data ? '修改人员信息' : '添加人员信息'; |
| admin.putTempData('t_cust', data); |
| admin.popupCenter({ |
| title: title, |
| path: '[[@{/customer/loadadd}]]', |
| finish: function () { |
| table.reload('customer-table', {}); |
| } |
| }); |
| }; |
| |
| |
| // 工具条点击事件 |
| table.on('tool(customer-table)', function (obj) { |
| let data = obj.data; |
| let layEvent = obj.event; |
| console.log(data); |
| if (layEvent === 'edit') { |
| showModel(data); |
| } else if (layEvent === 'del') { |
| showDelete(data); |
| } |
| }); |
| let showDelete = function (data) { |
| console.log(data); |
| layer.confirm('确定要删除吗?', function (i) { |
| layer.close(i); |
| layer.load(2); |
| let token = $("meta[name='_csrf_token']").attr("value"); |
| admin.go('[[@{/customer/delete}]]', { |
| custid: data.custid, |
| _csrf: token |
| }, function (data) { |
| console.log(data.code); |
| layer.closeAll('loading'); |
| if (data.code == 200) { |
| layer.msg(data.msg, {icon: 1}); |
| } else if (data.code == 401) { |
| layer.msg(data.msg, {icon: 2, time: 1500}, function () { |
| location.replace('/login'); |
| }, 1000); |
| return; |
| } else { |
| layer.msg(data.msg, {icon: 2}); |
| } |
| table.reload('customer-table', {}); |
| }, function (ret) { |
| console.log(ret); |
| layer.closeAll('loading'); |
| layer.msg('请求失败了,请稍后再试', {icon: 2}); |
| }); |
| }); |
| }; |
| |
| }); |
| </script> |