自动化立体仓库 - WMS系统
lty
3 天以前 8e943b7104561c3b14cf223016698709c5ade4b5
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
var insTb;
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"  // 配置模块所在的目录
}).use(['table','laydate', 'form',  'admin', 'tableX'], 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 tableX = layui.tableX;
 
    /****************************************** 左边表 *************************************************/
 
    var initTable = function() {
        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
            },
            text: {none: typeof I18n !== 'undefined' ? I18n.t('no_data') : '暂无数据'},
            // 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: typeof I18n !== 'undefined' ? I18n.t('date') : '日期'},
                {field: 'orderNo', title: typeof I18n !== 'undefined' ? I18n.t('order_no') : '单据编号', align: 'center'}
            ]],
            done: function (res, curr, count) {
                if (typeof I18n !== 'undefined' && I18n.isReady()) {
                    I18n.updatePage();
                    if (count === 0) {
                        $('.layui-table-empty').text(I18n.t('no_data'));
                    }
                }
                $('#dictTable+.layui-table-view .layui-table-body tbody>tr:first').trigger('click');
    
                // 绑定鼠标右键
                tableX.bindCtxMenu('originTable', function (d) {
                    return [
                        {
                            icon: 'layui-icon layui-icon-ok',
                            name: typeof I18n !== 'undefined' ? I18n.t('one_click_outbound') : '一键出库',
                            click: function (d) {
                                autoOut(d.id);
                            }
                        }
                    ]
    
                })
    
            }
        });
    }
 
    if (typeof I18n !== 'undefined' && I18n.isReady()) {
        initTable();
    } else {
        $(document).on('i18n:ready', function() {
            initTable();
        });
    }
 
    // 监听语言切换
    $(document).on('i18n:languageChanged', function () {
        insTb.reload({
            text: {none: I18n.t('no_data')},
            cols: [[
                {field: 'orderTime', title: I18n.t('date')},
                {field: 'orderNo', title: I18n.t('order_no'), align: 'center'}
            ]]
        });
    });
 
    /* 表格搜索 */
    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: 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 ? (typeof I18n !== 'undefined' ? I18n.t('modify_project') : '修改项目') : (typeof I18n !== 'undefined' ? I18n.t('add_project') : '添加项目')),
            content: $('#hostEditDialog').html(),
            success: function (layero, dIndex) {
                I18n.updatePage($(layero));
                // 回显表单数据
                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(typeof I18n !== 'undefined' ? I18n.t('confirm_delete_doc_type') : '确定要删除此单据类型吗?', {
            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});
                    }
                }
            })
        });
    }
 
})