123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771 |
- <!DOCTYPE html>
- <html lang="zh-cn">
- <head>
- <meta charset="UTF-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>河南星火燎原软件科技有限公司</title>
- <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
- <link rel="stylesheet" href="./librarys/bootstrap@3.4.1/bootstrap.css" />
- <link
- rel="stylesheet"
- href="./librarys/bootstrapValidator@0.5.3/bootstrapValidator.css"
- />
- <link rel="stylesheet" href="./css/comm.css" />
- <link rel="stylesheet" href="./css/header.css" />
- <style>
- body {
- background-color: #fff;
- }
- .user_main {
- margin: 20px auto;
- width: 1000px;
- }
- .user_main .header_box {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 10px;
- }
- .header_left .user_radio {
- cursor: pointer;
- }
- .header_left #searchUserName {
- display: inline-block;
- margin-left: 16px;
- width: 240px;
- }
- .header_left .searchBtn {
- margin-left: 16px;
- }
- .user_main .table.table-bordered th {
- text-align: center;
- background-color: #f7f7f7;
- }
- .user_main .table.table-bordered td {
- text-align: center;
- background-color: #fff;
- }
- .user_main .table.table-bordered .action_btn {
- margin: 0 10px;
- cursor: pointer;
- }
- .user_main .table.table-bordered .action_show {
- display: block;
- }
- .user_main .table.table-bordered .action_hide {
- display: none;
- }
- </style>
- </head>
- <body>
- <div class="top_header_root" data-header_page="index">
- <div class="header_html_root">
- <div class="header_html_item" data-url="index">用户信息</div>
- <div class="header_html_item" data-url="history">发展历程</div>
- <div class="header_html_item" data-url="service">服务案例</div>
- <div class="header_html_item" data-url="school">学校图标</div>
- <div class="header_html_item" data-url="trial">申请试用</div>
- <div class="header_html_item" data-url="news">新闻资讯</div>
- <div class="header_html_item" data-url="log">登录日志</div>
- </div>
- </div>
- <div class="user_main">
- <div class="header_box">
- <div class="header_left">
- <div class="radio-inline">
- <input
- id="s_0"
- class="user_radio"
- name="user_radio"
- type="radio"
- value="0"
- />
- <label for="s_0" class="user_radio">全部</label>
- </div>
- <div class="radio-inline">
- <input
- id="s_1"
- class="user_radio"
- name="user_radio"
- type="radio"
- value="1"
- />
- <label for="s_1" class="user_radio">正常</label>
- </div>
- <div class="radio-inline">
- <input
- id="s_10"
- class="user_radio"
- name="user_radio"
- type="radio"
- value="10"
- />
- <label for="s_10" class="user_radio">已删除</label>
- </div>
- <input
- type="text"
- id="searchUserName"
- class="form-control"
- placeholder="请输入用户姓名"
- />
- <div type="button" class="btn btn-primary searchBtn">搜索</div>
- </div>
- <div type="button" class="btn btn-primary user_add_btn">添加</div>
- </div>
- <table class="table table-bordered">
- <thead>
- <tr>
- <th style="width: 60px">序号</th>
- <th>用户姓名</th>
- <th>登录账户</th>
- <th style="width: 110px">手机号</th>
- <th style="width: 70px">状态</th>
- <th>创建人</th>
- <th style="width: 160px">创建时间</th>
- <th style="width: 140px">操作</th>
- </tr>
- </thead>
- <tbody class="userTableBody"></tbody>
- </table>
- <div class="user_page page_box">
- <!-- <div class="page_prev disabled"><</div>
- <div data-page="1" class="page_num selected">1</div>
- <div class="page_num">2</div>
- <div class="page_next">></div> -->
- </div>
- </div>
- <!-- 添加用户弹窗 -->
- <div
- class="modal fade"
- id="userAddModal"
- tabindex="-1"
- role="dialog"
- aria-labelledby="addTitle"
- >
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button
- type="button"
- class="close"
- data-dismiss="modal"
- aria-label="Close"
- >
- <span aria-hidden="true">×</span>
- </button>
- <h4 class="modal-title" id="addTitle">添加用户信息</h4>
- </div>
- <div class="modal-body">
- <form class="form-horizontal" id="userAddForm">
- <div class="form-group">
- <label for="usernameInput" class="col-sm-2 control-label"
- >用户姓名</label
- >
- <div class="col-sm-10">
- <input
- type="text"
- class="form-control"
- id="usernameInput"
- name="username"
- placeholder="请输入用户姓名"
- />
- </div>
- </div>
- <div class="form-group">
- <label for="loginnameInput" class="col-sm-2 control-label"
- >登录账号</label
- >
- <div class="col-sm-10">
- <input
- type="text"
- class="form-control"
- id="loginnameInput"
- name="loginname"
- placeholder="请输入登录账号"
- />
- </div>
- </div>
- <div class="form-group">
- <label for="loginpwdInput" class="col-sm-2 control-label"
- >登录密码</label
- >
- <div class="col-sm-10">
- <input
- type="password"
- class="form-control"
- id="loginpwdInput"
- name="loginpwd"
- placeholder="请输入登录密码"
- />
- </div>
- </div>
- <div class="form-group">
- <label for="userphoneInput" class="col-sm-2 control-label"
- >手机号</label
- >
- <div class="col-sm-10">
- <input
- type="text"
- class="form-control"
- id="userphoneInput"
- name="userphone"
- placeholder="请输入手机号"
- />
- </div>
- </div>
- </form>
- </div>
- <div class="modal-footer">
- <div type="button" class="btn btn-default" data-dismiss="modal">
- 取消
- </div>
- <div type="button" class="btn btn-primary add_save">确定</div>
- </div>
- </div>
- </div>
- </div>
- <!-- 修改用户弹窗 -->
- <div
- class="modal fade"
- id="userModifyModal"
- tabindex="-1"
- role="dialog"
- aria-labelledby="modifyTitle"
- >
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button
- type="button"
- class="close"
- data-dismiss="modal"
- aria-label="Close"
- >
- <span aria-hidden="true">×</span>
- </button>
- <h4 class="modal-title" id="modifyTitle">修改用户信息</h4>
- </div>
- <div class="modal-body">
- <form class="form-horizontal" id="userModifyForm">
- <div class="form-group">
- <label for="m_usernameInput" class="col-sm-2 control-label"
- >用户姓名</label
- >
- <div class="col-sm-10">
- <input
- type="text"
- class="form-control"
- id="m_usernameInput"
- name="username"
- placeholder="请输入用户姓名"
- />
- </div>
- </div>
- <div class="form-group">
- <label for="m_loginnameInput" class="col-sm-2 control-label"
- >登录账号</label
- >
- <div class="col-sm-10">
- <input
- type="text"
- class="form-control"
- id="m_loginnameInput"
- name="loginname"
- placeholder="请输入登录账号"
- />
- </div>
- </div>
- <div class="form-group">
- <label for="m_loginpwdInput" class="col-sm-2 control-label"
- >登录密码</label
- >
- <div class="col-sm-10">
- <input
- type="password"
- class="form-control"
- id="m_loginpwdInput"
- name="loginpwd"
- placeholder="请输入登录密码"
- />
- </div>
- </div>
- <div class="form-group">
- <label for="m_userphoneInput" class="col-sm-2 control-label"
- >手机号</label
- >
- <div class="col-sm-10">
- <input
- type="text"
- class="form-control"
- id="m_userphoneInput"
- name="userphone"
- placeholder="请输入手机号"
- />
- </div>
- </div>
- </form>
- </div>
- <div class="modal-footer">
- <div type="button" class="btn btn-default" data-dismiss="modal">
- 取消
- </div>
- <div type="button" class="btn btn-primary modify_save">确定</div>
- </div>
- </div>
- </div>
- </div>
- <!-- 删除用户弹窗 -->
- <div
- class="modal fade"
- id="userDelModal"
- tabindex="-1"
- role="dialog"
- aria-labelledby="delTitle"
- >
- <div class="modal-dialog tip_modal" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button
- type="button"
- class="close"
- data-dismiss="modal"
- aria-label="Close"
- >
- <span aria-hidden="true">×</span>
- </button>
- <h4 class="modal-title" id="delTitle">提示</h4>
- </div>
- <div class="modal-body">确定删除选中信息?</div>
- <div class="modal-footer">
- <div type="button" class="btn btn-default" data-dismiss="modal">
- 取消
- </div>
- <div type="button" class="btn btn-primary del_save">保存</div>
- </div>
- </div>
- </div>
- </div>
- <script src="./librarys/jquery@1.12.4/jquery.min.js"></script>
- <script src="./librarys/bootstrap@3.4.1/bootstrap.js"></script>
- <script src="./librarys/bootstrapValidator@0.5.3/bootstrapValidator.js"></script>
- <script src="./utils/index.js"></script>
- <script>
- $(function () {
- let page_url = $(".top_header_root").data("header_page");
- $(
- '.header_html_root .header_html_item[data-url="' + page_url + '"]'
- ).addClass("selected");
- $(".header_html_root").on("click", ".header_html_item", function () {
- let _url = $(this).data("url");
- if (_url === "index") {
- window.location.href = "/index.html";
- } else {
- window.location.href = "/sections/" + _url + ".html";
- }
- });
- if (!$.isLogin()) {
- window.location.href = "/sections/login.html";
- return;
- }
- let userSearch = {
- page: Number($.getQueryletiable("page")) || 1,
- size: 10,
- userstate: Number($.getQueryletiable("userstate")) || 0,
- username: $.getQueryletiable("username") || "",
- total: 0,
- list: [],
- };
- $('.header_left input:radio[name="user_radio"]').each(function (
- _index,
- radioItem
- ) {
- if (Number($(radioItem).val()) === userSearch.userstate) {
- $(radioItem).attr("checked", true);
- } else {
- $(radioItem).attr("checked", false);
- }
- });
- // 获取用户列表
- function getUserList() {
- $.ajax({
- type: "POST",
- url: $.baseUrl + "user/list",
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify({
- page: userSearch.page,
- size: userSearch.size,
- userstate: userSearch.userstate,
- username: userSearch.username,
- }),
- success: function (data) {
- if (data.code === 0) {
- userSearch.total = data.obj.total;
- userSearch.list = data.obj.list;
- setTableHtml();
- setPageList();
- } else {
- userSearch.total = 0;
- userSearch.list = [];
- alert(data.msg);
- }
- },
- });
- }
- // 设置页码信息
- function setPageList() {
- let pageBoxHtml =
- '<div class="page_prev ' +
- (userSearch.page === 1 ? "disabled" : "") +
- '"><</div>';
- for (
- let _pageIndex = 0;
- _pageIndex < Math.ceil(userSearch.total / userSearch.size);
- _pageIndex++
- ) {
- pageBoxHtml +=
- '<div data-page="' +
- (_pageIndex + 1) +
- '" class="page_num ' +
- (_pageIndex + 1 === userSearch.page ? "selected" : "") +
- '">' +
- (_pageIndex + 1) +
- "</div>";
- }
- pageBoxHtml +=
- '<div class="page_next ' +
- (userSearch.page === Math.ceil(userSearch.total / userSearch.size)
- ? "disabled"
- : "") +
- '">></div>';
- if (userSearch.total > 0) {
- $(".user_page.page_box").html(pageBoxHtml);
- $(".user_page.page_box").on("click", ".page_prev", function () {
- if (userSearch.page > 1) {
- userSearch.page--;
- window.location.href =
- "/index.html?page=" +
- userSearch.page +
- "&userstate=" +
- userSearch.userstate +
- "&username=" +
- userSearch.username;
- }
- });
- $(".user_page.page_box").on("click", ".page_num", function () {
- userSearch.page = $(this).data("page");
- window.location.href =
- "/index.html?page=" +
- userSearch.page +
- "&userstate=" +
- userSearch.userstate +
- "&username=" +
- userSearch.username;
- });
- $(".user_page.page_box").on("click", ".page_next", function () {
- if (
- userSearch.page < Math.ceil(userSearch.total / userSearch.size)
- ) {
- userSearch.page++;
- window.location.href =
- "/index.html?page=" +
- userSearch.page +
- "&userstate=" +
- userSearch.userstate +
- "&username=" +
- userSearch.username;
- }
- });
- } else {
- $(".user_page.page_box").html("");
- }
- }
- // 设置表格信息
- function setTableHtml() {
- let userTableBodyHtml = "";
- $.each(userSearch.list, function (_userIndex, _userItem) {
- userTableBodyHtml +=
- "<tr><td>" +
- (_userIndex + 1 + (userSearch.page - 1) * userSearch.size) +
- "</td><td>" +
- (_userItem.username ? _userItem.username : "") +
- "</td><td>" +
- _userItem.loginname +
- "</td><td>" +
- (_userItem.userphone ? _userItem.userphone : "") +
- "</td><td>" +
- (_userItem.userstate === 1 ? "正常" : "已删除") +
- "</td><td>" +
- (_userItem.createname ? _userItem.createname : "") +
- "</td><td>" +
- $.dateFormat(_userItem.createtime) +
- '</td><td><div class="' +
- (_userItem.userstate === 1 ? "action_show" : "action_hide") +
- '"><span class="my_theme_color action_btn modify_btn" data-userid="' +
- _userItem.userid +
- '">修改</span><span class="my_theme_color">|</span><span class="del_color action_btn del_btn" data-userid="' +
- _userItem.userid +
- '">删除</span></div></td></tr>';
- });
- $(".userTableBody").html(userTableBodyHtml);
- let del_userid = null;
- $(".userTableBody").on("click", ".del_btn", function () {
- $("#userDelModal").modal("show");
- del_userid = $(this).data("userid");
- });
- $("#userDelModal .del_save").on("click", function () {
- $.ajax({
- type: "POST",
- url: $.baseUrl + "user/del",
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify({
- userid: del_userid,
- }),
- success: function (data) {
- $("#userDelModal").modal("hide");
- if (data.code === 0) {
- window.location.href =
- "/index.html?page=" +
- userSearch.page +
- "&userstate=" +
- userSearch.userstate +
- "&username=" +
- userSearch.username;
- } else {
- alert(data.msg);
- }
- },
- });
- });
- }
- $(".user_main .header_box .user_add_btn").click(function () {
- $("#userAddModal").modal("show");
- });
- $("#userAddModal .add_save").on("click", function () {
- // 添加表单验证
- $("#userAddForm").bootstrapValidator({
- // 默认的提示消息
- message: "请输入内容",
- // 表单框里右侧的icon
- // feedbackIcons: {
- // valid: "glyphicon glyphicon-ok",
- // invalid: "glyphicon glyphicon-remove",
- // validating: "glyphicon glyphicon-refresh",
- // },
- fields: {
- username: {
- validators: {
- notEmpty: {
- message: "请输入用户姓名",
- },
- },
- },
- loginname: {
- validators: {
- notEmpty: {
- message: "请输入登录账号",
- },
- stringLength: {
- //长度限制
- min: 4,
- max: 18,
- message: "登录账号长度必须在4~18个字符之间",
- },
- },
- },
- loginpwd: {
- validators: {
- notEmpty: {
- message: "请输入登录密码",
- },
- stringLength: {
- //长度限制
- min: 6,
- max: 16,
- message: "登录密码长度必须在6~16个字符之间",
- },
- },
- },
- userphone: {
- validators: {
- // notEmpty: {
- // message: "请输入手机号",
- // },
- regexp: {
- regexp: /^1\d{10}$/,
- message: "请输入正确的11位手机号",
- },
- },
- },
- },
- });
- //先校验,在调是否通过校验的方法
- $("#userAddForm").data("bootstrapValidator").validate();
- //校验表单是否通过
- let flag = $("#userAddForm").data("bootstrapValidator").isValid();
- if (flag) {
- let _url = $.baseUrl + "user/save";
- $.ajax({
- type: "POST",
- url: _url,
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify({
- username: $("#userAddForm #usernameInput").val(),
- loginname: $("#userAddForm #loginnameInput").val(),
- loginpwd: $("#userAddForm #loginpwdInput").val(),
- createid: $.userInfo.userid,
- userphone: $("#userAddForm #userphoneInput").val(),
- }),
- success: function (data) {
- if (data.code === 0) {
- window.location.href =
- "/index.html?page=1&userstate=" +
- userSearch.userstate +
- "&username=" +
- userSearch.username;
- } else {
- alert(data.msg);
- }
- },
- });
- }
- });
- let modify_userid = null;
- $(".userTableBody").on("click", ".modify_btn", function () {
- modify_userid = $(this).data("userid");
- $("#userModifyModal").modal("show");
- $.each(userSearch.list, function (_index, _userItem) {
- if (_userItem.userid === modify_userid) {
- $("#userModifyForm #m_usernameInput").val(_userItem.username);
- $("#userModifyForm #m_loginnameInput").val(_userItem.loginname);
- $("#userModifyForm #m_loginpwdInput").val(_userItem.loginpwd);
- $("#userModifyForm #m_userphoneInput").val(_userItem.userphone);
- }
- });
- });
- $("#userModifyModal .modify_save").on("click", function () {
- // 添加表单验证
- $("#userModifyForm").bootstrapValidator({
- // 默认的提示消息
- message: "请输入内容",
- // 表单框里右侧的icon
- // feedbackIcons: {
- // valid: "glyphicon glyphicon-ok",
- // invalid: "glyphicon glyphicon-remove",
- // validating: "glyphicon glyphicon-refresh",
- // },
- fields: {
- username: {
- validators: {
- notEmpty: {
- message: "请输入用户姓名",
- },
- },
- },
- loginname: {
- validators: {
- notEmpty: {
- message: "请输入登录账号",
- },
- stringLength: {
- //长度限制
- min: 4,
- max: 18,
- message: "登录账号长度必须在4~18个字符之间",
- },
- },
- },
- loginpwd: {
- validators: {
- // notEmpty: {
- // message: "请输入登录密码",
- // },
- stringLength: {
- //长度限制
- min: 6,
- max: 16,
- message: "登录密码长度必须在6~16个字符之间",
- },
- },
- },
- userphone: {
- validators: {
- // notEmpty: {
- // message: "请输入手机号",
- // },
- regexp: {
- regexp: /^1\d{10}$/,
- message: "请输入正确的11位手机号",
- },
- },
- },
- },
- });
- //先校验,在调是否通过校验的方法
- $("#userModifyForm").data("bootstrapValidator").validate();
- //校验表单是否通过
- let flag = $("#userModifyForm").data("bootstrapValidator").isValid();
- if (flag) {
- let _url = $.baseUrl + "user/update";
- $.ajax({
- type: "POST",
- url: _url,
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify({
- username: $("#userModifyForm #m_usernameInput").val(),
- loginname: $("#userModifyForm #m_loginnameInput").val(),
- loginpwd: $("#userModifyForm #m_loginpwdInput").val(),
- userid: modify_userid,
- userphone: $("#userModifyForm #m_userphoneInput").val(),
- }),
- success: function (data) {
- if (data.code === 0) {
- window.location.href =
- "/index.html?page=" +
- userSearch.page +
- "&userstate=" +
- userSearch.userstate +
- "&username=" +
- userSearch.username;
- } else {
- alert(data.msg);
- }
- },
- });
- }
- });
- $(".header_left").on(
- "click",
- 'input:radio[name="user_radio"]',
- function () {
- window.location.href =
- "/index.html?page=" +
- userSearch.page +
- "&userstate=" +
- $('.header_left input:radio[name="user_radio"]:checked').val() +
- "&username=" +
- userSearch.username;
- }
- );
- $("#searchUserName").val(userSearch.username);
- $("#searchUserName").on("change", function () {
- userSearch.username = $(this).val();
- });
- $(".header_left .searchBtn").click(function () {
- window.location.href =
- "/index.html?page=" +
- userSearch.page +
- "&userstate=" +
- userSearch.userstate +
- "&username=" +
- userSearch.username;
- });
- getUserList();
- });
- </script>
- </body>
- </html>
|