1
duhe
2024-08-15 40cd70d9a9d13001c1b6c2269334e8a363c562c3
WebTM/views/Éú²ú¹ÜÀí/Éú²ú¿ª¹¤µ¥/Sc_Add_MESBeginWorkBillList.html
@@ -101,7 +101,7 @@
                                            <li class="layui-this">基本信息</li>
                                            <li>制单信息</li>
                                        </ul>
                                        <div class="layui-tab-content" style="height: 700px;">
                                        <div class="layui-tab-content" style="height: 400px;">
                                            <div class="layui-tab-item layui-show">
                                                <div class="layui-form-item">
                                                    <div class="layui-inline">
@@ -109,7 +109,7 @@
                                                        <div class="layui-input-inline">
                                                            <input class="layui-input" name="HBillNo" lay-verify="HBillNo" id="HBillNo" disabled autocomplete="off">
                                                            <input id="HInterID" name="HInterID" type="hidden" />
                                                        </div>
                                                    </div>
                                                    <div class="layui-inline">
@@ -154,7 +154,7 @@
                                                    <div class="layui-inline">
                                                        <label class="layui-form-label">开工时间:</label>
                                                        <div class="layui-input-inline">
                                                            <input class="layui-input" name="HBeginDate" id="HBeginDate" autocomplete="off" model="datetime" dateFormat="yyyy-MM-dd" placeholder="yyyy-MM-dd">
                                                            <input class="layui-input" name="HBeginWorkTime" id="HBeginWorkTime" autocomplete="off" model="datetime" dateFormat="yyyy-MM-dd" placeholder="yyyy-MM-dd">
                                                        </div>
                                                    </div>
                                                    <div class="layui-inline">
@@ -310,6 +310,23 @@
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-tab" lay-filter="tab-POStockInBill">
                                    <ul class="layui-tab-title" lay-filter="tab-all">
                                        <li lay-id="1" style="padding:1px;" class="layui-this">计划单</li>
                                    </ul>
                                    <div class="layui-tab-content">
                                        <!--子表-->
                                        <div class="layui-tab-item layui-show">
                                            <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                                            <script type="text/html" id="toolbarDemo">
                                                <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>
                                                </div>
                                            </script>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
@@ -319,11 +336,13 @@
    </div>
    <script>
        //获取参数
        var OptionData = [];
        var HBillType = "";  //单据类型
        var HSourceInterID = ""; //源单主内码
        var HSourceEntryID = "";  //源单子内码
        var HSourceBillNo = "";   //源单单号
        var HSourceBillType = "";  //源单类型
        var refSav = "";   //提交类型
        //获取页面跳转参数  //单据编辑状态: 1.无源单新增  Â 2.有源单新增  Â 3.编辑  4.浏览  5.变更
        var params = get_UrlVars();
        if (typeof (params[params[0]]) == "undefined") {
@@ -364,13 +383,26 @@
            //判断操作类型
            if (OperationType == 1) {//无源单
                $("#HEmpID").val(sessionStorage["HEmpID"]); //根据登录用户带出操作员ID
                $("#HEmpName").val(sessionStorage["HEmpName"]); //根据登录用户带出操作员
                $("#HGroupID").val(sessionStorage["HGroupID"]); //根据登录用户带出班组ID
                $("#HGroupName").val(sessionStorage["HGroup"]); //根据登录用户带出班组
                //初始化计划表
                get_InitGrid();
                set_AddFNew();
            }
            else if (OperationType == 2) {//有源单
                $("#HEmpID").val(sessionStorage["HEmpID"]); //根据登录用户带出操作员ID
                $("#HEmpName").val(sessionStorage["HEmpName"]); //根据登录用户带出操作员
                $("#HGroupID").val(sessionStorage["HGroupID"]); //根据登录用户带出班组ID
                $("#HGroupName").val(sessionStorage["HGroup"]); //根据登录用户带出班组
                //初始化计划表
                get_InitGrid();
                set_AddNew();
            }
            else if (OperationType == 3) {//编辑
                //初始化计划表
                get_InitGrid();
                set_EditFromGrid();
            }
            else {
@@ -381,7 +413,7 @@
            function set_InitFrom() {
                //日期时间选择器
                laydate.render({
                    elem: '#HBeginDate'
                    elem: '#HBeginWorkTime'
                    , type: 'datetime'
                });
                laydate.render({
@@ -421,11 +453,14 @@
            }
            //有源单新增
            function set_AddNew() {
                refSav = "Add";
                //初始基本信息赋值
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));      //单据日期
                $("#HBeginDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"))  //开工日期
                $("#HBeginWorkTime").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"))  //开工日期
                $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));  //制单日期
                $("#HMaker").val(sessionStorage["HUserName"]);     //制单人
@@ -435,7 +470,7 @@
                $('#HMaterList').addClass("layui-btn-disabled").attr("disabled", true);
                $('#HMaterName').attr("disabled", true);
                $('#HMaterSpec').attr("disabled", true);
                $('#HBeginDate').attr("disabled", true);
                $('#HBeginWorkTime').attr("disabled", true);
                $('#HSourceName').attr("disabled", true);
                $('#HSourceList').addClass("layui-btn-disabled").attr("disabled", true);
                $('#HMainSourceBillNo').attr("disabled", true);
@@ -470,7 +505,7 @@
                                $("#HMaterSpec").val(LoadData[0].HModel); //产品规格
                                $("#HSourceID").val(LoadData[0].HSourceID); //生产资源ID
                                $("#HSourceName").val(LoadData[0].HSourceName); //生产资源
                                $("#HMainSourceBillNo").val(LoadData[0].HICMOBillNo); //源单单号(暂时取值订单编号)
                                $("#HMainSourceBillNo").val(LoadData[0].HSourceBillNo); //源单单号
                                $("#HMainSourceInterID").val(LoadData[0].HSourceInterID); //源单主内码(取值HInterID)
                                $("#HMainSourceEntryID").val(LoadData[0].HSourceEntryID); //源单子内码(源单行号)
                                $("#HMainSourceBillType").val(HSourceBillType); //源单类型
@@ -494,11 +529,12 @@
            //编辑
            function set_EditFromGrid()
            {
                refSav = "Update";
                $('#HMaterCode').attr("disabled", true);
                $('#HMaterList').addClass("layui-btn-disabled").attr("disabled", true);
                $('#HMaterName').attr("disabled", true);
                $('#HMaterSpec').attr("disabled", true);
                $('#HBeginDate').attr("disabled", true);
                $('#HBeginWorkTime').attr("disabled", true);
                $('#HSourceName').attr("disabled", true);
                $('#HSourceList').addClass("layui-btn-disabled").attr("disabled", true);
                $('#HMainSourceBillNo').attr("disabled", true);
@@ -518,18 +554,19 @@
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data.h_v_Sc_MESBeginWorkBillList_NEW[0];
                            var data = result.data.h_v_Sc_MESBeginWorkBillList_Edit[0];
                            var tableSub = result.data.h_v_Sc_MESBeginWorkBillList_Edit;
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HInterID": data.hmainid
                                , "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HDate": Format(data.日期)
                                , "HProcID": data.HProcID
                                , "HProcName": data.工序名称
                                , "HMaterID": data.HMaterID
                                , "HMaterCode": data.产品代码
                                , "HMaterName": data.产品名称
                                , "HMaterSpec": data.规格型号
                                , "HBeginDate": data.开工时间
                                , "HBeginWorkTime": Format(data.开工时间)
                                , "HSourceID": data.HSourceID              //资源ID
                                , "HSourceName": data.资源名称             //资源名称
                                , "HEmpID": data.HEmpID                   //操作员ID
@@ -558,6 +595,20 @@
                                , "HDeleteDate": data.作废日期       //作废日期
                            });
                            //子表  èµ‹å€¼
                            var rowdata = [];
                            for (var i = 0; i < tableSub.length; i++) {
                                rowdata.push(
                                    {
                                        "HRelationBillInterID": tableSub[i].HRelationBillInterID, "HRelationBillEntryID": tableSub[i].HRelationBillEntryID, "HRelationBillNo": tableSub[i].HRelationBillNo, "HRelationBillType": tableSub[i].HRelationBillType,
                                        "HICMOInterID": tableSub[i].生产订单内码, "HICMOEntryID": tableSub[i].生产订单子内码, "HICMOBillNo": tableSub[i].生产订单, "HRemark": tableSub[i].备注,
                                        "HProcExchInterID": tableSub[i].HProcExchInterID, "HProcExchEntryID": tableSub[i].HProcExchEntryID, "HProcExchBillNo": tableSub[i].HProcExchBillNo,
                                        "HMaterID": tableSub[i].HMaterID, "HMaterName": tableSub[i].产品名称, "HProcID": tableSub[i].HProcID, "HProcName": tableSub[i].工序名称,
                                    }
                                )
                            }
                            option.data = rowdata;
                            table.render(option);
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
@@ -614,38 +665,12 @@
            //保存提交
            form.on('submit(Saver)', function (data) {
                var sMainStr = JSON.stringify(data.field);
                if (!AllowLoadData())//数据验证
                {
                    return false;
                }
                $.ajax({
                    type: "POST",
                    url: GetWEBURL() + "/Sc_MESBeginWorkBill/SaveGetMESBeginWorkFrom", //方法所在页面和方法名
                    async: true,
                    data: { "msg": sMainStr },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            $("#HInterID").val(data.HInterID);//获取提交成功返回的单据主ID
                            layer.confirm(data.Message, {
                                btn: ['确认']
                            }, function (index) {
                                 if (data.Verify == "Y") //自动审核
                                 {
                                     SaveVerify(); //审核
                                 }
                            });
                        }
                        else {
                            layer.alert(data.Message, { icon: 5 })
                        }
                    },
                    error: function (err) {
                        layer.alert(err, { icon: 5 })
                    }
                })
            form.on('submit(Saver)', function (data) {
                //禁用保存按钮
                $('#Saver').addClass("layui-btn-disabled").attr("disabled", true);
                //判断系统参数是否勾选
                Xt_AllowLoadData(data);
            });
            //审核按钮提交
@@ -662,7 +687,7 @@
                    return false;
                }
                $.ajax({
                    type: "POST",
                    type: "GET",
                    url: GetWEBURL() + "/Sc_MESBeginWorkBill/AuditProcessReportList", //方法所在页面和方法名
                    async: true,
                    data: { "HInterID": InterID, "IsAudit": 0, "CurUserName": sessionStorage["HUserName"] },
@@ -688,7 +713,7 @@
            //退出
            form.on('submit(Exit)', function (data) {
                Pub_Close(1);
                window.parent.location.reload();
                parent.location.reload();
            });
@@ -703,7 +728,7 @@
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/PartInformation.html', 'yes'],
                    content: ['../../../基础资料/公用基础资料/Gy_Material.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
@@ -713,10 +738,10 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HMaterName").val(checkStatus.data[0].HName);
                        $("#HMaterCode").val(checkStatus.data[0].HNumber);
                        $("#HMaterName").val(checkStatus.data[0].物料名称);
                        $("#HMaterNumber").val(checkStatus.data[0].物料代码);
                        $("#HMaterID").val(checkStatus.data[0].HItemID);
                        $("#HMaterSpec").val(checkStatus.data[0].HModel);
                        $("#HMaterSpec").val(checkStatus.data[0].规格型号);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
@@ -743,7 +768,7 @@
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/SourceInformation.html', 'yes'],
                    content: ['../../../基础资料/生产基础资料/Gy_Source.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
@@ -753,7 +778,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HSourceName").val(checkStatus.data[0].HName);
                        $("#HSourceName").val(checkStatus.data[0].生产资源名称);
                        $("#HSourceID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -781,7 +806,7 @@
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/UserInformation.html', 'yes'],
                    content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html?type=HEmp', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
@@ -791,7 +816,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HEmpName").val(checkStatus.data[0].HName);
                        $("#HEmpName").val(checkStatus.data[0].职员名称);
                        $("#HEmpID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -821,7 +846,7 @@
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/GroupInformation.html', 'yes'],
                    content: ['../../基础资料/工资基础资料/Gy_Group.html?type=HGroup', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
@@ -831,7 +856,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HGroupName").val(checkStatus.data[0].HName);
                        $("#HGroupName").val(checkStatus.data[0].班组名称);
                        $("#HGroupID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -859,7 +884,7 @@
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/DeptInformation.html', 'yes'],
                    content: ['../../../基础资料/公用基础资料/Gy_DepartmentList.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
@@ -869,7 +894,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HDeptName").val(checkStatus.data[0].HName);
                        $("#HDeptName").val(checkStatus.data[0].部门名称);
                        $("#HDeptID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -887,8 +912,294 @@
            });
            //以上为layui模块
        });
            //#region å­è¡¨ï¼šå¤´å·¥å…·æ äº‹ä»¶
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                //新增行表格数据
                var NewRow =
                {
                    "HMaterID": "0"
                    , "HMaterName": ""
                    , "HProcID": "0"
                    , "HProcName": ""
                    , "HRelationBillInterID": "0"
                    , "HRelationBillEntryID": "0"
                    , "HRelationBillType": ""
                    , "HRelationBillNo": ""
                    , "HICMOInterID": "0"
                    , "HICMOEntryID": "0"
                    , "HICMOBillNo": ""
                    , "HProcExchInterID": "0"
                    , "HProcExchEntryID": "0"
                    , "HProcExchBillNo": ""
                    , "HRemark": ""
                    , "HSourceInterID": "0"
                    , "HSourceEntryID": "0"
                    , "HSourceBillNo": ""
                    , "HSourceBillType": ""
                };
                switch (obj.event) {
                    case 'btn-AddLine':
                        table.cache["mainTable"].push(NewRow);
                        option.data = table.cache["mainTable"];
                        table.render(option);
                        break;
                    case 'btn-CopyLine':
                        var copydata = JSON.stringify(data);
                        if (data.length <= 0) {
                            layer.msg("请选择需要复制的一行!");
                        }
                        else if (data.length > 1) {
                            layer.msg("只能选择复制一行!");
                        }
                        else {
                            var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
                            var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
                            table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.render(option);//将数据渲染到表格上
                        }
                        break;
                    //上一行
                    case 'btn_up':
                        btn_up(data);
                        break;
                    //下一行
                    case 'btn_under':
                        btn_under(data);
                        break;
                }
            });
            //#endregion
            //#region å­è¡¨ï¼šè¡Œå†…事件
            table.on('tool(mainTable)', function (obj) {
                set_GridDelete(obj);   //行内删除
                set_GridCellCheck(obj); //行内快捷键筛选
            });
            //#endregion
            //#region è®¡åˆ’表初始化
            function get_InitGrid() {
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , limit: 100
                    , totalRow: true
                    , cellMinWidth: 120
                    , height: 400
                    , cols: [[
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', style: 'background-color: #f9f9f9;' }
                        , { field: 'HRelationBillInterID', title: '关联副产计划单内码', hide: true }
                        , { field: 'HRelationBillEntryID', title: '关联副产计划单子内码', hide: true }
                        , { field: 'HRelationBillType', title: '关联副产计划单类型', hide: true }
                        , { field: 'HRelationBillNo', title: '关联副产计划单', edit: 'text', event: "HRelationBillNo" }
                        , { field: 'HMaterID', title: 'HMaterID', event: "HMaterID", hide: true }
                        , { field: 'HMaterName', title: '物料名称', style: 'background-color: #f9f9f9;' }
                        , { field: 'HProcID', title: 'HProcID', edit: 'text', hide: true }
                        , { field: 'HProcName', title: '工序名称', edit: 'text', event: "HProcID" }
                        , { field: 'HICMOInterID', title: '生产订单内码', hide: true }
                        , { field: 'HICMOEntryID', title: '生产订单子内码', hide: true }
                        , { field: 'HICMOBillNo', title: '生产订单号', style: 'background-color: #f9f9f9;' }
                        , { field: 'HProcExchInterID', title: '工序流转卡内码', hide: true }
                        , { field: 'HProcExchEntryID', title: '工序流转卡子内码', hide: true }
                        , { field: 'HProcExchBillNo', title: '工序流转卡号', templet: "#HProcExchInterID" }
                        , { field: 'HRemark', title: '备注', edit: 'text' }
                        , { field: 'HSourceInterID', title: '源单内码', hide: true }
                        , { field: 'HSourceEntryID', title: '源单子内码', hide: true }
                        , { field: 'HSourceBillNo', title: '源单单号', hide: true }
                        , { field: 'HSourceBillType', title: '源单类型', hide: true }
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo' }
                    ]]
                }
                var rowdata = [
                    {
                        "HMaterID": "0"
                        , "HMaterName": ""
                        , "HProcID": "0"
                        , "HProcName": ""
                        , "HRelationBillInterID": "0"
                        , "HRelationBillEntryID": "0"
                        , "HRelationBillType": ""
                        , "HRelationBillNo": ""
                        , "HICMOInterID": "0"
                        , "HICMOEntryID": "0"
                        , "HICMOBillNo": ""
                        , "HProcExchInterID": "0"
                        , "HProcExchEntryID": "0"
                        , "HProcExchBillNo": ""
                        , "HRemark": ""
                        , "HSourceInterID": "0"
                        , "HSourceEntryID": "0"
                        , "HSourceBillNo": ""
                        , "HSourceBillType": ""
                    }
                ];
                option.data = rowdata;
                table.render(option);
                form.render('select');
            }
            //#endregion
            //#region å­è¡¨ï¼šåˆ é™¤æŒ‡å®šè¡Œ
            function set_GridDelete(obj) {
                var data = obj.data;
                var rowIndex = $(obj.tr).attr("data-index");
                if (obj.event === 'del') {
                    layer.confirm('真的删除行吗?', function (index) {
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                            layer.msg('首行无法删除!!!');
                        } else {
                            var oldData = table.cache["mainTable"];
                            oldData.splice(obj.tr.data('index'), 1)
                            option.data = oldData;//将数据绑定到data上
                            table.render(option);
                            for (var i = 0; i < oldData.length; i++) {
                                $('#HICMOBillNo' + (i + 1)).find("option[value='" + oldData[i].HICMOBillNo + "']").attr("selected", true);
                            }
                            form.render('select');
                            layer.close(index);
                        }
                    });
                }
            }
            //#endregion
            //#region å­è¡¨ï¼šå¿«æ·é”®(F7)打开弹窗
            function set_GridCellCheck(obj) {
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                    if (event.key == "F7") {
                        if (obj.event == "HRelationBillNo") {
                            layer.open({
                                type: 2
                                , skin: "layui-layer-rim"                           //加上边框
                                , title: "副产计划单"                             //标题
                                , closeBtn: 1                                       //窗体右上角关闭 çš„ æ ·å¼
                                , shift: 2                                          //弹出动画
                                , area: ["90%", "90%"]                              //窗体大小
                                , maxmin: true                                      //设置最大最小按钮是否显示
                                , content: ['../../../views/Baseset/基础资料/Sc_ProcessExchangeBillListView.html', 'yes']
                                , btn: ["确定", "取消"]
                                , btn1: function (index, laero) {
                                    //按钮一  çš„回调
                                    var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                    if (checkStatus.data.length != 1) {
                                        return layer.msg("请选择一条数据");
                                    }
                                    if ($("#HMaterName").val() == checkStatus.data[0].产品 && $("#HProcName").val() == checkStatus.data[0].工序) {
                                        obj.update({
                                            "HProcExchInterID": checkStatus.data[0].hmainid
                                            , "HProcExchEntryID": checkStatus.data[0].hsubid
                                            , "HProcExchBillNo": checkStatus.data[0].单据号
                                            , "HRelationBillInterID": checkStatus.data[0].hmainid
                                            , "HRelationBillEntryID": checkStatus.data[0].hsubid
                                            , "HRelationBillNo": checkStatus.data[0].单据号
                                            , "HICMOInterID": checkStatus.data[0].hicmointerid
                                            , "HICMOEntryID": checkStatus.data[0].HICMOEntryID
                                            , "HICMOBillNo": checkStatus.data[0].生产订单号
                                            , "HMaterID": checkStatus.data[0].HMaterID
                                            , "HMaterName": checkStatus.data[0].产品
                                            , "HProcID": checkStatus.data[0].HProcID
                                            , "HProcName": checkStatus.data[0].工序
                                            , "HSourceInterID": checkStatus.data[0].hmainid
                                            , "HSourceEntryID": checkStatus.data[0].hsubid
                                            , "HSourceBillNo": checkStatus.data[0].单据号
                                            , "HSourceBillType": 3772
                                        })
                                    }
                                    else {
                                        return layer.msg("选择副产计划单的物料与工序,跟当前工单不匹配");
                                    }
                                    layer.close(index);//关闭弹窗
                                }
                                , btn2: function (index, layero) { }
                                , end: function () {
                                    if ($("#HMaterName").val() == OptionData[0].产品 && $("#HProcName").val() == OptionData[0].工序) {
                                        obj.update({
                                            "HProcExchInterID": OptionData[0].hmainid
                                            , "HProcExchEntryID": OptionData[0].hsubid
                                            , "HProcExchBillNo": OptionData[0].单据号
                                            , "HRelationBillInterID": OptionData[0].hmainid
                                            , "HRelationBillEntryID": OptionData[0].hsubid
                                            , "HRelationBillNo": OptionData[0].单据号
                                            , "HICMOInterID": OptionData[0].hicmointerid
                                            , "HICMOEntryID": OptionData[0].HICMOEntryID
                                            , "HICMOBillNo": OptionData[0].生产订单号
                                            , "HMaterID": OptionData[0].HMaterID
                                            , "HMaterName": OptionData[0].产品
                                            , "HProcID": OptionData[0].HProcID
                                            , "HProcName": OptionData[0].工序
                                            , "HSourceInterID": OptionData[0].hmainid
                                            , "HSourceEntryID": OptionData[0].hsubid
                                            , "HSourceBillNo": OptionData[0].单据号
                                            , "HSourceBillType": 3772
                                        })
                                    } else {
                                        return layer.msg("选择副产计划单的物料与工序,跟当前工单不匹配");
                                    }
                                    OptionData = [];
                                }
                            })
                        }
                        if (obj.event == "HProcID") {
                            layer.open({
                                type: 2
                                , skin: "layui-layer-rim"                           //加上边框
                                , title: "副产计划单"                             //标题
                                , closeBtn: 1                                       //窗体右上角关闭 çš„ æ ·å¼
                                , shift: 2                                          //弹出动画
                                , area: ["90%", "90%"]                              //窗体大小
                                , maxmin: true                                      //设置最大最小按钮是否显示
                                , content: ['../../../views/基础资料/生产基础资料/Gy_Process.html', 'yes']
                                , btn: ["确定", "取消"]
                                , btn1: function (index, laero) {
                                    //按钮一  çš„回调
                                    var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                    if (checkStatus.data.length != 1) {
                                        return layer.msg("请选择一条数据");
                                    }
                                    if ($("#HProcName").val() == checkStatus.data[0].工序名称) {
                                        obj.update({
                                            "HProcID": checkStatus.data[0].HItemID
                                            , "HProcName": checkStatus.data[0].工序名称
                                        })
                                    } else {
                                        return layer.msg("选择的工序,跟当前工单的工序不匹配");
                                    }
                                    layer.close(index);//关闭弹窗
                                }
                                , btn2: function (index, layero) { }
                                , end: function () {
                                }
                            })
                        }
                        obj.event = "";
                        return false;
                    }
                })
            }
            //#endregion
        function AllowLoadData() {  //非空验证
            var Result = true;
@@ -904,7 +1215,7 @@
                layer.msg("产品编码不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return Result = false;
            }
            if ($("#HBeginDate").val() == '' || $("#HBeginDate").val() == null) {
            if ($("#HBeginWorkTime").val() == '' || $("#HBeginWorkTime").val() == null) {
                layer.msg("开工时间不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return Result = false;
            }
@@ -933,6 +1244,124 @@
            return Result;
        }
        //判断系统参数是否选中
        function Xt_AllowLoadData(data2) {
            $.ajax({
                type: "GET",
                url: GetWEBURL() + "/Sc_MESBeginWorkBill/Xt_AllowLoadData", //方法所在页面和方法名
                async: false,
                data: { "HKey": "Sc_MESBeginWorkBill_SwipeCardStart" },
                success: function (data) {
                    if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                        if (data.Verify == "Y") //刷卡验证
                        {
                            layer.msg("需要进行刷卡验证!", { time: 1 * 1000, icon: 1 }, function (index) {
                                layer.open({
                                    type: 2,
                                    skin: 'layui-layer-rim', //加上边框
                                    title: 'IC刷卡',
                                    closeBtn: 1,
                                    shift: 2,
                                    area: ['50%', '80%'],
                                    maxmin: true,
                                    content: '../../生产管理/报工台工序/开工/Sc_SwipeCardStart.html?HSourceInterID=' + HSourceInterID,
                                    end: function () {
                                        if (OptionData.length > 0) {
                                            if (OptionData[0]["data"] == "1") {
                                                save(data2);
                                            } else if (OptionData[0]["data"] == "0") {
                                                layer.msg("因为技能不匹配,无法保存!")
                                            }
                                            OptionData = [];
                                        } else {
                                            $('#Saver').removeClass("layui-btn-disabled").attr("disabled", false);
                                        }
                                    }
                                });
                            });
                        }
                        else {
                            save(data2);
                        }
                    }
                    else {
                        layer.alert(data.Message, { icon: 5 })
                    }
                },
                error: function (err) {
                    layer.alert(err, { icon: 5 })
                }
            })
        }
        //保存
        function save(data) {
            var index = layer.load();
            //获取子表数据
            var num = [];
            for (var i = 0; i < table.cache["mainTable"].length; i++) {
                if (table.cache["mainTable"][i] != "") {
                    table.cache["mainTable"][i].LAY_TABLE_INDEX = i;
                    num.push(table.cache["mainTable"][i])
                }
            }
            //子表数据序列化
            var sSubStr = JSON.stringify(num);
            var sMainStr = JSON.stringify(data.field);
            var sMainSub = sMainStr + ';' + sSubStr + ';' + sessionStorage["HUserName"] + ';' + refSav;
            if (!AllowLoadData())//数据验证
            {
                return false;
            }
            $.ajax({
                type: "POST",
                url: GetWEBURL() + "/Sc_MESBeginWorkBill/SaveGetMESBeginWorkFrom", //方法所在页面和方法名
                async: false,
                data: { "msg": sMainSub },
                dataType: "json",
                success: function (data) {
                    if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                        $("#HInterID").val(data.HInterID);//获取提交成功返回的单据主ID
                        layer.msg(data.Message, { time: 1 * 2000, icon: 1 }, function (index) {
                            //layer.close(layer.index);
                            //window.parent.location.reload();
                            if (data.Verify == "Y") //自动审核
                            {
                                layer.close(index);
                                SaveVerify(); //审核
                            }
                            else {
                                layer.close(index);
                            }
                        });
                        layer.close(index);
                        //layer.confirm(data.Message, {
                        //    btn: ['确认']
                        //}, function (index) {
                        //        if (data.Verify == "Y") //自动审核
                        //        {
                        //            layer.close(index);
                        //            SaveVerify(); //审核
                        //        }
                        //        else {
                        //            layer.close(index);
                        //        }
                        //});
                    }
                    else {
                        layer.alert(data.Message, { icon: 5 })
                        layer.close(index);
                    }
                },
                error: function (err) {
                    layer.alert(err, { icon: 5 })
                    layer.close(index);
                }
            })
        }
            //以上为layui模块
        });
        function formatDate(date) {
            var d = new Date(date),
                month = '' + (d.getMonth() + 1),
@@ -944,6 +1373,25 @@
            return [year, month, day].join('-');
        }
        //操作员
        function GetHEmpValue(obj) {
            $("#HEmpName").val(obj[0].职员名称);
            $("#HEmpID").val(obj[0].HItemID);
        }
        //生产班组
        function GetHGroupValue(obj) {
            $("#HGroupName").val(obj[0].班组名称);
            $("#HGroupID").val(obj[0].HItemID);
        }
        function GetSwipeCardStart(obj) {
            OptionData[0] = obj;
        }
        //流转卡
        function GetProcExValue(obj) {
            OptionData = obj;
        }
    </script>
</body>
</html>