zhangrg
2024-01-02 00a88abf340904065aa7882c7555fc7b65164f5e
WebTM/views/Éú²ú¹ÜÀí/Éú²úÈÎÎñµ¥/Sc_ICMOBillImport.html
@@ -58,23 +58,7 @@
                            <!--基本信息-->
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item" style="padding-top: 10px;">
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <div class="layui-inline">
                                                <label class="layui-form-label" style="width: 85px;">单据日期</label>
                                                <div class="layui-input-block" style="margin-left: 120px;">
                                                    <input type="date" class="layui-input" lay-verify="HDate" name="HDate" id="HDate" style="padding-left: 75px;">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <div class="layui-inline">
                                                <div class="layui-input-block" style="margin-left: 120px;">
                                                    <input type="hidden" name="HPRDORGID" id="HPRDORGID" lay-verify="HPRDORGID">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
@@ -120,232 +104,22 @@
        //#region è¿›å…¥é¡µé¢å³åŠ è½½
        var params = getUrlVars();
        var OperationType = params[params[0]]; //从参数中获取 æ•°æ®ç±»åž‹  æ·»åŠ  ä¿å­˜
        //初始化界面
        set_ClearBill();
        //#endregion
        //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
        //行内事件
        table.on('tool(mainTable)', function (obj) {
            set_GridDelete(obj);   //行内删除
            set_GridCellCheck(obj);//行内快捷键筛选
        });
        //文件上传
        upload.render({
            elem: '#UpLoad',
            url: GetWEBURL() + '/JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_DR',
            contentType: 'application/json',
            exts: 'xls|xlsx', //允许上传的类型
            before: function (data) {
                loadIndex = layer.load(2);
            },
            done: function (data1) {
                if (data1.count == 1) {
                    option.data = data1.data;
                    table.render(option);
                    layer.close(loadIndex);
                } else {
                    layer.close(loadIndex);
                    layer.alert(data1.code + data1.Message, { icon: 5 });
                }
            },
            error: function (err) {
                debugger
                layer.alert('导入出现异常', { icon: 2 });
            }
        });
        //退出
        form.on('submit(Cancel)', function () {
            if (OperationType == 1) {
                Pub_Close(1);
            }
            else {
                Pub_Close(2);
            }
        })
        //导入  ä¿å­˜æ•°æ®
        form.on('submit(btnSave)', function (data) {
            if (table.cache["mainTable"] != null) {
                set_AddNew(data);
            }
            else {
                layer.msg("无数据,请先导入数据!");
            }
        })
        //#endregion
        //#region æ­¤é¡µé¢æ‰€æœ‰çš„æ–¹æ³•
        //#region åˆå§‹åŒ–界面
        function set_ClearBill() {
            //初始化时间
            $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
            //初始化表格
            set_InitGrid();
        }
        //#endregion
        //初始化表格
        function set_InitGrid() {
            var columns = [];
            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: '生产订单明细行号*', title: '生产订单明细行号', width: 200 });
            columns.push({ field: '组织编码*', title: '组织编码' });
            columns.push({ field: 'HWorkShopID', title: 'HWorkShopID', hide: true });
            columns.push({ field: '生产车间编码*', title: '生产车间' });
            columns.push({ field: 'HSourceID', title: 'HSourceID', hide: true });
            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: 'HMaterID', title: '物料ID', hide: true });
            columns.push({ field: '物料编码*', title: '物料编码' });
            columns.push({ field: '物料名称', title: '物料名称', width: 200 });
            columns.push({ field: '规格型号', title: '规格型号' });
            columns.push({ field: 'HUnitID', title: 'HUnitID', hide: true });
            columns.push({ field: '计量单位', title: '计量单位' });
            columns.push({ field: '批次号', title: '批次' });
            columns.push({ field: '销售订单数量', title: '销售订单数量', width: 200 });
            columns.push({ field: '生产订单数量', title: '生产订单数量', width: 200 });
            columns.push({ field: '总齐套数量', title: '总齐套数量', width: 200 });
            columns.push({ field: 'ICMOBillHInterID', title: 'ICMOBillHInterID', hide: true });
            columns.push({ field: 'ICMOBillHEntryID', title: 'ICMOBillHEntryID', hide: true });
            columns.push({ fixed: 'right', title: '操作', toolbar: '#barDemo' });
            option = {
                elem: '#mainTable'
                , toolbar: '#toolbarDemo'
                , height: 'full-190'
                , page: true
                , cellMinWidth: 90
                , limit: 50
                , limits: [50, 500, 5000, 20000]
                , loading: false
                , cols: [columns]
            };
            //渲染页面
            table.render(option);
        }
        //导入(保存)
        function set_AddNew(data) {
            var num = [];
            for (var i = 0; i < table.cache["mainTable"].length; i++) {
                if (table.cache["mainTable"][i] != "") {
                    table.cache["mainTable"][i].LAY_TABLE_INDEX = i;
                    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: "温馨提示" });
                }
            });
        }
        //行内删除
        function set_GridDelete(obj) {
            if (obj.event === 'del') {
                layer.confirm('真的删除行吗?', function (index) {
                    obj.del();
                    option.data = table.cache["mainTable"];//将数据绑定到data上
                    table.reload(option);
                    layer.close(index);
                });
            }
        }
        //行内删除快捷键
        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