懒羊羊
2024-01-11 541017985eebeac1811cd115b6585fe76525ddaa
提交 | 用户 | 时间
71e81e 1 layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'ax','upload'], function () {
2     var layer = layui.layer;
3     var form = layui.form;
4     var table = layui.table;
5     var $ZTree = layui.ztree;
6     var $ax = layui.ax;
7     var laydate = layui.laydate;
8     var admin = layui.admin;
9     var upload = layui.upload;
10
11     /**
12      * 系统管理--用户管理
13      */
14     var MgrUser = {
15         tableId: "userTable",    //表格id
16         condition: {
17             name: "",
18             deptId: "",
19             timeLimit: ""
20         }
21     };
22
23     /**
24      * 初始化表格的列
25      */
26     MgrUser.initColumn = function () {
27         return [[
28             {type: 'checkbox'},
29             {field: 'userId', hide: true, sort: true, title: '用户id'},
30             {field: 'account', sort: true, title: '账号'},
31             {field: 'name', sort: true, title: '姓名'},
32             {field: 'sexName', sort: true, title: '性别'},
33             {field: 'roleName', sort: true, title: '角色'},
34             {field: 'deptName', sort: true, title: '部门'},
35             {field: 'email', sort: true, title: '邮箱'},
36             {field: 'phone', sort: true, title: '电话'},
37             {field: 'createTime', sort: true, title: '创建时间'},
38             {field: 'status', sort: true, templet: '#statusTpl', title: '状态'}
39         ]];
40     };
41
42     /**
43      * 导出excel按钮
44      */
45     MgrUser.exportExcel = function () {
46         var checkRows = table.checkStatus(MgrUser.tableId);
47         if (checkRows.data.length === 0) {
48             Feng.error("请选择要导出的数据");
49         } else {
50             table.exportFile(tableResult.config.id, checkRows.data, 'xls');
51         }
52     };
53
54     // 渲染表格
55     var tableResult = table.render({
56         elem: '#' + MgrUser.tableId,
57         url: Feng.ctxPath + '/mgr/list',
58         page: true,
59         height: "full-98",
60         cellMinWidth: 100,
61         cols: MgrUser.initColumn()
62     });
63
64     //渲染时间选择框
65     laydate.render({
66         elem: '#timeLimit',
67         range: true,
68         max: Feng.currentDate()
69     });
70
71     //执行实例
72     var uploadInst = upload.render({
73         elem: '#btnExp'
74         , url: '/excel/uploadExcel'
75         ,accept: 'file'
76         , done: function (res) {
77             table.reload(MgrUser.tableId, {url: Feng.ctxPath + "/excel/getUploadData"});
78         }
79         , error: function () {
80             //请求异常回调
81         }
82     });
83
84 });