WebTM/views/Éú²ú¹ÜÀí/Éú²ú»ã±¨µ¥/Sc_Add_ICMOReportBillList.html
@@ -13,8 +13,8 @@
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script src="../../../layuiadmin/PageTitle.js"></script>
    <style type="text/css">
        /*begin æ­¤æ ·å¼ç”¨äºŽæ¶ˆé™¤è¡Œå…ƒç´ ä¸­å¸ƒå±€å®½åº¦ä¸å¤Ÿçš„问题*/
        .layui-form-item .layui-inline {
            margin-top: 5px;
@@ -29,7 +29,7 @@
    <div class="layui-fluid" style="padding: 0;">
        <div class="layui-card" style="padding: 15px;">
            <div class="layui-card-body" style="padding: 1px;">
                <form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
                <form class="layui-form" action="" lay-filter="component-form-group" style="background-color:white;">
                    <div class="layui-card-header">
                        <div class="layui-btn-group">
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_AddNew" id="set_AddNew">新增</button>
@@ -42,7 +42,7 @@
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">退出</button>
                        </div>
                    </div>
                    <h1 style="text-align:center;"><b>生产汇报单</b></h1>
                    <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>
@@ -84,7 +84,7 @@
                                            <label class="layui-form-label">班组</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HGroupName" id="HGroupName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HGroupID" id="HGroupID" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HGroupID" id="HGroupID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HGroupList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
@@ -94,7 +94,7 @@
                                            <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;">
                                                <input type="hidden" name="HEmpID" id="HEmpID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HEmpList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
@@ -115,8 +115,8 @@
                                            <label class="layui-form-label">选单号</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HMainSourceInterID" id="HMainSourceInterID" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HMainSourceEntryID" id="HMainSourceEntryID" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HMainSourceInterID" id="HMainSourceInterID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <input type="hidden" name="HMainSourceEntryID" id="HMainSourceEntryID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="XDHList" id="XDHList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
@@ -228,7 +228,22 @@
                            </div>
                        </div>
                    </div>
                    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                    <div class="layui-tab layui-tab-card">
                        <ul class="layui-tab-title">
                            <li class="layui-this">生产汇报单</li>
                            <li>产量汇报单明细</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <!--生产汇报单明细-->
                                <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                            </div>
                            <div class="layui-tab-item">
                                <!--产量汇报单-->
                                <table class="layui-hide" id="mainTable_prodReport" lay-filter="mainTable_prodReport"></table>
                            </div>
                        </div>
                    </div>
                    <script type="text/html" id="toolbarDemo">
                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine" id="btn-AddLine"><i class="layui-icon layui-icon-form"></i>增加一行</button>
@@ -248,6 +263,7 @@
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script>
        var OptionData = [];
        //#region æŠ˜å æ³¨é‡Š
        //#endregion
        layui.config({
@@ -255,8 +271,8 @@
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element', 'upload'], function () {
        //#region å…¬ç”¨å˜é‡
            //#region å…¬ç”¨å˜é‡
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
@@ -266,17 +282,25 @@
                , laydate = layui.laydate
                , element = layui.element;
            var option;
            var option_prodReport;
            var sBillType = "3711";
            var TabRow = {
                "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "",
                "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0, "HRemark": ""
            };
            //var TabRow = {
            //    "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "",
            //    "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0,"HBadQty":0, "HRemark": ""
            //};
            var Sctag = "0";
            var columns = "";
        //#endregion
            //#endregion
        //#region è¿›å…¥é¡µé¢å³åŠ è½½
            //#region è¿›å…¥é¡µé¢å³åŠ è½½
            //#region ã€åŠ¨æ€èŽ·å–æ¨¡å—åç§°ã€‘
            var HModuleType = "3711";
            //通过单据类型,从数据库动态获取单据模块命名,引用js文件 PageTitle.js
            var HPageTitle = get_PageTitle(HModuleType) == "" ? $("h1").html() : get_PageTitle(HModuleType);
            $("h1").html('<b>' + HPageTitle + '</b>');
            //#endregion
            //判断是否登录 æœªç™»å½•则跳到登录页
            get_LoginIs();
@@ -301,24 +325,36 @@
            }
            //判断操作类型
            if (OperationType == 1) {//无源单新增
                $("#HDeptID").val(sessionStorage["HDeptID"]); //根据登录用户带出部门ID
                $("#HDeptName").val(sessionStorage["HDept"]); //根据登录用户带出部门
                $("#HGroupID").val(sessionStorage["HGroupID"]); //根据登录用户带出班组ID
                $("#HGroupName").val(sessionStorage["HGroup"]); //根据登录用户带出班组
                $("#HEmpID").val(sessionStorage["HEmpID"]); //根据登录用户带出操作员ID
                $("#HEmpName").val(sessionStorage["HEmpName"]); //根据登录用户带出操作员
                set_AddFNew();
            }
            else if (OperationType == 2) {//有源单新增
                $("#HDeptID").val(sessionStorage["HDeptID"]); //根据登录用户带出部门ID
                $("#HDeptName").val(sessionStorage["HDept"]); //根据登录用户带出部门
                $("#HGroupID").val(sessionStorage["HGroupID"]); //根据登录用户带出班组ID
                $("#HGroupName").val(sessionStorage["HGroup"]); //根据登录用户带出班组
                $("#HEmpID").val(sessionStorage["HEmpID"]); //根据登录用户带出操作员ID
                $("#HEmpName").val(sessionStorage["HEmpName"]); //根据登录用户带出操作员
                set_AddNew();
            }
            else if (OperationType == 3) {//编辑
                set_EditFromGrid();
                get_file();
                //get_file();
            }
            else {
                layer.alert("未知操作类型!", { icon: 5 });
            }
        //#endregion
            //#endregion
        //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
            //#region å¤´å·¥å…·æ äº‹ä»¶
            table.on('toolbar(mainTable)', function (obj) {
@@ -326,7 +362,13 @@
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;;
                var AddRow = table.cache['mainTable'];
                var NewRow = TabRow;
                var NewRow = {
                    "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "",
                    "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0, "HBadQty": 0,
                    "HICMOBillNo": "", "HICMOInterID": "0", "HICMOEntryID": "0", "HRemark": "", "HSourceInterID": 0, "HSourceEntryID": 0, "HSourceBillNo": "",
                    "HSourceBillType": 0
                };
                switch (obj.event) {
                    //新增一行
                    case 'btn-AddLine': btnAddLine(NewRow);
@@ -362,7 +404,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) {
@@ -372,7 +414,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内部动态递增计算的
                    }
@@ -408,7 +450,12 @@
                    content: ['../../PublicPage/ProductionOrder.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
                        option.data = [TabRow];
                        option.data = [{
                            "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "",
                            "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0, "HBadQty": 0,
                            "HICMOBillNo": "", "HICMOInterID": "0", "HICMOEntryID": "0", "HRemark": "", "HSourceInterID": 0, "HSourceEntryID": 0, "HSourceBillNo": "",
                            "HSourceBillType": 0, "HICMOTempID": 0
                        }];
                        table.render(option);
                        //按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -430,25 +477,31 @@
                        }
                        if (isAllEqual(list))  //相同单号
                        {
                            console.log(checkStatus.data);
                            //console.log(checkStatus.data);
                            if (checkStatus.data.length > 1) {
                                for (var i = 0; i < checkStatus.data.length - 1; i++) //补行
                                {
                                    //var NewRow = { "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0, "HRemark": "" };
                                    table.cache["mainTable"].push(TabRow);
                                    table.cache["mainTable"].push({
                                        "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "",
                                        "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0, "HBadQty": 0, "HICMOBillNo": "", "HICMOInterID": "0", "HICMOEntryID": "0", "HRemark": "", "HSourceInterID": 0, "HSourceEntryID": 0, "HSourceBillNo": "",
                                        "HSourceBillType": 0, "HICMOTempID": 0
                                    });
                                    option.data = table.cache["mainTable"];
                                    table.render(option);
                                }
                            }
                            for (var i = 0; i < checkStatus.data.length; i++) {
                                $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HMaterID"] .layui-table-cell').text(checkStatus.data[i].HMaterID);
                                $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HMaterCode"] .layui-table-cell').text(checkStatus.data[i].HMaterCode);
                                $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HMaterName"] .layui-table-cell').text(checkStatus.data[i].HMaterName);
                                $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HMaterSpec"] .layui-table-cell').text(checkStatus.data[i].HMaterSpec);
                                $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HUnitID"] .layui-table-cell').text(checkStatus.data[i].HUnitID);
                                $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HUnitCode"] .layui-table-cell').text(checkStatus.data[i].HUnitCode);
                                $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HUnitName"] .layui-table-cell').text(checkStatus.data[i].HUnitName);
                            }
                            option.data = checkStatus.data;
                            table.render(option);
                            //for (var i = 0; i < checkStatus.data.length; i++) {
                            //    $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HMaterID"] .layui-table-cell').text(checkStatus.data[i].HMaterID);
                            //    $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HMaterCode"] .layui-table-cell').text(checkStatus.data[i].HMaterCode);
                            //    $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HMaterName"] .layui-table-cell').text(checkStatus.data[i].HMaterName);
                            //    $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HMaterSpec"] .layui-table-cell').text(checkStatus.data[i].HMaterSpec);
                            //    $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HUnitID"] .layui-table-cell').text(checkStatus.data[i].HUnitID);
                            //    $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HUnitCode"] .layui-table-cell').text(checkStatus.data[i].HUnitCode);
                            //    $('.layui-table-view[lay-id="mainTable"]').children('.layui-table-box').children('.layui-table-body').find('table tbody tr[data-index="' + i + '"]').find('td[data-field="HUnitName"] .layui-table-cell').text(checkStatus.data[i].HUnitName);
                            //}
                            layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                        }
                        else {
@@ -480,16 +533,23 @@
            //#region æäº¤ä¿å­˜
            form.on('submit(Saver)', function (data) {//保存
                var refSav = "";
                if (linterid == "" || linterid == null) {
                if (OperationType == 1 || OperationType == 2) {
                    refSav = "Add";
                }
                if (linterid != "" && linterid != null) {
                if (OperationType == 3) {
                    refSav = "Update";
                }
                data.field.HMaker = sessionStorage["HUserName"];//制单人
                //筛选删除之后不为空的数据组
                var row = [];
                for (var i = 0; i < table.cache['mainTable'].length; i++) {
                    if (table.cache['mainTable'][i] != "") {
                        row.push(table.cache['mainTable'][i])
                    }
                }
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sMainSub = sMainStr + ';' + sSubStr + ';' + refSav;
                var sSubStr = JSON.stringify(row);
                var sMainSub = sMainStr + ';' + sSubStr + ';' + refSav + ";" + sessionStorage["HUserName"];
                if (!AllowLoadData(sSubStr))//数据验证
                {
                    return false;
@@ -503,9 +563,10 @@
                    success: function (data) {
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            layer.msg(data.Message, { time: 1 * 1000, icon: 1 }, function () {
                                $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭 Â  Â  Â  Â  Â Â  Â Â Â  Â 
                                $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);//保存按钮禁用
                                $('#set_CheckBill').removeClass("layui-btn-disabled").attr("disabled", false);//审核按钮启用
                                //var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                //parent.layer.close(index); //再执行关闭 Â  Â  Â  Â  Â Â  Â Â Â  Â 
                            });
                        }
                        else {
@@ -533,7 +594,7 @@
            //#region å®¡æ ¸
            form.on('submit(set_CheckBill)', function (data) {
                set_CheckBill()
            });
            //#endregion
@@ -549,10 +610,10 @@
            });
            //#endregion
        //#endregion
            //#endregion
        //#region æœ¬é¡µé¢æ‰€æœ‰è¢«è°ƒç”¨çš„æ–¹æ³•
            //#region æœ¬é¡µé¢æ‰€æœ‰è¢«è°ƒç”¨çš„æ–¹æ³•
            //#region åˆå§‹åŒ–表单
            function set_InitFrom() {
@@ -564,9 +625,15 @@
            //#region è¡¨æ ¼å¢žåŠ è¡Œäº‹ä»¶
            function btnAddLine(NewRow) {
                table.cache["mainTable"].push(NewRow);
                option.data = table.cache["mainTable"];
                table.render(option);
                var tableBak = table.cache["mainTable"]; //获取之前编辑过的表格数据
                buttonArr = [];//清空数组
                for (var i = 0; i < tableBak.length; i++) {
                    buttonArr.push(tableBak[i]);  //将之前的数据存储
                }
                buttonArr.push(NewRow);  //在尾部加一行
                table.reload("mainTable", {
                    data: buttonArr    //将数据重新载入表格
                })
            }
            //#endregion
@@ -608,6 +675,35 @@
            }
            //#endregion
            //#region å®¡æ ¸
            function set_CheckBill() {
                var InterID = $("#HInterID").val();
                //逻辑审核方法
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Sc_ICMOReportBill/AuditProcessReportList", //方法所在页面和方法名
                    data: { "HInterID": InterID, "IsAudit": 0, "CurUserName": sessionStorage["HUserName"] },
                    success: function (result) {
                        if (result.count == 1) {
                            layer.msg(result.Message, { time: 1 * 10000, icon: 1 }, function () {
                                // å¾—到frame索引
                                var index = layer.getFrameIndex(window.name);
                                //关闭当前frame
                                layer.close(index);
                                //修改为功后刷新界面
                                $("#btnSearch").trigger('click');
                            });
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
            //#region è¡¨æ ¼è¡Œå†…事件快捷键筛选
            function set_GridCellCheck(obj) {
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
@@ -623,7 +719,7 @@
                                shift: 2,
                                area: ['90%', '90%'],
                                maxmin: true,
                                content: ['../../PublicPage/PartInformation.html', 'yes'],
                                content: ['../../基础资料/公用基础资料/Gy_Material.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
                                    //按钮【按钮一】的回调
@@ -635,17 +731,26 @@
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HMaterID: checkStatus.data[0].HItemID,
                                        HMaterCode: checkStatus.data[0].HNumber,
                                        HMaterName: checkStatus.data[0].HName,
                                        HMaterSpec: checkStatus.data[0].HModel,
                                        HMaterCode: checkStatus.data[0].物料代码,
                                        HMaterName: checkStatus.data[0].物料名称,
                                        HMaterSpec: checkStatus.data[0].规格型号,
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }, end: function () {
                                    if (OptionData.length > 0) {
                                        //更新表格缓存的数据
                                        obj.update({
                                            HMaterID: OptionData[0].HItemID,
                                            HMaterCode: OptionData[0].物料代码,
                                            HMaterName: OptionData[0].物料名称,
                                            HMaterSpec: OptionData[0].规格型号,
                                        });
                                        OptionData = [];
                                    }
                                }
                            });
                        }
@@ -661,7 +766,7 @@
                                shift: 2,
                                area: ['90%', '90%'],
                                maxmin: true,
                                content: ['../../PublicPage/UnitInformation.html', 'yes'],
                                content: ['../../基础资料/公用基础资料/Gy_Unit.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
@@ -675,8 +780,8 @@
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HUnitID: checkStatus.data[0].HItemID,
                                        HUnitCode: checkStatus.data[0].HNumber,
                                        HUnitName: checkStatus.data[0].HName
                                        HUnitCode: checkStatus.data[0].计量单位代码,
                                        HUnitName: checkStatus.data[0].计量单位名称
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
@@ -684,9 +789,16 @@
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }, end: function () {
                                    if (OptionData.length > 0) {
                                        //更新表格缓存的数据
                                        obj.update({
                                            HUnitID: OptionData[0].HItemID,
                                            HUnitCode: OptionData[0].计量单位代码,
                                            HUnitName: OptionData[0].计量单位名称
                                        });
                                        OptionData = [];
                                    }
                                }
                            });
                        }
@@ -702,7 +814,7 @@
                                shift: 2,
                                area: ['90%', '90%'],
                                maxmin: true,
                                content: ['../../PublicPage/SourceInformation.html', 'yes'],
                                content: ['../../基础资料/生产基础资料/Gy_Source.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
@@ -716,8 +828,8 @@
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HSourceID: checkStatus.data[0].HItemID,
                                        HSourceCode: checkStatus.data[0].HNumber,
                                        HSourceName: checkStatus.data[0].HName
                                        HSourceCode: checkStatus.data[0].生产资源代码,
                                        HSourceName: checkStatus.data[0].生产资源名称
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
@@ -725,9 +837,16 @@
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }, end: function () {
                                    if (OptionData.length > 0) {
                                        //更新表格缓存的数据
                                        obj.update({
                                            HSourceID: OptionData[0].HItemID,
                                            HSourceCode: OptionData[0].生产资源代码,
                                            HSourceName: OptionData[0].生产资源名称
                                        });
                                        OptionData = [];
                                    }
                                }
                            });
                        }
@@ -743,7 +862,7 @@
                                shift: 2,
                                area: ['90%', '90%'],
                                maxmin: true,
                                content: ['../../PublicPage/UserInformation.html', 'yes'],
                                content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html?type=HManager', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
@@ -757,8 +876,8 @@
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HWorkerid: checkStatus.data[0].HItemID,
                                        HWorkerCode: checkStatus.data[0].HNumber,
                                        HWorkerName: checkStatus.data[0].HName
                                        HWorkerCode: checkStatus.data[0].职员代码,
                                        HWorkerName: checkStatus.data[0].职员名称
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
@@ -766,9 +885,16 @@
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }, end: function () {
                                    if (OptionData.length > 0) {
                                        //更新表格缓存的数据
                                        obj.update({
                                            HWorkerid: OptionData[0].HItemID,
                                            HWorkerCode: OptionData[0].职员代码,
                                            HWorkerName: OptionData[0].职员名称
                                        });
                                        OptionData = [];
                                    }
                                }
                            });
                        }
@@ -798,7 +924,18 @@
                    , { field: 'HWorkerid', title: 'HWorkerid', edit: 'text', width: 100, hide: true }
                    , { field: 'HWorkerCode', title: '操作员代码', edit: 'text', event: 'HWorkerCode', width: 100 }
                    , { field: 'HWorkerName', title: '操作员名称', edit: 'text', width: 100 }
                    , { field: 'HQty', title: '生产数量', edit: 'text', width: 100 }
                    , { field: 'HQty', title: '生产数量', edit: 'text', width: 100, totalRow: true }
                    , { field: 'HBadQty', title: '不良数量', edit: 'text', width: 100, totalRow: true }
                    , { field: 'HICMOBillNo', title: '生产订单', edit: 'text', width: 100 }
                    , { field: 'HICMOInterID', title: '生产订单内码', edit: 'text', width: 100, hide: true }
                    , { field: 'HICMOEntryID', title: '生产订单子内码', edit: 'text', width: 100, hide: true }
                    , { field: 'HSourceInterID', title: '源单内码', edit: 'text', width: 100, hide: true }
                    , { field: 'HSourceEntryID', title: '源单子内码', edit: 'text', width: 100, hide: true }
                    , { field: 'HSourceBillNo', title: '源单单号', edit: 'text', width: 100, hide: true }
                    , { field: 'HSourceBillType', title: '源单类型', edit: 'text', width: 100, hide: true }
                    , { field: 'HICMOTempID', title: 'HICMOTempID', edit: 'text', width: 100, hide: true }
                    , { field: 'HRemark', title: '表体备注', edit: 'text', width: 100 }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150 }
                ];
@@ -808,8 +945,43 @@
                    , toolbar: '#toolbarDemo'
                    , page: false
                    , cellMinWidth: 120
                    , totalRow: true
                    , height: 500
                    , cols: [columns]
                    , done: function (res, curr, count) {
                    }
                };
                columns_prodReport = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe", width: 100 }
                    , { field: 'HMaterID', title: 'HMaterID', edit: 'text', width: 100, hide: true }
                    , { field: 'HMaterCode', title: '物料代码', edit: 'text', event: 'HMaterCode', width: 100 }
                    , { field: 'HMaterName', title: '物料名称', edit: 'text', width: 100 }
                    , { field: 'HMaterSpec', title: '规格型号', edit: 'text', width: 100 }
                    , { field: 'HSourceID', title: 'HSourceID', edit: 'text', width: 100, hide: true }
                    , { field: 'HSourceCode', title: '资源代码', edit: 'text', event: 'HSourceCode', width: 100 }
                    , { field: 'HSourceName', title: '资源名称', edit: 'text', width: 100 }
                    , { field: 'HWorkerid', title: 'HWorkerid', edit: 'text', width: 100, hide: true }
                    , { field: 'HWorkerCode', title: '操作员代码', edit: 'text', event: 'HWorkerCode', width: 100 }
                    , { field: 'HWorkerName', title: '操作员名称', edit: 'text', width: 100 }
                    , { field: 'HQty', title: '生产数量', edit: 'text', width: 100, totalRow: true }
                    , { field: 'HBadQty', title: '不良数量', edit: 'text', width: 100, totalRow: true }
                    , { field: 'HICMOBillNo', title: '生产订单', edit: 'text', width: 100 }
                    , { field: 'HRemark', title: '表体备注', edit: 'text', width: 100 }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150 }
                ];
                option_prodReport = {
                    id: 'mainTable_prodReport'
                    , elem: '#mainTable_prodReport'
                    , page: true
                    , totalRow: true
                    , limit: 1000
                    , limits: [500, 1000, 1500, 2000, 3000]
                    , cellMinWidth: 120
                    , height: 500
                    , cols: [columns_prodReport]
                    , done: function (res, curr, count) {
                    }
@@ -833,7 +1005,7 @@
                    success: function (d) {
                        //console.log(d.data);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HInterID").val(0);
                        $("#HInterID").val(d.data[0].HInterID);
                        $("#HDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                        $("#HMakeDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                        $("#HMaker").val(sessionStorage["HUserName"]);
@@ -853,7 +1025,12 @@
                $('#set_AbandonCheck').addClass("layui-btn-disabled").attr("disabled", true);
                $('#set_DeleteBill').addClass("layui-btn-disabled").attr("disabled", true);
                $('#get_PrintReport').addClass("layui-btn-disabled").attr("disabled", true);
                option.data = [TabRow];
                option.data = [{
                    "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "",
                    "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0, "HBadQty": 0,
                    "HICMOBillNo": "", "HICMOInterID": "0", "HICMOEntryID": "0", "HRemark": "", "HSourceInterID": 0, "HSourceEntryID": 0, "HSourceBillNo": "",
                    "HSourceBillType": 0, "HICMOTempID": 0
                }];
                table.render(option);
            }
            //#endregion
@@ -862,8 +1039,66 @@
            function set_AddNew() {
                //获取最大单据号
                get_MAXNum();
                option.data = [TabRow];
                table.render(option);
                if (linterid.length > 0 && HSouceBillType == 3724) {
                    var arr = [];
                    var arr_detail = [];
                    $.ajax({
                        url: GetWEBURL() + "Sc_ICMOReportBill/GetProdReportBillList",
                        type: "GET",
                        data: {
                            "HInterID": linterid,
                            "user": sessionStorage["HUserName"]
                        },
                        async: false,
                        success: function (result) {
                            if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                                var data = result.data.h_p_Sc_ICMOBillWorkQtyStatus_TmpList1; //汇总信息
                                var data_detail = result.data.h_p_Sc_ICMOBillWorkQtyStatus_TmpList; //明细信息
                                for (let i = 0; i < data.length; i++) {
                                    arr.push({
                                        "HMaterID": data[i].物料ID, "HMaterCode": data[i].物料代码, "HMaterName": data[i].物料名称, "HMaterSpec": data[i].规格型号,
                                        "HUnitID": data[i].单位ID, "HUnitCode": data[i].计量单位代码, "HUnitName": data[i].计量单位, "HSourceID": data[i].生产资源ID, "HSourceCode": data[i].生产资源代码,
                                        "HSourceName": data[i].生产资源名称, "HWorkerid": data[i].操作员ID, "HWorkerCode": data[i].操作员代码,
                                        "HWorkerName": data[i].操作员名称, "HQty": data[i].产量, "HBadQty": data[i].不良数量 == '' ? 0 : data[i].不良数量, "HICMOBillNo": data[i].生产订单号,
                                        "HICMOInterID": data[i].HICMOInterID, "HICMOEntryID": data[i].HICMOEntryID, "HRemark": "", "HSourceInterID": data[i].HICMOInterID, "HSourceEntryID": data[i].HICMOEntryID, "HSourceBillNo": data[i].生产订单号,
                                        "HSourceBillType": 3710, "HICMOTempID": data[i].HICMOTempID
                                    });
                                }
                                for (let j = 0; j < data_detail.length; j++) {
                                    arr_detail.push({
                                        "HMaterID": data_detail[j].物料ID, "HMaterCode": data_detail[j].物料代码, "HMaterName": data_detail[j].物料名称,
                                        "HMaterSpec": data_detail[j].规格型号, "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HSourceID": data_detail[j].生产资源ID,
                                        "HSourceCode": data_detail[j].生产资源代码, "HSourceName": data_detail[j].生产资源名称, "HWorkerid": data_detail[j].操作员ID,
                                        "HWorkerCode": data_detail[j].操作员代码, "HWorkerName": data_detail[j].操作员名称, "HQty": data_detail[j].产量,
                                        "HBadQty": data_detail[j].不良数量, "HICMOBillNo": data_detail[j].生产订单号, "HRemark": ""
                                    })
                                }
                            } else {
                                layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                            }
                        }, error: function () {
                            layer.alert("发生错误!", { icon: 5 });
                        }
                    });
                    option.data = arr;
                    console.log(option.data);
                    table.render(option);
                    option_prodReport.data = arr_detail;
                    table.render(option_prodReport);
                } else {
                    option.data = [{
                        "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "",
                        "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0, "HBadQty": 0,
                        "HICMOBillNo": "", "HICMOInterID": "0", "HICMOEntryID": "0", "HRemark": "", "HSourceInterID": 0, "HSourceEntryID": 0, "HSourceBillNo": "",
                        "HSourceBillType": 0, "HICMOTempID": 0
                    }];
                    table.render(option);
                }
            }
            //#endregion
@@ -871,7 +1106,12 @@
            function set_EditFromGrid() {
                set_EditForm(linterid);  //编辑获取表头
                set_EditGrid(linterid);  //编辑获取表体
                option.data = [TabRow];
                option.data = [{
                    "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "",
                    "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0, "HBadQty": 0,
                    "HICMOBillNo": "", "HICMOInterID": "0", "HICMOEntryID": "0", "HRemark": "", "HSourceInterID": 0, "HSourceEntryID": 0, "HSourceBillNo": "",
                    "HSourceBillType": 0, "HICMOTempID": 0
                }];
                table.render(option);
            }
            //#endregion
@@ -894,6 +1134,7 @@
                            $("#HInnerBillNo").val(data.内部单据号);
                            $("#HDeptID").val(data.HDeptID);
                            $("#HDeptName").val(data.部门);
                            $("#HDeptNumber").val(data.部门代码);
                            $("#HGroupID").val(data.HGroupID);
                            $("#HGroupName").val(data.班组);
                            $("#HEmpID").val(data.HEmpID);
@@ -904,6 +1145,7 @@
                            $("#HExplanation").val("");
                            $("#HRemark").val(data.表头备注);
                            PicUpload();
                            get_file();
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
@@ -994,15 +1236,15 @@
            //#region éžç©ºéªŒè¯
            function AllowLoadData(sSubStr) {  //非空验证
                var Result = true;
                if ($("#HDeptID").val() == '' || $("#HDeptID").val() == null) {
                if ($("#HDeptID").val() == '' || $("#HDeptID").val() == null || $("#HDeptID").val() == "undefined" || $("#HDeptID").val() == 0) {
                    layer.msg("车间不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if ($("#HGroupID").val() == '' || $("#HGroupID").val() == null) {
                if ($("#HGroupID").val() == '' || $("#HGroupID").val() == null || $("#HGroupID").val() == "undefined" | $("#HGroupID").val() == 0) {
                    layer.msg("班组不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if ($("#HEmpID").val() == '' || $("#HEmpID").val() == null) {
                if ($("#HEmpID").val() == '' || $("#HEmpID").val() == null || $("#HGroupID").val() == "undefined" || $("#HEmpID").val() == 0) {
                    layer.msg("统计员不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
@@ -1061,7 +1303,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '职员列表'//标题
                    , shift: 2//弹出动画
                    ,content: ['../../PublicPage/UserInformation.html', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html?type=HEmp', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -1069,7 +1311,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(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -1086,7 +1328,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '部门列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../PublicPage/DeptInformation.html', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_DepartmentList.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -1094,9 +1336,9 @@
                        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);
                        $("#HDeptNumber").val(checkStatus.data[0].HNumber);
                        $("#HDeptNumber").val(checkStatus.data[0].部门代码);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
@@ -1171,6 +1413,7 @@
            //获取编辑时,已上传的文件列表
            function get_file() {
                var HBillNo = $("#HBillNo").val()
                if (HBillNo != null || HBillNo != undefined) {
                    var ProImgByList = $('#ProImgByList')
                    $.ajax({
@@ -1193,7 +1436,6 @@
                                        , '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" type="button" id="deltefile" onclick="javascript:toManager(this)"><i class="layui-icon layui-icon-delete layuiadmin-button-btn"></i>删除</button>'
                                        , '</td>'
                                        , '</tr>'].join(''));
                                    $('#ProImgByList').append(tr);
                                }
                            } else {
@@ -1207,54 +1449,87 @@
            }
            //删除文件
            function toManager(r) {
                //得到当前所在行
                var rows = r.parentNode.parentNode.rowIndex;
                //得到所在行的第一列的内容:主键ID
                var HItemID = $("#ProImgByList tr:eq(" + (rows - 1) + ") td:eq(0)").html();
                //得到所在行的第二列的内容:单据号
                var HSourceBillNo = $("#ProImgByList tr:eq(" + (rows - 1) + ") td:eq(1)").html();
                //得到所在行的第三列的内容:文件名称
                var HFileName = $("#ProImgByList tr:eq(" + (rows - 1) + ") td:eq(2)").html();
                layer.confirm("确认要删除吗,删除后不能恢复", { title: "删除确认" }, function (index) {
                    //删除已上传文件
                    $.ajax({
                        url: GetWEBURL() + '/Cj_StationOutBill/DeleteFilelist',
                        type: "GET",
                        data: { "HItemID": HItemID, "HSourceBillNo": HSourceBillNo, "HFileName": HFileName },
                        success: function (data1) {
                            if (data1.count == 1) {
                                layer.alert(data1.Message, { icon: 1 });
                                $("#ProImgByList tr").eq((rows - 1)).remove();
                            }
                            else {
                                layer.alert(data1.code + data1.Message, { icon: 5 });
                            }
                        }, error: function () {
                            layer.alert("接口请求失败!", { icon: 5 });
                        }
                    });
                })
            }
            //#endregion
            //下载文件
            function dowload(r) {
                //得到当前所在行
                var rows = r.parentNode.parentNode.rowIndex;
                //得到所在行的第五列的内容:文件地址
                var url = $("#ProImgByList tr:eq(" + (rows - 1) + ") td:eq(5)").html();
                /*window.location.href = url;*/
                window.open(url)
            }
        //#endregion
        });
        //删除文件
        function toManager(r) {
            //得到当前所在行
            var rows = r.parentNode.parentNode.rowIndex;
            //得到所在行的第一列的内容:主键ID
            var HItemID = $("#ProImgByList tr:eq(" + (rows - 1) + ") td:eq(0)").html();
            //得到所在行的第二列的内容:单据号
            var HSourceBillNo = $("#ProImgByList tr:eq(" + (rows - 1) + ") td:eq(1)").html();
            //得到所在行的第三列的内容:文件名称
            var HFileName = $("#ProImgByList tr:eq(" + (rows - 1) + ") td:eq(2)").html();
            layer.confirm("确认要删除吗,删除后不能恢复", { title: "删除确认" }, function (index) {
                //删除已上传文件
                $.ajax({
                    url: GetWEBURL() + '/Cj_StationOutBill/DeleteFilelist',
                    type: "GET",
                    data: { "HItemID": HItemID, "HSourceBillNo": HSourceBillNo, "HFileName": HFileName },
                    success: function (data1) {
                        if (data1.count == 1) {
                            layer.alert(data1.Message, { icon: 1 });
                            $("#ProImgByList tr").eq((rows - 1)).remove();
                        }
                        else {
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            })
        }
        //下载文件
        function dowload(r) {
            //得到当前所在行
            var rows = r.parentNode.parentNode.rowIndex;
            //得到所在行的第五列的内容:文件地址
            var url = $("#ProImgByList tr:eq(" + (rows - 1) + ") td:eq(5)").html();
            /*window.location.href = url;*/
            window.open(url)
        }
        //生产车间
        function GetHDeptNameValue(obj) {
            $("#HDeptName").val(obj[0].部门名称);
            $("#HDeptID").val(obj[0].HItemID);
            $("#HDeptNumber").val(obj[0].部门代码);
        }
        //生产班组
        function GetHGroupValue(obj) {
            $("#HGroupName").val(obj[0].班组名称);
            $("#HGroupID").val(obj[0].HItemID);
        }
        //统计员
        function GetHEmpValue(obj) {
            $("#HEmpName").val(obj[0].职员名称);
            $("#HEmpID").val(obj[0].HItemID);
        }
        //物料
        function GetMaterValue(obj) {
            OptionData = obj;
        }
        //单位
        function GetUnitValue(obj) {
            OptionData = obj;
        }
        //生产资源
        function GetGySource(obj) {
            OptionData[0] = obj;
        }
        //操作员
        function GetHManagerValue(obj) {
            OptionData = obj;
        }
    </script>
</body>
</html>