#
whycq
2023-06-30 3d6e22ee9a4eb70d9ce4e7a71fb4893a8c6f6056
src/main/webapp/static/js/console.js
@@ -9,8 +9,10 @@
    track = '',
    tracks = '',
    stn = '',
    barcode = '',
    stns = '',
    stnArr = [],
    barcodeArr = [],
    floorBtn = '',
    floorBtns = '',
    floorBtnss = '',
@@ -25,27 +27,94 @@
    for (let i = 0;i < rackss.length;i++) {
        let bay ='' // 单个库位
        let bays = '' // 库位集合
        let bayWidth = rackss[i].width / (rackss[i].maxBayNo / rackss[i].minBayNo)
        console.log(bayWidth)
        let maxBayNo = rackss[i].maxBayNo // 最大库位号
        let minBayNo = rackss[i].minBayNo // 最小库位号
        let bLen = maxBayNo / minBayNo // 库位个数
        let bLen
        let interval // 间隔数
        if (maxBayNo<35) {
            interval = 1
            bLen = maxBayNo / interval // 库位个数
        } else {
            interval = 2
            bLen = maxBayNo / interval // 库位个数
        }
        let bayWidth // 单个库位宽度
        let bNum // 库位号码
        // hpPosition 0 表示货架序号 左->右 1 表示货架序号 右->左
        if (minBayNo % 2 == 0) { // 从2开始
            if(interval == 1) {
                bLen = bLen - 1
            } else if (interval == 2) {
                if (maxBayNo % 2 == 0) { // 偶数
                    bLen = bLen
                } else { // 奇数
                    maxBayNo = maxBayNo + 1
                    bLen = maxBayNo / interval // 库位个数
                }
            }
        } else { // 从1开始
            if(interval == 1) {
                bLen = bLen
            } else if (interval == 2) {
                if (maxBayNo % 2 == 0) { // 偶数
                    bLen = bLen
                } else { // 奇数
                    bLen = bLen + 1
                }
            }
        }
        bayWidth = (rackss[i].width / bLen)-4
        // hpPosition 0 表示货架序号 左->右 1 表示货架序号 左<-右
        if (mapInfo.hpPosition == 1) {
            bNum = maxBayNo
            for (let j = bLen; j > 0; j--) {
                if (i === 0) {
                    if (j === 13) {
                        bay = "<button class='item' style='width: " + 160 + "px'>" + bNum + "</button>"
                        bays = bays + bay
                        bNum = bNum - interval;
                        continue
                    }
                    bay = "<button class='item' style='width: "+ bayWidth +"px'>" + bNum + "</button>"
                    bays = bays + bay
                    bNum = bNum - interval;
                    continue
                }
                if (j === 13) {
                    bay = "<button class='item' style='margin-left: 160px;width: "+ bayWidth +"px'>" + (bNum - 2) + "</button>"
                    bays = bays + bay
                    bNum = bNum - interval - 2;
                    continue
                }
                bay = "<button class='item' style='width: "+ bayWidth +"px'>" + bNum + "</button>"
                bays = bays + bay
                bNum = bNum - minBayNo;
                bNum = bNum - interval;
            }
        }else {
            bNum = minBayNo
            for (let j = 0; j < bLen; j++) {
                if (i === 0) {
                    if (j === 15 || j === 16) {
                        bay = "<button class='item' style='width: "+ 80 +"px'>" + bNum + "</button>"
                        bays = bays + bay
                        bNum = bNum + interval;
                        continue
                    }
                    bay = "<button class='item' style='width: "+ bayWidth +"px'>" + bNum + "</button>"
                    bays = bays + bay
                    bNum = bNum + interval;
                    continue
                }
                if (j === 15) {
                    bay = "<button class='item' style='margin-left: 160px;width: "+ bayWidth +"px'>" + (bNum + 4) + "</button>"
                    bays = bays + bay
                    bNum = bNum + interval + 4;
                    continue
                }
                bay = "<button class='item' style='width: "+ bayWidth +"px'>" + bNum + "</button>"
                bays = bays + bay
                bNum = bNum + minBayNo;
                bNum = bNum + interval;
            }
        }
@@ -91,17 +160,24 @@
    }
    // 楼层
    for (let i = 0; i < areas.length;i++) {
        let stnss = areas[i].stns
        let barcodes = areas[i].barcode
        let floor = areas[i].text
        floorId = areas[i].id
        var position = (i+1)*100
        floorBtn =
            "<button class='floorBtn btn-16' onclick='changFloor("+i+")' style='top: "+position+"px;'>" + floor +"</button>"
        floorBtnss =  floorBtnss + floorBtn
        if (mapInfo.areas[0].floors.length == 1) {
            floorBtnss = ''
        } else {
            floorBtnss =  floorBtnss + floorBtn
        }
        // 每层的 输送线站点
        var index = i
        var n = 1
        stnArr[index] = ''
        barcodeArr[index] = ''
        total[index] = ''
        for (let j = 0; j < stnss.length; j++) {
            if (stnss[j].type == "stn") {
@@ -126,20 +202,29 @@
            }
        }
        for (let k = 0; k < barcodes.length; k++) {
            barcode = "<div class='barcode' id='" + barcodes[k].id +
                "'style='width:" + barcodes[k].width +
                "px;height: " + barcodes[k].height +
                "px;line-height: " + barcodes[k].height +
                "px;top: "+ barcodes[k].top +
                "px;left: "+ barcodes[k].left + "px'>" + "</div>"
            barcodeArr[i] = barcodeArr[i] + barcode
        }
    }
    floorInfo = racks + rackDescs + tracks + crns + stnArr[0] + floorBtnss
    floorInfo = racks + rackDescs + tracks + crns + stnArr[0] + floorBtnss + barcodeArr[0]
    $(".main-part").append(floorInfo)
    $("#line-total").html(total[0])
    listenChange();
    // listenChange();
}
function changFloor(e) {
    $(".main-part").empty()  // 清空节点
    floorInfo = racks  + stnArr[e] +rackDescs + crns + tracks + floorBtnss
    floorInfo = racks  + stnArr[e] +rackDescs + crns + tracks + floorBtnss + barcodeArr[e]
    $(".main-part").append(floorInfo)
    $("#line-total").empty()
    $("#line-total").html(total[e])
    listenChange();
    // listenChange();
}