yangle
2023-08-24 22870b2ceda5ea1dc4e83c8b8d6a11973b834be3
WebTM/views/³µ¼ä¹ÜÀí/ίÍ⹤Ðò·¢³öµ¥/Cj_StationEntrustInBillList.html
@@ -62,9 +62,35 @@
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label" style="width: 85px;">任务单号</label>
                                        <div class="layui-input-block" style="margin-left: 120px;">
                                            <input type="text" class="layui-input" name="HICMOBillNo" id="HICMOBillNo">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label" style="width: 85px;">单据号</label>
                                        <div class="layui-input-block" style="margin-left: 120px;">
                                            <input type="text" class="layui-input" name="HBillNo" id="HBillNo">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label" style="width: 85px;">工序流转卡号</label>
                                        <div class="layui-input-block" style="margin-left: 120px;">
                                            <input type="text" class="layui-input" name="HProcExchBillNo" id="HProcExchBillNo">
                                        </div>
                                    </div>
                                    <div class="layui-row" style=" margin-top: 10px; margin-left: 80px;">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">产品代码</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HNumber" id="HNumber">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">当前工序</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HName" id="HName">
                                            </div>
                                        </div>
                                    </div>
                                </div>
@@ -78,6 +104,9 @@
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Delete" id="btn-Delete"><i class="layui-icon layui-icon-delete"></i>删除</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Audit" id="btn-Audit"><i class="layui-icon layui-icon-radio"></i>审核</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-DeAudit" id="btn-DeAudit"><i class="layui-icon layui-icon-circle"></i>反审核</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_CloseBill" id="set_CloseBill"><i class="layui-icon layui-icon-form"></i>关闭</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_CancelCloseBill" id="set_CancelCloseBill"><i class="layui-icon layui-icon-form"></i>反关闭</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Exit" id="btn-Exit">退出</button>
                            </div>
                        </script>
@@ -103,9 +132,11 @@
            //公用变量
            var sWhere = "";
            var option = [];
            var HModName = "Cj_StationEntrustInBillList";
            var titleData = ["HInterID","hsubid","hmainid", "HSupID", "HMaterID", "HProcID"];//不需要显示的字段 å¯æ‰©å±•
            //初始化表格
            set_InitGrid();
            DisPlay_HideColumn();
            //重置按钮
            form.on('submit(btnReSearch)', function (data) {
                set_ClearQuery();
@@ -114,6 +145,29 @@
            //查询按钮
            form.on('submit(btnSearch)', function (data) {
                get_FastQuery();
            });
            //生产订单回车方法
            $('#HICMOBillNo').on('keydown', function (event) {
                var HICMOBillNo = $('#HICMOBillNo').val();
                if (event.keyCode == 13) {
                    if (!HICMOBillNo) {
                        layer.msg("任务单号不能为空!")
                        return;
                    }
                    $("#btnSearch").click();
                }
            });
            //工序流转卡回车方法
            $('#HProcExchBillNo').on('keydown', function (event) {
                var HProcExchBillNo = $('#HProcExchBillNo').val();
                if (event.keyCode == 13) {
                    if (!HProcExchBillNo) {
                        layer.msg("工序流转卡号不能为空!")
                        return;
                    }
                    $("#btnSearch").click();
                }
            });
            //初始化表格
@@ -142,10 +196,10 @@
                        , { field: '产品名称', title: '产品名称' }
                        , { field: '规格型号', title: '规格型号' }
                        , { field: '计量单位', title: '计量单位' }
                        , { field: '流水号', title: '流水号' }
                        , { field: '流水号', title: '流水号', sort: true }
                        , { field: 'HProcID', title: 'HProcID', hide: true }
                        , { field: '工序代码', title: '工序代码' }
                        , { field: '工序', title: '工序' }
                        , { field: '工序', title: '工序', sort: true }
                        , { field: '发出数量', title: '发出数量' }
                        , { field: '发出时间', title: '发出时间' }
                        , { field: '备注', title: '备注' }
@@ -171,9 +225,13 @@
            //重置过滤条件
            function set_ClearQuery() {
                $("#HICMOBillNo").val("");
                $("#HProcExchBillNo").val("");
                $("#HBillNo").val("");
                $("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 30), "yyyy-MM-dd"));
                $("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));
                $("#HNumber").val("");
                $("#HName").val("");
            }
@@ -181,8 +239,18 @@
            function get_FastQuery() {
                var HStatus = $("select[name='HStatus']").val();//状态
                var HBillNo = $("#HBillNo").val();
                var HICMOBillNo = $("#HICMOBillNo").val();
                var HProcExchBillNo = $("#HProcExchBillNo").val();
                var HNumber = $("#HNumber").val(); //产品代码 å³ç‰©æ–™ç¼–码
                var HName = $("#HName").val(); //当前工序
                if (HBillNo) {
                    sWhere += " and å•据号 like '%" + HBillNo + "%'";
                }
                if (HNumber) {
                    sWhere += " and äº§å“ä»£ç  like '%" + HNumber + "%'";
                }
                if (HName) {
                    sWhere += " and å·¥åº like '%" + HName + "%'";
                }
                if (HStatus) {
                    switch (HStatus) {
@@ -200,6 +268,13 @@
                        default:
                    }
                }
                if (HICMOBillNo) {
                    sWhere += " and ç”Ÿäº§è®¢å•号 like '%" + HICMOBillNo + "%'";
                }
                if (HProcExchBillNo) {
                    sWhere += " and æµè½¬å¡å· like '%" + HProcExchBillNo + "%'";
                }
                get_Display(sWhere);
                sWhere = "";//调用接口后清空sWhere缓存
            }
@@ -208,26 +283,69 @@
            //加载网格
            function get_Display(sWhere) {
                //进入页面显示的缓存列表
                var ajaxLoad = layer.load();
                var wait = layer.load();
                $.ajax({
                    url: GetWEBURL() + '/Cj_StationEntrustInBill/list',
                    type: "GET",
                    data: { "sWhere": sWhere, "user": sessionStorage["HUserName"]},
                    success: function (data1) {
                        if (data1.count == 0) {
                            option.data = [];
                            layer.alert(data1.Message, { icon: 5 });
                        if (data1.count == 1) {
                            var data = [];
                            var col = [];
                            //给空的数组赋值
                            for (var key in data1.list) {
                                data.push({ "id": data1.list[key].ColmCols, "name": data1.list[key].ColmCols, "Type": data1.list[key].ColmType });
                            }
                            //在列表左边添加勾选框
                            col.push({ type: 'checkbox', fixed: 'left' });
                            for (var i = 0; i < data.length; i++) {
                                // if (data[i].name == 'HInterID' || data[i].name == 'HBillType' || data[i].name == 'hmainid') {
                                if ($.inArray(data[i].name, titleData) > -1) {
                                    col.push({ field: data[i].id, title: data[i].name, align: 'center', hide: true }); //隐藏id列
                                }
                                else {
                                    switch (data[i].Type) {
                                        //int
                                        case 'DateTime':
                                            col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, templet: "<div>{{d." + data[i].name + " ==null ?'':layui.util.toDateString(d." + data[i].name + ", 'yyyy-MM-dd')}}</div>", width: 200 });
                                            break;
                                        default:
                                            col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 200 });
                                    }
                                }
                            }
                            //动态显示列名
                            option = {
                                elem: '#mainTable'
                                , toolbar: '#toolbarDemo'
                                , cols: [col]
                                , data: data1.data
                                , height: 550
                                , page: true
                                , cellMinWidth: 90
                                , limit: 50
                                , limits: [50, 500, 5000, 20000]
                            }
                            table.render(option);
                            //刷新表格数据
                            DisPlay_HideColumn();
                            layer.close(ajaxLoad);
                            //layer.alert("查询成功", { icon: 1 });
                        } else {
                            option.data = data1.data;
                            layer.close(ajaxLoad);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                        table.render(option);
                        btnIs();
                        layer.close(wait);
                    }, error: function () {
                        layer.close(wait);
                        layer.close(ajaxLoad);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
                layer.close(wait);
            }
@@ -262,6 +380,12 @@
                    //反审核
                    case 'btn-DeAudit': set_AbandonCheck();
                        break;
                    //关闭
                    case 'set_CloseBill': set_CloseBill(1);
                        break;
                    //反关闭
                    case 'set_CancelCloseBill': set_CloseBill(2);
                        break;
                    //预览
                    case 'btn-Cell': layer.msg('预览!');
                        break;
@@ -270,6 +394,9 @@
                        break;
                    //默认列宽
                    case 'btn-RefreshCell': layer.msg('默认列宽!');
                        break;
                    //列设置
                    case 'set_HideColumn': get_HideColumn();
                        break;
                    //退出
                    case 'btn-Exit': get_Exit();
@@ -397,6 +524,40 @@
            }
            //#endregion
            //关闭  [1 å…³é—­ã€2 åå…³é—­]
            function set_CloseBill(num) {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (data.length == 1) {
                    layer.confirm("确认要关闭吗?", function (index) {
                        var wait = layer.load();
                        var HInterID = data[0].hmainid;
                        $.ajax({
                            url: GetWEBURL() + '/Cj_StationEntrustInBill/CloseCj_StationEntrustInBill',
                            type: "GET",
                            data: { "HInterID": HInterID, "Type": num, "user": sessionStorage["HUserName"] },
                            success: function (result) {
                                if (result.count == 1) {
                                    layer.msg(result.Message, { icon: 1 });
                                    layer.close(wait);
                                } else {
                                    layer.alert(result.code + result.Message, { icon: 5 });
                                    layer.close(wait);
                                }
                            }, error: function () {
                                layer.alert("接口请求失败!", { icon: 5 });
                                layer.close(wait);
                            }
                        });
                    })
                }
                else {
                    layer.msg("请选择一条数据!");
                }
            }
            //#region åˆ é™¤å•据
            function btn_Delete() {
                var checkStatus = table.checkStatus('mainTable')
@@ -428,6 +589,124 @@
                    layer.msg('请选择一行数据编辑!');
                }
            }
            //隐藏列设置
            function get_HideColumn() {
                var colName = "";
                var contentUrl = "";
                for (var i = 1; i < option.cols[0].length - 1; i++) {
                    colName += option.cols[0][i]["title"] + ",";
                }
                var urlStr = window.document.location.pathname;//获取文件路径
                var urlLen = urlStr.split('/');
                for (var i = 0; i < urlLen.length - 4; i++) {
                    contentUrl += "../";
                }
                colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI è¿›è¡Œç¼–码
                contentUrl += '基础资料/隐藏列设置/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName;
                layer.open({
                    type: 2
                    , skin: "layui-layer-rim" //加上边框
                    , title: "隐藏列设置"  //标题
                    , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                    , shift: 2 //弹出动画
                    , area: ["50%", "90%"] //窗体大小
                    , maxmin: true //设置最大最小按钮是否显示
                    , content: [contentUrl, "yes"]
                    , btn: ["确定", "取消"]
                    , btn1: function (index, laero) {
                        //刷新表格数据
                        DisPlay_HideColumn();
                        //更新表格缓存的数据
                        layer.close(index);//关闭弹窗
                    }
                })
            }
            //显示列数据
            function DisPlay_HideColumn() {
                $.ajax({
                    url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
                    type: "GET",
                    data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
                    success: function (data1) {
                        if (data1.data.length != 0) {
                            var dataCol = [];//数据库查询出的列数据
                            /*var titleData = ["hmainid", "HSupID", "HMaterID", "HProcID"];//不需要显示的字段 å¯æ‰©å±•*/
                            dataCol = data1.data[0].HGridString.split(',');
                            for (var i = 0; i < option.cols[0].length - 2; i++) {
                                var dataCols = dataCol[i].split('|');
                                //隐藏列
                                if (dataCols[1] == 1) {
                                    option.cols[0][i + 1]["hide"] = true;
                                }
                                //设置列宽
                                if (dataCols[3] > 0) {
                                    option.cols[0][i + 1]["width"] = dataCols[3];
                                }
                                //设置内容字体大小
                                if (data1.data[0].HFontSize != 0) {
                                    option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;";
                                } else {
                                    option.cols[0][i + 1]["style"] = "font-size:100%";
                                }
                                //设置列宽
                                //if (data1.data[0].HColumnWidth != 0) {
                                //    option.cols[0][i + 1]["width"] = data1.data[0].HColumnWidth + "px;";
                                //} else {
                                //    option.cols[0][i + 1]["width"] = "";
                                //}
                                //显示列
                                if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
                                    option.cols[0][i + 1]["hide"] = false;
                                }
                                //字体所在位置(å·¦ å±…中 å³)
                                switch (dataCols[2]) {
                                    case "L":
                                        option.cols[0][i + 1]["align"] = "left";
                                        break;
                                    case "M":
                                        option.cols[0][i + 1]["align"] = "center";
                                        break;
                                    case "R":
                                        option.cols[0][i + 1]["align"] = "right";
                                        break;
                                }
                            }
                            //取消冻结列
                            for (var i = 1; i < option.cols[0].length - 1; i++) {
                                if (option.cols[0][i]["fixed"] != null) {
                                    option.cols[0][i]["fixed"] = null;
                                }
                                else {
                                    break;
                                }
                            }
                            //冻结列
                            if (data1.data[0].HFixCols != 0) {
                                for (var i = 0; i < data1.data[0].HFixCols; i++) {
                                    if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) {
                                        data1.data[0].HFixCols += 1;
                                    }
                                    option.cols[0][i + 1]["fixed"] = "left";
                                }
                            }
                            table.render(option);
                        } else {
                            table.render(option);
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                })
            }
            //#endregion