| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- var ExcelData;
- var excel;
- layui.config({
- base: '/layuiadmin/' //静态资源所在路径
- }).extend({
- myexcel: 'layui/lay/modules/excel',
- index: 'lib/index' //主入口模块
- }).use(['index', 'table', 'excel', 'laydate'], function () {
- var $ = layui.$
- , form = layui.form
- , table = layui.table;
- //- 筛选条件-日期
- var laydate = layui.laydate;
- var layCreateDate = laydate.render({
- elem: '#CreateDate',
- type: 'date',
- range: true,
- trigger: 'click',
- change: function (value, date, endDate) {
- var op = true;
- if (date.year == endDate.year && endDate.month - date.month <= 2) {
- if (endDate.month - date.month == 2 && endDate.date > date.date) {
- op = false;
- layCreateDate.hint('日期范围请不要超过2个月');
- setTimeout(function () {
- $(".laydate-btns-confirm").addClass("laydate-disabled");
- }, 1);
- }
- } else {
- op = false;
- layCreateDate.hint('日期范围请不要超过2个月');
- setTimeout(function () {
- $(".laydate-btns-confirm").addClass("laydate-disabled");
- }, 1);
- }
- if (op) {
- $('#CreateDate').val(value);
- }
- }
- });
- //excel导入
- excel = layui.excel;
- $('#ExcelFile').change(function (e) {
- var files = e.target.files;
- excel.importExcel(files, {}, function (data) {
- ExcelData = data[0].sheet1;
- });
- });
- //列表数据
- table.render({
- elem: '#LAY-list-manage'
- , url: '/Admin/Users/BatchSeeUserInfoDo' //模拟接口
- , cols: [[
- { type: 'checkbox', fixed: 'left' }
- , { field: 'PosSn', width: 150, title: '机具Sn', sort: true }
- , { field: 'MerNo', width: 150, title: '商户编号', sort: true }
- , { field: 'PosFee', width: 150, title: '服务费', sort: true }
- , { field: 'BindingTime', width: 150, title: '绑定时间', sort: true }
- , { field: 'ActivationTime', width: 150, title: '激活时间', sort: true }
- , { field: 'MakerCode', width: 105, title: '创客编号', sort: true }
- , { field: 'RealName', width: 105, title: '创客姓名', sort: true }
- , { field: 'TopMakerCode', width: 160, title: '顶级创客编号', sort: true }
- , { field: 'TopRealName', width: 160, title: '顶级创客名称', sort: true }
- , { field: 'SecondMakerCode', width: 160, title: '次顶级创客编号', sort: true }
- , { field: 'SecondRealName', width: 160, title: '次顶级创客姓名', sort: true }
- , { field: 'ThirdMakerCode', width: 160, title: '次次顶级创客编号', sort: true }
- , { field: 'ThirdRealName', width: 160, title: '次次顶级创客姓名', sort: true }
- ]]
- , where: {
- }
- , page: true
- , limit: 30
- , height: 'full-' + String($('.layui-card-header').height() + 130)
- , text: '对不起,加载出现异常!'
- , done: function (res, curr, count) {
- $(".layui-none").text("无数据");
- }
- });
- //监听工具条
- table.on('tool(LAY-list-manage)', function (obj) {
- var data = obj.data;
- });
- //监听搜索
- form.on('submit(LAY-list-front-search)', function (data) {
- var field = data.field;
- //执行重载
- table.reload('LAY-list-manage', {
- where: field
- });
- });
- form.on('submit(LAY-list-front-searchall)', function (data) {
- table.reload('LAY-list-manage', {
- where: {
- UserId: UserId
- }
- });
- });
- //事件
- var active = {
- ImportData: function () {
- layer.open({
- type: 1,
- title: '导入',
- maxmin: false,
- area: ['460px', '180px'],
- content: $('#excelForm'),
- cancel: function () {
- }
- });
- }
- , ExportExcel: function () {
- var userdata = '';
- $(".layuiadmin-card-header-auto input").each(function (i) {
- userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
- });
- $(".layuiadmin-card-header-auto select").each(function (i) {
- userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
- });
- var index = layer.confirm('确定导出吗?', function (index) {
- var indexs = layer.load(1, {
- shade: [0.5, '#000']
- });
- $.ajax({
- type: "Post",
- url: "/Admin/Users/ExportBatchSeeUserInfoExcelDo?r=" + Math.random(1),
- data: userdata,
- dataType: "json",
- success: function (data) {
- layer.close(index); //关闭弹层
- if (data == "success") {
- layer.close(indexs); //关闭弹层
- layer.msg('成功', {
- time: 1000
- }, function () {
- window.location.reload();
- });
- } else {
- layer.close(indexs); //关闭弹层
- layer.msg(data);
- }
- }
- });
- });
- }
- };
- $('.layui-btn').on('click', function () {
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- });
|