ch
2022-11-07 a3aca1c1bfef24e3db60fa16b2618986e8b62fbe
WebTM/views/ϵͳ¹ÜÀí/Ä£¿é¹ÜÀí/Xt_XtgnbList.html
@@ -22,7 +22,11 @@
                    <form class="layui-form" action="" lay-filter="component-form-group">
                        <div class="layui-collapse">
                            <div class="layui-colla-item">
                                <div class="layui-colla-title layui-inline">
                                    <div class="layui-inline">
                                        <span>更多</span>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">功能代码</label>
                                    <div class="layui-input-block">
@@ -39,6 +43,35 @@
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnReSearch" id="btnReSearch" style="padding:0 5px">重置</button>
                                <div class="layui-colla-content" style="padding: 0px; margin-left: 6%;">
                                    <div class="layui-row" style="margin-top:5px">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">过滤</label>
                                            <div class="layui-input-block">
                                                <select name="ColName" id="ColName" lay-filter="ColName" style="width:190px;">
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <select name="Comparator" id="Comparator" lay-filter="Comparator" style="width:190px;">
                                                <option value="0" selected="selected"></option>
                                                <option value="=">=</option>
                                                <option value=">=">>=</option>
                                                <option value=">">></option>
                                                <option value="<="><=</option>
                                                <option value="<"><</option>
                                                <option value="<>"><></option>
                                                <option value="7">包含</option>
                                                <option value="8">左包含</option>
                                                <option value="9">右包含</option>
                                                <option value="10">不包含</option>
                                            </select>
                                        </div>
                                        <div class="layui-inline">
                                            <input type="text" class="layui-input" value="" name="ColContent" id="ColContent">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <table class="" id="mainTable" lay-filter="mainTable"></table>
@@ -51,6 +84,7 @@
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Exit"><i class="layui-icon layui-icon-logout"></i>退出</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-view"><i class="layui-icon layui-icon-tips"></i>预览</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-print"><i class="layui-icon layui-icon-print"></i>打印</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                            </div>
                        </script>
                    </form>
@@ -79,11 +113,23 @@
                , util = layui.util
            var sWhere = "";
            var option = [];
            var HModName = "Xt_XtgnbList";
            //不需要显示的字段 å¯æ‰©å±•
            var titleData = ["Hitemid"];
            //#endregion
            //#region åˆå§‹åŒ–界面
            set_ClearBill();
            //#endregion
            //#region å¤´å·¥å…·æ äº‹ä»¶
            table.on('toolbar(mainTable)', function (obj) {
                switch (obj.event) {
                    //列设置
                    case 'set_HideColumn': get_HideColumn();
                        break;
                };
            });
            //#endregion
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
@@ -153,26 +199,27 @@
                    , cellMinWidth: 90
                    , limit: 50
                    , limits: [50, 500, 5000, 20000]
                    , cols: [[
                        { type: 'radio', fixed: 'left' }
                        , { field: 'Hitemid', title: 'Hitemid', sort: true, hide: true }
                        , { field: '功能编码', title: '功能编码' }
                        , { field: '模块名称', title: '模块名称' }
                        , { field: '功能名称', title: '功能名称' }
                        , { field: '功能MS', title: '功能MS' }
                        , { field: '上级功能编码', title: '上级功能编码' }
                        , { field: '末级标志', title: '末级标志' }
                        , { field: '可见标志', title: '可见标志' }
                        , { field: '权限标志', title: '权限标志' }
                        , { field: '启用标志', title: '启用标志' }
                        , { field: 'NET可见标志', title: 'NET可见标志' }
                    ]]
                    //, cols: [[
                    //    { type: 'radio', fixed: 'left' }
                    //    , { field: 'Hitemid', title: 'Hitemid', sort: true, hide: true }
                    //    , { field: '功能编码', title: '功能编码' }
                    //    , { field: '模块名称', title: '模块名称' }
                    //    , { field: '功能名称', title: '功能名称' }
                    //    , { field: '功能MS', title: '功能MS' }
                    //    , { field: '上级功能编码', title: '上级功能编码' }
                    //    , { field: '末级标志', title: '末级标志' }
                    //    , { field: '可见标志', title: '可见标志' }
                    //    , { field: '权限标志', title: '权限标志' }
                    //    , { field: '启用标志', title: '启用标志' }
                    //    , { field: 'NET可见标志', title: 'NET可见标志' }
                    //]]
                };
            }
            //进入页面显示的缓存列表
            function get_Display(sWhere) {
                var index = layer.load(0, { shade: false });
                var ajaxLoad = layer.load();
                //进入页面显示的缓存列表
                $.ajax({
                    //url: "http://61.130.49.162:9090/WMSAPI///Web/GetMAXNum",
@@ -181,24 +228,95 @@
                    data: { "sWhere": sWhere },
                    success: function (data1) {
                        if (data1.count == 1) {
                            option.data = data1.data;
                            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: 'full-80'
                                , page: true
                                , cellMinWidth: 90
                                , limit: 50
                                , limits: [50, 500, 5000, 20000]
                            }
                            table.render(option);
                            layer.close(index);
                            //刷新表格数据
                            DisPlay_HideColumn();
                            layer.close(ajaxLoad);
                            if ($("#Comparator").val() == 0 && $("#ColContent").val() == "") {
                                ColFilter();
                            }
                            //layer.alert("查询成功", { icon: 1 });
                        } else {
                            layer.close(index);
                            layer.close(ajaxLoad);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(index);
                        layer.close(ajaxLoad);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
                layer.close(index);
            }
            // å¿«é€Ÿè¿‡æ»¤
            function get_FastQuery() {
                var HNumber = $("#HNumber").val();
                var HName = $("#HName").val();
                var ColName = $("#ColName").val();//复选框
                var Comparator = $("#Comparator").val()
                var ColContent = $("#ColContent").val();
                if (ColName != 0 && Comparator != 0) {
                    var com = "";
                    switch (Comparator) {
                        case "7":
                            com = "like'%" + ColContent + "%'";
                            break;
                        case "8":
                            com = "like'%" + ColContent + "'";
                            break;
                        case "9":
                            com = "like'" + ColContent + "%'";
                            break;
                        case "10":
                            com = "not like'%" + ColContent + "%'";
                            break;
                        default:
                            com = "" + Comparator + "'" + ColContent + "'";
                            break;
                    }
                    sWhere += " and " + ColName + " " + com;
                }
                if (HNumber) {
                    sWhere += " and åŠŸèƒ½ç¼–ç  like '%" + HNumber + "%'";
                }
@@ -213,11 +331,147 @@
            function set_ClearQuery() {
                $("#HNumber").val("");
                $("#HName").val("");
                $("#ColContent").val("");
                $("#ColName").val("0");
                $("#Comparator").val("0");
                form.render('select');
                sWhere = "";
            }
            //#endregion
            //#region éšè—åˆ—设置
            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);//关闭弹窗
                    }
                })
            }
            //#endregion
            //#region æ˜¾ç¤ºåˆ—数据
            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 = ["单据ID", "HMouldID", "hsubid", "HManagerID", "源单主内码", "源单子内码"];//不需要显示的字段 å¯æ‰©å±•
                            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
            //#region åˆ—明显示下拉框
            function ColFilter() {
                var Organization = '<option  value="0" selected="selected" ></option>';
                for (var i = 1; i < option.cols[0].length; i++) {
                    if (option.cols[0][i].hide != true) {
                        Organization += '<option  style="color:blue;" value="' + option.cols[0][i].field + '">' + option.cols[0][i].field + '</option>';
                    }
                }
                $("#ColName").empty();
                $("#ColName").append(Organization);
                form.render('select');
            }
            //#endregion
            //以上是layui模块
        });
    </script>