自动化立体仓库 - WMS系统
luxiaotao1123
2022-03-26 580a85c33e14a7d83d63de555bafc943547015f8
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
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"  // 配置模块所在的目录
}).use(['table','laydate', 'form',  '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 insTb = table.render({
        elem: '#originTable',
        url: baseUrl + '/order/nav/list/auth',
        height: 'full-120',
        headers: {token: localStorage.getItem('token')},
        request: {
            pageName: 'curr',
            pageSize: 'limit'
        },
        page: false,
        parseData: function (res) {
            return {
                'code': res.code,
                'msg': res.msg,
                'data': res.data
            }
        },
        response: {
            statusCode: 200
        },
        // toolbar: ['<p>',
        //     '<button lay-event="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
        //     '<button lay-event="edit" class="layui-btn layui-btn-sm layui-btn-warm icon-btn"><i class="layui-icon">&#xe642;</i>修改</button>&nbsp;',
        //     '<button lay-event="del" class="layui-btn layui-btn-sm layui-btn-danger icon-btn"><i class="layui-icon">&#xe640;</i>删除</button>',
        //     '</p>'].join(''),
        defaultToolbar: [],
        cols: [[
            // {type: 'numbers', title: '#'},
            {field: 'orderTime', title: '日期'},
            {field: 'orderNo', title: '单据编号', align: 'center'}
        ]],
        done: function (res, curr, count) {
            $('#dictTable+.layui-table-view .layui-table-body tbody>tr:first').trigger('click');
        }
    });
 
    /* 表格搜索 */
    form.on('submit(originTableSearch)', function (data) {
        insTb.reload({where: data.field});
        return false;
    });
 
    /* 表格重置 */
    form.on('submit(originTbReset)', function (data) {
        insTb.reload({where: null});
        insTb2.reload({where: {host_id: null}, page: {curr: 1}});
        return false;
    });
 
    /* 表格头工具栏点击事件 */
    table.on('toolbar(originTable)', function (obj) {
        if (obj.event === 'add') { // 添加
            showEdit();
        } else if (obj.event === 'edit') { // 修改
            if (selObj == null) {
                return;
            }
            showEdit(selObj.data);
        } else if (obj.event === 'del') { // 删除
            if (selObj == null) {
                return;
            }
            doDel(selObj);
        }
    });
 
    /* 监听行单击事件 */
    var selObj;
    table.on('row(originTable)', function (obj) {
        selObj = obj;
        obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
        insTb2.reload({where: {order_id: obj.data.id}, page: {curr: 1}});
    });
 
    /* 显示表单弹窗 */
    function showEdit(mData) {
        admin.open({
            type: 1,
            title: (mData ? '修改' : '添加') + '项目',
            content: $('#hostEditDialog').html(),
            success: function (layero, dIndex) {
                // 回显表单数据
                form.val('hostEditForm', mData);
                // 表单提交事件
                form.on('submit(hostEditSubmit)', function (data) {
                    var loadIndex = layer.load(2);
                    $.ajax({
                        url: baseUrl+"/host/"+(mData?'update':'add')+"/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: data.field,
                        method: 'POST',
                        success: function (res) {
                            layer.close(loadIndex);
                            selObj = null;
                            if (res.code === 200){
                                layer.close(dIndex);
                                layer.msg(res.msg, {icon: 1});
                                insTb.reload();
                            } else if (res.code === 403){
                                top.location.href = baseUrl+"/";
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }
                    })
                    return false;
                });
            }
        });
    }
 
    /* 删除 */
    function doDel(obj) {
        layer.confirm('确定要删除此单据类型吗?', {
            skin: 'layui-layer-admin',
            shade: .1
        }, function (i) {
            layer.close(i);
            var loadIndex = layer.load(2);
            $.ajax({
                url: baseUrl+"/host/delete/one/auth",
                headers: {'token': localStorage.getItem('token')},
                data: {param: JSON.stringify(obj.data)},
                method: 'POST',
                success: function (res) {
                    selObj = null;
                    layer.close(loadIndex);
                    if (res.code === 200){
                        layer.closeAll();
                        insTb.reload();
                        $('#dictTable+.layui-table-view .layui-table-body tbody>tr:first').trigger('click');
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }
            })
        });
    }
 
})