自动化立体仓库 - WMS系统
#
lsh
2024-12-10 dad49ebf53f8c11042f4de06157af7e3dd6e3c3e
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
layui.use(['form', 'tree'], function() {
    var form = layui.form;
    var tree = layui.tree;
    var $ = layui.jquery;
    var layer = layui.layer;
 
    // 权限分配树形图
    var powerTree = tree.render({
        elem: '#power-tree',
        id: 'powerTree',
        showCheckbox: true,
        data: parent.powerTreeData,
        isJump: true
    });
 
    loadPower();
    function loadPower(){
        $.ajax({
            url: baseUrl+"/power/"+parent.roleId+"/auth",
            headers: {'token': localStorage.getItem('token')},
            method: 'GET',
            beforeSend: function () {
                layer.load(1, {shade: [0.1,'#fff']});
            },
            success: function (res) {
                if (res.code === 200){
                    tree.setChecked('powerTree', res.data);
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                } else {
                    layer.msg(res.msg)
                }
                layer.closeAll("loading");
            }
        });
    }
 
    // 数据修改动作
    form.on('submit(save)', function () {
        var param = [];
        var checkData = tree.getChecked('powerTree');
        checkData.map(function (obj) {
            obj.children.map(function (resource) {
 
                var childrens = [];
                resource.children.map(function (resource) {
                    childrens.push(resource.id);
                });
                var one = {
                    'two': resource.id,
                    'three': childrens
                };
                param.push(one);
            })
        });
        $.ajax({
            url: baseUrl+"/power/auth",
            traditional: true,
            headers: {'token': localStorage.getItem('token')},
            data: {
                'roleId': parent.roleId,
                'powers': JSON.stringify(param)
            },
            method: 'POST',
            success: function (res) {
                if (res.code === 200){
                    parent.layer.closeAll();
                    parent.layer.msg(res.msg);
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                } else {
                    layer.msg(res.msg)
                }
            }
        });
    });
});
 
// 关闭动作
$(document).on('click','#data-detail-close', function () {
    parent.layer.closeAll();
});