自动化立体仓库 - WMS系统
pang.jiabao
2025-04-12 2e36f3e6ccd951fd85a15eff4fae54f938dbe503
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
var pageCurr;
var tableData;
var insTb2;
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).use(['table','laydate', 'form', 'util', 'admin'], function(){
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    var form = layui.form;
    var admin = layui.admin;
    var util = layui.util;
 
    insTb2 = table.render({
        elem: '#userTable',
        headers: {token: localStorage.getItem('token')},
        url: baseUrl+'/user/list/auth',
        page: true,
        limit: 15,
        limits: [15, 30, 50, 100, 200, 500],
        toolbar: '#userToolbar',
        height: 'full-100',
        cols: [[
            {type: 'checkbox'}
            // ,{field: 'hostName', align: 'center',title: '授权商户', templet: '#hostTpl', width: 140}
            // ,{field: 'nickname', align: 'center',title: '用户名'}
            ,{field: 'username', align: 'center',title: 'Учетная запись для входа'}
            ,{field: 'mobile', align: 'center',title: '手机号'}
            // ,{field: 'deptName', align: 'center',title: '所属部门'}
            ,{field: 'roleName', align: 'center',title: 'Роль'}
            ,{field: 'email', align: 'center',title: 'Электронная почта'}
            // ,{field: 'sex$', align: 'center',title: '性别'}
            ,{field: 'createTime$', align: 'center',title: '创建时间', hide: true}
            ,{field: 'status$', align: 'center',title: 'Статус', templet: '#statusTpl', width: 120, unresize: true}
 
            ,{fixed: 'right', title:'Операция', align: 'center', toolbar: '#operate', width:200}
        ]],
        request: {
            pageName: 'curr',
            pageSize: 'limit'
        },
        parseData: function (res) {
            return {
                'code': res.code,
                'msg': res.msg,
                'count': res.data.total,
                'data': res.data.records
            }
        },
        response: {
            statusCode: 200
        },
        done: function(res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            tableData = table.cache.userTable;
            pageCurr=curr;
            limit();
        }
    });
    /* 表格2搜索 */
    form.on('submit(userTbSearch)', function (data) {
        insTb2.reload({where: data.field, page: {curr: 1}});
        return false;
    });
 
    /* 表格2头工具栏点击事件 */
    table.on('toolbar(userTable)', function (obj) {
        var checkStatus = table.checkStatus(obj.config.id).data;
        if (obj.event === 'add') { // 添加
            showEditModel()
        } else if (obj.event === 'del') { // 删除
            if (checkStatus.length === 0) {
                layer.msg('Вы уверены, что хотите удалить эту запись?', {icon: 2});
                return;
            }
            del(checkStatus.map(function (d) {
                return d.id;
            }));
        }
    });
 
    // 修改状态
    form.on('switch(statusSwitch)', function (obj) {
        var index  = obj.othis.parents('tr').attr("data-index");
        var data = tableData[index];
        data[this.name] = obj.elem.checked?1:0;
        http.post(baseUrl+"/user/edit/auth", {id: data.id, status: data[this.name]}, function (res) {
            layer.msg(res.msg, {icon: 1});
        })
    })
 
    /* 表格2工具条点击事件 */
    table.on('tool(userTable)', function (obj) {
        var data = obj.data;
        switch (obj.event) {
            // 编辑
            case 'edit':
                showEditModel(data)
                break;
            // 删除
            case 'del':
                del([data.id]);
                break;
            // 重置密码
            case 'resetPwd':
                admin.open({
                    type: 1,
                    title: 'Сброс пароля',
                    offset: '150px',
                    area: ['360px'],
                    shade: 0.1,
                    shadeClose: true,
                    content: $("#resetpwd-window").html(),
                    success: function(layero, index){
                        layer.iframeAuto(index);
                        $('#resetUserId').val(data.id);
                    }
                });
                break;
        }
    });
 
    /* 显示表单弹窗 */
    function showEditModel(mData) {
        admin.open({
            type: 1,
            area: '600px',
            title: (mData ? 'Изменить' : 'Добавить') + 'Системные пользователи',
            content: $('#editDialog').html(),
            success: function (layero, dIndex) {
                // 回显表单数据
                form.val('detail', mData);
                // 表单提交事件
                form.on('submit(editSubmit)', function (data) {
                    if (isEmpty(data.field.roleId)) {
                        layer.msg('请选择角色', {icon: 2});
                        return false;
                    }
                    var loadIndex = layer.load(2);
                    $.ajax({
                        url: baseUrl+"/user/"+(mData?'update':'add')+"/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: data.field,
                        method: 'POST',
                        success: function (res) {
                            layer.close(loadIndex);
                            if (res.code === 200){
                                layer.close(dIndex);
                                layer.msg(res.msg, {icon: 1});
                                $(".layui-laypage-btn")[0].click();
                            } else if (res.code === 403){
                                top.location.href = baseUrl+"/";
                            }else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }
                    })
                    return false;
                });
                // 弹窗不出现滚动条
                $(layero).children('.layui-layer-content').css('overflow', 'visible');
                layui.form.render('select');
            }
        });
    }
 
 
    /* 删除订单 */
    function del(ids) {
        layer.confirm('确定要删除选中数据吗?', {
            skin: 'layui-layer-admin',
            shade: .1
        }, function (i) {
            layer.close(i);
            var loadIndex = layer.load(2);
            $.ajax({
                url: baseUrl+"/user/delete/auth",
                headers: {'token': localStorage.getItem('token')},
                data: {ids: ids},
                method: 'POST',
                success: function (res) {
                    layer.close(loadIndex);
                    if (res.code === 200){
                        layer.msg(res.msg, {icon: 1});
                        $(".layui-laypage-btn")[0].click();
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    }else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }
            })
 
        });
    }
 
    // 重置密码
    form.on('submit(savePwd)', function (data) {
        $.ajax({
            url: baseUrl+"/user/update/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {
                id: data.field.resetUserId,
                password: hex_md5(data.field.resetPassword)
            },
            method: 'POST',
            success: function (res) {
                if (res.code === 200){
                    layer.closeAll();
                    layer.msg("重置密码成功", {icon: 1});
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                }else {
                    layer.msg(res.msg, {icon: 2})
                }
            }
        })
        return false;
    })
 
});
 
function tableReload(child) {
    var searchData = {};
    $.each($('#search-box [name]').serializeArray(), function() {
        searchData[this.name] = this.value;
    });
    (child ? parent.tableIns : tableIns).reload({
        where: searchData,
        page: {
            curr: pageCurr
        }
    });
}