yusijie
2022-09-29 4c3079dc8b8cfc4a3cfc19167bfc18bbe12aae39
WebTM/views/É豸¹ÜÀí/Sb_EqpConkBookBillList.html
@@ -88,8 +88,8 @@
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Add"><i class="layui-icon layui-icon-add-1"></i>新增</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Edit"><i class="layui-icon layui-icon-edit"></i>编辑</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Delete"><i class="layui-icon layui-icon-delete"></i>删除</button>
                                <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="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                            </div>
                        </script>
                    </form>
@@ -101,6 +101,7 @@
    <script src="../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../layuiadmin/PubCustom.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
@@ -125,9 +126,11 @@
                , height: 'full-50'
                , page: true
                , cellMinWidth: 90
                , limit: 50
                , limits: [50, 500, 5000, 20000]
                , cols: [[
                    { type: 'checkbox', fixed: 'left' }
                    ,{ field: 'hmainid', title: '单据ID', hide: true }
                    , { field: 'hmainid', title: 'hmainid', hide: true }
                    , { field: '日期', title: '日期', width: 160, templet: "<div>{{d.日期 ==null ?'':layui.util.toDateString(d.日期, 'yyyy-MM-dd')}}</div>"}
                    , { field: '单据号', title: '单据号', width: 160 }
                    , { field: '单据类型', title: '单据类型', width: 160, hide: true }
@@ -165,7 +168,7 @@
                    , { field: '故障原因代码', title: '故障原因代码', width: 200 }
                    , { field: '故障原因名称', title: '故障原因名称', width: 200 }
                    , { field: '故障原因描述', title: '故障原因描述', width: 200 }
                    , { field: 'HManagerID', title: 'HManagerID', width: 115, hide: true }
                    , { field: 'HManagerID1', title: 'HManagerID1', width: 115, hide: true }
                    , { field: '表体负责人代码', title: '表体负责人代码', width: 200 }
                    , { field: '表体负责人', title: '表体负责人', width: 200 }
                    , { field: '行关闭人', title: '行关闭人', width: 200 }
@@ -179,8 +182,13 @@
                    , { field: 'HBillType', title: 'HBillType', width: 200, hide: true }
                ]]
            };
            var HModName = "Sb_EqpConkBookBillList";
            var col = [];
            var titleData = ["hmainid", "单据类型", "HEquipID", "HConkTypeID", "HEmpID", "HDeptID", "HManagerID", "hsubid", "HConkReasonID", "HManagerID1", "源单主内码", "源单子内码", "HBillType"];//不需要显示的字段 å¯æ‰©å±•
            var index = layer.load(0);
            //初始化表格
            DisPlay_HideColumn();
            //头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
@@ -246,7 +254,7 @@
                                $.ajax({
                                    type: "GET",
                                    url: GetWEBURL() + "Sb_EqpRepairWorkBill/DeltetEqpConkBookBill", //方法所在页面和方法名
                                    data: { "HInterID": InterID },
                                    data: { "HInterID": InterID, "user": sessionStorage["HUserName"]},
                                    success: function (result) {
                                        if (result.count == 1) {
                                            layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
@@ -271,26 +279,74 @@
                            layer.msg('请选择一行数据删除!');
                        }
                        break;
                    //退出
                    case 'get_Exit':
                        Pub_Close(2);
                        break;
                    //列设置
                    case 'set_HideColumn':
                        get_HideColumn();
                        break;
                };
            });
            //进入页面显示的缓存列表
            var ajaxLoad = layer.load();
            $.ajax({
                //url: "http://61.130.49.162:9090/WMSAPI///Web/GetMAXNum",
                url: GetWEBURL() + '/Sb_EqpRepairWorkBill/GetEqpConkBookBillList',
                type: "GET",
                data: { "sWhere": sWhere},
                data: { "sWhere": sWhere, "user": sessionStorage["HUserName"]},
                success: function (data1) {
                    if (data1.count == 1) {
                        option.data = data1.data;
                        var data = [];
                        //给空的数组赋值
                        for (var key in data1.list) {
                            data.push({ "id": data1.list[key].ColmCols, "name": data1.list[key].ColmCols, "Type": data1.list[key].ColmType });
                        }
                        for (var i = 0; i < data.length; i++) {
                            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 });
                                }
                            }
                        }
                        //在列表左边添加勾选框
                        col.unshift({ type: 'checkbox', fixed: 'left' })
                        //动态显示列名
                        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);
                        layer.close(index);
                        //刷新表格数据
                        DisPlay_HideColumn();
                        layer.close(ajaxLoad);
                        //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 });
                }
            });
@@ -322,7 +378,7 @@
                    //url: "http://61.130.49.162:9090/WMSAPI///Web/GetMAXNum",
                    url: GetWEBURL() + '/Sb_EqpRepairWorkBill/GetEqpConkBookBillList',
                    type: "GET",
                    data: { "sWhere": sWhere},
                    data: { "sWhere": sWhere, "user": sessionStorage["HUserName"]},
                    success: function (data1) {
                        if (data1.count == 1) {
                            option.data = data1.data;
@@ -353,6 +409,118 @@
                layer.alert("双击事件", { icon: 1 });
            });
            //隐藏列设置
            function get_HideColumn() {
                var colName = "";
                for (var i = 1; i < option.cols[0].length - 1; i++) {
                    colName += option.cols[0][i]["title"] + ",";
                }
                colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI è¿›è¡Œç¼–码
                layer.open({
                    type: 2
                    , skin: "layui-layer-rim" //加上边框
                    , title: "隐藏列设置"  //标题
                    , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                    , shift: 2 //弹出动画
                    , area: ["50%", "90%"] //窗体大小
                    , maxmin: true //设置最大最小按钮是否显示
                    , content: ['../基础资料/隐藏列设置/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName, "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", "单据类型", "HEquipID", "HConkTypeID", "HEmpID", "HDeptID", "HManagerID", "hsubid", "HConkReasonID", "HManagerID1", "源单主内码", "源单子内码","HBillType"];//不需要显示的字段 å¯æ‰©å±•*/
                            dataCol = data1.data[0].HGridString.split(',');
                            for (var i = 0; i < option.cols[0].length - 2; i++) {
                                //在不为空的情况下进行分割
                                if (dataCol[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 });
                    }
                })
            }
            //laydate.render({
            //    elem: '#HDate'