<%--
  Created by IntelliJ IDEA.
  User: wuxuan
  Date: 2021/12/31
  Time: 14:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page pageEncoding="UTF-8" language="java" %>

<%@ include file="../common/common.jsp" %>
<html>
<head>
    <title>商务管理</title>
</head>
<body>
<div class="page_container">
    <div class="page_head">
        <h3>商务管理</h3>
        <div class="breadcrumb">
            <a href="#">首页</a> > <a href="#">系统管理</a> > 商务管理
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <form action="${basepage}/business/busList.html" method="post">
                <div class="panel">
                    <div class="table_operate">
                        <label>账户ID:&nbsp;<input id="userId" name="userId" type="text" placeholder="账号登录ID"
                                                 class="form_control form_white" value="${business.userId}"/>
                        </label>
                        <label>用户名:&nbsp;<input id="username" name="username" type="text" placeholder="用户的名字"
                                                class="form_control form_white" value="${business.userName}"/>
                        </label>
                        <label>&nbsp;</label>
                        <button name="search" type="submit" class="btn btn_orange btn_icon"><span
                                class="ico_16px ico_search"></span>查询
                        </button>
                    </div>

                    <div class="table_wrap">
                        <table class="datatable">
                            <thead>
                            <tr>
                                <th style="text-align: center">序号</th>
                                <th style="text-align: center">账户名</th>
                                <th style="text-align: center">用户名称</th>
                                <th style="text-align: center">最近登陆时间</th>
                                <th style="text-align: center">最近登陆IP</th>
                                <th style="text-align: center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:choose>
                                <c:when test="${not empty list}">
                                    <c:forEach items="${list}" var="item" varStatus="vs">
                                        <tr class="main_info">
                                            <td>${vs.index}</td>
                                            <td>${item.userName}</td>
                                            <td>${item.name}</td>
                                            <td>${item.lastLoginTime}</td>
                                            <td>${item.lastLoginIp}</td>
                                            <td>
                                                <button class="btn btn_small btn_blue" type="button" onclick="edit('${item.userName}')">编辑所属商务</button>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                </c:when>
                                <c:otherwise>
                                    <tr class="main_info">
                                        <td colspan="8" align="center">没有相关数据</td>
                                    </tr>
                                </c:otherwise>
                            </c:choose>
                            </tbody>
                            <tfoot>
                            <tr>
                                <td>${business.page.pageStr}</td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </form>


        </div>
    </div>
</div>
</body>
<script>
    function edit(userId) {
        Dialog.ajaxOpen('${basepage}/business/busEdit.html?userId=' + userId, '编辑所属商务', me => {
            let $sale =  $("input[name=business]:checked")

            let arr = []
            $sale.each((index,item) => {
                arr.push($(item).val())
            })

           $.ajax({
               url: '${basepage}/business/submit.html',
               type: "POST",
               dataType: 'json',
               data: {userId: userId, selas: arr.join(",")},
               success: res => {
                   if (res.code === 0) {
                       Dialog.alertSucc(res.msg)
                       me.close()
                   } else {
                       Dialog.alertError(res.msg)
                   }
               },
               error: () => {
                   Dialog.alertError("请求失败")
               }
           })
        })
    }
</script>
</html>
