自动化立体仓库 - WMS系统
pang.jiabao
2025-02-20 831dbe10d1c0975b0de4251b67b939347b079006
src/main/webapp/static/js/order/order.js
@@ -1,5 +1,8 @@
var insTbCount = 0;
var printMatCodeNos = [];
var selectedData = [];
var selectType = 'one';
var queryWhere = {};
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect', 'laydate'], function () {
@@ -41,7 +44,8 @@
        page: true,
        cellMinWidth: 100,
        cols: [[
            {type: 'numbers'},
            {type: 'checkbox'},
            {type: 'numbers', title: '序号'},
            {field: 'orderNo', title: '单据编号'},
            {field: 'docType$', align: 'center', title: '类型',  minWidth: 160, width: 160},
            {align: 'center', title: '明细', toolbar: '#tbLook', minWidth: 160, width: 160},
@@ -73,37 +77,87 @@
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            var selectedOrderNos = selectedData.map(item => item.orderNo);
            var indexArr = []
            res.data.forEach(function (item,index) {
                  if (selectedOrderNos.includes(item.orderNo)) {
                      indexArr.push(index)
                  }
            })
            // 重新渲染
            table.setRowChecked('order',{
                index: indexArr
            });
            insTbCount = count;
        }
    });
    table.on('checkbox(order)', function (obj) {
        if (obj.type === 'all' && obj.checked) {
            selectType = 'all'
        } else if (obj.type === 'one' && obj.checked) {
            selectType = 'one'
            selectedData.push(obj.data); // 选中时保存数据
        } else if (obj.type === 'one' && !obj.checked && obj.index !== undefined) {
            selectType = 'one'
            selectedData = selectedData.filter(item => item.orderNo !== obj.data.orderNo); // 取消时移除数据
        } else if (obj.type === 'all' && !obj.checked && obj.index === undefined) {
            selectType = 'one'
            selectedData = [];
        }
    });
    // 搜索
    form.on('submit(tbSearch)', function (data) {
        insTb.reload({where: data.field, page: {curr: 1}});
        queryWhere = data.field
    });
    // 导出所有
    // 导出
    form.on('submit(exportAll)', function (data) {
        layer.closeAll();
        layer.load(1, {shade: [0.1,'#fff']});
        $.ajax({
            url: baseUrl+"/order/exportAll/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {},
            dataType:'json',
            contentType:'application/json;charset=UTF-8',
            method: 'POST',
            success: function (res) {
                if (res.code === 200) {
                    table.exportFile(['单据编号','数量','作业数量','完成数量','商品编码','商品名称','规格','重量','货主id','货物形态id'],res.data,'xls');
                } else if (res.code === 403) {
                    top.location.href = baseUrl+"/";
        layer.confirm('确定导出Excel吗', {shadeClose: true}, function () {
            layer.closeAll();
            layer.load(1, {shade: [0.1, '#fff']});
            var reqData = {};
            reqData.type = selectType;
            if (reqData.type === 'one') {
                reqData.orderNoList = selectedData.map(item => item.orderNo);
            } else {
                if (Object.keys(queryWhere).length === 0) {
                    reqData.queryWhere = {
                        create_time: "",
                        cstmr_name: "",
                        doc_type: "",
                        oper_memb: "",
                        order_no: "",
                        settle: ""
                    }
                } else {
                    layer.msg(res.msg)
                    reqData.queryWhere = queryWhere
                }
            }
            $.ajax({
                url: baseUrl + "/order/definedExcelExport/auth",
                headers: {'token': localStorage.getItem('token')},
                data: JSON.stringify(reqData),
                contentType: 'application/json;charset=UTF-8',
                method: 'POST',
                xhrFields: {
                    responseType: 'blob'  // 处理返回的文件流
                },
                success: function (res) {
                    var link = document.createElement('a');
                    link.href = URL.createObjectURL(res);  // 使用 Blob 对象生成临时 URL
                    link.download = new Date().getTime() + '.xlsx';  // 设置下载的文件名
                    document.body.appendChild(link);
                    link.click();  // 触发下载
                    document.body.removeChild(link);
                }
            });
            layer.closeAll('loading');
        });
        layer.closeAll('loading');
    });
    // 添加