yangle
2022-09-07 d9ccb1dfdb438225014b0b95d642a4e2a0c3736b
WebTM/views/Éú²ú¹ÜÀí/ÉÏÁÏ·À´íµ¥/Sc_Add_MaterToSourceBillList.html
@@ -383,7 +383,8 @@
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element'], function () {
             //#region å…¬ç”¨å˜é‡
            //#region å…¬ç”¨å˜é‡
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
@@ -396,7 +397,7 @@
            var option2;
            //#endregion
            //#region è¿›å…¥é¡µé¢å³åŠ è½½
            //初始化表单插件
            set_InitFrom();
@@ -418,302 +419,9 @@
                layer.alert("未知操作类型!", { icon: 5 });
            }
            //初始化插件
            function set_InitFrom() {
                //日期时间选择器
                laydate.render({
                    elem: '#HDate'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#HMakeDate'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#HUpDateDate'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#HCheckDate'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#HCloseDate'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#HDeleteDate'
                    , type: 'datetime'
                });
            }
            //#endregion
            //初始化表格
            function set_InitGrid() {
                Table1();  //保养项列表
                Table2();  //配件项列表
            }
            //初始化配料列表
            function Table1() {
                //表头
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe" }
                    , { field: 'HBarCode', title: '扫描条码', edit: 'text', hide: true }
                    , { field: 'HMaterID', title: '物料ID', edit: 'text', hide: true }
                    , { field: 'HNumber', title: '物料代码', edit: 'text' }
                    , { field: 'HName', title: '物料名称', edit: 'text' }
                    , { field: 'HModel', title: '规格型号', edit: 'text' }
                    , { field: 'HUnitID', title: '单位ID', edit: 'text', hide: true }
                    , { field: 'HUnitName', title: '单位', edit: 'text' }
                    , { field: 'HMQty', title: '配料数量', edit: 'text' }
                    , { field: 'HQty', title: '实配数量', edit: 'text' }
                ];
                option = {
                    id: 'mainTable'
                    , elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , defaultToolbar: false  //是否显示右侧工具栏
                    , page: false
                    , cellMinWidth: 120
                    , height: 350
                    , cols: [columns]
                    , done: function (res, curr, count) {
                    }
                };
            }
            //初始化配件项列表
            function Table2() {
                //表头
                columns1 = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao1', title: '序号', sort: true, fixed: 'left', event: "qwe" }
                    , { field: 'HMouldID', title: '治具ID', edit: 'text', hide: true}
                    , { field: 'HMouldNumber', title: '治具代码', edit: 'text' }
                    , { field: 'HMouldName', title: '治具名称', edit: 'text' }
                    , { field: 'HMouldSpec', title: '规格型号', edit: 'text' }
                ];
                option2 = {
                    id: 'mainTable1'
                    , elem: '#mainTable1'
                    , toolbar: '#toolbarDemo1'
                    , defaultToolbar: false  //是否显示右侧工具栏
                    , page: false
                    , cellMinWidth: 120
                    , height: 350
                    , cols: [columns1]
                    , done: function (res, curr, count) {
                    }
                };
            }
            //无源单新增
            function set_AddFNew()
            {
                //加源单类型区分(可以写不同的方法)
            }
            //有源单新增
            function set_AddNew() {
                get_MAXNum();
                set_SourceAdd();
                option.data = [];
                option2.data = [];
                table.render(option);
                table.render(option2);
            }
            //编辑
            function set_EditFromGrid()
            {
                $("#HInterID").val(linterid);//修改时主表ID
                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);
                $('#HSourceName').attr("disabled", true);
                $('#HSourceList').addClass("layui-btn-disabled").attr("disabled", true);
                $('#HMainSourceBillNo').attr("disabled", true);
                $('#XDHList').addClass("layui-btn-disabled").attr("disabled", true);
                $('#SourceType').attr("disabled", true);
                form.render('select');
                $('#HICMOBillNo').attr("disabled", true);
                set_EditForm(linterid);  //编辑获取表头
                set_EditGrid(linterid);  //编辑获取表体
            }
            //编辑获取表头
            function set_EditForm(linterid) {
                //查询检验方案单是否存在
                $.ajax({
                    url: GetWEBURL() + "Sc_MouldMaintainBill/Sc_MouldMaintainBillListCheckDetai",
                    type: "GET",
                    data: {
                        "HID": linterid
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data.h_v_Sc_MouldMaintain[0];
                            form.val("component-form-group", {
                                "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HInnerBillNo": data.内部单据号
                                , "HBeginDate": formatDate(data.保养开始日期)
                                , "HEndDate": formatDate(data.保养结束日期)
                                , "HExplanation": data.摘要
                                , "HRemark": data.备注
                                , "HPlanNo": data.保养计划编号
                                , "HPlanInterID": data.保养计划内码
                                , "HMouldID": data.HMouldID
                                , "HMouldName": data.产品模具
                            });
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            // ç¼–辑获取表头时时间格式矫正方式
            function formatDate(date) {
                var d = new Date(date),
                    month = '' + (d.getMonth() + 1),
                    day = '' + d.getDate(),
                    year = d.getFullYear();
                if (month.length < 2) month = '0' + month;
                if (day.length < 2) day = '0' + day;
                return [year, month, day].join('-');
            }
            // ç¼–辑获取表体
            function set_EditGrid(linterid) {
                $("#HInterID").val(linterid);//修改时主表ID
                //编辑加载数据
                $.ajax({
                    url: GetWEBURL() + 'Sc_MouldMaintainBill/Sc_MouldMaintainBillListProjectDetaiNew',
                    type: "GET",
                    data: { "HInterID": linterid },
                    success: function (result) {
                        if (result.count == 1) {
                            option.data = result.list[0];
                            table.render(option);
                            option2.data = result.list[1];
                            table.render(option2);
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(index0);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //有源单新增
            function set_SourceAdd() {
                refSav = "Add";
                //初始基本信息赋值
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));      //单据日期
                $("#HWorkReportDate").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"]);     //制单人
                //加源单类型区分(可以写不同的方法)
                $('#HICMOBillNo').attr("disabled", true);
                $('#HSourceBillNo').attr("disabled", true);
                $('#HProcExchBillNo').attr("disabled", true);
                $('#HProcName').attr("disabled", true);
                $('#HMaterCode').attr("disabled", true);
                $('#HMaterList').addClass("layui-btn-disabled").attr("disabled",true);
                $('#HMaterName').attr("disabled", true);
                $('#HMaterSpec').attr("disabled", true);
                $('#HPlanQty').attr("disabled", true);
                $('#HSourceName').attr("disabled", true);
                $('#HSourceList').addClass("layui-btn-disabled").attr("disabled", true);
                $('#HWorkBeginDate').attr("disabled", true);
                $('#HWorkReportDate').attr("disabled", true);
                $.ajax(
                    {
                        type: "GET",
                        url: GetWEBURL() + "/Sc_MaterToSourceBill/GetMESMaterToSourceFrom", //方法所在页面和方法名
                        async: true,
                        data: {
                            "HSourceInterID": HSourceInterID,
                            "HSourceEntryID": HSourceEntryID,
                            "HSourceBillNo": HSourceBillNo,
                            "HSourceBillType": HBillType
                        },
                        dataType: "json",
                        success: function (data) {
                            if (data.count == 1)// è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            {
                                var LoadData = data.data.h_p_JIT_GetInfoByICMOStatusInterID;
                                $("#HProcID").val(LoadData[0].HProcID); //当前工序ID
                                $("#HProcName").val(LoadData[0].HProcName); //当前工序
                                $("#HMaterID").val(LoadData[0].HMaterID); //产品ID
                                $("#HMaterCode").val(LoadData[0].HMaterNumber); //产品代码
                                $("#HMaterName").val(LoadData[0].HMaterName); //产品名称
                                $("#HMaterSpec").val(LoadData[0].HModel); //产品规格
                                $("#HSourceID").val(LoadData[0].HSourceID); //生产资源ID
                                $("#HSourceName").val(LoadData[0].HSourceName); //生产资源
                                $("#HSourceBillNo").val(LoadData[0].HICMOBillNo); //源单单号(暂时取值订单编号)
                                $("#HSourceInterID").val(LoadData[0].HSourceInterID); //源单主内码(取值HInterID)
                                $("#HSourceEntryID").val(LoadData[0].HSourceEntryID); //源单子内码(源单行号)
                                $("#HSourceBillType").val(HSourceBillType); //源单类型
                                $("#HGroupID").val(LoadData[0].HDeptID); //班组ID
                                $("#HGroupName").val(LoadData[0].HDeptName); //班组
                                $("#HICMOInterID").val(LoadData[0].HICMOInterID); //生产订单ID
                                $("#HICMOEntryID").val(LoadData[0].HICMOEntryID); //生产订单子ID
                                $("#HICMOBillNo").val(LoadData[0].HICMOBillNo); //生产订单号
                                $("#HWorkBeginDate").val(LoadData[0].HBeginDate); //开工时间
                                $("#HPlanQty").val(LoadData[0].HDatePlanQty); //订单数量
                            }
                            else {
                                layer.alert(data.Message, { icon: 5 });
                            }
                        },
                        error: function (err) {
                            layer.alert(err, { icon: 5 });
                        }
                    });
            }
            //获取最大单据号及默认值赋值
            function get_MAXNum() {
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": '3786' },
                    success: function (d) {
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HInterID").val(0);
                    }
                });
            }
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
            //新增保存
            form.on('submit(Add)', function (data) {
@@ -732,7 +440,7 @@
            form.on('submit(Saver)', function (data) {
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sSubStr1 = JSON.stringify(table.cache['mainTable1']);
                var sMainSub = sMainStr + ';' + sSubStr + ';' + refSav;
@@ -749,17 +457,18 @@
                    success: function (data) {
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            $("#HInterID").val(data.HInterID);//获取提交成功返回的单据主ID
                            layer.confirm(data.Message, {icon: 1,
                            layer.confirm(data.Message, {
                                icon: 1,
                                btn: ['确认']
                            }, function (index) {
                                    if (data.Verify == "Y") //自动审核
                                    {
                                        layer.close(index);
                                        SaveVerify(); //审核
                                    }
                                    else {
                                        layer.close(index);
                                    }
                                if (data.Verify == "Y") //自动审核
                                {
                                    layer.close(index);
                                    SaveVerify(); //审核
                                }
                                else {
                                    layer.close(index);
                                }
                            });
                        }
                        else {
@@ -782,72 +491,6 @@
                ReVerIfySaver();
            });
            //审核提交
            function SaveVerify()
            {
                var InterID = $("#HInterID").val();
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sSubStr1 = JSON.stringify(table.cache['mainTable1']);
                if (!AllowLoadData(sSubStr, sSubStr1))//数据验证
                {
                    return false;
                }
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Sc_MaterToSourceBill/AuditProcessReportList", //方法所在页面和方法名
                    async: true,
                    data: { "HInterID": InterID, "IsAudit": 0, "CurUserName": sessionStorage["HUserName"] },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            layer.msg(data.Message, { time: 1 * 2000, icon: 1 }, function (index) {
                                //layer.close(layer.index);
                                //window.parent.location.reload();
                            });
                        }
                        else {
                            layer.alert(data.Message, { icon: 5 })
                        }
                    },
                    error: function (err) {
                        layer.alert(err, { icon: 5 })
                    }
                })
            }
            //反审核提交
            function ReVerIfySaver() {
                var InterID = $("#HInterID").val();
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sSubStr1 = JSON.stringify(table.cache['mainTable1']);
                if (!AllowLoadData(sSubStr, sSubStr1))//数据验证
                {
                    return false;
                }
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Sc_MaterToSourceBill/AuditProcessReportList", //方法所在页面和方法名
                    async: true,
                    data: { "HInterID": InterID, "IsAudit": 1, "CurUserName": sessionStorage["HUserName"] },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            layer.msg(data.Message, { time: 1 * 2000, icon: 1 }, function (index) {
                                //layer.close(layer.index);
                                //window.parent.location.reload();
                            });
                        }
                        else {
                            layer.alert(data.Message, { icon: 5 })
                        }
                    },
                    error: function (err) {
                        layer.alert(err, { icon: 5 })
                    }
                })
            }
            //退出
            form.on('submit(Exit)', function (data) {
                Pub_Close(1);
@@ -868,7 +511,7 @@
                    $.ajax({
                        url: GetWEBURL() + "/Sc_MaterToSourceBill/get_CheckTypeByBarCode_Json",
                        type: "GET",
                        data: { "HBarCode": HBarCode, "HSourceID": "111", "HICMOInterID": "100030", "HICMOEntryID": "100050"},
                        data: { "HBarCode": HBarCode, "HSourceID": "111", "HICMOInterID": "100030", "HICMOEntryID": "100050" },
                        success: function (result) {
                            console.info(result);
                            if (result.count == 1) {
@@ -876,8 +519,7 @@
                                    $("#HSourceID").val(result.data.Gy_Source[0].HItemID);
                                    $("#HSourceName").val(result.data.Gy_Source[0].HName);
                                }
                                if (result.Verify == '用料清单物料条码')
                                {
                                if (result.Verify == '用料清单物料条码') {
                                    //回写用料清单数据列表
                                    // æºæ•°æ®
                                    tableBak = table.cache.mainTable;
@@ -889,8 +531,7 @@
                                        option.data = table.cache["mainTable"];
                                        table.render(option);
                                    }
                                    else
                                    {
                                    else {
                                        // åŽ»é‡(不能有相同扫码物料)
                                        for (var i = 0; i < tableBak.length; i++) {
                                            console.log(tableBak[i].HMaterID, result.data[0].HMaterID);
@@ -1116,7 +757,7 @@
                var AddRow = table.cache['mainTable'];
                switch (obj.event) {
                    //删除一行
                    case 'btn-DeleteLine': btnDeleteLine(checkStatus,data, obj);
                    case 'btn-DeleteLine': btnDeleteLine(checkStatus, data, obj);
                        break;
                }
            });
@@ -1133,6 +774,405 @@
                        break;
                }
            });
            //#endregion
            //#region æœ¬é¡µé¢æ‰€æœ‰è¢«è°ƒç”¨çš„æ–¹æ³•
            //初始化插件
            function set_InitFrom() {
                //日期时间选择器
                laydate.render({
                    elem: '#HDate'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#HMakeDate'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#HUpDateDate'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#HCheckDate'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#HCloseDate'
                    , type: 'datetime'
                });
                laydate.render({
                    elem: '#HDeleteDate'
                    , type: 'datetime'
                });
            }
            //初始化表格
            function set_InitGrid() {
                Table1();  //保养项列表
                Table2();  //配件项列表
            }
            //初始化配料列表
            function Table1() {
                //表头
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe" }
                    , { field: 'HBarCode', title: '扫描条码', edit: 'text', hide: true }
                    , { field: 'HMaterID', title: '物料ID', edit: 'text', hide: true }
                    , { field: 'HNumber', title: '物料代码', edit: 'text' }
                    , { field: 'HName', title: '物料名称', edit: 'text' }
                    , { field: 'HModel', title: '规格型号', edit: 'text' }
                    , { field: 'HUnitID', title: '单位ID', edit: 'text', hide: true }
                    , { field: 'HUnitName', title: '单位', edit: 'text' }
                    , { field: 'HMQty', title: '配料数量', edit: 'text' }
                    , { field: 'HQty', title: '实配数量', edit: 'text' }
                ];
                option = {
                    id: 'mainTable'
                    , elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , defaultToolbar: false  //是否显示右侧工具栏
                    , page: false
                    , cellMinWidth: 120
                    , height: 350
                    , cols: [columns]
                    , done: function (res, curr, count) {
                    }
                };
            }
            //初始化配件项列表
            function Table2() {
                //表头
                columns1 = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao1', title: '序号', sort: true, fixed: 'left', event: "qwe" }
                    , { field: 'HMouldID', title: '治具ID', edit: 'text', hide: true}
                    , { field: 'HMouldNumber', title: '治具代码', edit: 'text' }
                    , { field: 'HMouldName', title: '治具名称', edit: 'text' }
                    , { field: 'HMouldSpec', title: '规格型号', edit: 'text' }
                ];
                option2 = {
                    id: 'mainTable1'
                    , elem: '#mainTable1'
                    , toolbar: '#toolbarDemo1'
                    , defaultToolbar: false  //是否显示右侧工具栏
                    , page: false
                    , cellMinWidth: 120
                    , height: 350
                    , cols: [columns1]
                    , done: function (res, curr, count) {
                    }
                };
            }
            //无源单新增
            function set_AddFNew()
            {
               //加源单类型区分(可以写不同的方法)
                refSav = "Add";
                //初始基本信息赋值
                $("#form0")[0].reset();
                layui.form.render();
                get_MAXNum();
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));      //单据日期
                $("#HWorkReportDate").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"]);     //制单人
            }
            //有源单新增
            function set_AddNew() {
                get_MAXNum();
                set_SourceAdd();
                option.data = [];
                option2.data = [];
                table.render(option);
                table.render(option2);
            }
            //编辑
            function set_EditFromGrid()
            {
                $("#HInterID").val(linterid);//修改时主表ID
                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);
                $('#HSourceName').attr("disabled", true);
                $('#HSourceList').addClass("layui-btn-disabled").attr("disabled", true);
                $('#HMainSourceBillNo').attr("disabled", true);
                $('#XDHList').addClass("layui-btn-disabled").attr("disabled", true);
                $('#SourceType').attr("disabled", true);
                form.render('select');
                $('#HICMOBillNo').attr("disabled", true);
                set_EditForm(linterid);  //编辑获取表头
                set_EditGrid(linterid);  //编辑获取表体
            }
            //编辑获取表头
            function set_EditForm(linterid) {
                //查询检验方案单是否存在
                $.ajax({
                    url: GetWEBURL() + "Sc_MaterToSourceBill/Sc_MaterToSourceBillListCheckDetai",
                    type: "GET",
                    data: {
                        "HID": linterid
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data.h_v_Sc_MaterToSourceBillMain[0];
                            form.val("component-form-group", {
                                "HInterID": data.hmainid
                                , "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HPlanQty":"0"
                                , "HICMOBillNo": data.任务单号
                                , "HICMOInterID": data.HICMOInterID
                                , "HICMOEntryID": data.HICMOEntryID
                                , "HProcExchBillNo": data.工序流转卡号
                                , "HProcExchQty": ""
                                , "HSourceInterID": data.HMainSourceInterID
                                , "HSourceEntryID": data.HMainSourceEntryID
                                , "HSourceBillNo": data.HMainSourceBillNo
                                , "HSourceBillType": data.HMainSourceBillType
                                , "HProcName":""
                                , "HProcID": "0"
                                , "HMaterCode": data.产品代码
                                , "HMaterID": data.HMaterID
                                , "HMaterName": data.产品名称
                                , "HMaterSpec": data.规格型号
                                , "HSourceID": data.HSourceID
                                , "HSourceName": data.生产资源
                                , "HGroupName": data.生产班组
                                , "HGroupID": data.HGroupID
                                , "HWorkerName": data.操作工
                                , "HWorkerID": data.HWorkerID
                                , "HMaker": data.制单人                                            //制单人
                                , "HMakeDate": formatDate(data.制单日期)                           //制单日期
                                , "HUpDater": sessionStorage["HUserName"]                          //修改人
                                , "HUpDateDate": Format(new Date(), "yyyy-MM-dd hh:mm:ss")         //修改日期
                                , "HChecker": data.审核人                                          //审核人
                                , "HCheckDate": formatDate(data.审核日期)                          //审核日期
                                , "HCloseMan": data.关闭人                                         //关闭人
                                , "HCloseDate": formatDate(data.关闭日期)                          //关闭日期
                                , "HDeleteMan": data.作废人                                        //作废人
                                , "HDeleteDate": formatDate(data.作废日期)                         //作废日期
                            });
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            // ç¼–辑获取表头时时间格式矫正方式
            function formatDate(date) {
                var d = new Date(date),
                    month = '' + (d.getMonth() + 1),
                    day = '' + d.getDate(),
                    year = d.getFullYear();
                if (month.length < 2) month = '0' + month;
                if (day.length < 2) day = '0' + day;
                return [year, month, day].join('-');
            }
            // ç¼–辑获取表体
            function set_EditGrid(linterid) {
                $("#HInterID").val(linterid);//修改时主表ID
                //编辑加载数据
                $.ajax({
                    url: GetWEBURL() + 'Sc_MaterToSourceBill/Sc_MaterToSourceBillListProjectDetai',
                    type: "GET",
                    data: { "HInterID": linterid },
                    success: function (result) {
                        if (result.count == 1) {
                            option.data = result.list[0];
                            table.render(option);
                            option2.data = result.list[1];
                            table.render(option2);
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(index0);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //有源单新增
            function set_SourceAdd() {
                refSav = "Add";
                //初始基本信息赋值
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));      //单据日期
                $("#HWorkReportDate").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"]);     //制单人
                //加源单类型区分(可以写不同的方法)
                $('#HICMOBillNo').attr("disabled", true);
                $('#HSourceBillNo').attr("disabled", true);
                $('#HProcExchBillNo').attr("disabled", true);
                $('#HProcName').attr("disabled", true);
                $('#HMaterCode').attr("disabled", true);
                $('#HMaterList').addClass("layui-btn-disabled").attr("disabled",true);
                $('#HMaterName').attr("disabled", true);
                $('#HMaterSpec').attr("disabled", true);
                $('#HPlanQty').attr("disabled", true);
                $('#HSourceName').attr("disabled", true);
                $('#HSourceList').addClass("layui-btn-disabled").attr("disabled", true);
                $('#HWorkBeginDate').attr("disabled", true);
                $('#HWorkReportDate').attr("disabled", true);
                $.ajax(
                    {
                        type: "GET",
                        url: GetWEBURL() + "/Sc_MaterToSourceBill/GetMESMaterToSourceFrom", //方法所在页面和方法名
                        async: true,
                        data: {
                            "HSourceInterID": HSourceInterID,
                            "HSourceEntryID": HSourceEntryID,
                            "HSourceBillNo": HSourceBillNo,
                            "HSourceBillType": HBillType
                        },
                        dataType: "json",
                        success: function (data) {
                            if (data.count == 1)// è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            {
                                var LoadData = data.data.h_p_JIT_GetInfoByICMOStatusInterID;
                                $("#HProcID").val(LoadData[0].HProcID); //当前工序ID
                                $("#HProcName").val(LoadData[0].HProcName); //当前工序
                                $("#HMaterID").val(LoadData[0].HMaterID); //产品ID
                                $("#HMaterCode").val(LoadData[0].HMaterNumber); //产品代码
                                $("#HMaterName").val(LoadData[0].HMaterName); //产品名称
                                $("#HMaterSpec").val(LoadData[0].HModel); //产品规格
                                $("#HSourceID").val(LoadData[0].HSourceID); //生产资源ID
                                $("#HSourceName").val(LoadData[0].HSourceName); //生产资源
                                $("#HSourceBillNo").val(LoadData[0].HICMOBillNo); //源单单号(暂时取值订单编号)
                                $("#HSourceInterID").val(LoadData[0].HSourceInterID); //源单主内码(取值HInterID)
                                $("#HSourceEntryID").val(LoadData[0].HSourceEntryID); //源单子内码(源单行号)
                                $("#HSourceBillType").val(HSourceBillType); //源单类型
                                $("#HGroupID").val(LoadData[0].HDeptID); //班组ID
                                $("#HGroupName").val(LoadData[0].HDeptName); //班组
                                $("#HICMOInterID").val(LoadData[0].HICMOInterID); //生产订单ID
                                $("#HICMOEntryID").val(LoadData[0].HICMOEntryID); //生产订单子ID
                                $("#HICMOBillNo").val(LoadData[0].HICMOBillNo); //生产订单号
                                $("#HWorkBeginDate").val(LoadData[0].HBeginDate); //开工时间
                                $("#HPlanQty").val(LoadData[0].HDatePlanQty); //订单数量
                            }
                            else {
                                layer.alert(data.Message, { icon: 5 });
                            }
                        },
                        error: function (err) {
                            layer.alert(err, { icon: 5 });
                        }
                    });
            }
            //获取最大单据号及默认值赋值
            function get_MAXNum() {
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": '3786' },
                    success: function (d) {
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HInterID").val(0);
                    }
                });
            }
            //审核提交
            function SaveVerify()
            {
                var InterID = $("#HInterID").val();
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sSubStr1 = JSON.stringify(table.cache['mainTable1']);
                if (!AllowLoadData(sSubStr, sSubStr1))//数据验证
                {
                    return false;
                }
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Sc_MaterToSourceBill/AuditProcessReportList", //方法所在页面和方法名
                    async: true,
                    data: { "HInterID": InterID, "IsAudit": 0, "CurUserName": sessionStorage["HUserName"] },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            layer.msg(data.Message, { time: 1 * 2000, icon: 1 }, function (index) {
                                //layer.close(layer.index);
                                //window.parent.location.reload();
                            });
                        }
                        else {
                            layer.alert(data.Message, { icon: 5 })
                        }
                    },
                    error: function (err) {
                        layer.alert(err, { icon: 5 })
                    }
                })
            }
            //反审核提交
            function ReVerIfySaver() {
                var InterID = $("#HInterID").val();
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sSubStr1 = JSON.stringify(table.cache['mainTable1']);
                if (!AllowLoadData(sSubStr, sSubStr1))//数据验证
                {
                    return false;
                }
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Sc_MaterToSourceBill/AuditProcessReportList", //方法所在页面和方法名
                    async: true,
                    data: { "HInterID": InterID, "IsAudit": 1, "CurUserName": sessionStorage["HUserName"] },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            layer.msg(data.Message, { time: 1 * 2000, icon: 1 }, function (index) {
                                //layer.close(layer.index);
                                //window.parent.location.reload();
                            });
                        }
                        else {
                            layer.alert(data.Message, { icon: 5 })
                        }
                    },
                    error: function (err) {
                        layer.alert(err, { icon: 5 })
                    }
                })
            }
            //删除行
            function btnDeleteLine(checkStatus,data) {
@@ -1182,6 +1222,7 @@
                });
            }
            //#endregion
            //以上为layui模块
        });