duhe
2025-01-13 66cb29ca746fae50bac1cfae82db41b538fe7348
WebTM/views/Éú²ú¹ÜÀí/Éú²ú¼Æ»®Æ½Ì¨/JIT_DayPlanPlatFormImport.html
@@ -11,37 +11,6 @@
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <style>
        .main-btn { /*头部主按钮*/
            padding: 0 2px; /*调整按钮左右空隙大小*/
            height: 30px;
            line-height: 30px;
        }
        .btn-title {
            font-size: 16px;
        }
        /* é˜²æ­¢ä¸‹æ‹‰æ¡†çš„下拉列表被隐藏---必须设置--- */
        .layui-table-cell {
            overflow: visible !important;
        }
        /* ä½¿å¾—下拉框与单元格刚好合适 */
        td .layui-form-select {
            margin-top: -10px;
            margin-left: -15px;
            margin-right: -15px;
        }
        .layui-form-item .layui-inline {
            margin-top: 5px;
            margin-bottom: 5px;
            margin-right: 0px;
        }
        .layui-form-label {
            width: 25%;
        }
    </style>
</head>
<body>
    <div class="layui-fluid" style="padding: 0;">
@@ -49,7 +18,7 @@
            <div class="layui-card-body" style="padding: 1px;">
                <form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
                    <div style="padding: 10px; ">
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">导入</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">导入数据</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="Cancel" id="Cancel">退出</button>
                        <button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="UpLoad" id="UpLoad">文件上传</button>
                    </div>
@@ -129,6 +98,9 @@
        //#region è¿›å…¥é¡µé¢å³åŠ è½½
        var params = getUrlVars();
        var OperationType = params[params[0]]; //从参数中获取 æ•°æ®ç±»åž‹  æ·»åŠ  ä¿å­˜
        //初始化界面
        set_ClearBill();
@@ -139,6 +111,7 @@
        //行内事件
        table.on('tool(mainTable)', function (obj) {
            set_GridDelete(obj);   //行内删除
            set_GridCellCheck(obj);//行内快捷键筛选
        });
        //文件上传
@@ -168,7 +141,12 @@
        //退出
        form.on('submit(Cancel)', function () {
            Pub_Close(2);
            if (OperationType == 1) {
                Pub_Close(1);
            }
            else {
                Pub_Close(2);
            }
        })
        //导入  ä¿å­˜æ•°æ®
@@ -204,37 +182,63 @@
            var dd = myDate.getDate();
            var SumMonth = 31; //动态两月之差 new Date(yyyy, MM, 0).getDate()
            var columns = [];
            var HBEGINDATE = new Date(new Date($("#HDate").val())).getDate(); //获取开始日期天数
            columns.push({ type: 'checkbox', fixed: 'left' });
            columns.push({ field: 'hmainid', title: ' hmainid', width: 200, hide: true });
            columns.push({ field: '单据号', title: ' å•据号', width: 200 });
            columns.push({ field: '生产订单号*', title: '生产订单号' });
            columns.push({ field: 'hmainid', title: 'hmainid', width: 200, hide: true });
            columns.push({ field: '单据号', title: '单据号', width: 200 });
            columns.push({ field: '生产订单号*', title: '生产订单号', width: 150 });
            columns.push({ field: '生产订单明细行号*', title: '生产订单明细行号', width: 200 });
            columns.push({ field: '组织编码*', title: '组织编码' });
            columns.push({ field: '组织编码*', title: '组织编码', width: 150});
            columns.push({ field: 'HWorkShopID', title: 'HWorkShopID', hide: true });
            columns.push({ field: '生产车间编码*', title: '生产车间' });
            columns.push({ field: '生产车间编码*', title: '生产车间', width: 150});
            columns.push({ field: 'HSourceID', title: 'HSourceID', hide: true });
            columns.push({ field: '生产资源编码*', title: '生产资源' });
            columns.push({ field: '生产资源编码*', title: '生产资源', edit: 'text', event: "HSourceID"   });
            columns.push({ field: '优先级', title: '优先级' });
            columns.push({ field: 'HEmpID', title: 'HEmpID', hide: true });
            columns.push({ field: '员工', title: '员工' });
            columns.push({ field: '员工编码', title: '员工编码' });
            columns.push({ field: '员工', title: '员工', width: 150 });
            columns.push({ field: '员工编码', title: '员工编码', width: 150 });
            columns.push({ field: 'HMaterID', title: '物料ID', hide: true });
            columns.push({ field: '物料编码*', title: '物料编码' });
            columns.push({ field: '物料编码*', title: '物料编码', width: 150 });
            columns.push({ field: '物料名称', title: '物料名称', width: 200 });
            columns.push({ field: '规格型号', title: '规格型号' });
            columns.push({ field: '规格型号', title: '规格型号', width: 150});
            columns.push({ field: 'HUnitID', title: 'HUnitID', hide: true });
            columns.push({ field: '计量单位', title: '计量单位' });
            columns.push({ field: '批次号', title: '批次' });
            columns.push({ field: '计量单位', title: '计量单位', width: 150});
            columns.push({ field: '批次号', title: '批次', width: 150});
            columns.push({ field: '销售订单数量', title: '销售订单数量', width: 200 });
            columns.push({ field: '生产订单数量', title: '生产订单数量', width: 200 });
            columns.push({ field: '总齐套数量', title: '总齐套数量', width: 200 });
            for (var i = 0; i <= (SumMonth - dd); i++) {
                columns.push({ field: Format(yyyy + '/' + MM + '/' + (dd + i), 'yyyy-MM-dd'), title: Format(yyyy + '/' + MM + '/' + (dd + i), 'yyyy-MM-dd'), edit: 'text' })
            columns.push({ field: 'ICMOBillHInterID', title: 'ICMOBillHInterID', hide: true});
            columns.push({ field: 'ICMOBillHEntryID', title: 'ICMOBillHEntryID', hide: true });
            columns.push({ field: 'HProdORGID', title: 'HProdORGID', hide: true });
            var k = 0;//收集循环次数
            var Days = 45;
            for (var j = 0; j <= (Days - k); j++) {
                columns.push({ field: Format(yyyy + '/' + MM + '/' + (HBEGINDATE + j), 'yyyy-MM-dd'), title: Format(yyyy + '/' + MM + '/' + (HBEGINDATE + j), 'MM.dd'), width: 70, totalRow: true })
                //跨年的话 ä¼šä»Žä¸€æœˆä¸€å·å¼€å§‹
                if (MM == 12 && (HBEGINDATE + j) == 31) {
                    yyyy += 1;
                    MM = 1;
                    SumMonth = new Date(yyyy, MM, 0).getDate();
                    HBEGINDATE = 0;
                    k += j;
                    j = 0;
                } else if ((HBEGINDATE + j) == SumMonth) { //跨月 æœˆæ•°åР䏀  å¤©æ•°ä»Žä¸€å¼€å§‹
                    HBEGINDATE = 0;
                    MM += 1;
                    SumMonth = new Date(yyyy, MM, 0).getDate();
                    k += j;
                    j = 0;
                }
            }
            for (var i = 1; i < dd; i++) {
                columns.push({ field: Format(yyyy + '/' + (MM + 1) + '/' + i, 'yyyy-MM-dd'), title: Format(yyyy + '/' + (MM + 1) + '/' + i, 'yyyy-MM-dd'), edit: 'text' })
            }
            //for (var i = 0; i <= (SumMonth - dd); i++) {
            //    columns.push({ field: Format(yyyy + '/' + MM + '/' + (dd + i), 'yyyy-MM-dd'), title: Format(yyyy + '/' + MM + '/' + (dd + i), 'MM.dd'), edit: 'text', width:80 })
            //}
            //for (var i = 1; i <= dd; i++) {
            //    columns.push({ field: Format(yyyy + '/' + (MM + 1) + '/' + i, 'yyyy-MM-dd'), title: Format(yyyy + '/' + (MM + 1) + '/' + i, 'MM.dd'), edit: 'text', width: 80 })
            //}
            columns.push({ fixed: 'right', title: '操作', toolbar: '#barDemo' });
            option = {
@@ -251,7 +255,7 @@
            //渲染页面
            table.render(option);
        }
        }
        //导入(保存)
        function set_AddNew(data) {
@@ -260,36 +264,61 @@
            for (var i = 0; i < table.cache["mainTable"].length; i++) {
                if (table.cache["mainTable"][i] != "") {
                    table.cache["mainTable"][i].LAY_TABLE_INDEX = i;
                    if (table.cache["mainTable"][i].物料名称.indexOf("\"") != -1 || table.cache["mainTable"][i].物料名称.indexOf(";") != -1) {
                        table.cache["mainTable"][i].物料名称 = table.cache["mainTable"][i].物料名称.replaceAll("\"", "”").replaceAll(";", ";")
                    }
                    if (table.cache["mainTable"][i].规格型号.indexOf("\"") != -1 || table.cache["mainTable"][i].规格型号.indexOf(";") != -1) {
                        table.cache["mainTable"][i].规格型号 = table.cache["mainTable"][i].规格型号.replaceAll("\"", "”").replaceAll(";", ";")
                    }
                    num.push(table.cache["mainTable"][i])
                }
            }
            data.field.HPRDORGID = sessionStorage["OrganizationID"];//组织
            var sMainStr = JSON.stringify(data.field);
            var sSubStr = JSON.stringify(num);
            var sMainSub = sMainStr + ';' + sSubStr + ';' + sessionStorage["HUserName"];
            var index = layer.load();
            $.ajax({
                type: "POST",
                url: GetWEBURL() + "/JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_btnSave",
                async: true,
                data: { "sMainSub": sMainSub },
                dataType: "json",
                success: function (data) {
                    if (data.count == 1) {
                        layer.close(index);
                        layer.msg("提交成功");
                    }
                    else {
                        layer.close(index);
                        layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                },
                error: function (err) {
                    layer.close(index);
                    layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            for (var i = 0; i < option.data.length; i++) {
                if (option.data[i].物料名称.indexOf("\"") != -1 || option.data[i].物料名称.indexOf(";") != -1) {
                    option.data[i].物料名称 = option.data[i].物料名称.replaceAll("\"", "”").replaceAll(";", ";")
                }
            });
                if (option.data[i].规格型号.indexOf("\"") != -1 || option.data[i].规格型号.indexOf(";") != -1) {
                    option.data[i].规格型号 = option.data[i].规格型号.replaceAll("\"", "”").replaceAll(";", ";")
                }
            }
            var HDataSub = [];
            //JIT导入计划,每次导入100行数据,可修改i的自增值决定每次循环导入的行数
            for (var i = 0; i < option.data.length; i += 100) {
                HDataSub = option.data.slice(i, i + 100)
                data.field.HPRDORGID = sessionStorage["OrganizationID"];//组织
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(HDataSub);
                var sMainSub = sMainStr + ';' + sSubStr + ';' + sessionStorage["HUserName"];
                var index = layer.load();
                $.ajax({
                    type: "POST",
                    url: GetWEBURL() + "/JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_btnSave",
                    async: false,
                    data: { "sMainSub": sMainSub },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) {
                            layer.close(index);
                            layer.msg("提交成功");
                        }
                        else {
                            layer.close(index);
                            layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        }
                    },
                    error: function (err) {
                        layer.close(index);
                        layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                });
            }
        }
        //行内删除
@@ -304,6 +333,57 @@
            }
        }
        //行内删除快捷键
        function set_GridCellCheck(obj) {
            $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                if (event.key == "F7") {
                    //生产资源
                    if (obj.event == "HSourceID") {
                        layer.open({
                            type: 2
                            , skin: "layui-layer-rim" //加上边框
                            , title: "生产资源列表"  //标题
                            , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                            , shift: 2 //弹出动画
                            , area: ["90%", "90%"] //窗体大小
                            , maxmin: true //设置最大最小按钮是否显示
                            , content: ["../../基础资料/生产基础资料/Gy_Source.html", "yes"]
                            , btn: ["确定", "取消"]
                            , btn1: function (index, laero) {
                                //按钮一  çš„回调
                                var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                if (checkStatus.data.length != 1) {
                                    return layer.msg("请选择一条数据");
                                }
                                //更新表格缓存的数据
                                obj.update({
                                    "HSourceID": checkStatus.data[0].HItemID
                                    , "生产资源编码*": checkStatus.data[0].生产资源代码
                                })
                                layer.close(index);//关闭弹窗
                            }
                        })
                    }
                    obj.event = "";
                    return false;
                }
            })
        }
        //获取参数
        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;
        }
        //#endregion