自动化立体仓库 - WMS系统
chen.llin
3 天以前 74951023b54f1789d1244fe923219d467487d771
src/main/webapp/static/js/user/user.js
@@ -23,14 +23,15 @@
        height: 'full-100',
        cols: [[
            {type: 'checkbox'}
            ,{field: 'hostName', align: 'center',title: '授权商户', templet: '#hostTpl', width: 140}
            // ,{field: 'hostName', align: 'center',title: '授权商户', templet: '#hostTpl', width: 140}
            // ,{field: 'nickname', align: 'center',title: '用户名'}
            ,{field: 'username', align: 'center',title: '用户名'}
            ,{field: 'username', align: 'center',title: '登录账户'}
            ,{field: 'mobile', align: 'center',title: '手机号'}
            // ,{field: 'deptName', align: 'center',title: '所属部门'}
            ,{field: 'deptName', align: 'center',title: '所属部门'}
            ,{field: 'roleName', align: 'center',title: '角色'}
            ,{field: 'email', align: 'center',title: '邮箱'}
            // ,{field: 'sex$', align: 'center',title: '性别'}
            ,{field: 'adLogin$', align: 'center',title: 'AD登录', templet: '#adLoginTpl', width: 100, unresize: true}
            ,{field: 'createTime$', align: 'center',title: '注册时间', hide: true}
            ,{field: 'status$', align: 'center',title: '状态', templet: '#statusTpl', width: 120, unresize: true}
@@ -68,18 +69,17 @@
    /* 表格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') { // 删除
            var checkRows = table.checkStatus('userTable');
            if (checkRows.data.length === 0) {
            if (checkStatus.length === 0) {
                layer.msg('请选择要删除的数据', {icon: 2});
                return;
            }
            var ids = checkRows.data.map(function (d) {
            del(checkStatus.map(function (d) {
                return d.id;
            });
            doDelUser({ids: ids});
            }));
        }
    });
@@ -89,6 +89,16 @@
        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});
        })
    })
    // 修改AD登录状态
    form.on('switch(adLoginSwitch)', 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, adLogin: data[this.name]}, function (res) {
            layer.msg(res.msg, {icon: 1});
        })
    })
@@ -103,8 +113,7 @@
                break;
            // 删除
            case 'del':
                var ids = [obj.id];
                doDelUser({ids: ids});
                del([data.id]);
                break;
            // 重置密码
            case 'resetPwd':
@@ -134,12 +143,46 @@
            content: $('#editDialog').html(),
            success: function (layero, dIndex) {
                // 回显表单数据
                form.val('detail', mData);
                if (mData) {
                    form.val('detail', mData);
                    // 处理AD登录复选框的回显(编辑用户时)
                    if (mData.adLogin === 1 || mData.adLogin === '1') {
                        $('input[name="adLogin"]').prop('checked', true);
                    } else {
                        $('input[name="adLogin"]').prop('checked', false);
                    }
                } else {
                    // 新增用户时,确保AD登录默认为未选中
                    $('input[name="adLogin"]').prop('checked', false);
                    // 清空表单
                    form.val('detail', {
                        username: '',
                        mobile: '',
                        email: '',
                        roleId: '',
                        roleName: '',
                        deptId: '',
                        deptName: '',
                        adLogin: 0
                    });
                }
                // 重新渲染表单,确保开关控件正确显示
                form.render('checkbox');
                // 表单提交事件
                form.on('submit(editSubmit)', function (data) {
                    if (isEmpty(data.field.roleId)) {
                        layer.msg('请选择角色', {icon: 2});
                        return false;
                    }
                    if (isEmpty(data.field.deptId)) {
                        layer.msg('请选择部门', {icon: 2});
                        return false;
                    }
                    // 处理AD登录复选框的值
                    if (data.field.adLogin === '1' || data.field.adLogin === true) {
                        data.field.adLogin = 1;
                    } else {
                        data.field.adLogin = 0;
                    }
                    var loadIndex = layer.load(2);
                    $.ajax({
@@ -171,7 +214,7 @@
    /* 删除订单 */
    function doDelUser(obj) {
    function del(ids) {
        layer.confirm('确定要删除选中数据吗?', {
            skin: 'layui-layer-admin',
            shade: .1
@@ -181,7 +224,7 @@
            $.ajax({
                url: baseUrl+"/user/delete/auth",
                headers: {'token': localStorage.getItem('token')},
                data: {ids: obj.ids},
                data: {ids: ids},
                method: 'POST',
                success: function (res) {
                    layer.close(loadIndex);