| <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="customer-search-value" class="layui-input search-input" type="text" placeholder="输入姓名"/>  |
| <button id="customer-btn-search" class="layui-btn icon-btn" data-type="search"><i class="layui-icon"></i>搜索 |
| </button> |
| <button id="customer-btn-add" class="layui-btn icon-btn" data-type="add"><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: '[[@{/customer/list}]]', |
| page: true, |
| minWidth: 80, |
| cols: [ |
| [ |
| {field: 'custname', sort: true, width: 120, title: '客户姓名'}, |
| {field: 'cardno', sort: true,width: 120, title: '市名卡号'}, |
| {field: 'phone', title: '联系电话'}, |
| {field: 'bankcardno', sort: true, width: 200, 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: 'deptcode', |
| title: '部门', |
| sort: true, |
| align: 'center', |
| templet: function (item) { |
| console.log(deptlist); |
| for(var i=0 ;i<deptlist.length;i++){ |
| if(item.deptcode==deptlist[i].deptcode){ |
| return deptlist[i].deptname; |
| } |
| } |
| return item.deptno; |
| } |
| }, |
| { |
| field: 'custtype', width:100, title: '人员类别', templet: function (item) { |
| for(var i=0 ;i<custtypelist.length;i++){ |
| if(item.custtypeid==custtypelist[i].custtypeid){ |
| return custtypelist[i].custtypename; |
| } |
| } |
| return item.custtypeid; |
| } |
| }, |
| { |
| field: 'custid', align: 'center',width:150, title: '操作', fixed: 'right', templet: function (item) { |
| return ' <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a> '+ |
| ' <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>'; |
| } |
| } |
| ] |
| ] |
| }); |
| $('#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 = $('#customer-search-value').val().trim(); |
| table.reload('customer-table', {where: {searchkey: key}, 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_cus', 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> |