Browse Source

修改表格问题

leihy 2 years ago
parent
commit
e0736e71ba

+ 3 - 0
src/main/resources/static/web/css/main.css

@@ -29,4 +29,7 @@
 }
 .layui-table-tips-c {
 	display: none
+}
+.layui-table-grid-down {
+	display: none;
 }

+ 39 - 1
src/main/resources/static/web/index.html

@@ -54,6 +54,34 @@
 				right: 0;
 				left: auto;
 			}
+
+			.rightmenu {
+				position: absolute;
+				width: 100px;
+				z-index: 9999;
+				display: none;
+				background-color: #fff;
+				padding: 2px;
+				color: rgba(0,0,0,.8);
+				border: 1px solid #f6f6f6;
+				border-radius: 2px;
+				cursor: pointer;
+
+				box-shadow: 0 2px 4px rgb(0 0 0 / 12%);
+				border-radius: 2px;
+			}
+
+			.rightmenu li {
+				text-align: center;
+				display: block;
+				height: 25px;
+				line-height: 25px;
+			}
+
+			.rightmenu li:hover {
+				background-color: #f6f6f6;
+				color: rgba(0,0,0,.8);
+			}
 		</style>
 	</head>
 	<body>
@@ -101,8 +129,18 @@
 			  <!-- 内容主体区域 -->
 			  <div class="layui-tab layui-tab-brief"  lay-filter="index-nev" lay-allowclose="true">
 				  <ul class="layui-tab-title">
-					  <li  lay-id="welcome" class="layui-this">欢迎页</li>
+					  <li  lay-id="welcome" class="layui-this">主页</li>
+				  </ul>
+
+				  <ul class="rightmenu" style="display: none;position: absolute;">
+					  <li data-type="refreshthis">刷新选项卡</li>
+					  <li data-type="closethis">关闭当前</li>
+					  <li data-type="closeall">关闭所有</li>
+					  <li data-type="closeothe">关闭其他</li>
+					  <li data-type="refreshsys">刷新系统</li>
 				  </ul>
+
+
 				  <div class="layui-tab-content">
 					  <div class="layui-tab-item layui-show index-layui-tab-item">
 						  <img src="./img/welcome.png">

+ 3 - 3
src/main/resources/static/web/js/dealt.js

@@ -27,13 +27,13 @@ const initTable = (result) => {
 		url: '/service/paging?queryType=1',
 		cols: [[
 			{type: 'numbers', title: '序号'},
-			{ title: '区县', templet: (res) => {
+			{ title: '区县', width : 80, templet: (res) => {
 				return qxbmObj[res.qxbm]
 			}},
 			{field: 'sqrxm', title: '申请人姓名'},
-			{field: 'sqrzjhm', title: '证件号'},
+			{field: 'sqrzjhm', width : 180, title: '证件号'},
 			{field: 'sqrlxdh', title: '电话号码'},
-			{title: '类别', templet: (res) => {
+			{title: '类别', width : 80, templet: (res) => {
 				return sortObj[res.type]
 			}},
 			// {title: '户号', templet: (res) => {

+ 5 - 5
src/main/resources/static/web/js/done.js

@@ -33,13 +33,13 @@ const initTable = (result) => {
 		url: '/service/paging?queryType=3',
 		cols: [[
 			{type: 'numbers', title: '序号'},
-			{ title: '区县', templet: (res) => {
+			{ title: '区县', width : 80, templet: (res) => {
 				return qxbmObj[res.qxbm]
 			}},
 			{field: 'sqrxm', title: '申请人姓名'},
-			{field: 'sqrzjhm', title: '证件号'},
+			{field: 'sqrzjhm', width : 180, title: '证件号'},
 			{field: 'sqrlxdh', title: '电话号码'},
-			{title: '类别', templet: (res) => {
+			{title: '类别', width : 80, templet: (res) => {
 				return sortObj[res.type]
 			}},
 			// {title: '户号', templet: (res) => {
@@ -67,7 +67,7 @@ const initTable = (result) => {
 					}
 				return dateFormatNull(res.completion_time)
 			}},
-			{title: '办结状态', templet: (res) => {
+			{title: '办结状态', width : 100, templet: (res) => {
 					let color = '#5FB878', txt = '已办结'
 					if (res.case_status == 6) {
 						color = '#f96565'
@@ -75,7 +75,7 @@ const initTable = (result) => {
 					}
 					return `<span style="color:${color};">${txt}</span>`
 				}},
-			{title: '操作', width: 300, templet}
+			{title: '操作', width: 200, templet}
 		]]
 	})
 }

+ 102 - 15
src/main/resources/static/web/js/index.js

@@ -201,7 +201,7 @@ layui.config({
 	/**
 	 * 菜单点击
 	 */
-	$(".layui-tab-title li:eq(0) i").remove();
+	//$(".layui-tab-title li:eq(0) i").remove();
 	element.on('nav(menu)', (elem) => {
 		/*if (elem.parent().find('.layui-nav-child').length > 0
 			|| elem.data('menu') == $('.layui-tab-item').attr('menu')) {
@@ -219,28 +219,115 @@ layui.config({
 		if(!menu) {
 			return;
 		}
-		let has = false;
+		let isTabAdd = true;
 		$(".layui-tab-title li").each((i,dom) => {
 			const layid = $(dom).attr("lay-id");
 			if(layid == menu){
-				has = true;
+				isTabAdd = false;
 				return;
 			}
 		})
 
-		if(has){
-			element.tabChange('index-nev', menu);
-			return;
+		if(isTabAdd == true){
+			//新增一个Tab项
+			active.tabAdd('view/' + menu + '.html', menu, elem.text())
 		}
 
-		//新增一个Tab项
-		element.tabAdd('index-nev', {
-			title: elem.text()
-			,content: '<iframe class="fast-iframe" src="view/' + menu + '.html"></iframe>'
-			,id: menu
-		})
-		element.tabChange('index-nev', menu);
-		$(".layui-tab-title li:eq(0) i").remove();
+
+		active.tabChange(menu);
+		// $(".layui-tab-title li:eq(0) i").remove();
 
 	});
-});
+
+	//触发事件
+	const active = {
+		tabfilter : 'index-nev',
+		//在这里给active绑定几项事件,后面可通过active调用这些事件
+		tabAdd: function (url, id, name) {
+			//新增一个Tab项 传入三个参数,分别对应其标题,tab页面的地址,还有一个规定的id,是标签中data-id的属性值
+			//关于tabAdd的方法所传入的参数可看layui的开发文档中基础方法部分
+			element.tabAdd(active.tabfilter, {
+				title: name,
+				content: '<iframe class="fast-iframe" data-frameid="' + id + '" src="' + url + '"></iframe>',
+				id: id //规定好的id
+			})
+			CustomRightClick(id); //给tab绑定右击事件
+		},
+		tabChange: function (id) {
+			//切换到指定Tab项
+			element.tabChange(active.tabfilter, id); //根据传入的id传入到指定的tab项
+		},
+		tabDelete: function (id) {
+			element.tabDelete(active.tabfilter, id);//删除
+		},
+		tabDeleteAll: function (ids) {//删除所有
+			$.each(ids, function (i, item) {
+				element.tabDelete(active.tabfilter, item); //ids是一个数组,里面存放了多个id,调用tabDelete方法分别删除
+			})
+		},
+		tabRefresh: function (id) { //刷新页面
+			$("iframe[data-frameid='" + id + "']").attr("src", $("iframe[data-frameid='" + id + "']").attr("src")) //刷新框架
+		}
+	};
+
+	let timeOutIndex = -1;
+	function CustomRightClick(id) {
+		//取消右键 rightmenu属性开始是隐藏的 ,当右击的时候显示,左击的时候隐藏
+		$('.layui-tab-title').on('contextmenu', function () { return false; })
+		$('body').click(function () {
+			$('.rightmenu').hide();
+		});
+		//桌面点击右击
+		$('.layui-tab-title').on('contextmenu', function (e) {
+			var popupmenu = $(".rightmenu");
+			popupmenu.find("li").attr("data-id", id); //在右键菜单中的标签绑定id属性
+
+			//判断右侧菜单的位置
+			l = ($(document).width() - e.clientX) < popupmenu.width() ? (e.clientX - popupmenu.width()) : e.clientX - 200;
+			t = ($(document).height() - e.clientY) < popupmenu.height() ? (e.clientY - popupmenu.height()) : e.clientY - 30;
+			popupmenu.css({ left: l, top: t }).show(); //进行绝对定位
+
+			if(timeOutIndex != -1){
+				clearTimeout(timeOutIndex);
+			}
+			timeOutIndex = setTimeout(() => {
+				$('.rightmenu').hide();
+			}, 3000)
+
+			//alert("右键菜单")
+			return false;
+		});
+	}
+
+	$(".rightmenu li").click(function () {
+
+		//右键菜单中的选项被点击之后,判断type的类型,决定关闭所有还是关闭当前。
+		if ($(this).attr("data-type") == "closethis") {
+			//如果关闭当前,即根据显示右键菜单时所绑定的id,执行tabDelete
+			active.tabDelete($(this).attr("data-id"))
+		} else if ($(this).attr("data-type") == "closeall") {
+			var tabtitle = $(".layui-tab-title li");
+			var ids = new Array();
+			$.each(tabtitle, function (i) {
+				ids[i] = $(this).attr("lay-id");
+			})
+			//如果关闭所有 ,即将所有的lay-id放进数组,执行tabDeleteAll
+			active.tabDeleteAll(ids);
+		} else if ($(this).attr("data-type") == "closeothe") {
+			var id = $(this).attr("data-id");
+			var tabtitle = $(".layui-tab-title li");
+			var ids = new Array();
+			$.each(tabtitle, function (i) {
+				if (id != $(this).attr("lay-id")) {
+					ids[i] = $(this).attr("lay-id");
+				}
+
+			})
+			active.tabDeleteAll(ids);
+		} else if ($(this).attr("data-type") == "refreshsys") {
+			location.reload();
+		} else if ($(this).attr("data-type") == "refreshthis") {
+			active.tabRefresh($(this).attr("data-id"))
+		}
+	})
+});

+ 3 - 3
src/main/resources/static/web/js/process.js

@@ -27,13 +27,13 @@ const initTable = (result) => {
 		url: '/service/paging?queryType=2',
 		cols: [[
 			{type: 'numbers', title: '序号'},
-			{ title: '区县', templet: (res) => {
+			{ title: '区县', width : 80, templet: (res) => {
 				return qxbmObj[res.qxbm]
 			}},
 			{field: 'sqrxm', title: '申请人姓名'},
-			{field: 'sqrzjhm', title: '证件号'},
+			{field: 'sqrzjhm', width : 180, title: '证件号'},
 			{field: 'sqrlxdh', title: '电话号码'},
-			{title: '类别', templet: (res) => {
+			{title: '类别', width : 80, templet: (res) => {
 				return sortObj[res.type]
 			}},
 			// {title: '户号', templet: (res) => {

+ 2 - 2
src/main/resources/static/web/js/user.js

@@ -44,12 +44,12 @@ const initTable = (result) => {
 		url: '/user/paging',
 		cols: [[
 			{type: 'numbers', title: '序号'},
-			{field: 'userName', title: '姓名'},
+			{field: 'userName', width : 280, title: '姓名'},
 			{field: 'account', title: '账号'},
 			{title: '角色', templet: (res) => {
 				return roleObj[res.roleId] || ''
 			}},
-			{title: '单位', templet: (res) => {
+			{title: '单位', width : 280, templet: (res) => {
 				return deptObj[res.deptId] || ''
 			}},
 			{field: 'phone', title: '手机号'},