自动化立体仓库 - WMS系统
luxiaotao1123
2022-03-26 3602043d8c79939e1feebb22e4dfcae629d7fde6
src/main/webapp/static/js/order/out.js
@@ -1,7 +1,5 @@
var pageCurr;
var tableData;
var insTb2;
const sensorType = 5;
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).extend({
@@ -18,96 +16,41 @@
    var treeTable = layui.treeTable;
    var xmSelect = layui.xmSelect;
    // 设备类型数据
    var modelTb = treeTable.render({
        elem: '#nothing',
        url: baseUrl+'/sensorModel/list/auth',
        headers: {token: localStorage.getItem('token')},
        tree: {
            iconIndex: 2,           // 折叠图标显示在第几列
            isPidData: true,        // 是否是id、pid形式数据
            idName: 'id',           // id字段名称
            pidName: 'parentId'     // pid字段名称
        },
        cols: [[
            {type: 'checkbox'}
            ,{type: 'numbers'}
            ,{field: 'name', align: 'left',title: '名称', minWidth: 150}
        ]],
        done: function (data) {
            modelTb.expandAll();
        }
    });
    insTb2 = table.render({
        elem: '#sensorTable',
        elem: '#orderDetlTable',
        headers: {token: localStorage.getItem('token')},
        url: baseUrl+'/sensor/list/auth?sensor_type='+sensorType,
        url: baseUrl+'/orderDetl/list/auth',
        page: true,
        limit: 15,
        limits: [15, 30, 50, 100, 200, 500],
        toolbar: '#sensorToolbar',
        height: 'full-100',
        toolbar: '#orderDetToolbar',
        height: 'full-120',
        cols: [[
            {type: 'checkbox'}
            // ,{field: 'id', align: 'center',title: 'ID'}
            ,{field: 'hostId$', align: 'center',title: '所属项目', templet: '#hostTpl', width: 130}
            // ,{field: 'sensorType$', align: 'center',title: '设备类型'}
            ,{field: 'uuid', align: 'center',title: '设备编码', width: 160}
            ,{field: 'location', align: 'center',title: '地理位置', width: 180, style: 'font-size: 13px', hide: false}
            ,{field: 'sensorModel$', align: 'center',title: '设备型号', width: 130, hide: false}
            // ,{field: 'ccid', align: 'center',title: 'CCID'}
            ,{field: 'sim', align: 'center',title: 'sim卡号',hide: true}
            // ,{field: 'name', align: 'center',title: '设备名'}
            // ,{field: 'topic', align: 'center',title: '主题'}
            // ,{field: 'ip', align: 'center',title: 'ip'}
            // ,{field: 'port', align: 'center',title: '端口'}
            // ,{field: 'data', align: 'center',title: '报文'}
            // ,{field: 'lon', align: 'center',title: '经度'}
            // ,{field: 'lat', align: 'center',title: '纬度'}
            ,{field: 'signal', align: 'center',title: '信号值'}
            ,{field: 'battery', align: 'center',title: '电量',hide: true}
            // ,{field: 'charge$', align: 'center',title: '充电状态'}
            // ,{field: 'tiltX', align: 'center',title: 'x轴倾斜'}
            // ,{field: 'tiltY', align: 'center',title: 'y轴倾斜'}
            // ,{field: 'tiltZ', align: 'center',title: 'z轴倾斜'}
            // ,{field: 'tilt$', align: 'center',title: '倾斜状态'}
            ,{field: 'tempe', align: 'center',title: '温度', hide: true}
            ,{
                field: 'online', title: '网络', templet: function (d) {
                    var strs = [
                        '<span class="text-success">在线</span>',
                        '<span class="text-danger">离线</span>'
                    ];
                    return strs[d.online?0:1];
                }, align: 'center', sort: true
            }
            ,{
                field: 'error', title: '状态', templet: function (d) {
                    var strs = [
                        '<span class="layui-badge layui-badge-red">异常</span>',
                        '<span class="layui-badge layui-badge-green">正常</span>'
                    ];
                    return strs[d.error?0:1];
                }, align: 'center', sort: false, minWidth: 70, hide: false
            }
            // ,{field: 'worn$', align: 'center',title: '破损状态'}
            // ,{field: 'overflow$', align: 'center',title: '定点水位'}
            // ,{field: 'nsAngle', align: 'center',title: '南北角度'}
            // ,{field: 'waterGage', align: 'center',title: '管道水压'}
            // ,{field: 'harmGas', align: 'center',title: '有害气体'}
            // ,{field: 'lnGas', align: 'center',title: '可燃气体'}
            // ,{field: 'hsGas', align: 'center',title: '硫化氢气体'}
            // ,{field: 'reserve0', align: 'center',title: '预留0'}
            // ,{field: 'reserve1', align: 'center',title: '预留1'}
            // ,{field: 'status$', align: 'center',title: '状态', templet: '#statusTpl', width: 120, unresize: true}
            // ,{field: 'createTime$', align: 'center',title: '添加时间'}
            ,{type: 'numbers', title: '#'}
            ,{field: 'orderNo', align: 'center',title: '单据编号', templet: '#orderNoTpl', width: 160}
            ,{field: 'matnr', align: 'center',title: '商品编码', width: 160}
            ,{field: 'maktx', align: 'center',title: '商品名称', width: 200}
            ,{field: 'batch', align: 'center',title: '批号'}
            ,{field: 'specs', align: 'center',title: '规格'}
            // ,{field: 'anfme', align: 'center',title: '数量'}
            // ,{field: 'qty', align: 'center',title: '作业数量', style: 'font-weight: bold'}
            ,{field: 'enableQty', align: 'center',title: '待出数量', style: 'font-weight: bold'}
            // ,{field: 'name', align: 'center',title: '名称'}
            // ,{field: 'model', align: 'center',title: '型号'}
            ,{field: 'unit', align: 'center',title: '单位', hide: true}
            ,{field: 'barcode', align: 'center',title: '商品条码', hide: true}
            // ,{field: 'supplier', align: 'center',title: '供应商'}
            // ,{field: 'unitPrice', align: 'center',title: '单价'}
            // ,{field: 'itemNum', align: 'center',title: '品项数'}
            // ,{field: 'count', align: 'center',title: '数量'}
            // ,{field: 'weight', align: 'center',title: '重量'}
            // ,{field: 'status$', align: 'center',title: '状态'}
            // ,{field: 'createBy$', align: 'center',title: '添加人员'}
            ,{field: 'updateTime$', align: 'center',title: '更新时间', minWidth: 170}
            // ,{field: 'createTime$', align: 'center',title: '添加时间'}
            // ,{field: 'updateBy$', align: 'center',title: '修改人员'}
            ,{field: 'addr', align: 'center',title: '详细地址', hide: true}
            ,{field: 'memo', align: 'center',title: '备注', hide: true}
            // ,{field: 'updateTime$', align: 'center',title: '修改时间'}
            // ,{field: 'memo', align: 'center',title: '备注'}
            ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width: 160}
        ]],
        request: {
@@ -129,7 +72,6 @@
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            tableData = table.cache.sensorTable;
            pageCurr=curr;
            limit();
        }
@@ -141,9 +83,16 @@
    });
    /* 表格2头工具栏点击事件 */
    table.on('toolbar(sensorTable)', function (obj) {
        if (obj.event === 'add') { // 添加
            showEditModel()
    table.on('toolbar(orderDetlTable)', function (obj) {
        var checkStatus = table.checkStatus(obj.config.id).data;
        if (obj.event === 'pakoutPreview') { // 添加
            if (checkStatus.length === 0) {
                layer.msg('请选择至少一条出库明细', {icon: 2});
                return;
            }
            pakoutPreview(checkStatus.map(function (d) {
                return d.id;
            }));
        } else if (obj.event === 'del') { // 删除
            var checkRows = table.checkStatus('sensorTable');
            if (checkRows.data.length === 0) {
@@ -158,61 +107,85 @@
    });
    /* 表格2工具条点击事件 */
    table.on('tool(sensorTable)', function (obj) {
    table.on('tool(orderDetlTable)', function (obj) {
        var data = obj.data;
        switch (obj.event) {
            case 'detl':
                top.sensorByDetl = data.id;
            // 出库
            case 'pakoutPreview':
                pakoutPreview([data.id])
                break;
            // 编辑
            case 'edit':
                showEditModel(data);
                break;
            // 删除
            case 'del':
                var ids = [data.id];
                doDelSensor({ids: ids});
                break;
            // 基点定位
            case 'lbs':
                notice.msg('请求中...', {icon: 4, position: "topCenter"});
                var param = {
                    uuid: data.uuid,
                    event: obj.event
                };
                $.ajax({
                    url: baseUrl+"/main/command/v1/auth",
                    headers: {'token': localStorage.getItem('token')},
                    data: JSON.stringify(param),
                    contentType:'application/json;charset=UTF-8',
                    method: 'POST',
                    success: function (res) {
                        notice.destroy();
                        if (res.code === 200){
                            admin.open({
                                title: '终端响应',
                                url: 'callback.html',
                                area: '360px',
                                data: {
                                    request: param,
                                    response: res.data
                                },
                                tpl: true
                            });
                        } else if (res.code === 403){
                            top.location.href = baseUrl+"/";
                        }else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }
                })
                break
        }
    });
    // 设备明细展开回调
    window.onSensorDetlDialog = function () {
    };
    function pakoutPreview(ids) {
        var loadIndex = layer.load(2);
        $.ajax({
            url: baseUrl + "/out/pakout/preview/auth",
            headers: {'token': localStorage.getItem('token')},
            contentType: 'application/json;charset=UTF-8',
            data: JSON.stringify(ids),
            method: 'POST',
            success: function (res) {
                layer.close(loadIndex);
                if (res.code === 200){
                    layer.open({
                        type: 1
                        ,title: false
                        ,closeBtn: false
                        ,offset: '100px'
                        ,area: '1000px'
                        ,shade: 0.5
                        ,shadeClose: true
                        ,btn: ['立即生成', '稍后处理']
                        ,btnAlign: 'c'
                        ,moveType: 1 //拖拽模式,0或者1
                        ,content: $('#pakoutPreviewBox')
                        ,success: function(layero, index){
                            console.log(res.data)
                            table.render({
                                elem: '#stoPreTab',
                                data: res.data,
                                page: false,
                                cellMinWidth: 100,
                                height: 432,
                                cols: [[
                                    {field: 'title', title: '商品', merge: true, align: 'center'},
                                    {field: 'anfme', title: '总数量', merge: ['title'], align: 'center', style: 'font-weight: bold', width: 90},
                                    {field: 'type', title: '仓库', merge: true, align: 'center', templet: '#typeTpl', width: 90},
                                    {field: 'locNo', title: '货位', align: 'center'},
                                    {field: 'prior$', title: '推荐货位', align: 'center', width: 100},
                                    {field: 'reduce', title: '数量', align: 'center', width: 90, style: 'font-weight: bold'},
                                    // {field: 'remQty', title: '余量', align: 'center', width: 80},
                                    {field: 'total', title: '总量', align: 'center', width: 90},
                                ]],
                                done: function () {
                                    $('.layui-table-body.layui-table-main').css("overflow", "auto")
                                }
                            });
                        }
                        ,yes: function(index, layero){
                            //按钮【马上拣货】的回调
                            stockOut(data.orderNo);
                        }
                        ,btn2: function(index, layero){
                            //按钮【稍后处理】的回调
                            layer.close(index)
                            //return false 开启该代码可禁止点击该按钮关闭
                        }
                    });
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                } else {
                    layer.msg(res.msg, {icon: 2})
                }
            }
        })
    }
    /* 显示表单弹窗 */