新增通用功能模块
This commit is contained in:
parent
7ef5cfe0cf
commit
2a6b0bbd63
@ -0,0 +1,32 @@
|
||||
package com.cm.common.controller.route;
|
||||
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: CommonRouteController
|
||||
* @Description:
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/8/4 1:46 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "通用路由")
|
||||
@Controller
|
||||
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/common")
|
||||
public class CommonRouteController {
|
||||
|
||||
@ApiOperation(value = "选择用户列表")
|
||||
@GetMapping("listselectuser")
|
||||
public ModelAndView listUser() {
|
||||
return new ModelAndView("common/list-select-user");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,226 @@
|
||||
<!doctype html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<base th:href="${#request.getContextPath() + '/'}">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-anim layui-anim-fadein">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="test-table-reload-btn">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
<button type="button" id="confirm" class="layui-btn layui-btn-normal layui-btn-sm" style="float: right;">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'table', 'laydate', 'common'], function() {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var table = layui.table;
|
||||
var admin = layui.admin;
|
||||
var common = layui.common;
|
||||
var selectType = top.restAjax.params(window.location.href).selectType;
|
||||
selectType = selectType ? selectType : 'radio'
|
||||
var tableUrl = 'api/user/listpageusersimple';
|
||||
var oldSelectedUserList = top.dialog.dialogData.oldSelectedUserList;
|
||||
// 清空上次选择
|
||||
top.dialog.dialogData.newSelectedUserList = [];
|
||||
var newSelectedUserList = [];
|
||||
var tableData = [];
|
||||
|
||||
// 初始化表格
|
||||
function initTable() {
|
||||
$.extend(table, {config: {checkName: 'checked'}});
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
width: admin.screen() > 1 ? '100%' : '',
|
||||
height: $win.height() - 50,
|
||||
limit: 20,
|
||||
limits: [20, 40, 60, 80, 100, 200],
|
||||
request: {
|
||||
pageName: 'page',
|
||||
limitName: 'rows'
|
||||
},
|
||||
cols: [
|
||||
[
|
||||
{type: selectType, fixed: 'left'},
|
||||
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||
{field: 'userUsername', width: 150, title: '用户名', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field: 'userName', width: 150, title: '昵称', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field: 'userPhone', width: 220, title: '用户手机', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field: 'userEmail', width: 220, title: '用户邮箱', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
page: true,
|
||||
parseData: function(data) {
|
||||
for(var i = 0, item; item = data.rows[i++];) {
|
||||
if(!oldSelectedUserList) {
|
||||
item.checked = false;
|
||||
continue;
|
||||
}
|
||||
var isSelected = false;
|
||||
for(var j = 0, jItem; jItem = oldSelectedUserList[j++];) {
|
||||
if(item.userId === jItem.userId) {
|
||||
isSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(isSelected) {
|
||||
item.checked = true;
|
||||
} else {
|
||||
item.checked = false;
|
||||
}
|
||||
}
|
||||
tableData = data.rows;
|
||||
|
||||
return {
|
||||
'code': 0,
|
||||
'msg': '',
|
||||
'count': data.total,
|
||||
'data': data.rows
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
},
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 50,
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
|
||||
function isUserSelected(userId) {
|
||||
for(var i = 0, item; item = newSelectedUserList[i++];) {
|
||||
if(userId == item.userId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function addUserSelected(userItem) {
|
||||
if(isUserSelected(userItem.userId)) {
|
||||
return;
|
||||
}
|
||||
newSelectedUserList.push({
|
||||
userId: userItem.userId,
|
||||
userName: userItem.userName,
|
||||
userPhone: userItem.userPhone,
|
||||
userEmail: userItem.userEmail
|
||||
})
|
||||
}
|
||||
|
||||
function removeUserSelected(userItem) {
|
||||
for(var i = 0, item; item = newSelectedUserList[i++];) {
|
||||
if(userItem.userId == item.userId) {
|
||||
newSelectedUserList.splice(--i, 1);
|
||||
i--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
table.on('checkbox(dataTable)', function(obj) {
|
||||
if(obj.type === 'all') {
|
||||
if(obj.checked) {
|
||||
// 添加全部
|
||||
for(var i = 0, item; item = tableData[i++];) {
|
||||
addUserSelected(item);
|
||||
}
|
||||
} else {
|
||||
// 删除全部
|
||||
for(var i = 0, item; item = tableData[i++];) {
|
||||
removeUserSelected(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(obj.checked) {
|
||||
addUserSelected(obj.data);
|
||||
} else {
|
||||
removeUserSelected(obj.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
table.on('radio(dataTable)', function(obj) {
|
||||
newSelectedUserList.splice(0, newSelectedUserList.length);
|
||||
addUserSelected(obj.data);
|
||||
});
|
||||
$(document).on('click', '#search', function() {
|
||||
reloadTable(1);
|
||||
});
|
||||
$(document).on('click', '#confirm', function() {
|
||||
top.dialog.dialogData.newSelectedUserList = newSelectedUserList;
|
||||
top.dialog.closeBox();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user