自动化立体仓库 - WMS系统
chen.lin
7 小时以前 fc51cbb9cd2514f7a9c2a22f41572666b5cbf1d9
src/main/webapp/views/erpMaterialwwout/materialwwout.html
@@ -81,7 +81,9 @@
            <el-form-item label="">
                <el-button type="primary" @click="dialogVisible = true">数据查询</el-button>
            </el-form-item>
            <el-form-item label="">
               <el-button type="success" @click="manualSync()">手动同步</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="tableData" border style="width: 100%" row-key="id" @selection-change="handleSelectionChange" max-height="650">
            <el-table-column type="selection" >
@@ -498,14 +500,18 @@
                        });
                        return ;
                    }
                    ElementPlus.ElMessageBox.confirm('确定打印吗?')
                        .then(() => {
                            print(izPrint,0)
                        })
                        .catch(() => {
                            // catch error
                        })
                    // 打印前确认
                    if (izPrint === '是') {
                        ElementPlus.ElMessageBox.confirm('确定打印吗?')
                            .then(() => {
                                print(izPrint, 0);
                            })
                            .catch(() => {
                                // 取消
                            });
                    } else {
                        print(izPrint, 0);
                    }
                }
                function fnPrintView(izPrint){
@@ -516,120 +522,153 @@
                        });
                        return ;
                    }
                    print(izPrint,0)
                    // 打印预览直接调用打印接口(后端不校验出库完成状态)
                    print(izPrint, 0);
                }
                // 手动同步
                function manualSync() {
                    if (selectList.value.length === 0){
                        ElementPlus.ElMessage({
                            message: "请先选择要同步的数据",
                            type: 'error'
                        });
                        return ;
                    }
                    ElementPlus.ElMessageBox.confirm('确定要同步选中的数据到WMS吗?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        const loading = ElementPlus.ElLoading.service({
                            lock: true,
                            text: '同步中...',
                            background: 'rgba(0, 0, 0, 0.7)',
                        });
                        // 优先使用选中的数据列表进行同步
                        $.ajax({
                            url: "http://127.0.0.1:8133/api/materialWwOut/sync/manual",
                            headers: {
                                'token': localStorage.getItem('token')
                            },
                            data: JSON.stringify({
                                wwRecords: JSON.stringify(selectList.value)
                            }),
                            contentType: 'application/json;charset=UTF-8',
                            method: 'POST',
                            success: function(res) {
                                loading.close();
                                if (res.code == 200) {
                                    ElementPlus.ElMessage({
                                        message: res.data.message || "同步任务已提交",
                                        type: 'success'
                                    });
                                    // 刷新列表
                                    setTimeout(() => {
                                        page();
                                    }, 2000);
                                } else {
                                    ElementPlus.ElMessage({
                                        message: res.msg || "同步失败",
                                        type: 'error'
                                    });
                                }
                            },
                            error: function() {
                                loading.close();
                                ElementPlus.ElMessage({
                                    message: "同步请求失败",
                                    type: 'error'
                                });
                            }
                        });
                    }).catch(() => {
                        // 取消
                    });
                }
                function print(izPrint,izRed){
                    const LODOP = getLodop()
                    const loading = ElementPlus.ElLoading.service({
                        lock: true,
                        text: 'Loading',
                        background: 'rgba(0, 0, 0, 0.7)',
                    })
                    let data = JSON.parse(JSON.stringify(tableSearchParam.value))
                    data.curr = currentPage.value
                    data.limit = pageSize.value
                    if (tableSearchParam.value.datetime != null) {
                        data.datetime = null
                        data.create_time = tableSearchParam.value.datetime[0] + " - " + tableSearchParam.value.datetime[1]
                    }
                    $.ajax({
                        url: "http://127.0.0.1:8133/mo/materialwwout/updateprint",
                        url:"http://127.0.0.1:8133/mo/materialwwout/print",
                        headers: {
                            'token': localStorage.getItem('token')
                        },
                        data: data,
                        data: JSON.stringify({
                            wwRecords : JSON.stringify(selectList.value),
                            izPrint : izPrint,
                            izRed : izRed
                        }),
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'GET',
                        method: 'POST',
                        success: function(res) {
                            loading.close()
                            if (res.code == 200) {
                                ElementPlus.ElMessage({
                                    message: "打印状态更新成功!",
                                    message: "获取数据完成,等待唤起打印",
                                    type: 'success'
                                });
                                page()
                                LODOP.PRINT_INITA(0,0,800,1100,"委外加工出库单");
                                LODOP.SET_PRINT_PAGESIZE(1,0,0,"A4");
                                LODOP.SET_PRINT_MODE("PRINT_NOCOLLATE",1);
                                if(izRed==1)
                                {
                                    LODOP.ADD_PRINT_TEXT(28,268,331,36,"委外加工出库单(红字)");
                                }
                                else{
                                    LODOP.ADD_PRINT_TEXT(28,268,331,36,"委外加工出库单");
                                }
                                LODOP.SET_PRINT_STYLEA(0,"FontSize",20);
                                LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                                LODOP.ADD_PRINT_TEXT(69,21,213,25,"供应商:"+depName.value);
                                LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
                                LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                                LODOP.ADD_PRINT_TEXT(70,268,213,25,"开工日期:"+dateFormat("YYYY-mm-dd", tableSearchParam.value.dateStart)+" 到 "+dateFormat("YYYY-mm-dd", tableSearchParam.value.dateEnd));
                                LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
                                LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                                LODOP.ADD_PRINT_TABLE(96,16,2000,960,CreateTable(res.data));
                                LODOP.SET_PRINT_STYLEA(0,"TableHeightScope",1);
                                LODOP.SET_PRINT_MODE("FULL_WIDTH_FOR_OVERFLOW",true);
                                // 根据izPrint参数决定是打印还是预览
                                // izPrint=="是":直接打印,弹出打印对话框(不弹出预览窗口)
                                // izPrint=="否":打印预览,弹出预览窗口
                                if(izPrint=="是")
                                {
                                    LODOP.PRINT();
                                }
                                else{
                                    // 打印预览,弹出预览窗口
                                    LODOP.PREVIEW();
                                }
                            } else if (res.code === 403) {
                                top.location.href = baseUrl + "/";
                            } else {
                                ElementPlus.ElMessage({
                                    message: res.msg,
                                // 后端返回错误信息(校验失败)
                                ElementPlus.ElMessageBox.alert(res.msg || "打印失败", '错误', {
                                    confirmButtonText: '确定',
                                    type: 'error'
                                });
                            }
                        },
                        error: function(xhr, status, error) {
                            loading.close()
                            ElementPlus.ElMessage({
                                message: "打印请求失败,请稍后重试",
                                type: 'error'
                            });
                        }
                    });
                    var gridData = [];
                    var listVen=[];
                    for(var i=0; i<selectList.value.length; i++) {
                        var curRowData = selectList.value[i]
                        var izExist=false;
                        for (var j = 0; j < listVen.length; j++) {
                            if(curRowData.venId === listVen[j].venId)
                            {
                                izExist=true;
                                break;
                            }
                        }
                        if(izExist === false)
                        {
                            var o={};
                            o.venId=curRowData.venId;
                            o.venName=curRowData.venName;
                            listVen.push(o);
                        }
                        gridData.push(curRowData);
                    }
                    LODOP.PRINT_INITA(0,0,800,1100,"委外加工出库单");
//        LODOP.SET_PRINT_PAGESIZE(1,0,0,"A5");
//        LODOP.SET_PRINT_PAGESIZE(1,870,520,"");
//        LODOP.PRINT_INITA(0,0,800,500,"委外加工出库单");
//        LODOP.SET_PRINT_PAGESIZE(1,800,500,"");
                    LODOP.SET_PRINT_MODE("PRINT_NOCOLLATE",1);
                    LODOP.ADD_PRINT_TEXT(28,375,331,36,"委外加工出库单");
                    LODOP.SET_PRINT_STYLEA(0,"FontSize",20);
                    LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                    LODOP.ADD_PRINT_TEXT(69,128,413,25,"开工日期:"+dateFormat("YYYY-mm-dd", tableSearchParam.value.dateStart)+" 到 "+dateFormat("YYYY-mm-dd", tableSearchParam.value.dateEnd));
                    LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
                    LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                    LODOP.ADD_PRINT_TEXT(69,451,196,25,"单据日期:"+dateFormat("YYYY-mm-dd", new Date()));
                    LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
                    LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                    LODOP.ADD_PRINT_TEXT(69,645,176,25,"发料人:");
                    LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
                    LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                    LODOP.ADD_PRINT_TABLE(96,123,2000,960,CreateTable(gridData));
                    LODOP.SET_PRINT_STYLEA(0,"TableHeightScope",1);
                    LODOP.SET_PRINT_MODE("FULL_WIDTH_FOR_OVERFLOW",true);
                    LODOP.PRINT_DESIGN();
                    //        if(izPrint=="是")
                    //        {
                    //            LODOP.PRINT();
                    //        }
                    //        else{
                    //            LODOP.PREVIEW();
                    //        }
                }
                function dateFormat(fmt, date) {
@@ -653,27 +692,24 @@
                }
                function  CreateTable(result) {
//        var css =" <style> table,td,th {border: 1px solid black;border-style: solid;border-collapse: collapse;font-size: 15px;}</style><table border=1>";
                    var css = "<style> table,td,th {table-layout: fixed;border: 1px black solid;border-collapse: collapse;font-size: 15px;}</style><table>";
                    var css = "<style> table,td,th {table-layout: fixed;border: 1px black solid;border-collapse: collapse;font-size: 13px;}</style><table>";
                    //第一行
                    var th = "<thead><tr style='height:30px'>" +
                    var th = "<thead><tr style='height:20px'>" +
                        "<th  >序号</th>" +
                        "<th  >供应商</th>" +
                        "<th  >物料编码</th>" +
                        "<th  >物料名称</th>" +
                        "<th  >物料规格</th>" +
                        "<th >规格</th>" +
                        "<th  >单位</th>" +
                        "<th  >仓库</th>" +
                        "<th  >应发数量</th>" +
                        "<th  >未发数量</th>" +
                        "<th  >实发数量</th>" +
                        "</tr></thead>";
                    var td="";
                    var row=1;
                    for (var i = 0; i <result.length; i++) {
                        td = td+"<tr style='height:30px'><td style='width:30px;' align='center' >"+(row)+"</td><td style='width:170px;word-wrap:break-word;word-break:break-all;'  align='left'  >" + result[i].venName + "</td><td style='width:90px;'  align='left'  >" + result[i].invCode + "</td><td style='width:110px;word-wrap:break-word;word-break:break-all;'  align='left'  >" + result[i].invName + "</td> <td style='width:60px;'  align='left'  >" + result[i].invStd + "</td>  <td style='width:40px;'  align='left'  >" + result[i].unit + "</td><td style='width:80px;'  align='left'  >" + result[i].whName + "</td> <td style='width:60px;'  align='left'  >" + result[i].fqty + "</td> <td style='width:60px;'  align='left'  >" + result[i].wqty + "</td> <td style='width:60px;'  align='left'  ></td>  </tr>"
                        td = td+"<tr style='height:20px'><td style='width:30px;' align='center' >"+(row)+"</td><td style='width:170px;word-wrap:break-word;word-break:break-all;'  align='left'  >" + (result[i].venName || '') + "</td><td style='width:80px;'  align='left'  >" + (result[i].invCode || '') + "</td><td style='width:250px;word-wrap:break-word;word-break:break-all;'  align='left'  >" + (result[i].invName || '') + "</td>  <td style='width:50px;'  align='left'  >" + (result[i].invStd || '') + "</td> <td style='width:35px;'  align='left'  >" + (result[i].unit || '') + "</td><td style='width:80px;'  align='left'  >" + (result[i].whName || '') + "</td><td style='width:60px;'  align='left'  >" + (result[i].fqty || 0) + "</td><td style='width:60px;'  align='left'  ></td>   </tr>"
                        row++;
                    }
@@ -731,6 +767,7 @@
                    fnCanelPrint,
                    fnTongBu,
                    fnCanelTongBu,
                    manualSync,
                    handleSizeChange,
                    handleCurrentChange,
                    handleSelectionChange,