123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824 |
- <!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 #searchschoolname {
- 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;
- line-height: 40px;
- }
- .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;
- }
- .ser_img {
- width: 40px;
- height: 40px;
- cursor: pointer;
- }
- .showimgurl,
- .showimgurl img {
- width: 100%;
- height: 100%;
- }
- </style>
- </head>
- <body>
- <div class="top_header_root" data-header_page="school">
- <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_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_2"
- class="user_radio"
- name="user_radio"
- type="radio"
- value="2"
- />
- <label for="s_2" class="user_radio">英文</label>
- </div>
- <input
- type="text"
- id="searchschoolname"
- 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 style="width: 140px">学校图标</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="showImg"
- tabindex="-1"
- role="dialog"
- aria-labelledby="imgTitle"
- >
- <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="imgTitle">查看图片</h4>
- </div>
- <div class="modal-body">
- <div class="showimgurl"></div>
- </div>
- </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="schoolnameInput" class="col-sm-2 control-label"
- >学校名称</label
- >
- <div class="col-sm-10">
- <input
- type="text"
- class="form-control"
- id="schoolnameInput"
- name="schoolname"
- placeholder="请输入学校名称"
- />
- </div>
- </div>
- <div class="form-group">
- <label for="loginnameInput" class="col-sm-2 control-label"
- >学校图标</label
- >
- <div class="col-sm-10">
- <input type="file" id="uploadFile" />
- </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_schoolnameInput" class="col-sm-2 control-label"
- >用户姓名</label
- >
- <div class="col-sm-10">
- <input
- type="text"
- class="form-control"
- id="m_schoolnameInput"
- name="schoolname"
- 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 Search = {
- page: Number($.getQueryletiable("page")) || 1,
- size: 10,
- ltype: Number($.getQueryletiable("ltype")) || 1,
- schoolname: $.getQueryletiable("schoolname") || "",
- total: 0,
- list: []
- };
- //默认中英文单选框 1
- $('.header_left input:radio[name="user_radio"]').each(function (
- _index,
- radioItem
- ) {
- if (Number($(radioItem).val()) === Search.ltype) {
- $(radioItem).attr("checked", true);
- } else {
- $(radioItem).attr("checked", false);
- }
- });
- // 获取用户列表
- function getUserList() {
- $.ajax({
- type: "POST",
- url: $.baseUrl + "sl/list",
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify({
- page: Search.page,
- size: Search.size,
- ltype: Search.ltype,
- schoolname: Search.schoolname
- }),
- success: function (data) {
- if (data.code === 0) {
- Search.total = data.obj.total;
- Search.list = data.obj.list;
- console.log(Search);
- setTableHtml();
- setPageList();
- } else {
- Search.total = 0;
- Search.list = [];
- alert(data.msg);
- }
- }
- });
- }
- // 设置页码信息
- function setPageList() {
- let pageBoxHtml =
- '<div class="page_prev ' +
- (Search.page === 1 ? "disabled" : "") +
- '"><</div>';
- for (
- let _pageIndex = 0;
- _pageIndex < Math.ceil(Search.total / Search.size);
- _pageIndex++
- ) {
- pageBoxHtml +=
- '<div data-page="' +
- (_pageIndex + 1) +
- '" class="page_num ' +
- (_pageIndex + 1 === Search.page ? "selected" : "") +
- '">' +
- (_pageIndex + 1) +
- "</div>";
- }
- pageBoxHtml +=
- '<div class="page_next ' +
- (Search.page === Math.ceil(Search.total / Search.size)
- ? "disabled"
- : "") +
- '">></div>';
- if (Search.total > 0) {
- $(".user_page.page_box").html(pageBoxHtml);
- $(".user_page.page_box").on("click", ".page_prev", function () {
- if (Search.page > 1) {
- Search.page--;
- window.location.href =
- "/index.html?page=" +
- Search.page +
- "<ype=" +
- Search.ltype +
- "&schoolname=" +
- Search.schoolname;
- }
- });
- $(".user_page.page_box").on("click", ".page_num", function () {
- Search.page = $(this).data("page");
- window.location.href =
- "/index.html?page=" +
- Search.page +
- "<ype=" +
- Search.ltype +
- "&schoolname=" +
- Search.schoolname;
- });
- $(".user_page.page_box").on("click", ".page_next", function () {
- if (Search.page < Math.ceil(Search.total / Search.size)) {
- Search.page++;
- window.location.href =
- "/index.html?page=" +
- Search.page +
- "<ype=" +
- Search.ltype +
- "&schoolname=" +
- Search.schoolname;
- }
- });
- } else {
- $(".user_page.page_box").html("");
- }
- }
- // 设置表格信息
- function setTableHtml() {
- let userTableBodyHtml = "";
- $.each(Search.list, function (_userIndex, _userItem) {
- userTableBodyHtml +=
- "<tr><td>" +
- (_userIndex + 1 + (Search.page - 1) * Search.size) +
- "</td><td>" +
- (_userItem.schoolname ? _userItem.schoolname : "") +
- "</td><td><img class='ser_img' src='" +
- (_userItem.schoollogo
- ? $.showImageUrl + _userItem.schoollogo
- : "") +
- "' data-img='" +
- (_userItem.schoollogo
- ? $.showImageUrl + _userItem.schoollogo
- : "") +
- "' data-title='" +
- (_userItem.schoolname ? _userItem.schoolname : "") +
- "'></td><td>" +
- (_userItem.createname ? _userItem.createname : "") +
- "</td><td>" +
- $.dateFormat(_userItem.createtime) +
- '</td><td><div class="' +
- (_userItem.ltype === 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>';
- });
- //点击图片放大 ser_img
- $(".userTableBody").on("click", ".ser_img", function () {
- let _url = $(this).data("img");
- let title = $(this).data("title");
- if (_url) {
- $("#showImg").modal("show");
- $(".showimgurl").html("<img src='" + _url + "'>");
- }
- if (title) {
- $("#imgTitle").text(title);
- }
- });
- $(".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=" +
- Search.page +
- "<ype=" +
- Search.ltype +
- "&schoolname=" +
- Search.schoolname;
- } else {
- alert(data.msg);
- }
- }
- });
- });
- }
- //添加弹窗
- $(".user_main .header_box .user_add_btn").click(function () {
- $("#userAddModal").modal("show");
- });
- //获取图片地址
- $("#uploadFile").on("change", function () {
- let file = this.files[0]; //这是我们上传的文件
- let size = file.size / 1024 / 1024;
- let str = file.name.split(".");
- let suffix = str[str.length - 1];
- if (suffix !== "png" && suffix !== "jpg" && suffix !== "jpeg") {
- alert("请上传png、jpg、jpeg类型的文件");
- return false;
- }
- if (size > 10) {
- alert("图片太大,不能超过10M!");
- return false;
- }
- var formData = new FormData();
- formData.append("file", file);
- formData.append("savefolder", "schoolcase");
- console.log(formData);
- $.ajax({
- type: "POST",
- url: $.baseUrl + "file/upload",
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- data: JSON.stringify(formData),
- success: function (data) {
- if (data.code === 0) {
- console.log(data);
- } else {
- alert(data.msg);
- }
- }
- });
- });
-
- //确定添加
- $("#userAddModal .add_save").on("click", function () {
- // 添加表单验证
- $("#UserAddForm").bootstrapValidator({
- // 默认的提示消息
- message: "请输入内容",
- // 表单框里右侧的icon
- feedbackIcons: {
- valid: "glyphicon glyphicon-ok",
- invalid: "glyphicon glyphicon-remove",
- validating: "glyphicon glyphicon-refresh"
- },
- fields: {
- schoolname: {
- 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({
- schoolname: $("#UserAddForm #schoolnameInput").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<ype=" +
- Search.ltype +
- "&schoolname=" +
- Search.schoolname;
- } else {
- alert(data.msg);
- }
- }
- });
- }
- });
- let modify_userid = null;
- //修改
- $(".userTableBody").on("click", ".modify_btn", function () {
- modify_userid = $(this).data("userid");
- $("#userModifyModal").modal("show");
- $.each(Search.list, function (_index, _userItem) {
- if (_userItem.userid === modify_userid) {
- console.log("modify_userid", _userItem);
- $("#userModifyForm #m_schoolnameInput").val(_userItem.schoolname);
- $("#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: {
- schoolname: {
- 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({
- schoolname: $("#userModifyForm #m_schoolnameInput").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=" +
- Search.page +
- "<ype=" +
- Search.ltype +
- "&schoolname=" +
- Search.schoolname;
- } else {
- alert(data.msg);
- }
- }
- });
- }
- });
- //切换中英文
- $(".header_left").on(
- "click",
- 'input:radio[name="user_radio"]',
- function () {
- window.location.href =
- "/sections/school.html?page=" +
- Search.page +
- "<ype=" +
- $('.header_left input:radio[name="user_radio"]:checked').val() +
- "&schoolname=" +
- Search.schoolname;
- }
- );
- $("#searchschoolname").val(Search.schoolname);
- $("#searchschoolname").on("change", function () {
- Search.schoolname = $(this).val();
- });
- //搜索
- $(".header_left .searchBtn").click(function () {
- window.location.href =
- "/sections/school.html?page=" +
- Search.page +
- "<ype=" +
- Search.ltype +
- "&schoolname=" +
- Search.schoolname;
- });
- getUserList();
- });
- </script>
- </body>
- </html>
|