<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<link rel="stylesheet" th:href="@{/css/common/base.css}" />
	<link rel="stylesheet" th:href="@{/css/common/page_new.css}" />
	<link rel="stylesheet" th:href="@{/js/plugins/bootstrapselect/css/product_list.css}" />
</head>
<style type="text/css">
	.box .search_pro .cx input{
		background: #00B983;
		width: 100px;
		height: 39px;
		color:white;
		margin-right: 10px;
		padding: 10px -1px;
	}
	.content p span input{
		background: #00B983;
		color:white;
		margin-right: 10px;
		padding: 10px 20px;
		border:1px solid #EEEEEE;
		text-indent: 5px;
	}
</style>
<body>
<div class="box">
	<h2><span></span>用户列表<button onclick="location.reload()">刷新</button></h2>
	<div class="search">
		<p class="title">筛选查询</p>
		<p class="search_pro">
			<span><b>用户名称：</b><input type="text" name="userName" placeholder="请输入"/></span>
			<span class="cx">
                <input type="button" style=" border: 1px solid #000000;background-color: #2b2b2b;width: 64px;height: 35px;color: white;border-radius: 0px;text-align: center;line-height: 30px;" value="查询" onclick="getBargainProduct()">
			</span>
		</p>
	</div>
	<div class="content">
		<p class="title list_ti"><span>用户列表</span></p>
		<table border="" cellspacing="" cellpadding="">


		</table>
	</div>
	<div class="footer" style="display: flex;justify-content: space-between;align-items:center;padding:10px 10px;border:1px solid #e4e4e4;font-size:14px;color:#999">
		<div style="flex-grow: 1;display: flex;justify-content: flex-end;">
			<p style="line-height:33px">共<span style="color:#d00" id="pages">0</span>页/<span style="color:#d00" id="total">0</span>条数据</p>
			<div class="pagediv" style="clear:both;"></div>
		</div>
	</div>
</div>
</body>
</html>
<script src="/js/plugins/jquery.min.js"></script>
<script src="/js/plugins/layer/layer.js"></script>
<script type="text/javascript" src="/js/plugins/page_new.js"></script>
<script type="text/javascript">
    $(function(){
        $.post(
            "/bpm/user/userList",
            {
                pageSize:10,
                pageNum:1,
                teamName:"",
                status:""
            },
            function (data) {
                var size = data.data.pages;
                if (!data.data.pages){
                    size = 0;
                }
                var current = data.pageNum;
                /*分页*/
                $(".pagediv").createPage({
                    pageNum: size,//总页码
                    current: current,//当前页
                    shownum: 10,//每页显示个数
                    showPageNum: true, //显示总页数
                    showToPage: true, //显示跳转页码
                    backfun: function (page) {
                        flushHtml(page.current);
                    }
                });
            },
            'json'
        );
        flushHtml();
    });
    function flushHtml(current) {
        var pageNum = 1;
        if(current){
            pageNum = current;
        }
        var teamName = $("[name='teamName']").val();
        var status = $("[name='status']").val();
        $.post(
            "/bpm/user/userList",
            {
                pageSize:10,
                pageNum:pageNum,
                teamName:teamName,
                status:status
            },
            function (data) {
                selectListAll(data.data);
            },'json'
        );
    }
    function selectListAll(data) {
        var pages = data.pages;
        var total = data.total;
        data = data.list;
        var content = '';
        content += '<tr><th>用户编号</th><th style="width: 15%">用户标识</th><th style="width: 8%">用户名称</th><th>邮箱</th><th style="width: 8%">手机</th><th style="width: 8%">创建时间</th><th>操作</th></tr>';
        if(data!=null){
            for (var i in data) {
                content += '<tr>';
                content += '<td class="product_name" style="width: 5%;">'+data[i].id+'</td>';
                content += '<td class="product_num">'+data[i].userUuid+'</td><td class="product_num">'+data[i].username+'</td>';
                content += '<td class="product_num">'+data[i].email+'</td><td class="product_num">'+data[i].telephone+'</td>';
                content += '<td class="product_num">'+data[i].lastTime+'</td>';
                content += '<td class="cao_zuo"><span onclick="toActivityDetail('+data[i].id+')">查看</span><span onclick="deleteDeployMent('+data[i].id+')">删除</span></td></tr>';
            }
            $('#pages').text(pages);
            $('#total').text(total);
        }else{
            content+= '<div class="tipImg"><img src="/images/non.png" ><p class="tipNon">暂无数据</p></div>';
            $('#pages').text(0);
            $('#total').text(0);
        }
        $('table').html(content);
    }
    /*条件查询*/
    function getBargainProduct() {
        var name = $("[name='userName']").val();
        $.post("/bpm/user/userList",
            {
                pageSize:10,
                pageNum:1,
                userName:name
            },function (data) {
                selectListAll(data.data);
                var size = data.data.pages;
                if (!data.data.pages){
                    size = 0;
                }
                /*分页*/
                $(".pagediv").createPage({
                    pageNum: size,//总页码
                    current: 1,//当前页
                    shownum: 10,//每页显示个数
                    showPageNum: true, //显示总页数
                    showToPage: true, //显示跳转页码
                    backfun: function (page) {
                        flushHtml(page.current);
                    }
                });
            },'json')
    }

    /*跳转活动详情页 */
    function toActivityDetail(id) {
        location.href="/activityManage/toActivityInfo?activityId="+id+"&type=1";
    }



    /*删除用户 */
    function deleteUser(id) {
        alert(id)
        $.post("/api/bpm/model/deleteModel",
            {
                modelId:id
            },function (data) {
                if(data.code==200){
                    layer.msg('删除成功');
                    location.reload();
                }else {
                    layer.msg('删除失败');
                    location.reload();
                }
            },'json')
    }
</script>