WebTM/views/É豸¹ÜÀí/É豸¹¤ÒÕ²ÎÊý¶©µ¥µã¼ì±í/SB_EquipICMOTechParamBillEdit.html
@@ -351,6 +351,13 @@
        </select>
    </script>
    <!--复选框 æ˜¯å¦å¿…录控制-->
    <script type="text/html" id="HIsRequired">
        <div class="layui-input-block" style="margin-left: 20px;">
            <input type="checkbox" name="HIsRequired" lay-filter="HIsRequired" id="HIsRequired{{d.LAY_TABLE_INDEX+1}}" lay-skin="primary">
        </div>
    </script>
    <script>
        //获取参数
        var OptionData = [];
@@ -371,19 +378,19 @@
        }
        var edit = function (data) {
        var edit = function (data) {
            HSourceInterID = data[0].HSourceInterID;
            HSourceEntryID = data[0].HSourceEntryID;
            HSourceBillNo = data[0].HSourceBillNo;
            HSourceBillType = data[0].HSourceBillType;
        }
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element','upload'], function () {
        }).use(['index', 'form', 'laydate', 'table', 'element', 'upload'], function () {
            //#region å…¬å…±å˜é‡
            var $ = layui.$
                , admin = layui.admin
@@ -397,7 +404,7 @@
            var HMaker = sessionStorage["HUserName"]
            var HStockOrgID = sessionStorage["OrganizationID"]  //组织ID
            var option = {};
            //#endregion
            //判断是否登录 æœªç™»å½•则跳到登录页
@@ -453,9 +460,35 @@
                //初始化日期、创建人、创建时间
                $("#HDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                $("#HMaker").val(HMaker);
                $("#HMakeDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                $("#HMakeDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                $("#HEmpID").val(sessionStorage["HEmpID"]); //根据登录用户带出操作员ID
                $("#HEmpName").val(sessionStorage["HEmpName"]); //根据登录用户带出操作员
                $("#HDeptID").val(sessionStorage["HDeptID"]); //根据登录用户带出车间ID
                $("#HDeptName").val(sessionStorage["HDept"]); //根据登录用户带出车间
                $("#HGroupID").val(sessionStorage["HGroupID"]); //根据登录用户带出班组ID
                $("#HGroupName").val(sessionStorage["HGroup"]); //根据登录用户带出班组
            }
            else if (OperationType == 2) {  //编辑
            else if (OperationType == 2) {  //复制
                //编辑状态时,根据内码,获取信息并写入界面
                RoadBillMain(HInterID);
                //文件选择初始化
                PicUpload();
                getFile();
                //获取最大单据号
                get_MAXNum();
                $("#HDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                $("#HMaker").val(HMaker);
                $("#HMakeDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                $("#HEmpID").val(sessionStorage["HEmpID"]); //根据登录用户带出操作员ID
                $("#HEmpName").val(sessionStorage["HEmpName"]); //根据登录用户带出操作员
                $("#HDeptID").val(sessionStorage["HDeptID"]); //根据登录用户带出车间ID
                $("#HDeptName").val(sessionStorage["HDept"]); //根据登录用户带出车间
                $("#HGroupID").val(sessionStorage["HGroupID"]); //根据登录用户带出班组ID
                $("#HGroupName").val(sessionStorage["HGroup"]); //根据登录用户带出班组
                OperationType = 1;
            }
            else if (OperationType == 3) {  //编辑
                $("#HInterID").val(HInterID);//修改时主表ID
                //编辑状态时,根据内码,获取信息并写入界面
                RoadBillMain(HInterID);
@@ -472,15 +505,21 @@
                $("#HDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                $("#HMaker").val(HMaker);
                $("#HMakeDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                $("#HEmpID").val(sessionStorage["HEmpID"]); //根据登录用户带出操作员ID
                $("#HEmpName").val(sessionStorage["HEmpName"]); //根据登录用户带出操作员
                $("#HDeptID").val(sessionStorage["HDeptID"]); //根据登录用户带出车间ID
                $("#HDeptName").val(sessionStorage["HDept"]); //根据登录用户带出车间
                $("#HGroupID").val(sessionStorage["HGroupID"]); //根据登录用户带出班组ID
                $("#HGroupName").val(sessionStorage["HGroup"]); //根据登录用户带出班组
                //工序流转卡页面下推
                if (HInterID == "") {    //报工台下推
                    set_ProcessBill(HSourceInterID, HSourceEntryID);
                } else {
                    set_ProcessBill(HInterID, HEntry);
                }
                OperationType = 1;
            }
            }
            else {
                layer.alert("未知操作类型!", { icon: 5 });
            }
@@ -521,7 +560,7 @@
                                $('#btn_Save').addClass("layui-btn-disabled").attr("disabled", true);
                            }
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HBillNo": data.单据号
                                "HBillNo": OperationType == 2 ? '' : data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HICMOInterID": data.HICMOInterID
                                , "HICMOEntryID": data.HICMOEntryID
@@ -570,7 +609,7 @@
                            for (let i = 0; i < result.data.length; i++) {
                                rowdata.push(
                                    {
                                        "HTechParamID": result.data[i].HTechParamID
                                        "HTechParamID": result.data[i].HTechParamID
                                        , "HTechParamNumber": result.data[i].HTechParamNumber
                                        , "HTechParamName": result.data[i].HTechParamName
                                        , 'HTechParamUnitID': result.data[i].HTechParamUnitID
@@ -589,6 +628,7 @@
                                        , 'HMax': result.data[i].HMax
                                        , 'HMin': result.data[i].HMin
                                        , 'HResult': result.data[i].HResult
                                        , 'HIsRequired': result.data[i].HIsRequired
                                        , 'HRemark': result.data[i].HRemark
                                    }
                                )
@@ -634,16 +674,17 @@
                        , { field: 'HTechParamUnitName', title: '工艺参数单位名称', width: 130, style: 'background-color:#efefef4d;' }
                        , { field: 'HSNO', title: '工艺次序', width: 110, style: 'background-color:#efefef4d;' }
                        , { field: 'HTechParamIDStd', title: 'HTechParamIDStd', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HTechParamIDStdName', title: '设备设定值工艺参数', width: 130, edit: 'text', event: "HTechParamIDStdName" }
                        , { field: 'HResultStd', title: '设备设定值', width: 130, edit: 'text' }
                        , { field: 'HVaule', title: '工艺参数值', width: 100, edit: false, event: "HVaule"  }
                        , { field: 'HTechParamIDStdName', title: '设备设定值工艺参数', hide: true, width: 130, edit: 'text', event: "HTechParamIDStdName" }
                        , { field: 'HResultStd', title: '设备设定值', hide: true, width: 130, edit: 'text' }
                        , { field: 'HVaule', title: '工艺参数值', width: 100, edit: false, event: "HVaule" }
                        , { field: 'HStd', title: '标准值', width: 100, edit: 'text' }
                        , { field: 'HMax', title: '上限', width: 100, edit: 'text' }
                        , { field: 'HMin', title: '下限', width: 100, edit: 'text' }
                        , { field: 'HResult', title: '检测结果', width: 100, templet: "#HResult" }
                        , { field: 'HIsRequired', title: '是否必录', width: 100, templet: "#HIsRequired" }
                        , { field: 'HRemark', title: '备注', width: 100, edit: 'text' }
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                    ]]
                        // , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                    ]]
                }
                var rowdata = [{
@@ -653,18 +694,19 @@
                    , "HTechParamID": "0"
                    , "HTechParamNumber": ""
                    , "HTechParamName": ""
                    ,"HSNO":"0"
                    , "HSNO": "0"
                    , "HTechParamUnitID": "0"
                    , "HTechParamUnitNumber": ""
                    , "HTechParamUnitName": ""
                    , "HTechParamIDStd": "0"
                    , "HTechParamIDStdName": ""
                    ,"HResultStd":""
                    , "HResultStd": ""
                    , "HVaule": ""
                    , "HStd": ""
                    , "HMax": ""
                    , "HMin": ""
                    , "HResult": "OK"
                    , "HIsRequired": false
                    , "HRemark": ""
                }];
@@ -729,7 +771,7 @@
                    , shift: 2                  //弹出动画
                    , area: ["90%", "90%"]      //窗体大小
                    , maxmin: true              //设置最大最小按钮是否显示
                    , content: ['../../基础资料/生产基础资料/Gy_Process.html', 'yes']
                    , content: ['../../基础资料/生产基础资料/Gy_Process.html?openType=2', 'yes']
                    , btn: ["确定", "取消"]
                    , btn1: function (index, laero) {
                        //按钮一  çš„回调
@@ -787,7 +829,7 @@
                    , shift: 2                  //弹出动画
                    , area: ["90%", "90%"]      //窗体大小
                    , maxmin: true              //设置最大最小按钮是否显示
                    , content: ['../../基础资料/生产基础资料/Gy_Source.html', 'yes']
                    , content: ['../../基础资料/生产基础资料/Gy_Source.html?Htype=&openType=2', 'yes']
                    , btn: ["确定", "取消"]
                    , btn1: function (index, laero) {
                        //按钮一  çš„回调
@@ -845,7 +887,7 @@
                    , shift: 2                  //弹出动画
                    , area: ["90%", "90%"]      //窗体大小
                    , maxmin: true              //设置最大最小按钮是否显示
                    , content: ['../../基础资料/公用基础资料/Gy_DepartmentList.html', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_DepartmentList.html?openType=2&HOrgName=' + sessionStorage["Organization"], 'yes']
                    , btn: ["确定", "取消"]
                    , btn1: function (index, laero) {
                        //按钮一  çš„回调
@@ -874,7 +916,7 @@
                    , shift: 2                  //弹出动画
                    , area: ["90%", "90%"]      //窗体大小
                    , maxmin: true              //设置最大最小按钮是否显示
                    , content: ['../../设备管理/设备档案/Gy_EquipFileMainList.html', 'yes']
                    , content: ['../../设备管理/设备档案/Gy_EquipFileMainList.html?openType=2', 'yes']
                    , btn: ["确定", "取消"]
                    , btn1: function (index, laero) {
                        //按钮一  çš„回调
@@ -990,6 +1032,7 @@
                    , "HMax": ""
                    , "HMin": ""
                    , "HResult": "OK"
                    , "HIsRequired": false
                    , "HRemark": ""
                };
@@ -1284,17 +1327,47 @@
                var field = cell.data('field'); // èŽ·å–å­—æ®µ
                var rowIndex = cell.closest('tr').data('index'); // èŽ·å–å½“å‰è¡Œæ•°æ®ç´¢å¼•
                // ä½¿ç”¨ layui çš„表格方法更新数据
                // ä½¿ç”¨layui的表格方法更新数据
                var updatedData = table.cache['mainTable'].map(function (item) {
                    if (item.LAY_TABLE_INDEX === rowIndex) { // ä½¿ç”¨ numbers åˆ—索引定位
                    if (item.LAY_TABLE_INDEX === rowIndex) { // ä½¿ç”¨numbers列索引定位
                        item[field] = newValue;
                    }
                    return item;
                });
                layui.table.reload('mainTable', {
                    data: updatedData
                // èŽ·å–å½“å‰è¡Œæ•°æ®
                var currentRowData = table.cache['mainTable'].find(function (item) {
                    return item.LAY_TABLE_INDEX === rowIndex;
                });
                // å‡è®¾è¿™é‡Œè¦åˆ¤æ–­çš„字段是 'HVaule',你可以根据实际需求修改要判断的字段名
                if (field === 'HVaule') {
                    var valueToCheck = parseFloat(newValue);
                    var lowerLimit = parseFloat(currentRowData.HMin);
                    var upperLimit = parseFloat(currentRowData.HMax);
                    // å¾ªçŽ¯éåŽ†å½“å‰è¡Œä¸Šä¸‹é™æ•°æ®å¹¶è¿›è¡Œåˆ¤æ–­ï¼ˆè¿™é‡Œå…¶å®žä¸»è¦æ˜¯åˆ¤æ–­å½“å‰è¡Œçš„ä¸Šä¸‹é™ä¸Žæ›´æ–°å€¼çš„å…³ç³»ï¼‰
                    if (valueToCheck >= lowerLimit && valueToCheck <= upperLimit) {
                        // æ›´æ–°å½“前行的HResult为OK
                        currentRowData.HResult = 'OK';
                    } else {
                        currentRowData.HResult = 'NG';
                    }
                }
                checkRefresh();
                //// ä½¿ç”¨ layui çš„表格方法更新数据
                //var updatedData = table.cache['mainTable'].map(function (item) {
                //    if (item.LAY_TABLE_INDEX === rowIndex) { // ä½¿ç”¨ numbers åˆ—索引定位
                //        item[field] = newValue; // æ›´æ–°å­—段值
                //        item.HResult = hResult; // æ›´æ–°æ£€æµ‹ç»“æžœ
                //    }
                //    return item;
                //});
                //layui.table.reload('mainTable', {
                //    data: updatedData
                //});
                // å–消编辑状态
                cell.removeAttr('contenteditable');
                //取消冒泡
@@ -1413,13 +1486,29 @@
                });
            });
            //是否 å¿…录控制
            form.on('checkbox(HIsRequired)', function (data) {
                //获取下拉框选中的值
                var elem = data.othis.parents('tr');
                var dataindex = elem.attr("data-index");
                $.each(option.data, function (index, value) {
                    if (value.LAY_TABLE_INDEX == dataindex) {
                        value.HIsRequired = data.elem.checked;//把选中下拉框id值赋值给表格缓存
                    }
                });
            });
            //行数据 ä¸‹æ‹‰å¤é€‰æ¡†  åˆ·æ–°è¡¨æ ¼
            function checkRefresh() {
                for (var i = 1; i <= option.data.length; i++) {
                    //状态
                    $('#HResult' + i + '').find("option[value='" + option.data[i - 1].HResult + "']").attr("selected", true);
                    $('#HResult' + i + '').find("option[value='" + option.data[i - 1].HResult + "']").prop("selected", true);
                    if (option.data[i - 1].HIsRequired) {
                        $('#HIsRequired' + i + '').attr("checked", true);
                    }
                }
                form.render('select');
                form.render('checkbox');
            }
            //#endregion
@@ -1474,6 +1563,13 @@
                            });
                            var rowdata = [];
                            for (var i = 0; i < result.data.length; i++) {
                                // èŽ·å–å½“å‰çš„æ•°é‡‡å€¼ã€ä¸Šé™å€¼å’Œä¸‹é™å€¼ï¼Œå¹¶ç¡®ä¿å®ƒä»¬æ˜¯æ•°å€¼ç±»åž‹
                                var value = parseFloat(result.data[i]["数采值"]);
                                var max = parseFloat(result.data[i]["上限值"]);
                                var min = parseFloat(result.data[i]["下限值"]);
                                // åˆ¤æ–­ HResult çš„值
                                var hResult = (value <= max && value >= min) ? "OK" : "NG";
                                rowdata.push(
                                    {
                                        "HTechParamClassID": result.data[i]["HTechParamClassID"] == null ? 0 : result.data[i]["HTechParamClassID"],
@@ -1483,7 +1579,7 @@
                                        "HTechParamName": result.data[i]["工艺参数名称"],
                                        "HTechParamUnitID": result.data[i]["HTechParamUnitID"] == null ? 0 : result.data[i]["HTechParamUnitID"],
                                        "HTechParamUnitNumber": result.data[i]["工艺参数单位代码"],
                                        "HTechParamUnitName": result.data[i]["工艺参数单位名称"] ,
                                        "HTechParamUnitName": result.data[i]["工艺参数单位名称"],
                                        "HSNO": result.data[i]["工艺次序"] == null ? 0 : result.data[i]["工艺次序"],
                                        "HTechParamIDStd": result.data[i]["HTechParamIDStd"] == null ? 0 : result.data[i]["HTechParamIDStd"],
                                        "HTechParamIDStdName": result.data[i]["对应设定值工艺参数"],
@@ -1492,13 +1588,15 @@
                                        "HStd": result.data[i]["标准值"],
                                        "HMax": result.data[i]["上限值"],
                                        "HMin": result.data[i]["下限值"],
                                        "HRemark": result.data[i]["采集来源"]
                                        "HRemark": result.data[i]["采集来源"],
                                        "HResult": hResult,
                                        "HIsRequired": result.data[i]["HIsRequired"]
                                    }
                                );
                            }
                            option.data = rowdata;
                            table.render(option);
                            checkRefresh();
                            layer.close(ajaxLoad);
                        } else {
                            layer.close(ajaxLoad);
@@ -1511,7 +1609,7 @@
                })
            }
            //#endregion
            //#region åŠŸèƒ½æŽ§ä»¶
            //#region æäº¤
@@ -1555,6 +1653,12 @@
                        if (data.count == 1) {
                            layer.msg(data.Message, { icon: 1 });
                            $('#btn_Save').addClass("layui-btn-disabled").attr("disabled", true);
                            if (data.Verify == "Y") //自动审核
                            {
                                $("#HInterID").val(data.HInterID);//获取提交成功返回的单据主ID
                                set_CheckBill(1); //审核
                            }
                            layer.close(index);
                            layer.close(index);
                        }
                        else {
@@ -1573,11 +1677,39 @@
            //#endregion
            //#region  å®¡æ ¸ï¼ˆnum=1)/反审核(num=2)
            function set_CheckBill(num) {
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBill_Check_Json",
                    async: false,    //async用于控制(false)同步和(true)异步,默认的是true,即请求默认的是异步请求
                    data: { "HInterID": HInterID, "Type": num, "HMaker": HMaker },
                    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);
                                //修改为功后刷新界面
                                $("#btnSearch").trigger('click');
                            });
                        } else {
                            layer.msg(result.Message, { icon: 2, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        }
                    }, error: function () {
                        layer.msg('错误' + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                });
            }
            //#endregion
            //#region é€€å‡º
            form.on('submit(btn_Cancel)', function () {
                layer.confirm('您确定要退出吗?', { icon: 3, title: '提示' }, function (index) {
                    //操作类型(OperationType=1新增、OperationType=2编辑)
                    if (OperationType == 2) {
                    if (OperationType == 2 || OperationType == 1) {
                        Pub_Close(1);
                    }
                    else {
@@ -1774,7 +1906,15 @@
                sSubStr = JSON.parse(sSubStr);
                for (var i = 0; i <= sSubStr.length - 1; i++) {
                    if (sSubStr[i].HTechParamID == "0") {
                        layer.msg("明细记录第" + (i + 1) + "行,工艺参数信息为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        layer.msg("明细记录第" + (i + 1) + "行,工艺参数代码/名称不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        return Result = false;
                    }
                    //if (sSubStr[i].HRemark == "手动输入" && (sSubStr[i].HVaule == "" || sSubStr[i].HVaule == null)) {
                    //    layer.msg("明细记录第" + (i + 1) + "行,手术输入的工艺参数值不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    //    return Result = false;
                    //}
                    if (sSubStr[i].HIsRequired == "true" && (sSubStr[i].HVaule == "" || sSubStr[i].HVaule == null)) {
                        layer.msg("明细记录第" + (i + 1) + "行,工艺参数值不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        return Result = false;
                    }
                }
@@ -1849,7 +1989,7 @@
                });
            })
        }
        //#endregion
            //#endregion
    </script>
</body>
</html>