YL
2021-09-08 2cc50f9f4c831bb4f113ef8f8d453ea07f9a6ed6
WebTM/views/Éú²ú¹ÜÀí/ÉÏÁÏ·À´íµ¥/Sc_Add_MaterToSourceBillList.html
@@ -99,6 +99,7 @@
                    <form id="form0" class="layui-form" lay-filter="component-form-group" action="">
                        <div class="layui-card-header">
                            <div class="layui-btn-group">
                                <button type="button" id="Add" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Add">新增</button>
                                <button type="button" id="Saver" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Saver">保存</button>
                                <button type="button" id="VerIfySaver" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="VerIfySaver">审核</button>
                                <button type="button" id="ReVerIfySaver" class="layui-btn layui-btn-normal layui-btn-circle" lay-submit="" lay-filter="ReVerIfySaver">反审核</button>
@@ -229,9 +230,9 @@
                                                    <div class="layui-inline">
                                                        <label class="layui-form-label">操作员:</label>
                                                        <div class="layui-input-inline">
                                                            <input type="text" name="HEmpName" id="HEmpName" class="layui-input" value="" style="float:left;width:150px;">
                                                            <input type="hidden" name="HEmpID" id="HEmpID" class="layui-input" value="" style="float:left;width:150px;">
                                                            <button type="button" lay-submit="" class="layui-btn" lay-filter="HEmpList" id="HEmpList" style="width:40px;">
                                                            <input type="text" name="HWorkerName" id="HWorkerName" class="layui-input" value="" style="float:left;width:150px;">
                                                            <input type="hidden" name="HWorkerID" id="HWorkerID" class="layui-input" value="" style="float:left;width:150px;">
                                                            <button type="button" lay-submit="" class="layui-btn" lay-filter="HWorkerList" id="HEmpList" style="width:40px;">
                                                                <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                            </button>
                                                        </div>
@@ -395,6 +396,7 @@
            var option2;
            //#endregion
            //初始化表单插件
            set_InitFrom();
@@ -452,19 +454,19 @@
            }
            //初始化保养项列表
            //初始化配料列表
            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: 'HModel', title: '规格型号', edit: 'text' }
                    , { field: 'HMQty', title: '配料数量', edit: 'text' }
                    , { field: 'HQty', title: '实配数量', edit: 'text' }
                ];
@@ -546,52 +548,35 @@
                form.render('select');
                $('#HICMOBillNo').attr("disabled", true);
                set_EditForm(linterid);  //编辑获取表头
                set_EditGrid(linterid);  //编辑获取表体
            }
            //编辑获取表头
            function set_EditForm(linterid) {
                //查询检验方案单是否存在
                $.ajax({
                    url: GetWEBURL() + "Sc_MESBeginWorkBill/Sc_MESBeginWorkBillListCheckDetai",
                    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_MESBeginWorkBillList_NEW[0];
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HInterID": data.hmainid
                                , "HBillNo": data.单据号
                            var data = result.data.h_v_Sc_MouldMaintain[0];
                            form.val("component-form-group", {
                                "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HProcID": data.HProcID
                                , "HProcName": data.工序名称
                                , "HMaterID": data.HMaterID
                                , "HMaterCode": data.产品代码
                                , "HMaterName": data.产品名称
                                , "HMaterSpec": data.规格型号
                                , "HBeginDate": data.开工时间
                                , "HSourceID": data.HSourceID              //资源ID
                                , "HSourceName": data.资源名称             //资源名称
                                , "HEmpID": data.HEmpID                   //操作员ID
                                , "HEmpName": data.申请开工人员           //操作员
                                , "HMainSourceInterID": data.HMainSourceInterID                 //源单ID
                                , "HMainSourceEntryID": data.HMainSourceEntryID                 //源单子ID
                                , "HMainSourceBillNo": data.HMainSourceBillNo                 //源单单号
                                , "HMainSourceBillType": data.HMainSourceBillType               //源单类型
                                , "HGroupID": data.HGroupID                //班组ID
                                , "HGroupName": data.班组名称              //班组名称
                                , "HICMOInterID": data.HICMOInterID                       //生产订单主ID
                                , "HICMOEntryID": data.HICMOEntryID                        //生产订单子ID
                                , "HICMOBillNo": data.HICMOBillNo                        //生产订单
                                , "HRemark": data.备注                    //备注
                                , "HMaker": data.制单人                            //制单人
                                , "HMakeDate": data.制单日期                          //制单日期
                                , "HUpDater": sessionStorage["HUserName"]             //修改人
                                , "HUpDateDate": Format(new Date(), "yyyy-MM-dd hh:mm:ss")//修改日期
                                , "HChecker": data.审核人             //审核人
                                , "HCheckDate": data.审核日期   //审核日期
                                , "HCloseMan": data.关闭人                //关闭人
                                , "HCloseDate": data.关闭日期             //关闭日期
                                , "HDeleteMan": data.作废人               //作废人
                                , "HDeleteDate": data.作废日期       //作废日期
                                , "HInnerBillNo": data.内部单据号
                                , "HBeginDate": formatDate(data.保养开始日期)
                                , "HEndDate": formatDate(data.保养结束日期)
                                , "HExplanation": data.摘要
                                , "HRemark": data.备注
                                , "HPlanNo": data.保养计划编号
                                , "HPlanInterID": data.保养计划内码
                                , "HMouldID": data.HMouldID
                                , "HMouldName": data.产品模具
                            });
@@ -604,6 +589,43 @@
                });
            }
            // ç¼–辑获取表头时时间格式矫正方式
            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() {
@@ -693,6 +715,18 @@
                });
            }
          
            //新增保存
            form.on('submit(Add)', function (data) {
                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"]);     //制单人
            });
            //保存提交
            form.on('submit(Saver)', function (data) {
@@ -715,7 +749,7 @@
                    success: function (data) {
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            $("#HInterID").val(data.HInterID);//获取提交成功返回的单据主ID
                            layer.confirm(data.Message, {
                            layer.confirm(data.Message, {icon: 1,
                                btn: ['确认']
                            }, function (index) {
                                    if (data.Verify == "Y") //自动审核
@@ -760,17 +794,19 @@
                }
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Sc_MESBeginWorkBill/AuditProcessReportList", //方法所在页面和方法名
                    url: GetWEBURL() + "/Sc_MaterToSourceBill/AuditProcessReportList", //方法所在页面和方法名
                    async: true,
                    data: { "HInterID": InterID, "IsAudit": 0, "CurUserName": sessionStorage["HUserName"] },
                    dataType: "json",
                    success: function (data) {
                        if (result.count == 1) {
                            layer.msg(result.Message, { time: 1 * 2000, icon: 1 }, function () {
                        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(result.code + result.Message, { icon: 5 });
                        }
                        else {
                            layer.alert(data.Message, { icon: 5 })
                        }
                    },
                    error: function (err) {
@@ -790,17 +826,19 @@
                }
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Sc_MESBeginWorkBill/AuditProcessReportList", //方法所在页面和方法名
                    url: GetWEBURL() + "/Sc_MaterToSourceBill/AuditProcessReportList", //方法所在页面和方法名
                    async: true,
                    data: { "HInterID": InterID, "IsAudit": 1, "CurUserName": sessionStorage["HUserName"] },
                    dataType: "json",
                    success: function (data) {
                        if (result.count == 1) {
                            layer.msg(result.Message, { time: 1 * 2000, icon: 1 }, function () {
                        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(result.code + result.Message, { icon: 5 });
                        }
                        else {
                            layer.alert(data.Message, { icon: 5 })
                        }
                    },
                    error: function (err) {
@@ -845,7 +883,7 @@
                                    tableBak = table.cache.mainTable;
                                    console.log(tableBak.length);
                                    //获取物料条码信息
                                    var NewRow = { "HMaterID": result.data[0].HMaterID, "HNumber": result.data[0].HNumber, "HName": result.data[0].HName, "HModel": result.data[0].HModel, "HUnitID": result.data[0].HUnitID, "HUnitName": result.data[0].HUnitName, "HMQty": result.data[0].HMQty, "HQty": result.data[0].HQty };
                                    var NewRow = { "HBarCode": result.data[0].HBarCode, "HMaterID": result.data[0].HMaterID, "HNumber": result.data[0].HNumber, "HName": result.data[0].HName, "HModel": result.data[0].HModel, "HUnitID": result.data[0].HUnitID, "HUnitName": result.data[0].HUnitName, "HMQty": result.data[0].HMQty, "HQty": result.data[0].HQty };
                                    if (tableBak.length <= 0) {
                                        table.cache["mainTable"].push(NewRow);
                                        option.data = table.cache["mainTable"];
@@ -858,13 +896,12 @@
                                            console.log(tableBak[i].HMaterID, result.data[0].HMaterID);
                                            if (tableBak[i].HMaterID == result.data[0].HMaterID) {
                                                layer.msg("已扫描,请勿重复扫码!", { icon: 0, time: 2000 });
                                                return;
                                            }
                                            else {
                                        }
                                                table.cache["mainTable"].push(NewRow);
                                                option.data = table.cache["mainTable"];
                                                table.render(option);
                                            }
                                        }
                                    }
                                }
                            }
@@ -958,7 +995,7 @@
            });
            //操作员
            form.on('submit(HEmpList)', function () {
            form.on('submit(HWorkerList)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
@@ -978,8 +1015,8 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HEmpName").val(checkStatus.data[0].HName);
                        $("#HEmpID").val(checkStatus.data[0].HItemID);
                        $("#HWorkerName").val(checkStatus.data[0].HName);
                        $("#HWorkerID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
@@ -1175,7 +1212,7 @@
                layer.msg("生产资源不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return Result = false;
            }
            if ($("#HEmpID").val() == '' || $("#HEmpID").val() == null) {
            if ($("#HWorkerID").val() == '' || $("#HWorkerID").val() == null) {
                layer.msg("操作员不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return Result = false;
            }