first commit

master
xiaofeng 5 years ago
commit 1e583b0fcf

@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>修改</title>
<link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<div class="layui-main">
<div class="site-content">
<br><br>
<h1 class="site-h1">修改信息</h1>
<br><br>
<form class="layui-form" action="alter" method="post">
<input type="hidden" name = 'donor_code' value="{{donor.donor_code}}">
<div class="layui-form-item">
<label class="layui-form-label">金额</label>
<div class="layui-input-block">
<input type="text" name="amount" required lay-verify="required" placeholder="请输入金额"
autocomplete="off"
class="layui-input" value="{{donor.amount}}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">物流</label>
<div class="layui-input-block">
<input type="text" name="trans" required lay-verify="required" placeholder="请输入物流情况" autocomplete="off"
class="layui-input" value="{{donor.trans}}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日期</label>
<div class="layui-input-block">
<input type="text" name="date" required lay-verify="required" placeholder="请输入日期"
autocomplete="off"
class="layui-input" value="{{donor.date}}">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
</div>
</div>
<script src="/static/layui/layui.js"></script>
<script>
//Demo
layui.use('form', function () {
var form = layui.form;
});
</script>
</body>
</html>

110
app.py

@ -0,0 +1,110 @@
from flask import Flask,render_template,request,redirect
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy(app)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:@127.0.0.1:3306/epidemic2'
class Donor(db.Model):
donor_code = db.Column(db.String(255),primary_key=True)
donor_name = db.Column(db.String(255))
type1 = db.Column(db.String(255))
ded_name = db.Column(db.String(255))
ded_code = db.Column(db.String(255))
amount = db.Column(db.Integer)
date = db.Column(db.String(255))
trans = db.Column(db.String(255))
db.create_all()
@app.route("/select")
def selectAll():
donorList = Donor.query.all()
return render_template("index.html", donor_list=donorList)
@app.route('/')
def index():
return selectAll()
# 添加数据
@app.route('/insert', methods=['GET', 'POST'])
def insert():
# 进行添加操作
donor_code = request.form['donor_code']
donor_name = request.form['donor_name']
type1 = request.form['type1']
ded_name = request.form['ded_name']
ded_code = request.form['ded_code']
amount = request.form['amount']
date = request.form['date']
trans = request.form['trans']
donor = Donor(donor_code=donor_code, donor_name=donor_name, type1=type1, ded_name=ded_name, ded_code=ded_code, amount= amount, date=date, trans=trans)
db.session.add(donor)
db.session.commit()
# 添加完成重定向至主页
return redirect('/')
@app.route("/insert_page")
def insert_page():
# 跳转至添加信息页面
return render_template("insert.html")
# 删除数据
@app.route("/delete", methods=['GET'])
def delete():
# 操作数据库得到目标数据before_number表示删除之前的数量after_name表示删除之后的数量
donor_code = request.args.get("donor_code")
donor = Donor.query.filter_by(donor_code=donor_code).first()
db.session.delete(donor)
db.session.commit()
return redirect('/')
# 修改操作
@app.route("/alter", methods=['GET', 'POST'])
def alter():
# 可以通过请求方式来改变处理该请求的具体操作
# 比如用户访问/alter页面 如果通过GET请求则返回修改页面 如果通过POST请求则使用修改操作
if request.method == 'GET':
donor_code = request.args.get("donor_code")
donor_name = request.args.get("donor_name")
type1 = request.args.get("type1")
ded_name = request.args.get("ded_name")
ded_code = request.args.get("ded_code")
amount = request.args.get("amount")
date = request.args.get("date")
trans = request.args.get("trans")
donor = Donor(donor_code=donor_code, donor_name=donor_name, type1=type1, ded_name=ded_name,ded_code=ded_code,
amount=amount, date=date, trans=trans)
return render_template("alter.html", donor=donor)
else:
donor_code = request.form["donor_code"]
donor_name = request.form['donor_name']
type1 = request.form['type1']
ded_name = request.form['ded_name']
ded_code = request.form['ded_code']
amount = request.form['amount ']
date = request.form['date']
trans = request.form['trans']
donor = Donor.query.filter_by(donor_code=donor_code).first()
donor.donor_name = donor_name
donor.type1 = type1
donor.ded_name = ded_name
donor.ded_code = ded_code
donor.amount = amount
donor.date = date
donor.trans = trans
db.session.commit()
return redirect('/')
if __name__ == "__main__":
app.run(debug=True)

@ -0,0 +1,140 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="refresh" content="3;http://127.0.0.1:5000">
<title>Animated Login Form</title>
<style>
body {
margin: 0px;
padding: 0px;
font-family: montserrat;
background: linear-gradient(120deg, #2980b9, #8e44ad);
height: 100vh;
overflow: hidden;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 400px;
background: white;
border-radius: 10px;
}
.center h1 {
text-align: center;
padding: 0 0 20px 0;
border-bottom: 1px solid silver;
}
.center form {
padding: 0 40px;
box-sizing: border-box;
}
form .txt_field {
position: relative;
border-bottom: 2px solid #adadad;
margin: 30px 0;
}
.txt_field input {
width: 100%;
padding: 0 5px;
height: 40px;
font-size: 16px;
border: none;
background: none;
outline: none;
}
.txt_field label {
position: absolute;
top: 50%;
left: 5px;
color: #adadad;
transform: translateY(-50%);
font-size: 16px;
pointer-events: none;
transition: .5s;
}
.txt_field span::before {
content: "";
position: absolute;
top: 40px;
left: 0;
width: 0%;
height: 2px;
background: #2691d9;
transition: .5s;
}
.txt_field input:focus ~ label,
.txt_field input:valid ~ label {
top: -5px;
color: #2691d9;
}
.txt_field input:focus ~ span::before,
.txt_field input:valid ~ span::before {
width: 100%;
}
.pass {
margin: -5px 0 20px 5px;
color: #a6a6a6;
cursor: pointer;
}
.pass:hover {
text-decoration: underline;
}
input[type="submit"] {
width: 100%;
height: 50px;
border: 1px solid;
background: #2691d9;
border-radius: 25px;
font-size: 18px;
color: #e9f4fb;
font-weight: 700;
cursor: pointer;
outline: none;
}
input[type="submit"]:hover {
border-color: #2691d9;
transition: .5s;
}
.signup_link {
margin: 30px 0;
text-align: center;
font-size: 16px;
color: #666666;
}
.signup_link a {
color: #2691d9;
text-decoration: none;
}
.signup_link a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="center">
<h1>Login</h1>
<form action="" method="POST">
<div class="txt_field">
<input type="text" required>
<label for="">Username</label>
</div>
<div class="txt_field">
<input type="password" required>
<label for="">Password</label>
</div>
<div class="pass">Forget Password</div>
<input type="submit" name="" id="" value="login">
<div class="login">
<a href="http://127.0.0.1:5000/">login</a>
</div>
<div class="signup_link">
Not a member?<a href="#">Signup</a>
</div>
</form>
</div>
</body>
</html>

@ -0,0 +1,77 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>首页</title>
<link rel="stylesheet" href="/static/layui/css/layui.css"> </head>
<body>
<div align="center"> <br>
<a href="insert_page"><font color="red"><b><i><u><font size="6">添加情况</font></u></i></b></font></a> <br>
<br>
<table id = 'tabledemo'lay-filter="test">
<thead>
<tr>
<th lay-data="{field:'donor_code', width:100}">捐赠方代码</th>
<th lay-data="{field:'donor_name', width:100}">捐赠方名字</th>
<th lay-data="{field:'type1', width:100}">捐赠方类型</th>
<th lay-data="{field:'ded_code', width:100}">被赠方代码</th>
<th lay-data="{field:'ded_name', width:100}">被赠方名字</th>
<th lay-data="{field:'amount', width:100}">金额</th>
<th lay-data="{field:'date', width:100}">日期</th>
<th lay-data="{field:'trans', width:100}">物流</th>
<th lay-data="{fixed: 'right', width: 165, align:'center', toolbar: '#barDemo'}"></th>
</tr>
</thead>
<tbody>
{% for item in donor_list %}
<tr>
<td>{{ item.donor_code }}</td>
<td>{{ item.donor_name }}</td>
<td>{{ item.type1 }}</td>
<td>{{ item.ded_code }}</td>
<td>{{ item.ded_name }}</td>
<td>{{ item.amount }}</td>
<td>{{ item.date }}</td>
<td>{{ item.trans }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script src="/static/layui/layui.js"></script>
<script>
layui.use('table', function () {
var table = layui.table;
//转换静态表格
table.init('test', {
height: 1000,
width: 1500//设置高度
,limit:100
});
table.on('tool(test)', function(obj){ //注tool 是工具条事件名test 是 table原始容器的属性 lay-filter="对应的值"
var data = obj.data ,layEvent = obj.event; //获得 lay-event 对应的值
if(layEvent === 'detail'){
layer.msg('查看操作');
} else if(layEvent === 'del'){ layer.confirm('真的删除行么', function(index){
location.href='/delete?id='+data.id; });
} else if(layEvent === 'edit'){
location.href='/alter?id=' + data.id + "&donor_code=" +data.donor_code + "&donor_name=" + data.donor_name + "&type=" + data.type+ "&ded_name=" + data.ded_name+ "&ded_code=" +data.ded_code+ "&amount=" +data.amount+ "&trans=" +data.trans;
}
});
});
</script>
</body>
</html>

@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>增加</title>
<link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<div class="layui-main">
<div class="site-content">
<br><br>
<h1 class="site-h1">添加信息</h1>
<br><br>
<form class="layui-form" action="insert" method="post">
<div class="layui-form-item">
<label class="layui-form-label">捐赠方代码</label>
<div class="layui-input-block">
<input type="text" name="donor_code" required lay-verify="required" placeholder="请输入捐赠方代码" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">捐赠方名字</label>
<div class="layui-input-block">
<input type="text" name="donor_name" required lay-verify="required" placeholder="请输入捐赠方姓名" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">捐赠方类型</label>
<div class="layui-input-block">
<input type="text" name="type1" required lay-verify="required" placeholder="请输入捐赠方类型" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">受赠方代码</label>
<div class="layui-input-block">
<input type="text" name="ded_code" required lay-verify="required" placeholder="请输入受赠方代码" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">受赠方名字</label>
<div class="layui-input-block">
<input type="text" name="ded_name" required lay-verify="required" placeholder="请输入受赠方名字" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">金额</label>
<div class="layui-input-block">
<input type="text" name="amount" required lay-verify="required" placeholder="请输入金额" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">日期</label>
<div class="layui-input-block">
<input type="text" name="date" required lay-verify="required" placeholder="请输入日期" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">物流</label>
<div class="layui-input-block">
<input type="text" name="trans" required lay-verify="required" placeholder="请输入物流" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
</div>
</div>
<script src="/static/layui/layui.js"></script>
<script>
layui.use('form', function () {
var form = layui.form;
});
</script>
</body>
</html>

@ -0,0 +1,66 @@
@charset "utf-8";
body
{
background:url("壁纸01.jpg");
background-repeat:no-repeat;
background-size: 100% auto;
}
#login_box
{
width:200;
height:400px;
background:#00000060;
margin:auto;
margin-top:10%;
text-align:center;
border-radius: 10px;
padding:50px 50px;
}
#login_box h2
{
color:#FFFFFF90;
margin-top:5%;
}
#login_box #form #input_box
{
margin-top: 5%;
}
#login_box #form #input_box i
{
color:#FFFFFF;
}
#login_box #form #input_box input
{
border:0;
width:60%;
font-size:15px;
color:#FFFFFF;
background:#FFFFFF00;
border-bottom: 2px solid #FFFFFF;
padding:5px 10px;
margin-top: 10px;
}
#login_box button
{
margin-top:50px;
width:40%;
height:20px;
border-radius: 10px;
border:0;
color:#FFFFFF;
font-size:15px;
background-image: linear-gradient(to right,#b8cbb8 0%,#b8cbb8 0%,#b465da 0%,#cf6cc9 33%,#ee689c 66%,#ee689c 100%);
}
#login_box #Sign
{
margin-top: 45%;
margin-right:50%;
}
#login_box #Sign a
{
color:#894648;
}

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LOGIN</title>
<link href="Login.css" rel="stylesheet" type="text/css"
</head>
<body>
<div id="login_box">
<h2>LOGIN</h2>
<div id="form">
<div id="input_box">
<i class="fas fa_user"></i>
<input type="text" placeholder="Username">
</div>
<div id="input_box">
<i class="fas fa-lock"></i>
<input type="password" placeholder="Password">
</div>
</div>
<button><a href="http://127.0.0.1:5000/">sign in</a></button>
</body>
</html>
<div id="input_box">
<i class="fas fa-lock"></i>

@ -0,0 +1,106 @@
body{
margin:0;
padding:0;
font-family:montserrat;
background:linear-gradient(120deg,#2980b9,#8e44ad);
height: 100vh;
overflow:hidden;
}
.center{
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
width:400px;
background:white;
border-radius:10px;
}
.center h1{
text-align:center;
padding:0 0 20px 0;
boder-bottom:1px solid silver;
}
.center form{
padding:0 40px;
box-sizing:border-box;
}
form.txt_field{
position:relative;
boder-bottom:2px solid #adadad;
margin:30px 0;
}
.txt_field input{
width.100%;
padding:0 5px;
height:40px;
font-size:16px;
border:none;
background:none;
outline:none;
}
.txt_field label{
position:absolute;
top:50%;
left:5px;
color:#adadad;
transform:translateY(-50%);
font-size:16px;
pointer-events:none;
transition:.5s;
}
.txt_field span::before{
content:'';
position:absolute;
top:40px;
left:0;
width:0%;
height:2px;
background: #2691d9;
transition: .5s;
}
.txt_field input:focus ~ label,
.txt_field input:valid ~ label{
top: -5px;
color: #2691d9;
}
.txt_field input:focus ~ span::before,
.txt_field input:valid ~ span::before{
width:100%;
}
.pass{
margin: -5px 0 20pc 5px;
color:#a6a6a6;
cursor:pointer;
}
.pass:hover{
text-decoration:underline;
}
input[type="submit"]{
width: 100%;
height:50px;
border:1px solid;
background: #2691d9;
border-radius: 25px;
font-size:18px;
color:#e9f4fb;
font-weight: 700;
cursor:pointer;
outline:none;
}
input[type="submit"]:hover{
border-color:#2691d9;
transition: ,5s;
}
.signup_link{
margin:30px 0;
text-align:center;
font-size:16px;
color:#666666;
}
.signup_link a{
color:#2691d9;
text-decoration:none;
}
.signup_link a:hover{
text-decoration: underline;
}
Loading…
Cancel
Save