Administrator
2024-03-12 9f1ce41802f261ee72cd026a5f925e2dc750aa98
PDA托盘绑定页分页功能修改
1个文件已修改
308 ■■■■■ 已修改文件
Pda/View/AsnSetting/productEnterQuantity.html 308 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Pda/View/AsnSetting/productEnterQuantity.html
@@ -1083,7 +1083,8 @@
                                tr.show();
                                arrTrs[i] = tr
                            }
                            //设置分页
                            setPages(1, res.data.length)
                        } else { //不成功
                            layer.msg("无数据", {
@@ -1091,6 +1092,7 @@
                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                            }, function () { });
                            $("#boxNum").val(0)
                            setPages(1, 0)
                        }
                    });
                }
@@ -1168,7 +1170,7 @@
                            }
                            //设置分页
                            setPages(1, list.length)
                            setPages(1, res.data.length)
                        } else { //不成功
                            layer.msg("无数据", {
@@ -1291,218 +1293,99 @@
            /* 分页 */
            //设置分页
            function setPages(pageIndex, boxNum) {
                if (boxNum <= 0) {
                    //列表为空,隐藏分页页码
                    $("#tableBoxPages").hide()
                    return
                }
                if (xianshiyemian == 0) {
                    if (boxNum <= 0) {
                        //列表为空,隐藏分页页码
                        $("#tableBoxPages").hide()
                        return
                    }
                let pageNum = Math.floor(boxNum / 10);
                if (boxNum % 10 > 0) {
                    pageNum += 1;
                }
                //console.log("pageNum is " + pageNum)
                    let pageNum = Math.floor(boxNum / 10);
                    if (boxNum % 10 > 0) {
                        pageNum += 1;
                    }
                    //console.log("pageNum is " + pageNum)
                $("#tableBoxPages").find("tr").remove()
                let table = $("#tableBoxPages")
                $("<tr></tr>").appendTo("#tableBoxPages")
                    $("#tableBoxPages").find("tr").remove()
                    let table = $("#tableBoxPages")
                    $("<tr></tr>").appendTo("#tableBoxPages")
                // let newTr = table.append("<tr></tr>")
                // newTr.append("<td class='page-prev'>上一页</td>")
                $("<td id='prevPage' class='page-prev'>上一页</td>").appendTo("#tableBoxPages tr")
                $("#tableBoxPages tr").eq(0).find("td[id^='prevPage']").click(function () {
                    onClickPrevPage()
                })
                for (i = 1; i < pageNum + 1; i++) {
                    // newTr.append("<td class='page-num'>"+ i +"</td>")
                    $("<td class='page-num'>" + i + "</td>").appendTo("#tableBoxPages tr")
                }
                // newTr.append("<td class='page-next'>下一页</td>")
                $("<td id='nextPage' class='page-next'>下一页</td>").appendTo("#tableBoxPages tr")
                $("#tableBoxPages tr").eq(0).find("td[id^='nextPage']").click(function () {
                    onClickNextPage()
                })
                // pages.show()
                $("#tableBoxPages").show()
                    // let newTr = table.append("<tr></tr>")
                    // newTr.append("<td class='page-prev'>上一页</td>")
                    $("<td id='prevPage' class='page-prev'>上一页</td>").appendTo("#tableBoxPages tr")
                    $("#tableBoxPages tr").eq(0).find("td[id^='prevPage']").click(function () {
                        onClickPrevPage()
                    })
                    for (i = 1; i < pageNum + 1; i++) {
                        // newTr.append("<td class='page-num'>"+ i +"</td>")
                        $("<td class='page-num'>" + i + "</td>").appendTo("#tableBoxPages tr")
                    }
                    // newTr.append("<td class='page-next'>下一页</td>")
                    $("<td id='nextPage' class='page-next'>下一页</td>").appendTo("#tableBoxPages tr")
                    $("#tableBoxPages tr").eq(0).find("td[id^='nextPage']").click(function () {
                        onClickNextPage()
                    })
                    // pages.show()
                    $("#tableBoxPages").show()
                setCurPage(1)
            }
                    setCurPage(1)
                }
                else if (xianshiyemian == 1) {
                    if (boxNum <= 0) {
                        //列表为空,隐藏分页页码
                        $("#tableBoxPages1").hide()
                        return
                    }
            //设置当前分页
            function setCurPage(pageIndex) {
                let totalTrNum = $("#tableBoxList tr").length
                if (totalTrNum <= 2) {
                    //console.log("tableBoxList 为空 totalTrNum: " + totalTrNum)
                    //curPageIndex = 1
                    return
                }
                    let pageNum = Math.floor(boxNum / 10);
                    if (boxNum % 10 > 0) {
                        pageNum += 1;
                    }
                    //console.log("pageNum is " + pageNum)
                let pageNum = getBoxPageNum()
                if (pageIndex > pageNum) {
                    //console.log("设置的页码超出页数, pageIndex : " + pageIndex)
                    //curPageIndex = 1
                    return
                }
                    $("#tableBoxPages1").find("tr").remove()
                    let table = $("#tableBoxPages1")
                    $("<tr></tr>").appendTo("#tableBoxPages1")
                let startIndex = (pageIndex - 1) * 10 + 1
                let n = totalTrNum - startIndex
                let endIndex = 0
                if (n > 9) {
                    endIndex = startIndex + 9
                } else {
                    endIndex = startIndex + n
                }
                //console.log("startIndex is "+startIndex)
                //console.log("endIndex is "+endIndex)
                //startIndex =2
                //endIndex = 2
                let trs = $("#tableBoxList tr")
                //console.log("行数 "+trs.length)
                let d = 0
                for (let i = 2; i < trs.length; i++) {
                    //console.log("行索引 " + trs.eq(i).attr('index'))
                    let t = trs.eq(i)
                    d = t.attr('index')
                    if (d >= startIndex && d <= endIndex) {
                        //console.log("需要显示")
                        //显示行
                        t.show()
                    } else {
                        //隐藏行
                        t.hide()
                    }
                }
                    // let newTr = table.append("<tr></tr>")
                    // newTr.append("<td class='page-prev'>上一页</td>")
                    $("<td id='prevPage' class='page-prev'>上一页</td>").appendTo("#tableBoxPages1 tr")
                    $("#tableBoxPages1 tr").eq(0).find("td[id^='prevPage']").click(function () {
                        onClickPrevPage()
                    })
                    for (i = 1; i < pageNum + 1; i++) {
                        // newTr.append("<td class='page-num'>"+ i +"</td>")
                        $("<td class='page-num'>" + i + "</td>").appendTo("#tableBoxPages1 tr")
                    }
                    // newTr.append("<td class='page-next'>下一页</td>")
                    $("<td id='nextPage' class='page-next'>下一页</td>").appendTo("#tableBoxPages1 tr")
                    $("#tableBoxPages1 tr").eq(0).find("td[id^='nextPage']").click(function () {
                        onClickNextPage()
                    })
                    // pages.show()
                    $("#tableBoxPages1").show()
                curPageIndex = pageIndex
                    setCurPage(1)
                }
            }
            //设置当前分页
            function setCurPage(pageIndex) {
                if (xianshiyemian == 0) {
                    let totalTrNum = $("#tableBoxList tr").length
                    if (totalTrNum <= 2) {
                        //console.log("tableBoxList 为空 totalTrNum: " + totalTrNum)
                        //curPageIndex = 1
                        return
                    }
                    let pageNum = getBoxPageNum()
                    if (pageIndex > pageNum) {
                        //console.log("设置的页码超出页数, pageIndex : " + pageIndex)
                        //curPageIndex = 1
                        return
                    }
                    let startIndex = (pageIndex - 1) * 10 + 1
                    let n = totalTrNum - startIndex
                    let endIndex = 0
                    if (n > 9) {
                        endIndex = startIndex + 9
                    } else {
                        endIndex = startIndex + n
                    }
                    let trs = $("#tableBoxList tr")
                    //console.log("行数 "+trs.length)
                    let d = 0
                    for (let i = 2; i < trs.length; i++) {
                        //console.log("行索引 " + trs.eq(i).attr('index'))
                        let t = trs.eq(i)
                        d = t.attr('index')
                        if (d >= startIndex && d <= endIndex) {
                            //console.log("需要显示")
                            //显示行
                            t.show()
                        } else {
                            //隐藏行
                            t.hide()
                        }
                    }
                    curPageIndex = pageIndex
                    let ptr = $("#tableBoxPages tr")
                    for (let i = 1; i < pageNum + 1; i++) {
                        ptr.eq(0).find("td").eq(i).removeClass("page-num-select")
                        if (i == curPageIndex) {
                            ptr.eq(0).find("td").eq(i).addClass("page-num-select")
                        }
                    }
                }
                else if (xianshiyemian == 1) {
                    let totalTrNum = $("#tableBoxList1 tr").length
                    if (totalTrNum <= 2) {
                        return
                    }
                    let pageNum = getBoxPageNum()
                    if (pageIndex > pageNum) {
                        //console.log("设置的页码超出页数, pageIndex : " + pageIndex)
                        //curPageIndex = 1
                        return
                    }
                    let startIndex = (pageIndex - 1) * 10 + 1
                    let n = totalTrNum - startIndex
                    let endIndex = 0
                    if (n > 9) {
                        endIndex = startIndex + 9
                    } else {
                        endIndex = startIndex + n
                    }
                    let trs = $("#tableBoxList1 tr")
                    //console.log("行数 "+trs.length)
                    let d = 0
                    for (let i = 2; i < trs.length; i++) {
                        //console.log("行索引 " + trs.eq(i).attr('index'))
                        let t = trs.eq(i)
                        d = t.attr('index')
                        if (d >= startIndex && d <= endIndex) {
                            //console.log("需要显示")
                            //显示行
                            t.show()
                        } else {
                            //隐藏行
                            t.hide()
                        }
                    }
                    curPageIndex = pageIndex
                    let ptr = $("#tableBoxPages1 tr")
                    for (let i = 1; i < pageNum + 1; i++) {
                        ptr.eq(0).find("td").eq(i).removeClass("page-num-select")
                        if (i == curPageIndex) {
                            ptr.eq(0).find("td").eq(i).addClass("page-num-select")
                        }
                    }
                }
            }
            function getBoxPageNum() {
                if (xianshiyemian == 0) {
                    let num = $("#tableBoxList tr").length
                    if (num <= 2) {
                        return 0
                    }
                    let pageNum = Math.floor(num / 10);
                    if (num % 10 > 0) {
                        pageNum += 1;
                    }
                    return pageNum
                }
                else if (xianshiyemian == 1) {
                    let num = $("#tableBoxList1 tr").length
                    if (num <= 2) {
                        return 0
                    }
                    let pageNum = Math.floor(num / 10);
                    if (num % 10 > 0) {
                        pageNum += 1;
                    }
                    return pageNum
                }
            }
                let ptr = $("#tableBoxPages tr")
                for (let i = 1; i < pageNum + 1; i++) {
                    ptr.eq(0).find("td").eq(i).removeClass("page-num-select")
                    if (i == curPageIndex) {
                        ptr.eq(0).find("td").eq(i).addClass("page-num-select")
                    }
                }
                //console.log("totalTrNum is " + totalTrNum)
            }
            function onClickPrevPage() {
                //console.log("上一页按钮被点击")
@@ -1515,11 +1398,24 @@
            function onClickNextPage() {
                //console.log("下一页按钮被点击")
                let n = getBoxPageNum()
                if (curPageIndex == n) {
                if (curPageIndex == n-1) {
                    return
                }
                setCurPage(curPageIndex + 1)
            }
            function getBoxPageNum() {
                let num = $("#tableBoxList tr").length
                if (num <= 2) {
                    return 0
                }
                let pageNum = Math.floor(num / 10);
                if (num % 10 > 0) {
                    pageNum += 1;
                }
                return pageNum
            }
            /*——————————————————————————————————————————————————————————*/