wtt
2024-10-28 07cf94734c36d4eae6ddbc4dd338bf5af81a2193
WebTM/views/Éú²ú¹ÜÀí/²úÁ¿»ã±¨µ¥/Sc_ProductReportBillList.html
@@ -13,7 +13,12 @@
            padding-right: 15px;
            cursor: pointer;
        }
        #top-title
        {
            margin: 0 30%;
            font-size: 24px;
            font-weight: bold;
        }
    </style>
    <script src="../../../layuiadmin/layui/layui.js"></script>
@@ -24,14 +29,13 @@
            <div class="layui-card" style="padding: 1px">
                <form class="layui-form" action="" lay-filter="component-form-group">
                    <div class="layui-card-header">
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="Delete"><i class="layui-icon layui-icon-add"></i>删除</button>
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="Delete" id="Delete"><i class="layui-icon layui-icon-add"></i>删除</button>
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="AskReport" id="AskReport"><i class="layui-icon layui-icon-add"></i>申请检验</button>
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="Exit"><i class="layui-icon layui-icon-add"></i>退出</button>
                        <span style="margin:0 30%;font-size:24px;font-weight:bold;">产量汇报</span>
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="Exit" id="Exit"><i class="layui-icon layui-icon-add"></i>退出</button>
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="ProdReport" id="ProdReport"><i class="layui-icon layui-icon-add"></i>生产汇报</button>
                        <span id="top-title">产量汇报</span>
                    </div>
                    <div class="layui-card-body" style="padding: 1px;">
                        <div class="layui-collapse">
                            <div class="layui-colla-item">
                                <div class="layui-colla-title layui-inline">
@@ -113,6 +117,7 @@
    <script src="../../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script>
        //获取参数
        var workcode = "";  //工单号
@@ -121,21 +126,6 @@
        var HICMOEntryID = ""; //生产订单子ID
        var HSourceBillType = ""; //源单类型
        var SchWhere = ""; //按钮查询参数
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }
        var params = getUrlVars();
        var hID = params[params[0]];//编辑查看
        var Type = params[params[1]];//单据编辑状态: 1.无源单新增  Â 2.有源单新增  Â 3.编辑  4.浏览  5.变更
        var edit = function (data) {
            workcode = data[0].workcode;
            HSourceID = data[0].HSourceID;
@@ -143,14 +133,27 @@
            HICMOInterID = data[0].HICMOInterID;
            HICMOEntryID = data[0].HICMOEntryID;
            HMaker = data[0].HMaker;
            Czybm = data[0].Czybm;
            HSourceBillType = data[0].HSourceBillType;
        }
        //获取页面跳转参数  //单据编辑状态: 1.无源单新增  Â 2.有源单新增  Â 3.编辑  4.浏览  5.变更
        var params = get_UrlVars();
        if (typeof (params[params[0]]) == "undefined") {
            var OperationType = 1;//操作类型
        } else {
            var OperationType = params[params[0]];//操作类型
            var linterid = params[params[1]];//源单id
            var HSouceBillType = params[params[2]];//源单类型
        }
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index', //主入口模块
        }).use(['index', 'form', 'table', 'element', 'laypage','laydate'], function () {
        }).use(['index', 'form', 'table', 'element', 'laypage', 'laydate'], function () {
            //#region å…¬ç”¨å˜é‡
            var $ = layui.$
            , admin = layui.admin
            , layer = layui.layer
@@ -161,49 +164,96 @@
                , laydate = layui.laydate
            var sWhere = "";
            var option = [];
            //#endregion
            var option = {
                elem: '#mainTable'
                ,height: 'full-50'
                , page: true
                ,cellMinWidth: 90
                , cols: [[
                     { type: 'checkbox', fixed: 'left' }
                    , { field: 'HInterID', title: 'HInterID', sort: true, hide: true, width: 200}
                    , { field: 'HDate', title: '日期', width: 200, templet: "<div>{{d.HDate ==null ?'':layui.util.toDateString(d.HDate, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                    , { field: 'HBillNo', title: '单据号', width: 200}
                    , { field: 'HBillType', title: '单据类型', width: 200 }
                    , { field: 'HICMOBillNo', title: '生产订单号', width: 200 }
                    , { field: 'HICMOInterID', title: '生产订单主ID', width: 200, hide: true}
                    , { field: 'HICMOEntryID', title: '生产订单子ID', width: 200, hide: true}
                    , { field: 'HSourceBillNo', title: '源单单号', width: 200 }
                    , { field: 'HSourceInterID', title: '源单主内码', width: 200, hide: true}
                    , { field: 'HSourceEntryID', title: '源单子内码', width: 200, hide: true}
                    , { field: 'HSourceBillType', title: '源单类型', width: 200 }
                    , { field: 'HMaterID', title: '产品ID', width: 200, hide: true}
                    , { field: 'HMaterCode', title: '产品代码', width: 200 }
                    , { field: 'HMaterName', title: '产品名称', width: 200 }
                    , { field: 'HMaterSpec', title: '产品规格', width: 200 }
                    , { field: 'HQty', title: '汇报数量', width: 200 }
                    , { field: 'HSourceID', title: '生产资源ID', width: 200, hide: true}
                    , { field: 'HSourceCode', title: '生产资源代码', width: 200 }
                    , { field: 'HSourceName', title: '生产资源', width: 200 }
                    , { field: 'HGroupID', title: '生产班组ID', width: 200, hide: true}
                    , { field: 'HGroupCode', title: '生产班组代码', width: 200 }
                    , { field: 'HGroupName', title: '生产班组名称', width: 200 }
                    , { field: 'HWorkManID', title: '操作员ID', width: 200, hide: true}
                    , { field: 'HWorkManName', title: '操作员', width: 200 }
                    , { field: 'HMaker', title: '制单人', width: 200 }
                    , { field: 'HMakeDate', title: '制单日期', width: 160, templet: "<div>{{d.HMakeDate ==null ?'':layui.util.toDateString(d.HMakeDate, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                    , { field: 'HReportType', title: '汇报类型', width: 200 }
                ]]
            };
            //#region è¿›å…¥é¡µé¢å³åŠ è½½
            //有源单新增
            if (Type == 2)
            //初始化表格
            set_InitGrid();
            //判断操作类型
           if (OperationType == 2) {//有源单
                //报工平台报检申请查看列表
                set_AddNew();
            }
            else {
                layer.alert("未知操作类型!", { icon: 5 });
            }
            //#endregion
            table.on('row(mainTable)', function (obj) {
                //选中行改变颜色
                var flag = !obj.tr.find(':checkbox:first').prop('checked');
                obj.tr.find(':checkbox').prop('checked', flag);
                if (flag) {
                    obj.tr.find('.layui-form-checkbox').addClass('layui-form-checked');  //设置复选框选中样式
                    $(obj.tr.selector).attr({ "style": "background:#ceedfa;color:black" });//改变当前tr背景颜色和字体颜色
                } else {
                    obj.tr.find('.layui-form-checkbox').removeClass('layui-form-checked');//取消复选框选中样式
                    $(obj.tr.selector).attr({ "style": "background:" });//取消当前tr颜色
                }
                //mainTable ä¸ºè¡¨æ ¼ID   æ³¨æ„æ­¤å¤„如果ID不正确将导致你在监听复选框时获取不到你选择的数据,前面的只是添加或删除选中未选中样式以及设置背景色,字体颜色
                layui.each(table.cache.mainTable, function (i, l) {
                    if (obj.tr.index() == l.LAY_TABLE_INDEX) {
                        l.LAY_CHECKED = flag;
                    }
                });
            })
            //#region æœ¬é¡µé¢æ‰€æœ‰è¢«è°ƒç”¨çš„æ–¹æ³•
            //初始化表格
            function set_InitGrid()
            {
                sWhere = " where a.HSourceID='" + HSourceID + "' and a.HICMOBillNo='" + workcode + "' and HICMOInterID='" + (HICMOInterID == "null" ? 0 : HICMOInterID) + "' and HICMOEntryID='" + (HICMOEntryID == "null"?0: HICMOEntryID) + "' and HMaker='" + HMaker + "' ";
                 option = {
                    elem: '#mainTable'
                    , height: 'full-50'
                    , page: true
                    , limit:500
                    , totalRow: true
                    , limits: [100, 500, 1000, 2000]
                    , cellMinWidth: 90
                    , cols: [[
                        { type: 'checkbox', fixed: 'left', totalRowText: '合计' }
                        , { field: 'HInterID', title: 'HInterID', sort: true, hide: true, width: 200 }
                        , { field: 'HDate', title: '日期', width: 200, templet: "<div>{{d.HDate ==null ?'':layui.util.toDateString(d.HDate, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                        , { field: 'HBillNo', title: '单据号', width: 200 }
                        , { field: 'HBillType', title: '单据类型', width: 200 }
                        , { field: 'HBillStatus', title: '单据状态', width: 200}
                        , { field: 'HICMOBillNo', title: '生产订单号', width: 200 }
                        , { field: 'HICMOInterID', title: '生产订单主ID', width: 200, hide: true }
                        , { field: 'HICMOEntryID', title: '生产订单子ID', width: 200, hide: true }
                        , { field: 'HSourceBillNo', title: '源单单号', width: 200 }
                        , { field: 'HSourceInterID', title: '源单主内码', width: 200, hide: true }
                        , { field: 'HSourceEntryID', title: '源单子内码', width: 200, hide: true }
                        , { field: 'HSourceBillType', title: '源单类型', width: 200 }
                        , { field: 'HMaterID', title: '产品ID', width: 200, hide: true }
                        , { field: 'HMaterCode', title: '产品代码', width: 200 }
                        , { field: 'HMaterName', title: '产品名称', width: 200 }
                        , { field: 'HMaterSpec', title: '产品规格', width: 200 }
                        , { field: 'HQty', title: '汇报数量', width: 200, totalRow: true }
                        , { field: 'HSourceID', title: '生产资源ID', width: 200, hide: true }
                        , { field: 'HSourceCode', title: '生产资源代码', width: 200 }
                        , { field: 'HSourceName', title: '生产资源', width: 200 }
                        , { field: 'HGroupID', title: '生产班组ID', width: 200, hide: true }
                        , { field: 'HGroupCode', title: '生产班组代码', width: 200 }
                        , { field: 'HGroupName', title: '生产班组名称', width: 200 }
                        , { field: 'HWorkManID', title: '操作员ID', width: 200, hide: true }
                        , { field: 'HWorkManName', title: '操作员', width: 200 }
                        , { field: 'HMaker', title: '制单人', width: 200 }
                        , { field: 'HMakeDate', title: '制单日期', width: 160, templet: "<div>{{d.HMakeDate ==null ?'':layui.util.toDateString(d.HMakeDate, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                        , { field: 'HReportType', title: '汇报类型', width: 200 }
                    ]]
                };
            }
            //报工平台进入(有源单) åªèƒ½çœ‹åˆ°å½“前生产资源上开工了的生产订单的产量汇报单
            function set_AddNew()
            {
                sWhere = " where HSourceID='" + HSourceID + "' and HICMOBillNo='" + workcode + "' and HICMOInterID='" + (HICMOInterID == "null" ? 0 : HICMOInterID) + "' and HICMOEntryID='" + (HICMOEntryID == "null" ? 0 : HICMOEntryID) + "' and HMaker='" + HMaker + "' ";
                SchWhere = sWhere;
                console.log(sWhere);
                //进入页面显示的缓存列表
@@ -215,19 +265,18 @@
                        if (data1.count == 1) {
                            option.data = data1.data;
                            table.render(option);
                            layer.close(index);
                        } else {
                            layer.close(index);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                        sWhere = "";
                    }, error: function () {
                        layer.close(index);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //删除按钮
            form.on('submit(Delete)', function (data)
@@ -236,12 +285,15 @@
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1) {
                    var InterID = data[0].HInterID.toString();
                    var HICMOInID = data[0].HICMOInterID.toString();
                    var HICMOEnID = data[0].HICMOEntryID.toString();
                    //逻辑删除方法
                    layer.confirm("确认要删除吗,删除后不能恢复", { title: "删除确认" }, function (index) {
                        $.ajax({
                            type: "GET",
                            url: GetWEBURL() + "Sc_MESBeginWorkBill/DeltetMESProductReportBill", //方法所在页面和方法名
                            data: { "HInterID": InterID },
                            data: { "HInterID": InterID, "HICMOInterID": HICMOInID, "HICMOEntryID": HICMOEnID, "UserName":sessionStorage["HUserName"] },
                            success: function (result) {
                                if (result.count == 1) {
                                    layer.msg(result.Message, { time: 1 * 2000, icon: 1 });
@@ -271,7 +323,6 @@
            //申请检验
            form.on('submit(AskReport)', function (data)
            {
                $('#AskReport').addClass("layui-btn-disabled").attr("disabled", true);
                var TabData = table.cache['mainTable'];
                if (TabData == undefined)
                {
@@ -281,35 +332,69 @@
                if (TabData.length <= 0) {
                    return layer.alert("无产量汇报数据!", { icon: 5 })
                }
                //判断是否有未审核数据
                $.ajax(
                    {
                        type: "GET",
                        type: "Get",
                        url: GetWEBURL() + "/Sc_MESBeginWorkBill/SaveGetMESProductReportBillList", //方法所在页面和方法名
                        async: false,
                        data: { "ScMaxWork": ScMaxWork(),"HSourceBillType": HSourceBillType, "workcode": workcode, "HSourceID": HSourceID, "HICMOInterID": (HICMOInterID == "null" ? 0 : HICMOInterID), "HICMOEntryID": (HICMOEntryID == "null" ? 0 : HICMOEntryID), "HMaker": HMaker },
                        async: true,
                        data: { "ScMaxWork": ScMaxWork(), "HSourceBillType": HSourceBillType, "workcode": workcode, "HSourceID": HSourceID, "HICMOInterID": (HICMOInterID == "null" ? 0 : HICMOInterID), "HICMOEntryID": (HICMOEntryID == "null" ? 0 : HICMOEntryID), "HMaker": HMaker, "Czybm": Czybm },
                        dataType: "json",
                        beforeSend: function () {
                            $('#AskReport').addClass("layui-btn-disabled").attr("disabled", true);
                        },
                        success: function (data) {
                            if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                                $('#AskReport').removeClass("layui-btn-disabled").attr("disabled", false);
                                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 })
                                layer.alert(data.Message, { icon: 5 })
                                $('#AskReport').removeClass("layui-btn-disabled").attr("disabled", false);
                            }
                        },
                        error: function (err) {
                            layer.alert(data.Message, { icon: 5 })
                            $('#AskReport').removeClass("layui-btn-disabled").attr("disabled", false);
                        }
                    });
            })
            //生产汇报
            form.on('submit(ProdReport)', function (data) {
                var checkStatus = table.checkStatus('mainTable');
                var TabData = checkStatus.data;
                var HInterID = TabData[0].HInterID;
                if (checkStatus.data.length != 1) {
                    layer.alert("请选择一条数据!同一订单的生产数量将由系统判断并自动带出。");
                } else {
                    layer.open({
                        type: 2
                        , area: ['100%', '100%']
                        , title: '生产汇报单-编辑'
                        , shade: 0.6
                        , maxmin: false
                        , anim: 0
                        , content: ['../生产汇报单/Sc_Add_ICMOReportBillList.html?OperationType=2&linterid=' + HInterID.toString() + '&HSouceBillType=' + 3724, 'yes']
                        , resize: false
                        , cancel: function () {
                        }
                        , end: function () {
                        }
                    })
                }
            })
            //退出
            //删除按钮
            form.on('submit(Exit)', function (data) {
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            form.on('submit(Exit)', function (data)
            {
               Pub_Close(1);  //关闭弹窗
            })
@@ -323,29 +408,27 @@
            });
            //查询按钮
            if (Type == 2) {
                form.on('submit(btnSearch)', function (data) {
            form.on('submit(btnSearch)', function (data) {
                    var HDate = $("#HDate").val();//开始日期
                    var HDate1 = $("#HDate1").val();//结束日期
                    var HBillNo = $("#HBillNo").val(); //单据号
                    var Part = $("#Part").val();       //物料信息
                    var Source = $("#Source").val();  //资源
                    sWhere += SchWhere;
                    if (HDate) {
                        sWhere += " and CONVERT(varchar(100),a.HDate, 23) >= '" + HDate + "'";
                        sWhere += " and CONVERT(varchar(100),HDate, 23) >= '" + HDate + "'";
                    }
                    if (HDate1) {
                        sWhere += " and CONVERT(varchar(100),a.HDate, 23) <= '" + HDate1 + "'";
                        sWhere += " and CONVERT(varchar(100),HDate, 23) <= '" + HDate1 + "'";
                    }
                    if (HBillNo) {
                        sWhere += " and a.HBillNo like '%" + HBillNo + "%'";
                        sWhere += " and HBillNo like '%" + HBillNo + "%'";
                    }
                    if (Part) {
                        sWhere += " and concat(m.HNumber,m.HName,m.HModel) like '%" + Part + "%'";
                        sWhere += " and concat(HNumber,HName,HModel) like '%" + Part + "%'";
                    }
                    if (Source) {
                        sWhere += " and s.HName like '%" + Dept + "%'";
                        sWhere += " and HName like '%" + Dept + "%'";
                    }
                    $.ajax({
                        //url: "http://61.130.49.162:9090/WMSAPI///Web/GetMAXNum",
@@ -356,7 +439,7 @@
                            if (data1.count == 1) {
                                option.data = data1.data;
                                table.render(option);
                                layer.alert("查询成功", { icon: 1 });
                            } else {
                                layer.alert(data1.code + data1.Message, { icon: 5 });
                            }
@@ -366,7 +449,8 @@
                    });
                    sWhere = "";//调用接口后清空sWhere缓存
                });
            }
           // #endregion
            //以上是layui模块
        });
@@ -383,7 +467,6 @@
                    ScMaxWork = d.data[0].HBillNo;
                }
            });
            console.log(ScMaxWork);
            return ScMaxWork;
        }
    </script>