糊弄完了
This commit is contained in:
parent
ea5ce567ef
commit
196e210d26
@ -1,26 +1,189 @@
|
||||
from flask import Flask, render_template
|
||||
import json
|
||||
|
||||
from flask import Flask, render_template, request, redirect
|
||||
from pkg_resources import require
|
||||
from com.native.parser.parser_core import *
|
||||
from com.native.view.msg import *
|
||||
from com.native.view.info import *
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
class Student(object):
|
||||
def __init__(self, sid, name, native):
|
||||
self.sid = sid
|
||||
self.name = name
|
||||
self.native = native
|
||||
|
||||
|
||||
# 访问路径
|
||||
@app.route('/')
|
||||
def hello_world():
|
||||
stuInfo = {
|
||||
'sid': 111111,
|
||||
'name': 'jack',
|
||||
'native': 'China'
|
||||
}
|
||||
infos = []
|
||||
list = queryAllInfo()
|
||||
for i in list:
|
||||
stuInfo = queryInfoBySid(i)
|
||||
|
||||
native = json.dumps(stuInfo.pop(), ensure_ascii=False)
|
||||
native = native.split(',')[1][2:-2]
|
||||
print(native)
|
||||
name = json.dumps(stuInfo.pop(), ensure_ascii=False)
|
||||
name = name.split(',')[1][2:-2]
|
||||
print(name)
|
||||
sid = json.dumps(stuInfo.pop(), ensure_ascii=False)
|
||||
sid = sid.split(',')[1][2:-2]
|
||||
print(sid)
|
||||
|
||||
info = Info().string(native, name, sid)
|
||||
infos.append(info)
|
||||
return render_template('index.html', info=infos)
|
||||
|
||||
|
||||
# 返回模板 index.html 模板引擎可以渲染number变量 传到前端
|
||||
return render_template('index.html', info=stuInfo)
|
||||
@app.route('/searchBySid/<data>/', methods=['GET', 'POST'])
|
||||
def searchStuBySid(data):
|
||||
if str(queryInfoBySid(data)) == 'False':
|
||||
return str(queryInfoBySid(data))
|
||||
else:
|
||||
infos = []
|
||||
stuInfo = queryInfoBySid(data)
|
||||
native = json.dumps(stuInfo.pop(), ensure_ascii=False)
|
||||
native = native.split(',')[1][2:-2]
|
||||
name = json.dumps(stuInfo.pop(), ensure_ascii=False)
|
||||
name = name.split(',')[1][2:-2]
|
||||
sid = json.dumps(stuInfo.pop(), ensure_ascii=False)
|
||||
sid = sid.split(',')[1][2:-2]
|
||||
info = Info().string(native, name, sid)
|
||||
infos.append(info)
|
||||
return render_template('search.html', info=infos)
|
||||
|
||||
|
||||
@app.route('/search/<data>/', methods=['GET', 'POST'])
|
||||
def searchStu(data):
|
||||
return str(queryInfoBySid(data))
|
||||
@app.route('/searchByName/<data>/', methods=['GET', 'POST'])
|
||||
def searchStuByName(data):
|
||||
if str(queryInfoByName(data)) == 'False':
|
||||
return str(queryInfoByName(data))
|
||||
else:
|
||||
infos = []
|
||||
stuInfo = queryInfoByName(data)
|
||||
for i in range(len(stuInfo)):
|
||||
temp = stuInfo[i]
|
||||
native = json.dumps(temp, ensure_ascii=False)
|
||||
native = native.split(',')[5][2:-2]
|
||||
|
||||
name = json.dumps(temp, ensure_ascii=False)
|
||||
name = name.split(',')[3][2:-2]
|
||||
print(name)
|
||||
sid = json.dumps(temp, ensure_ascii=False)
|
||||
sid = sid.split(',')[1][2:-2]
|
||||
info = Info().string(native, name, sid)
|
||||
print(info)
|
||||
infos.append(info)
|
||||
return render_template('search.html', info=infos)
|
||||
|
||||
|
||||
@app.route('/searchByNative/<data>/', methods=['GET', 'POST'])
|
||||
def searchStuByNative(data):
|
||||
if str(queryAllInfoByNative(data)) == 'False':
|
||||
return str(queryAllInfoByNative(data))
|
||||
else:
|
||||
infos = []
|
||||
stuInfo = queryAllInfoByNative(data)
|
||||
for i in range(len(stuInfo)):
|
||||
temp = stuInfo[i]
|
||||
native = json.dumps(temp, ensure_ascii=False)
|
||||
native = native.split(',')[5][2:-2]
|
||||
print(native)
|
||||
name = json.dumps(temp, ensure_ascii=False)
|
||||
name = name.split(',')[3][2:-2]
|
||||
sid = json.dumps(temp, ensure_ascii=False)
|
||||
sid = sid.split(',')[1][2:-2]
|
||||
info = Info().string(native, name, sid)
|
||||
print(info)
|
||||
infos.append(info)
|
||||
return render_template('search.html', info=infos)
|
||||
|
||||
|
||||
@app.route('/add', methods=['GET', 'POST'])
|
||||
def insert_data():
|
||||
username = request.form.get('username')
|
||||
native = request.form.get('native')
|
||||
usid = request.form.get('usid')
|
||||
s = Student(usid, username, native)
|
||||
return str(inster(s))
|
||||
|
||||
|
||||
@app.route('/update', methods=['GET', 'POST'])
|
||||
def updete_data():
|
||||
username = request.form.get('username')
|
||||
native = request.form.get('native')
|
||||
usid = request.form.get('usid')
|
||||
s = Student(usid, username, native)
|
||||
return str(updeteStu(s))
|
||||
|
||||
|
||||
@app.route('/delete', methods=['GET', 'POST'])
|
||||
def delete_data():
|
||||
sid = request.form.get('sid')
|
||||
return str(delete(sid))
|
||||
|
||||
|
||||
@app.route('/login', methods=['GET', 'POST'])
|
||||
def login():
|
||||
return render_template('login.html')
|
||||
|
||||
|
||||
@app.route('/checklogin', methods=['GET', 'POST'])
|
||||
def checklogin():
|
||||
username = request.form.get('username')
|
||||
password = request.form.get('password')
|
||||
config = configparser.ConfigParser() # 类实例化
|
||||
# 定义文件路径
|
||||
path = r'../../../resources/user.ini'
|
||||
config.read(path, encoding="utf-8")
|
||||
r = Msg()
|
||||
try:
|
||||
passwordini = config.get('user', username)
|
||||
if password == passwordini:
|
||||
# return redirect('/')
|
||||
return r.string(200, '登陆成功')
|
||||
else:
|
||||
return r.string(500, '登录失败')
|
||||
except:
|
||||
return r.string(500, '登录失败')
|
||||
|
||||
|
||||
@app.route('/add_stu', methods=['GET', 'POST'])
|
||||
def addStuInfo():
|
||||
sid = request.form.get('sid')
|
||||
name = request.form.get('name')
|
||||
native = request.form.get('native')
|
||||
r = Msg()
|
||||
|
||||
if inster(Student(sid, name, native)):
|
||||
return r.string(200, '添加成功')
|
||||
else:
|
||||
return r.string(500, '添加失败')
|
||||
|
||||
|
||||
@app.route('/remove_stu', methods=['GET', 'POST'])
|
||||
def removeStu():
|
||||
sid = request.form.get('sid')
|
||||
r = Msg()
|
||||
if delete(sid) :
|
||||
return r.string(200, '删除成功')
|
||||
else:
|
||||
return r.string(500, '删除失败')
|
||||
|
||||
|
||||
@app.route('/update_stu', methods=['GET', 'POST'])
|
||||
def updateStu():
|
||||
sid = request.form.get('sid')
|
||||
name = request.form.get('name')
|
||||
native = request.form.get('native')
|
||||
print("-------------------" + sid)
|
||||
print("-------------------" + name)
|
||||
print("-------------------" + native)
|
||||
r = Msg()
|
||||
if updeteStu(Student(str(sid), str(name), str(native))):
|
||||
return r.string(200, '删除成功')
|
||||
else:
|
||||
return r.string(500, '删除失败')
|
||||
|
@ -0,0 +1,2 @@
|
||||
|
||||
|
1
com/native/gui/static/css/layui.css
Normal file
1
com/native/gui/static/css/layui.css
Normal file
File diff suppressed because one or more lines are too long
1
com/native/gui/static/css/modules/code.css
Normal file
1
com/native/gui/static/css/modules/code.css
Normal file
@ -0,0 +1 @@
|
||||
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#FAFAFA;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view .layui-code-ol li:first-child{padding-top:10px}.layui-code-view .layui-code-ol li:last-child{padding-bottom:10px}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}
|
File diff suppressed because one or more lines are too long
BIN
com/native/gui/static/css/modules/layer/default/icon-ext.png
Normal file
BIN
com/native/gui/static/css/modules/layer/default/icon-ext.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
BIN
com/native/gui/static/css/modules/layer/default/icon.png
Normal file
BIN
com/native/gui/static/css/modules/layer/default/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
File diff suppressed because one or more lines are too long
BIN
com/native/gui/static/css/modules/layer/default/loading-0.gif
Normal file
BIN
com/native/gui/static/css/modules/layer/default/loading-0.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
BIN
com/native/gui/static/css/modules/layer/default/loading-1.gif
Normal file
BIN
com/native/gui/static/css/modules/layer/default/loading-1.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 701 B |
BIN
com/native/gui/static/css/modules/layer/default/loading-2.gif
Normal file
BIN
com/native/gui/static/css/modules/layer/default/loading-2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
com/native/gui/static/font/iconfont.eot
Normal file
BIN
com/native/gui/static/font/iconfont.eot
Normal file
Binary file not shown.
554
com/native/gui/static/font/iconfont.svg
Normal file
554
com/native/gui/static/font/iconfont.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 299 KiB |
BIN
com/native/gui/static/font/iconfont.ttf
Normal file
BIN
com/native/gui/static/font/iconfont.ttf
Normal file
Binary file not shown.
BIN
com/native/gui/static/font/iconfont.woff
Normal file
BIN
com/native/gui/static/font/iconfont.woff
Normal file
Binary file not shown.
BIN
com/native/gui/static/font/iconfont.woff2
Normal file
BIN
com/native/gui/static/font/iconfont.woff2
Normal file
Binary file not shown.
5
com/native/gui/static/layui.js
Normal file
5
com/native/gui/static/layui.js
Normal file
File diff suppressed because one or more lines are too long
@ -11,69 +11,193 @@
|
||||
<div class="container">
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="inputGroup-sizing-default">sid | name | native</span>
|
||||
<input type="text" id="search_input" class="form-control" aria-label="Sizing example input"
|
||||
aria-describedby="inputGroup-sizing-default">
|
||||
</div>
|
||||
<div class="row align-items-start" style="margin-top: 10px;padding: 20px">
|
||||
<div class="col">
|
||||
<div class="input-group mb-3">
|
||||
{# <span class="input-group-text" id="inputGroup-sizing-default">sid | name | native</span>#}
|
||||
<div class="btn-group" role="group" aria-label="Basic outlined example">
|
||||
<button type="button" class="btn btn-outline-primary" onclick="searchType=0">sid</button>
|
||||
<button type="button" class="btn btn-outline-primary" onclick="searchType=1">name</button>
|
||||
<button type="button" class="btn btn-outline-primary" onclick="searchType=2">native</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button type="button" id="search_btn" class="btn btn-primary">search</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-primary">add</button>
|
||||
<button type="button" class="btn btn-primary">remove</button>
|
||||
<input type="text" id="search_input" class="form-control" aria-label="Sizing example input"
|
||||
aria-describedby="inputGroup-sizing-default">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
<button type="button" id="search_btn" class="btn btn-primary">search</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdropAdd">add
|
||||
</button>
|
||||
{# <button type="button" class="btn btn-primary">remove</button>#}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-start" style="padding:0 20px">
|
||||
<div class="col">
|
||||
<div class="col">
|
||||
<div class="col">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">sid</th>
|
||||
<th scope="col">name</th>
|
||||
<th scope="col">native</th>
|
||||
<th scope="col">operation</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="col">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">sid</th>
|
||||
<th scope="col">name</th>
|
||||
<th scope="col">native</th>
|
||||
<th scope="col">operation</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="col">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
{% for item in info %}
|
||||
<tr id="user">
|
||||
<th scope="col"></th>
|
||||
<th scope="col">{{ item.sid }}</th>
|
||||
<th scope="col">{{ item.name }}</th>
|
||||
<th scope="col">{{ item.native }}</th>
|
||||
<th scope="col">
|
||||
<button type="button" class="btn btn-outline-dark btn-sm updateStd" data-bs-toggle="modal"
|
||||
data-bs-target="#staticBackdrop" value="{{ item.sid }}">update
|
||||
</button>
|
||||
<button type="button" class="btn btn-outline-danger btn-sm remove"
|
||||
value="{{ item.sid }}" data-bs-toggle="modal"
|
||||
data-bs-target="#staticBackdropRemove">
|
||||
remove
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row align-items-start" style="padding:0 20px">
|
||||
<div class="col">
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
{# <li class="page-item"><a class="page-link" href="#">2</a></li>#}
|
||||
{# <li class="page-item"><a class="page-link" href="#">3</a></li>#}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 修改信息-->
|
||||
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
|
||||
aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="staticBackdropLabel">修改学生户籍信息</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="layui-form-item" style="display: flex;margin-top: 10px">
|
||||
<label class="layui-form-label" style="width: 100px">用户名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="changename" name="name" lay-verify="title" autocomplete="off"
|
||||
placeholder="请输入姓名"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="display: flex;margin-top: 10px">
|
||||
<label class="layui-form-label" style="width: 100px">籍贯</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="changenative" name="native" placeholder="请输入籍贯" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" id="update_info">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 确认删除?-->
|
||||
<div class="modal" tabindex="-1" id="staticBackdropRemove">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">确认删除该用户信息?</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" id="Remove">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 添加用户-->
|
||||
<div class="modal" tabindex="-1" id="staticBackdropAdd">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">确认添加该用户信息?</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="layui-form-item" style="display: flex;margin-top: 10px">
|
||||
<label class="layui-form-label" style="width: 100px">学号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="add_sid" name="add_sid" lay-verify="title" autocomplete="off"
|
||||
placeholder="请输入学号"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="display: flex;margin-top: 10px">
|
||||
<label class="layui-form-label" style="width: 100px">用户名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="add_name" name="add_name" lay-verify="title" autocomplete="off"
|
||||
placeholder="请输入姓名"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="display: flex;margin-top: 10px">
|
||||
<label class="layui-form-label" style="width: 100px">籍贯</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="add_native" name="add_native" placeholder="请输入籍贯" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary " id="addStudent">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -83,36 +207,153 @@
|
||||
|
||||
|
||||
<script>
|
||||
{#添加学生#}
|
||||
var deleteSid;
|
||||
var updateSid;
|
||||
$("#addStudent").click(function () {
|
||||
ajax('/add_stu', {username:$("#add_name").val(),native: $("#add_native").val(),usid:$("#add_sid").val()}, function (data){
|
||||
console.log(data)
|
||||
window.location.href = '/'
|
||||
})
|
||||
})
|
||||
|
||||
//修改学生信息
|
||||
let updatenoteList = document.querySelectorAll(".updateStd")
|
||||
console.log(updatenoteList,"222")
|
||||
for(let i = 0; i < updatenoteList.length; i++){
|
||||
updatenoteList[i].addEventListener("click",function () {
|
||||
updateSid = this.getAttribute("value")
|
||||
updateSid = updateSid.slice(2, -3)
|
||||
console.log(updateSid)
|
||||
})
|
||||
}
|
||||
|
||||
$("#update_info").click(function () {
|
||||
console.log($("#changenative").val(), $("#changename").val())
|
||||
ajax('/update_stu',{name:$("#changename").val(),native: $("#changenative").val(),sid:updateSid}, function (){
|
||||
window.location.href = '/'
|
||||
console.log(data)
|
||||
})
|
||||
|
||||
var myModal = $("#staticBackdrop")
|
||||
myModal.hide()
|
||||
})
|
||||
|
||||
|
||||
//删除
|
||||
let noteList = document.querySelectorAll(".remove")
|
||||
for(let i = 0; i < noteList.length; i++){
|
||||
noteList[i].addEventListener("click", function () {
|
||||
deleteSid = this.getAttribute("value")
|
||||
deleteSid = deleteSid.slice(2, -3)
|
||||
})
|
||||
}
|
||||
|
||||
$("#Remove").click(function () {
|
||||
ajax('/remove_stu',{sid:deleteSid}, function (data){
|
||||
console.log(data)
|
||||
window.location.href = '/'
|
||||
})
|
||||
var myModal = $("#staticBackdropRemove")
|
||||
myModal.hide()
|
||||
})
|
||||
|
||||
|
||||
// function $(s) {
|
||||
// return document.getElementById(s)
|
||||
// }
|
||||
|
||||
$(function () {
|
||||
let tr = $('#col').append('<tr></tr>')
|
||||
tr.append('<th>1</th>')
|
||||
tr.append('<td>{{info.sid}}</td>')
|
||||
tr.append('<td>{{info.name}}</td>')
|
||||
tr.append('<td>{{info.native}}</td>')
|
||||
tr.append('<td></td>').append("<button type=\"button\" class=\"btn btn-outline-dark btn-sm\">update</button>\n  " +
|
||||
"<button type=\"button\" class=\"btn btn-outline-danger btn-sm\">remove</button>")
|
||||
})
|
||||
//$(function () {
|
||||
// let tr = $('#col').append('<tr id=\"user\"></tr>')
|
||||
// tr.append('<th>1</th>')
|
||||
// tr.append('<td>{{info.sid}}</td>')
|
||||
// tr.append('<td>{{info.name}}</td>')
|
||||
// tr.append('<td>{{info.native}}</td>')
|
||||
// tr.append('<td></td>').append("<button type=\"button\" class=\"btn btn-outline-dark btn-sm\" data-bs-toggle=\"modal\" data-bs-target=\"#staticBackdrop\">update</button>\n  " +
|
||||
// "<button type=\"button\" class=\"btn btn-outline-danger btn-sm\" id=\"remove\" onclick=\'user(`${info.sid`})\'>remove</button>")
|
||||
//})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
//搜索
|
||||
let searchType = 0;
|
||||
var search;
|
||||
$("#search_btn").click(function () {
|
||||
let search = $("#search_input").val()
|
||||
ajax('/search',search)
|
||||
search = $("#search_input").val()
|
||||
if (searchType === 0) {
|
||||
$.ajax({
|
||||
url: '/searchBySid/' + search,
|
||||
type: 'post',
|
||||
success: function (data) {
|
||||
if (data === 'False') {
|
||||
alert('该用户不存在!')
|
||||
} else {
|
||||
window.location.href = "/searchBySid/" + search
|
||||
}
|
||||
}
|
||||
})
|
||||
} else if (searchType === 1) {
|
||||
|
||||
$.ajax({
|
||||
url: '/searchByName/' + search,
|
||||
type: 'post',
|
||||
success: function (data) {
|
||||
if (data === 'False') {
|
||||
alert('该用户不存在!')
|
||||
} else {
|
||||
window.location.href = "/searchByName/" + search
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
|
||||
$.ajax({
|
||||
url: '/searchByNative/' + search,
|
||||
type: 'post',
|
||||
success: function (data) {
|
||||
if (data === 'False') {
|
||||
alert('该用户不存在!')
|
||||
} else {
|
||||
window.location.href = "/searchByNative/" + search
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function ajax(url,data) {
|
||||
function ajax(url, data, fun) {
|
||||
$.ajax({
|
||||
url: url + '/' + data,
|
||||
type:'post',
|
||||
success:function (data){
|
||||
console.log(data)
|
||||
}
|
||||
url: url,
|
||||
type: 'post',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: fun
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 添加
|
||||
{#$("#addStudent").click(function (){#}
|
||||
{# let sid = $("#add_sid").val()#}
|
||||
{# let name = $("#add_name").val()#}
|
||||
{# let native = $("#add_native").val()#}
|
||||
{# let stu_info = {#}
|
||||
{# "sid" : sid,#}
|
||||
{# "name" : name,#}
|
||||
{# "native" : native#}
|
||||
{# }#}
|
||||
{# ajax("/add_stu", stu_info, function (data){#}
|
||||
{# console.log(data)#}
|
||||
{# layui.img(data)#}
|
||||
{# location.href = '/'#}
|
||||
{# })#}
|
||||
// })
|
||||
|
||||
</script>
|
||||
|
||||
|
74
com/native/gui/templates/login.html
Normal file
74
com/native/gui/templates/login.html
Normal file
@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<link rel="stylesheet" href="../static/css/layui.css">
|
||||
</head>
|
||||
<body>
|
||||
<div style="width: 500px;height: 400px;margin: 200px auto;">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">用户名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="username" name="username" lay-verify="title" autocomplete="off" placeholder="请输入用户名"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码框</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" id="password" name="password" placeholder="请输入密码" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<input type="button" id="btn" class="layui-btn" lay-submit lay-filter="fromDemo" value="提交"/>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script src="../static/layui.js"></script>
|
||||
<script>
|
||||
$("#btn").click(function () {
|
||||
ajax('/checklogin', {username: $("#username").val(), password: $("#password").val()},
|
||||
function (data) {
|
||||
window.location.href = '/'
|
||||
})
|
||||
})
|
||||
|
||||
function ajax(url, data, fun) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'post',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
console.log(data, "111")
|
||||
if(data.code===500){
|
||||
alert(data.msg)
|
||||
}else {
|
||||
window.location.href = '/'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
layui.use('form', function () {
|
||||
var form = layui.form
|
||||
|
||||
//监听提交
|
||||
form.on('submit(fromDemo)', function (data) {
|
||||
{#layer.msg(messages)#}
|
||||
//可以发送动态请求
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
198
com/native/gui/templates/search.html
Normal file
198
com/native/gui/templates/search.html
Normal file
@ -0,0 +1,198 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<!-- 引入样式 -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="row align-items-start" style="margin-top: 30px">
|
||||
<h3 style="margin: 0 auto;width: 20%">搜索结果</h3>
|
||||
|
||||
|
||||
<button type="button" class="btn btn-primary" style="width: 150px" id="goback">返回学生列表</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row align-items-start" style="padding:20px">
|
||||
<div class="col">
|
||||
<div class="col">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">sid</th>
|
||||
<th scope="col">name</th>
|
||||
<th scope="col">native</th>
|
||||
<th scope="col">operation</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="col">
|
||||
|
||||
|
||||
{% for item in info %}
|
||||
<tr id="user">
|
||||
<th scope="col">{{ item.sid }}</th>
|
||||
<th scope="col">{{ item.name }}</th>
|
||||
<th scope="col">{{ item.native }}</th>
|
||||
<th scope="col">
|
||||
<button type="button" class="btn btn-outline-dark btn-sm updateStd" data-bs-toggle="modal" value="{{ item.sid }}"
|
||||
data-bs-target="#staticBackdrop">update
|
||||
</button>
|
||||
<button type="button" class="btn btn-outline-danger btn-sm remove" value="{{ item.sid }}" data-bs-toggle="modal"
|
||||
data-bs-target="#staticBackdropRemove">
|
||||
remove
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- 修改信息-->
|
||||
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
|
||||
aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="staticBackdropLabel">修改学生户籍信息</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="layui-form-item" style="display: flex">
|
||||
<label class="layui-form-label" style="width: 100px;margin-top: 10px">用户名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="changename" name="name" lay-verify="title" autocomplete="off"
|
||||
placeholder="请输入姓名"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" style="display: flex;margin-top: 10px">
|
||||
<label class="layui-form-label" style="width: 100px">籍贯</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="changenative" name="native" placeholder="请输入籍贯" autocomplete="off"
|
||||
class="layui-input"
|
||||
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" id="update">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 确认删除?-->
|
||||
<div class="modal" tabindex="-1" id="staticBackdropRemove">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">确认删除该用户信息?</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" id="Remove">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!-- 引入组件库 -->
|
||||
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
|
||||
<script>
|
||||
var deleteSid;
|
||||
var updateSid;
|
||||
//返回学生列表
|
||||
$("#goback").click(function () {
|
||||
window.location.href = '/'
|
||||
})
|
||||
|
||||
|
||||
//修改学生信息
|
||||
let updatenoteList = document.querySelectorAll(".updateStd")
|
||||
console.log(updatenoteList,"222")
|
||||
for(let i = 0; i < updatenoteList.length; i++){
|
||||
updatenoteList[i].addEventListener("click",function () {
|
||||
updateSid = this.getAttribute("value")
|
||||
updateSid = updateSid.slice(2, -3)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
$("#update").click(function () {
|
||||
ajax('/update',{username:$("#changename").val(),native: $("#changenative").val(),usid:updateSid})
|
||||
|
||||
window.location.href = '/searchBySid'+'/'+updateSid
|
||||
var myModal = $("#staticBackdrop")
|
||||
myModal.hide()
|
||||
})
|
||||
|
||||
|
||||
//删除
|
||||
let noteList = document.querySelectorAll(".remove")
|
||||
for(let i = 0; i < noteList.length; i++){
|
||||
noteList[i].addEventListener("click",function () {
|
||||
deleteSid = this.getAttribute("value")
|
||||
deleteSid = deleteSid.slice(2, -3)
|
||||
})
|
||||
}
|
||||
|
||||
$("#Remove").click(function () {
|
||||
ajax('/delete',{sid:deleteSid})
|
||||
|
||||
window.location.href = '/'
|
||||
var myModal = $("#staticBackdropRemove")
|
||||
myModal.hide()
|
||||
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
function ajax(url, data, fun) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'post',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
console.log(data, "111")
|
||||
if(data.code===500){
|
||||
|
||||
}else {
|
||||
window.location.href = '/'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
@ -4,11 +4,17 @@
|
||||
# version: 1.0
|
||||
###########################################################################################
|
||||
|
||||
from flask import Flask, render_template
|
||||
from flask import Flask
|
||||
import com.native.gui
|
||||
from gevent import pywsgi
|
||||
|
||||
app = com.native.gui.app
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
server = pywsgi.WSGIServer(('0.0.0.0', 5000), app)
|
||||
|
||||
server.serve_forever()
|
||||
|
||||
app.run()
|
||||
|
@ -21,10 +21,15 @@ config_indexes.read(path_indexes, encoding="utf-8")
|
||||
config_name_sid.read(path_name_sid, encoding="utf-8")
|
||||
|
||||
|
||||
def queryAllInfo():
|
||||
values = config.sections()
|
||||
return values
|
||||
|
||||
|
||||
def queryInfoBySid(sid):
|
||||
try:
|
||||
value = config.items(sid)
|
||||
print(f"[sid:{sid}] :", value)
|
||||
# print(f"[sid:{sid}] :", value)
|
||||
except:
|
||||
print(f"sid【{sid}】不存在")
|
||||
return False
|
||||
@ -32,22 +37,37 @@ def queryInfoBySid(sid):
|
||||
|
||||
|
||||
def queryInfoByName(name):
|
||||
sid_indexs = config_name_sid.get("name_sid", name)
|
||||
sid_list = sid_indexs.split(",")
|
||||
|
||||
stu_list = {}
|
||||
for i, sid in enumerate(sid_list):
|
||||
sid_info = config.items(sid)
|
||||
print(f"[{name}][s] -> {sid_info}")
|
||||
stu_list[i-1] = sid_info
|
||||
return stu_list
|
||||
try:
|
||||
sid_indexs = config_name_sid.get("name_sid", name)
|
||||
sid_list = sid_indexs.split(",")
|
||||
stu_list = []
|
||||
for i, sid in enumerate(sid_list):
|
||||
if sid == "":
|
||||
continue
|
||||
sid_info = config.items(sid)
|
||||
print(f"[{name}][s] -> {sid_info}")
|
||||
# stu_list[i - 1] = sid_info
|
||||
stu_list.append(sid_info)
|
||||
return stu_list
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def queryAllInfoByNative(native):
|
||||
sid_index = config_indexes.get(native, "sid_index")
|
||||
sid_list = sid_index.split(",")
|
||||
for sid in sid_list:
|
||||
print(f"native[{native}] ---> {config.items(sid)}")
|
||||
try:
|
||||
sid_index = config_indexes.get(native, "sid_index")
|
||||
sid_list = sid_index.split(",")
|
||||
stu_list = []
|
||||
for i,sid in enumerate(sid_list):
|
||||
if sid == "":
|
||||
continue
|
||||
sid_info = config.items(sid)
|
||||
stu_list.append(sid_info)
|
||||
# print(f"native[{native}] ---> {config.items(sid)}")
|
||||
return stu_list
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def updeteStu(student):
|
||||
@ -146,3 +166,4 @@ def delete(key):
|
||||
config_name_sid.write(open(path_name_sid, 'w+', encoding="utf-8")) # 将修改写入到配置文件
|
||||
print(f'sid:{key}【已删除】')
|
||||
return True
|
||||
|
||||
|
18
com/native/view/info.py
Normal file
18
com/native/view/info.py
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
class Info:
|
||||
def __init__(self):
|
||||
self.sid = None
|
||||
self.name = None
|
||||
self.native = None
|
||||
|
||||
def string(self,native,name,sid):
|
||||
self.sid = sid,
|
||||
self.name = name,
|
||||
self.native = native,
|
||||
return {
|
||||
'sid':self.sid,
|
||||
'name':self.name,
|
||||
'native':self.native,
|
||||
}
|
||||
|
12
com/native/view/msg.py
Normal file
12
com/native/view/msg.py
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
|
||||
class Msg:
|
||||
def __init__(self):
|
||||
self.code = None
|
||||
self.msg=None
|
||||
|
||||
def string(self,code,msg):
|
||||
self.code = code
|
||||
self.msg = msg
|
||||
return {'code':self.code, 'msg':self.msg}
|
@ -1,4 +1,5 @@
|
||||
[name_sid]
|
||||
某某 = 22100917,22100918,
|
||||
某某某 = 22100919
|
||||
赵四 = 222222,2,
|
||||
张三 = 22100991
|
||||
|
||||
|
@ -1,8 +1,3 @@
|
||||
[22100917]
|
||||
sid = 22100917
|
||||
name = 某某
|
||||
native = 黑龙省
|
||||
|
||||
[22100918]
|
||||
sid = 22100918
|
||||
name = 某某
|
||||
@ -13,3 +8,13 @@ sid = 22100919
|
||||
name = 某某某
|
||||
native = 黑龙省
|
||||
|
||||
[2]
|
||||
sid = 2
|
||||
name = 赵四
|
||||
native = 天津
|
||||
|
||||
[22100991]
|
||||
sid = 22100991
|
||||
name = 张三
|
||||
native = 黑龙江省哈尔滨市
|
||||
|
||||
|
@ -1,3 +1,27 @@
|
||||
[黑龙省]
|
||||
sid_index = 22100917,22100918,22100919,
|
||||
sid_index = 22100918,22100919,,
|
||||
|
||||
[1]
|
||||
sid_index = ,,,,,
|
||||
|
||||
[2]
|
||||
sid_index = ,
|
||||
|
||||
[上海]
|
||||
sid_index = ,
|
||||
|
||||
[天津]
|
||||
sid_index = ,2,
|
||||
|
||||
[黑龙江省哈尔滨市]
|
||||
sid_index = 22100991,,
|
||||
|
||||
[hk]
|
||||
sid_index = ,
|
||||
|
||||
[njmj,m]
|
||||
sid_index = ,
|
||||
|
||||
[yjyj]
|
||||
sid_index = ,
|
||||
|
||||
|
2
resources/user.ini
Normal file
2
resources/user.ini
Normal file
@ -0,0 +1,2 @@
|
||||
[user]
|
||||
admin=123456
|
Loading…
x
Reference in New Issue
Block a user