Browse Source

新增表格列宽拖动插件

RuoYi 4 years ago
parent
commit
c523be9f34

+ 9 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java

@@ -214,6 +214,15 @@ public class DemoTableController extends BaseController
         return prefix + "/reorder";
     }
 
+    /**
+     * 表格列宽拖动
+     */
+    @GetMapping("/resizable")
+    public String resizable()
+    {
+        return prefix + "/resizable";
+    }
+
     /**
      * 表格行内编辑操作
      */

File diff suppressed because it is too large
+ 8 - 0
ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/resizable/bootstrap-table-resizable.min.js


File diff suppressed because it is too large
+ 7 - 0
ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-table/extensions/resizable/jquery.resizableColumns.min.js


+ 20 - 0
ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css

@@ -872,6 +872,26 @@ label {
 	height: 32px!important;
 }
 
+/** 表格列宽拖动样式 **/
+.rc-handle-container {
+  position: relative;
+}
+.rc-handle {
+  position: absolute;
+  width: 7px;
+  cursor: ew-resize;
+  margin-left: -3px;
+  z-index: 2;
+}
+table.rc-table-resizing {
+  cursor: ew-resize;
+}
+table.rc-table-resizing thead,
+table.rc-table-resizing thead > th,
+table.rc-table-resizing thead > th > a {
+  cursor: ew-resize;
+}
+
 /** 表格冻结列样式 **/
 .fixed-columns, .fixed-columns-right {
   position: absolute;

+ 78 - 0
ruoyi-admin/src/main/resources/templates/demo/table/resizable.html

@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
+<head>
+	<th:block th:include="include :: header('表格列宽拖动')" />
+</head>
+<body class="gray-bg">
+     <div class="container-div">
+		<div class="row">
+			<div class="col-sm-12 select-table table-bordered">
+				<table id="bootstrap-table" data-resizable="true"></table>
+			</div>
+		</div>
+	</div>
+    <div th:include="include :: footer"></div>
+    <th:block th:include="include :: bootstrap-table-resizable-js" />
+    
+    <script th:inline="javascript">
+        var prefix = ctx + "demo/table";
+        var datas = [[${@dict.getType('sys_normal_disable')}]];
+
+        $(function() {
+            var options = {
+                url: prefix + "/list",
+		        showSearch: false,
+		        showRefresh: false,
+		        showToggle: false,
+		        showColumns: false,
+                columns: [{
+		            checkbox: true
+		        },
+				{
+					field : 'userId', 
+					title : '用户ID'
+				},
+				{
+					field : 'userCode', 
+					title : '用户编号'
+				},
+				{
+					field : 'userName', 
+					title : '用户姓名'
+				},
+				{
+					field : 'userPhone', 
+					title : '用户手机'
+				},
+				{
+					field : 'userEmail', 
+					title : '用户邮箱'
+				},
+				{
+				    field : 'userBalance',
+				    title : '用户余额'
+				},
+				{
+                    field: 'status',
+                    title: '用户状态',
+                    align: 'center',
+                    formatter: function(value, row, index) {
+                    	return $.table.selectDictLabel(datas, value);
+                    }
+                },
+		        {
+		            title: '操作',
+		            align: 'center',
+		            formatter: function(value, row, index) {
+		            	var actions = [];
+		            	actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
+                        actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
+						return actions.join('');
+		            }
+		        }]
+            };
+            $.table.init(options);
+        });
+    </script>
+</body>
+</html>

+ 6 - 0
ruoyi-admin/src/main/resources/templates/include.html

@@ -176,6 +176,12 @@
 	<script th:src="@{/ajax/libs/bootstrap-table/extensions/reorder/jquery.tablednd.js}"></script>
 </div>
 
+<!-- 表格列宽拖动插件 -->
+<div th:fragment="bootstrap-table-resizable-js">
+	<script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/jquery.resizableColumns.min.js}"></script>
+    <script th:src="@{/ajax/libs/bootstrap-table/extensions/resizable/bootstrap-table-resizable.min.js}"></script>
+</div>
+
 <!-- 表格行内编辑插件 -->
 <div th:fragment="bootstrap-editable-css">
     <link th:href="@{/ajax/libs/bootstrap-table/extensions/editable/bootstrap-editable.css}" rel="stylesheet"/>

+ 1 - 0
ruoyi-admin/src/main/resources/templates/index-topnav.html

@@ -135,6 +135,7 @@
 					<li><a class="menuItem" th:href="@{/demo/table/image}">表格图片预览</a></li>
 					<li><a class="menuItem" th:href="@{/demo/table/curd}">动态增删改查</a></li>
 					<li><a class="menuItem" th:href="@{/demo/table/reorder}">表格拖拽操作</a></li>
+					<li><a class="menuItem" th:href="@{/demo/table/resizable}">表格列宽拖动</a></li>
 					<li><a class="menuItem" th:href="@{/demo/table/editable}">表格行内编辑</a></li>
 					<li><a class="menuItem" th:href="@{/demo/table/subdata}">主子表提交</a></li>
 					<li><a class="menuItem" th:href="@{/demo/table/refresh}">表格自动刷新</a></li>

+ 1 - 0
ruoyi-admin/src/main/resources/templates/index.html

@@ -116,6 +116,7 @@
 								<li><a class="menuItem" th:href="@{/demo/table/image}">表格图片预览</a></li>
 								<li><a class="menuItem" th:href="@{/demo/table/curd}">动态增删改查</a></li>
 								<li><a class="menuItem" th:href="@{/demo/table/reorder}">表格拖拽操作</a></li>
+								<li><a class="menuItem" th:href="@{/demo/table/resizable}">表格列宽拖动</a></li>
 								<li><a class="menuItem" th:href="@{/demo/table/editable}">表格行内编辑</a></li>
 								<li><a class="menuItem" th:href="@{/demo/table/subdata}">主子表提交</a></li>
 								<li><a class="menuItem" th:href="@{/demo/table/refresh}">表格自动刷新</a></li>

Some files were not shown because too many files changed in this diff