chenhaozhe
2025-06-27 9cff4e362bc3e6ff83b841658bfadd918b8773b0
WebTM/views/ÖÊÁ¿¹ÜÀí/»·¾³¼ì²âµ¥/QC_EnvironmentTestDotCheckBillEdit.html
@@ -23,6 +23,7 @@
                <form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
                    <div style="padding: 2px; ">
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">保存</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button"  lay-submit="" lay-filter="set_CheckBill" id="set_CheckBill">审核</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnEdit" id="btnEdit">退出</button>
                    </div>
                    <div class="layui-tab" lay-filter="tab-POStockInBill">
@@ -229,6 +230,7 @@
                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>增加一行</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                        </div>
                    </script>
                </form>
@@ -242,6 +244,7 @@
    </script>
    <div>
        <script>
            var OptionData = [];
            layui.config({
                base: '../../../layuiadmin/' //静态资源所在路径
            }).extend({
@@ -358,6 +361,9 @@
                                table.render(option);//将数据渲染到表格上
                            }
                            break;
                        //列设置
                        case 'set_HideColumn':get_HideColumn();
                            break;
                    }
                });
@@ -375,6 +381,12 @@
                    }
                });
                // å®¡æ ¸æŒ‰é’®
                form.on('submit(set_CheckBill)', function (data) {
                    set_CheckBill(1);
                });
                //退出
                form.on('submit(btnEdit)', function (data) {
                    if (params[1] != null) {
@@ -389,6 +401,7 @@
                //#region æ­¤é¡µé¢æ‰€æœ‰çš„æ–¹æ³•
                function set_ClearBill() {
                    $('#set_CheckBill').addClass("layui-btn-disabled").attr("disabled", true);//初始化禁用审核按钮
                    //制单人
                    $("#HMaker").val(sessionStorage["HUserName"]);
                    $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd"));
@@ -403,6 +416,8 @@
                    $("#HOrgID").prop("disabled", true);
                    //初始化列表
                    set_InitGrid();
                    //表体列设置查询
                    DisPlay_HideColumn();
                }
                //初始化列表
@@ -415,13 +430,13 @@
                        , height: 650
                        , cols: [[ //表头
                            { type: 'checkbox', totalRowText: '合计行' }
                            , { type: 'numbers', title: '序号', totalRow: true }
                            , { type: 'numbers', title: '序号', totalRow: true, style: 'background-color: #f9f9f9;'}
                            , { field: 'HEnvironmentItemID', title: 'HEnvironmentItemID', hide: true }
                            , { field: 'HEnvironmentItemName', title: '检测项目', edit: 'text', event: "HEnvironmentItemID" }
                            , { field: 'HMeasure', title: '实际值', edit: 'text' }
                            , { field: 'HTargetVal', title: '目标值' }
                            , { field: 'HUpLimit', title: '上限值' }
                            , { field: 'HDownLimit', title: '下限值'}
                            , { field: 'HTargetVal', title: '目标值', style: 'background-color: #f9f9f9;'}
                            , { field: 'HUpLimit', title: '上限值', style: 'background-color: #f9f9f9;' }
                            , { field: 'HDownLimit', title: '下限值', style: 'background-color: #f9f9f9;'}
                            , { fixed: 'right', title: '操作', toolbar: '#barDemo' }
                        ]]
                    }
@@ -654,15 +669,52 @@
                                        var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                        var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                        if (checkStatus.data.length != 1) {
                                        if (checkStatus.data.length == 0) {
                                            return layer.msg("请选择一条数据");
                                        }
                                        //更新表格缓存的数据
                                        obj.update({
                                            "HEnvironmentItemID": checkStatus.data[0].HItemID
                                            , "HEnvironmentItemName": checkStatus.data[0].检测名称
                                        })
                                        layer.close(index);//关闭弹窗
                                        if (checkStatus.data.length === 1) {
                                            //更新表格缓存的数据
                                            obj.update({
                                                "HEnvironmentItemID": checkStatus.data[0].HItemID
                                                , "HEnvironmentItemName": checkStatus.data[0].环境检测项目名称
                                            })
                                            layer.close(index);//关闭弹窗
                                        } else {
                                            //(多选行)
                                            //将原有表体数据写入数组
                                            var tableBak = table.cache["mainTable"]; //获取之前编辑过的表格数据
                                            buttonArr = [];//清空数组
                                            for (var i = 0; i < tableBak.length; i++) {
                                                if (tableBak[i]["HEnvironmentItemID"] != 0 && tableBak[i]["HEnvironmentItemName"] != "") {
                                                    buttonArr.push(tableBak[i]);  //如果关键字段不为空,则将之前的数据存储
                                                }
                                            }
                                            //将批量选择的数据写入数组(多选行)
                                            for (var i = 0; i < checkStatus.data.length; i++) {
                                                buttonArr.push({
                                                    "HEnvironmentItemID": checkStatus.data[i].HItemID, "HEnvironmentItemName": checkStatus.data[i].环境检测项目名称, "HMeasure": "", "HTargetVal": "", "HUpLimit": "", "HDownLimit": ""
                                                });
                                            }
                                            table.reload("mainTable", {
                                                data: buttonArr    //将数据重新载入表格
                                            })
                                            layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                        }
                                    }
                                    , btn2: function (index, layero) {
                                        //按钮【按钮二】的回调
                                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                    },
                                    end: function () {
                                        if (OptionData.length > 0) {
                                            //更新表格缓存的数据
                                            obj.update({
                                                HEnvironmentItemName: OptionData[0].环境检测项目名称,
                                                HEnvironmentItemID: OptionData[0].HItemID
                                            });
                                            OptionData = [];
                                        }
                                    }
                                })
                            }
@@ -713,6 +765,7 @@
                        success: function (data) {
                            if (data.count == 1) {
                                $('#btnSave').addClass("layui-btn-disabled").attr("disabled", true);
                                $('#set_CheckBill').removeClass("layui-btn-disabled").removeAttr("disabled").addClass("layui-btn-normal");
                                layer.close(index);
                                layer.msg("提交成功");
                            }
@@ -812,6 +865,30 @@
                    })
                }
                //表头双击 èŽ·å–è¡¨ä½“æ£€éªŒæ–¹æ¡ˆ
                window.get_CheckItem1 = function () {
                    $.ajax({
                        url: GetWEBURL() + "/Gy_BaseInformation/Gy_EnvironmentTestSchemeBillMainEditList",
                        type: "GET",
                        async: false,
                        data: { "linterid": $("#HEnvironmentTestSchemeID").val() == "" ? 0 : $("#HEnvironmentTestSchemeID").val(), "user": sessionStorage["HUserName"] },
                        success: function (d) {
                            //子表  èµ‹å€¼
                            var rowdata = [];
                            for (var i = 0; i < d.data.length; i++) {
                                rowdata.push(
                                    {
                                        "HEnvironmentItemID": d.data[i].HEnvironmentItemID, "HEnvironmentItemName": d.data[i].检测项目,
                                        "HMeasure": "0", "HTargetVal": d.data[i].目标值, "HUpLimit": d.data[i].上限值, "HDownLimit": d.data[i].下限值
                                    }
                                )
                            }
                            option.data = rowdata;
                            table.render(option);
                        }
                    })
                }
                // èŽ·å–ç»„ç»‡
                function Organ() {
                    //获取登录页组织列
@@ -879,7 +956,156 @@
                        }
                    }
                    return true;
                };
                //#region å®¡æ ¸æ•°æ®
                function set_CheckBill() {
                    var HInterID = $("#HInterID").val();
                    //逻辑审核方法
                    $.ajax({
                        type: "GET",
                        url: GetWEBURL() + "/QC_EnvironmentTestDotCheckBill/AuditQC_EnvironmentTestDotCheckBill", //方法所在页面和方法名
                        data: { "HInterID": HInterID, "Type": 1, "user": sessionStorage["HUserName"] },
                        success: function (result) {
                            if (result.count == 1) {
                                layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                    // å¾—到frame索引
                                    var index = layer.getFrameIndex(window.name);
                                    //关闭当前frame
                                    layer.close(index);
                                });
                                $('#set_CheckBill').addClass("layui-btn-disabled").attr("disabled", true);// ç¦ç”¨å®¡æ ¸æŒ‰é’®
                            } else {
                                layer.alert(result.code + result.Message, { icon: 5 });
                            }
                        }, error: function () {
                            layer.alert("接口请求失败!", { icon: 5 });
                        }
                    });
                }
            //#endregion
                //#region å­è¡¨1:隐藏列设置
                function get_HideColumn() {
                    var colName = "";
                    var contentUrl = "";
                    for (var i = 1; i < option.cols[0].length - 1; i++) {
                        colName += option.cols[0][i]["title"] + ",";
                    }
                    var urlStr = window.document.location.pathname;//获取文件路径
                    var urlLen = urlStr.split('/');
                    for (var i = 0; i < urlLen.length - 4; i++) {
                        contentUrl += "../";
                    }
                    colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI è¿›è¡Œç¼–码
                    contentUrl += '基础资料/隐藏列设置/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName;
                    layer.open({
                        type: 2
                        , skin: "layui-layer-rim" //加上边框
                        , title: "隐藏列设置"  //标题
                        , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                        , shift: 2 //弹出动画
                        , area: ["50%", "90%"] //窗体大小
                        , maxmin: true //设置最大最小按钮是否显示
                        , content: [contentUrl, "yes"]
                        , btn: ["确定", "取消"]
                        , btn1: function (index, laero) {
                            //刷新表格数据
                            DisPlay_HideColumn();
                            //更新表格缓存的数据
                            layer.close(index);//关闭弹窗
                        }
                    })
                }
                //#endregion
                //#region å­è¡¨1:显示列数据
                function DisPlay_HideColumn() {
                    $.ajax({
                        url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
                        async: false,
                        type: "GET",
                        data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
                        async: false,
                        success: function (data1) {
                            if (data1.data.length != 0) {
                                var dataCol = [];//数据库查询出的列数据
                                var titleData = ["HEnvironmentItemID"];
                                dataCol = data1.data[0].HGridString.split(',');
                                for (var i = 0; i < option.cols[0].length - 2; i++) {
                                    if (dataCol.length <= i) {
                                        break;
                                    }
                                    var dataCols = dataCol[i].split('|');
                                    //隐藏列
                                    if (dataCols[1] == 1) {
                                        option.cols[0][i + 1]["hide"] = true;
                                    }
                                    //设置列宽
                                    if (dataCols[3] > 0) {
                                        option.cols[0][i + 1]["width"] = dataCols[3];
                                    }
                                    //设置内容字体大小
                                    if (data1.data[0].HFontSize != 0) {
                                        option.cols[0][i + 1]["style"] += "font-size:" + data1.data[0].HFontSize + "px;";
                                    } else {
                                        option.cols[0][i + 1]["style"] += "font-size:100%";
                                    }
                                    //显示列
                                    if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
                                        option.cols[0][i + 1]["hide"] = false;
                                    }
                                    //字体所在位置(å·¦ å±…中 å³)
                                    switch (dataCols[2]) {
                                        case "L":
                                            option.cols[0][i + 1]["align"] = "left";
                                            break;
                                        case "M":
                                            option.cols[0][i + 1]["align"] = "center";
                                            break;
                                        case "R":
                                            option.cols[0][i + 1]["align"] = "right";
                                            break;
                                    }
                                    //设置表格title属性显示别名
                                    if (dataCols[4] != null && dataCols[4] != "") {
                                        option.cols[0][i + 1]["title"] = dataCols[4];
                                    }
                                }
                                //取消冻结列
                                for (var i = 1; i < option.cols[0].length - 1; i++) {
                                    if (option.cols[0][i]["fixed"] != null) {
                                        option.cols[0][i]["fixed"] = null;
                                    }
                                    else {
                                        break;
                                    }
                                }
                                //冻结列
                                if (data1.data[0].HFixCols != 0) {
                                    for (var i = 0; i < data1.data[0].HFixCols; i++) {
                                        if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) {
                                            data1.data[0].HFixCols += 1;
                                        }
                                        option.cols[0][i + 1]["fixed"] = "left";
                                    }
                                }
                                table.render(option);
                            } else {
                                table.render(option);
                            }
                        }, error: function () {
                            layer.alert("接口请求失败!", { icon: 5 });
                        }
                    })
                }
            //#endregion
            });
@@ -898,7 +1124,27 @@
                $("#HProcID").val(obj[0].HItemID);//工序id
                $("#HProcName").val(obj[0].工序名称);//工序名称
            }
            //工作中心
            function GetWorkCenterValue(obj) {
                $("#HCenterWorkName").val(obj[0].工作中心名称);
                $("#HCenterWorkID").val(obj[0].HItemID);
            }
            //检测方案
            function GetEnvironmentTestSchemeValue(obj) {
                $("#HEnvironmentTestSchemeName").val(obj[0].单据号);
                $("#HEnvironmentTestSchemeID").val(obj[0].HInterID);
                $("#HProcID").val(obj[0].HProcID);
                $("#HProcName").val(obj[0].工序名称);
                $("#HCenterWorkID").val(obj[0].HCenterWorkID);
                $("#HCenterWorkName").val(obj[0].工作中心);
                $("#HDeptID").val(obj[0].HDeptID);
                $("#HDeptName").val(obj[0].生产部门);
                get_CheckItem1();
            }
            //检验项目
            function GetHEnvironmentTestItemrValue(obj) {
                OptionData = obj;
            }
        </script>
    </div>
</body>