懒羊羊
2023-12-04 b3e9a47f4c17c0d708398698432a109420e7d9e1
guns-vip-main/src/main/webapp/assets/modular/kb/formula/formulaView.js
@@ -7,6 +7,59 @@
    var form = layui.form;
    var element = layui.element;
    /**
     * 配方配置子信息管理
     */
    var FormulaChildInfo = {
        tableId: "formulaChildInfoTable"
    };
    $('#imgs').attr("src", "http://localhost:8081/img/9f2f070828381f30fdf1be0da9014c086f06f0ad.jpg");
    /**
     * 初始化表格的列
     */
    FormulaChildInfo.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: 'id'},
            {type:"numbers" ,title:'工步',width:40},
            {field: 'operationSteps', sort: true, title: '操作内容'},
            {field: 'techRequirement', sort: true, title: '技术要求'},
            {field: 'operationType', sort: true, title: '类型'},
        ]];
    };
    $('#imgs').click(function (){
        console.log("11111111111111");
        var img = new Image();
        img.src = "http://localhost:8081/img/9f2f070828381f30fdf1be0da9014c086f06f0ad.jpg";
        // var height = img.height; //获取图片高度
        // var width = img.width; //获取图片宽度
        var height = 500; //获取图片高度
        var width = 800; //获取图片宽度
        if (height > 1000 || width > 800) {
            height = height / 1.5;
            width = width / 1.5;
        }
        var imgHtml = "<img src='http://localhost:8081/img/9f2f070828381f30fdf1be0da9014c086f06f0ad.jpg' style='width: " + width + "px;height:" + height + "px'/>";
        layer.open({
            type: 1,
            offset: 'auto',
            area: [width + 'px', height + 'px'],
            shadeClose: true,//点击外围关闭弹窗
            scrollbar: true,//不现实滚动条
            title: false, //不显示标题
            content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
            cancel: function () {
            }
        });
        console.log(height);
        console.log(width);
    });
    initLineInfo();
    var ajax = new $ax(Feng.ctxPath + "/workOrder/list?state=3");
@@ -19,7 +72,40 @@
    $('#planQty').text(msg.planQty);
    $('#planStartTime').text(msg.planStartTime);
    $('#planEndTime').text(msg.planEndTime);
    $('#recipeCode').text(msg.recipeCode);
    var radioElement = $('#sex1');
    var queryData = {};
    queryData['formulaCode'] = msg.recipeCode;
    // 渲染表格
    table.render({
        elem: '#' + FormulaChildInfo.tableId,
        url: Feng.ctxPath + '/formulaChildInfo/list',
        page: false,
        // height: "full-158",
        // height: 460,
        height: 400,
        cellMinWidth: 100,
        where: queryData,
        cols: FormulaChildInfo.initColumn(),
        done: function (res, curr, count) {
            console.log(res);
            //得到当前页码
            console.log(curr);
            //得到数据总量
            console.log(count);
            // 根据条件判断加背景色
            $.each(res.data, function (index, item) {
                console.log(item)
                console.log(item.spareField1)
                if (item.spareField1 === "3") {
                    // 法1
                    $("#formulaChildInfoTable").next().find('tbody tr[data-index="' + index +
                        '"]').css("background-color", "#00ff66");
                }
            });
        }
    });
    function initLineInfo(){
        $.ajax({
@@ -54,13 +140,13 @@
                    $.ajax({
                        type: "POST",
                        contentType: "application/json;charset=UTF-8",
                        url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+data.value,
                        url: Feng.ctxPath + '/opInfo/list?lineCode='+data.value,
                        success: function (result) {
                            $('#locationCode').empty();
                            $('#locationCode').append(new Option("请选择工位", ""));// 下拉菜单里添加元素
                            $.each(result.data, function (index, value) {
                                $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
                                $('#locationCode').append(new Option(value.opCode));// 下拉菜单里添加元素
                            });
                            layui.form.render("select");//重新渲染 固定写法
                        },
@@ -68,8 +154,6 @@
                }
                break;
            case 'locationCode':
                console.log($('#locationCode').val());
                console.log($('#lineCode').val());
                var getIp = new $ax(Feng.ctxPath + "/kanbanConf/ipSetting?lineCode="+$('#lineCode').val()+"&locationCode="+$('#locationCode').val());
                var result = getIp.start();
                Feng.info("更新完成!")
@@ -77,12 +161,13 @@
        }
    });
    setInterval(function() {
        $('input[name="sex1"][value="nan1"]').prop('checked', true);
    }, 1000);
    setInterval(function() {
        radioElement.prop('checked', false);
    }, 2000);
    // //redio闪烁
    // setInterval(function() {
    //     $('input[name="sex1"][value="nan1"]').prop('checked', true);
    // }, 1000);
    // setInterval(function() {
    //     radioElement.prop('checked', false);
    // }, 2000);
    //Hash地址的定位
    var layid = location.hash.replace(/^#test=/, '');
@@ -92,4 +177,54 @@
        location.hash = 'test='+ $(this).attr('lay-id');
    });
    /**
     * 基础BOM管理
     */
    var ProductBomChildInfo = {
        tableId: "productBomChildInfoTable"
    };
    /**
     * 初始化表格的列
     */
    ProductBomChildInfo.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: '主键id'},
            {field: 'opCode', sort: true, title: '工序编码'},
            {field: 'opName', sort: true, title: '工序名称'},
            {field: 'materialCode', sort: true, title: '物料编码'},
            {field: 'costQty', sort: true, title: '单耗'},
            {field: 'bomCode', sort: true, title: 'BOM编码'},
        ]];
    };
    var queryData = {};
    queryData['bomCode'] = "301002000021";
    // 渲染表格
    table.render({
        elem: '#' + ProductBomChildInfo.tableId,
        url: Feng.ctxPath + '/productBomChildInfo/list',
        page: true,
        height: 460,
        cellMinWidth: 100,
        where: queryData,
        cols: ProductBomChildInfo.initColumn()
    });
    $("#scanCode").keydown(function(event) {
        if (event.keyCode === 13) {
            // 执行您想要的代码
            var ajax = new $ax(Feng.ctxPath + "/kb/formulaView/addFormulaState?formulaCode="+msg.recipeCode);
            var result = ajax.start();
            table.reload("formulaChildInfoTable")
            return false; // 阻止默认行为
        }
    });
    $("#clear").click(function() {
        var ajax = new $ax(Feng.ctxPath + "/kb/formulaView/clear?formulaCode="+msg.recipeCode);
        var result = ajax.start();
        table.reload("formulaChildInfoTable")
    });
});