浏览代码

新增表格列表内容弹窗展示

Karson 2 年之前
父节点
当前提交
e6f2894af7

+ 22 - 1
public/assets/css/backend.css

@@ -971,7 +971,7 @@ form.form-horizontal .control-label {
   min-width: 36px;
 }
 .fixed-table-container tr[data-origpos] > td > .tooltip.in {
-  display: none!important;
+  display: none !important;
 }
 /*修复nice-validator新版下的一处BUG*/
 .nice-validator input,
@@ -1613,4 +1613,25 @@ table.table-nowrap thead > tr > th {
   display: block;
   border-bottom: 1px solid #ddd;
 }
+.autocontent {
+  position: relative;
+}
+.autocontent .autocontent-caret {
+  position: absolute;
+  right: 0;
+  top: 0;
+  height: 100%;
+  line-height: 1;
+  background: #eee;
+  color: #ddd;
+  vertical-align: middle;
+  padding: 0 5px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  cursor: pointer;
+}
+.autocontent .autocontent-caret:hover {
+  color: #ccc;
+}
 /*# sourceMappingURL=backend.css.map */

文件差异内容过多而无法显示
+ 1 - 1
public/assets/css/backend.min.css


+ 21 - 0
public/assets/css/frontend.css

@@ -1108,4 +1108,25 @@ main.content {
   display: block;
   border-bottom: 1px solid #ddd;
 }
+.autocontent {
+  position: relative;
+}
+.autocontent .autocontent-caret {
+  position: absolute;
+  right: 0;
+  top: 0;
+  height: 100%;
+  line-height: 1;
+  background: #eee;
+  color: #ddd;
+  vertical-align: middle;
+  padding: 0 5px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  cursor: pointer;
+}
+.autocontent .autocontent-caret:hover {
+  color: #ccc;
+}
 /*# sourceMappingURL=frontend.css.map */

文件差异内容过多而无法显示
+ 1 - 1
public/assets/css/frontend.min.css


文件差异内容过多而无法显示
+ 3 - 3
public/assets/js/require-backend.min.js


文件差异内容过多而无法显示
+ 15 - 15
public/assets/js/require-frontend.min.js


+ 28 - 5
public/assets/js/require-table.js

@@ -196,6 +196,8 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                 //当刷新表格时
                 table.on('refresh.bs.table', function (e, settings, data) {
                     $(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin");
+                    //移除指定浮动弹窗
+                    $(".layui-layer-autocontent").remove();
                 });
                 //当执行搜索时
                 table.on('search.bs.table common-search.bs.table', function (e, settings, data) {
@@ -463,9 +465,6 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                     $("tbody", table).dragsort({
                         itemSelector: 'tr:visible',
                         dragSelector: "a.btn-dragsort",
-                        dragBegin: function (a, b) {
-                            $("[data-toggle='tooltip']", this).tooltip("destroy");
-                        },
                         dragEnd: function (a, b) {
                             var element = $("a.btn-dragsort", this);
                             var data = table.bootstrapTable('getData');
@@ -549,6 +548,30 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                         }
                     );
                 });
+                table.on("mouseenter mouseleave", ".autocontent", function (e) {
+                    var target = $(".autocontent-item", this).get(0);
+                    if (!target) return;
+                    if (e.type === 'mouseenter') {
+                        if (target.scrollWidth > target.offsetWidth) {
+                            $(this).append("<div class='autocontent-caret'><i class='fa fa-chevron-down'></div>");
+                        }
+                    } else {
+                        $(".autocontent-caret", this).remove();
+                    }
+                });
+                table.on("click", ".autocontent-caret", function () {
+                    var text = $(this).prev().text();
+                    var tdrect = $(this).parent().get(0).getBoundingClientRect();
+                    tdrect.x += document.documentElement.scrollLeft;
+                    tdrect.y += document.documentElement.scrollTop;
+                    var index = Layer.open({id: 'autocontent', skin: 'layui-layer-fast layui-layer-autocontent', title: false, content: text, btn: false, anim: false, shade: 0, isOutAnim: false, area: 'auto', maxWidth: 450, maxHeight: 350, offset: [tdrect.y, tdrect.x]});
+
+                    $(document).one("mousedown", function (e) {
+                        if ($(e.target).closest(".layui-layer").length === 0) {
+                            Layer.close(index);
+                        }
+                    });
+                });
 
                 //修复dropdown定位溢出的情况
                 if (options.fixDropdownPosition) {
@@ -730,8 +753,8 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                     return html.join(' ');
                 },
                 content: function (value, row, index) {
-                    var width = this.width != undefined ? (this.width.match(/^\d+$/) ? this.width + "px" : this.width) : "250px";
-                    return "<div style='white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:" + width + ";'>" + value + "</div>";
+                    var width = this.width != undefined ? (this.width.toString().match(/^\d+$/) ? this.width + "px" : this.width) : "250px";
+                    return "<div class='autocontent-item' style='white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:" + width + ";'>" + value + "</div>";
                 },
                 status: function (value, row, index) {
                     var custom = {normal: 'success', hidden: 'gray', deleted: 'danger', locked: 'info'};

+ 25 - 1
public/assets/less/backend.less

@@ -891,7 +891,7 @@ form.form-horizontal .control-label {
 
     //拖拽时隐藏tooltip,避免出现错位
     tr[data-origpos] > td > .tooltip.in {
-        display:none!important;
+        display: none !important;
     }
 }
 
@@ -1663,3 +1663,27 @@ table.table-nowrap {
 
     }
 }
+
+.autocontent {
+    position: relative;
+
+    .autocontent-caret {
+        position: absolute;
+        right: 0;
+        top: 0;
+        height: 100%;
+        line-height: 1;
+        background: #eee;
+        color: #ddd;
+        vertical-align: middle;
+        padding: 0 5px;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        cursor: pointer;
+
+        &:hover {
+            color: #ccc;
+        }
+    }
+}

+ 24 - 0
public/assets/less/frontend.less

@@ -969,3 +969,27 @@ main.content {
 
     }
 }
+
+.autocontent {
+    position: relative;
+
+    .autocontent-caret {
+        position: absolute;
+        right: 0;
+        top: 0;
+        height: 100%;
+        line-height: 1;
+        background: #eee;
+        color: #ddd;
+        vertical-align: middle;
+        padding: 0 5px;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        cursor: pointer;
+
+        &:hover {
+            color: #ccc;
+        }
+    }
+}