学员管理

//有表单验证,

表格格式 ,

启动项,

回馈,

增删改查。

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Document</title>

<link rel="stylesheet" href="bootstrap/css/bootstrap.css">

<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">

<link href="bootstrap/css/dashboard.css" rel="stylesheet">

<link rel="stylesheet" href="index.css">

<!--第一个时间插件-->

<!--<link rel="stylesheet" href="src/bootstrapDatepickr-1.0.0.css">-->

<!--第二个时间插件-->

<link rel="stylesheet" href="bootstrap-datetimepicker.css">

<!--时间插件-->

<style>

.wen{

/* white-space: pre-wrap;*/

margin-left: 280px;

}

</style>

</head>

<body>

<!--top-->

<div class="top">

<div class="container">

<span>学员信息管理</span>

<div class="picture">

<div class="dropdown">

<button id="dLabel" class="tx" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

</button>

<ul class="dropdown-menu" aria-labelledby="dLabel">

<li>个人资料</li>

<li>修改密码</li>

<li>退出登录</li>

</ul>

</div>

</div>

</div>

</div>

<!--下边的整体-->

<div class="bottom">

<!--left-->

<div>

<!--左边的标签页-->

<!-- Nav tabs -->

<div class="left1 col-sm-3 col-md-2 sidebar">

<ul class="nav nav-tabs" role="tablist">

<li role="presentation" class="active aaaaa"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Boos管理</a></li>

<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">学院管理</a></li>

<li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">个人资料</a></li>

</ul>

</div>

<!-- Tab panes -->

<div class="tab-content clearfix">

<div role="tabpanel" class="tab-pane active" id="home">

<!--插入右边的模块-->

<!--左一-->

<!--right-->

<div class="right1 col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">

<!--右边的上边的导航栏-->

<div class="right-top shrink beyong-hidden">

<span>学员管理 / 班级管理</span>

<!--注释掉的是按钮形式的-添加班级-->

<!-- <button style="color: white;float:right;" class="btn append" type="submit">添加班级</button> -->

<!--添加班级bootstrap-->

<!-- Button trigger modal -->

<button type="button" class="btn btn-primary btn-lg append" data-toggle="modal" data-target="#myModal">添加班级 </button>

<!-- <button type="button" class="btn btn-primary btn-lg refresh">刷新 </button> -->

<!-- Modal -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">

<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">&times;</span></button>

<h4 class="modal-title append-class-color" id="myModalLabel">添加班级</h4>

</div>

<div class="modal-body">

<form class="form-horizontal">

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">班级名称</label>

<div class="col-sm-10 modal-con">

<input type="email" class="form-control modal-con banjimingcheng" id="inputEmail3" placeholder="" value="">

</div>

</div>

<!--下拉列表-->

<div class="form-group">

<label for="studyobject" class="col-sm-2 control-label modal-body">学习科目</label>

<div class="col-sm-10 modal-con">

<select class="form-control modal-con" id="studyobject">

<option>HTML</option>

<hr>

<option>CSS</option>

<option>Javascript</option>

<option>PhotoShop</option>

<option>seperate word</option>

</select>

</div>

</div>

<!--入学时间-->

<div class="form-group">

<label for="updatetime" class="col-sm-2 control-label modal-body">入学时间</label>

<div class="col-sm-10 modal-con">

<!--<input type="email" class="form-control modal-con" id="inputEmail3" placeholder="">-->

<!--time第一次引用的时间插件-->

<div class="form-group">

<!--<div class="col-md-4">

<div class="input-group">

<span class="input-group-addon rili" id="basic-addon1"><i class="fa fa-calendar"></i></span>

<input type="text" id="calendar" placeholder="27/07/2017" class="form-control timewidth" Readonly>

</div>

</div>-->

<!--第二次引用的时间插件-->

<div class=‘input-group date‘ id=‘datetimepicker1‘>

<input type=‘text‘ class="form-control" id="updatetime" />

<span class="input-group-addon">

<span class="glyphicon glyphicon-calendar"></span>

</span>

</div>

<!--第二次引用的时间插件-->

</div>

<!--time-->

</div>

</div>

<!--学员人数-->

<div class="form-group">

<label for="xxx" class="col-sm-2 control-label modal-body">学员人数</label>

<div class="col-sm-10 modal-con">

<input type="email" class="form-control modal-con xueyuanrenshu" id="xxx" placeholder="" value="">

</div>

</div>

<!--班主任-->

<div class="form-group">

<label for="banzhuren" class="col-sm-2 control-label modal-body">班主任</label>

<div class="col-sm-10 modal-con">

<select class="form-control modal-con" id="banzhuren">

<option>杨老师</option>

<option>杨老师2</option>

<option>杨老师3</option>

<option>杨老师4</option>

<option>杨老师5</option>

</select>

</div>

</div>

<!--班级介绍-->

<div class="form-group">

<label for="banjijieshao" class="col-sm-2 control-label modal-body">班级介绍</label>

<div class="col-sm-10 modal-con">

<textarea class="form-control " rows="3" id="banjijieshao"></textarea>

<!--<input type="email" class="form-control modal-con" id="inputEmail3" placeholder="">-->

</div>

</div>

</form>

<!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-->

</div>

<div class="modal-footer">

<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>

<button type="button" class="btn btn-primary preserve" onclick="save_data(this)">保存</button>

</div>

</div>

</div>

</div>

<!--往上添加班级bootstrap-->

</div>

<!--添加的表格bootstrap-->

<div class="table-responsive shrink tbackground">

<table class="table table-bordered table-hover table-striped success tb">

<thead class="active">

<th>#</th>

<th>班级名称</th>

<th>学习科目</th>

<th>入学日期</th>

<th>学员人数</th>

<th>班主任</th>

<th>操作</th>

</thead>

<tbody class="tbodytbody">

<tr class="big" id="‘+(parseInt(this.parentNode.id)+1)+‘">

</tbody>

</table>

<!--表格下边的灰线-->

<div class="gray-line"></div>

<!--默认分页用bootstrap写的-->

<nav aria-label="Page navigation">

<ul class="pagination anniu">

<!-- <li><a href="javascript:;">1</a></li> -->

</ul>

</nav>

</div>

</div>

<!--左一-->

</div>

<div role="tabpanel" class="tab-pane" id="profile">

<!--左二-->

<!--right-->

<div class="right1 col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" id="zuoerbackground">

<!--右边的上边的导航栏-->

<div class="right-top shrink beyong-hidden">

<span>学员管理 / 班级管理</span>

<!--注释掉的是按钮形式的-添加班级-->

<!--<button style="color: white;float:right;" class="btn append" type="submit">添加班级</button>-->

<!--添加班级bootstrap-->

<!-- Button trigger modal -->

<button type="button" class="btn btn-primary btn-lg append" data-toggle="modal" data-target="#myModal">添加班级 </button>

<!-- Modal -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">

<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">&times;</span></button>

<h4 class="modal-title append-class-color" id="myModalLabel">添加班级</h4>

</div>

<div class="modal-body">

<form class="form-horizontal">

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">学院名称</label>

<div class="col-sm-10 modal-con">

<input type="email" class="form-control modal-con" id="inputEmail3" placeholder="">

</div>

</div>

<!--下拉列表-->

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">学院教程</label>

<div class="col-sm-10 modal-con">

<select class="form-control modal-con">

<option>H5</option>

<option></option>

<option>PS</option>

<option></option>

<option>VUE</option>

<option></option>

<option>PhotoShop</option>

<option></option>

<option>seperate word</option>

<option></option>

</select>

</div>

</div>

<!--入学时间-->

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">入学时间</label>

<div class="col-sm-10 modal-con">

<!--<input type="email" class="form-control modal-con" id="inputEmail3" placeholder="">-->

<!--time-->

<div class="form-group">

<div class="col-md-4">

<div class="input-group">

<span class="input-group-addon rili" id="basic-addon1"><i class="fa fa-calendar"></i></span>

<input type="text" id="calendar" placeholder="27/07/2017" class="form-control timewidth" Readonly>

</div>

</div>

</div>

<!--time-->

</div>

</div>

<!--学员人数-->

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">学员人数</label>

<div class="col-sm-10 modal-con">

<input type="email" class="form-control modal-con" id="inputEmail3" placeholder="">

</div>

</div>

<!--班主任-->

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">班主任</label>

<div class="col-sm-10 modal-con">

<select class="form-control modal-con">

<option>杨老师</option>

<option>杨老师2</option>

<option>杨老师3</option>

<option>杨老师4</option>

<option>杨老师5</option>

</select>

</div>

</div>

<!--班级介绍-->

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">班级介绍</label>

<div class="col-sm-10 modal-con">

<textarea class="form-control " rows="3"></textarea>

<!--<input type="email" class="form-control modal-con" id="inputEmail3" placeholder="">-->

</div>

</div>

</form>

___________________________________________________________

</div>

<div class="modal-footer">

<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>

<button type="button" class="btn btn-primary">保存</button>

</div>

</div>

</div>

</div>

<!--往上添加班级bootstrap-->

</div>

<!--添加的表格bootstrap-->

<div class="table-responsive shrink tbackground">

<table class="table table-bordered table-hover table-striped success tb">

<thead class="active">

<th>#</th>

<th>学院名称</th>

<th>教学大纲</th>

<th>学习时间</th>

<th>教师人数</th>

<th>任课教师</th>

<th>操作</th>

</thead>

<tbody>

<tr class="big">

<th id="1">1</th>

<td>百杉教育</td>

<td>Javascript</td>

<td>四个月</td>

<th>12</th>

<td>杨老师</td>

<td style="width: 160px">

<!--编辑-->

<!--编辑-->

<button style="margin-right:5px;color: white;" class="btn" type="submit">编辑</button>

<button style="margin-right:5px;color: white;" class="btn deletedelete" type="submit" onclick="remove_item(this)">删除</button>

</td>

</tr>

<tr>

<th id="2">2</th>

<td>百杉教育</td>

<td>PhotoShop</td>

<td>五个月</td>

<th>12</th>

<td>于老师</td>

<td style="width: 160px">

<!--编辑-->

<!--编辑-->

<button style="margin-right:5px;color: white;" class="btn" type="submit">编辑</button>

<button style="margin-right:5px;color: white;" class="btn" type="submit" onclick="remove_item(this)">删除</button></td>

</tr>

<tr>

<th id="3">3</th>

<td>百杉教育</td>

<td>css样式表</td>

<td>六个月</td>

<th>12</th>

<td>迟老师</td>

<td style="width: 160px">

<!--编辑-->

<!--编辑-->

<button style="margin-right:5px;color: white;" class="btn" type="submit">编辑</button>

<button style="margin-right:5px;color: white;" class="btn" type="submit" onclick="remove_item(this)">删除</button></td>

</tr>

<tr>

<th>4</th>

<td>百杉教育</td>

<td>VR</td>

<td>好多月</td>

<th>12</th>

<td>殷老师</td>

<td style="width: 160px">

<!--编辑-->

<button type="submit" class="btn" data-toggle="modal" data-target="#myModal"

style="margin-right:5px;color: white;">编辑</button>

<!-- Modal -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">

<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">&times;</span></button>

<h4 class="modal-title append-class-color" id="myModalLabel">添加班级</h4>

</div>

<div class="modal-body">

<form class="form-horizontal">

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">班级名称</label>

<div class="col-sm-10 modal-con">

<input type="email" class="form-control modal-con" id="inputEmail3" placeholder="">

</div>

</div>

<!--下拉列表-->

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">学习科目</label>

<div class="col-sm-10 modal-con">

<select class="form-control modal-con">

<option>HTML</option>

<option></option>

<option>CSS</option>

<option></option>

<option>Javascript</option>

<option></option>

<option>PhotoShop</option>

<option></option>

<option>seperate word</option>

<option></option>

</select>

</div>

</div>

<!--入学时间-->

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">入学时间</label>

<div class="col-sm-10 modal-con">

<!--<input type="email" class="form-control modal-con" id="inputEmail3" placeholder="">-->

<!--time-->

<div class="form-group">

<div class="col-md-4">

<div class="input-group">

<span class="input-group-addon rili" id="basic-addon1"><i class="fa fa-calendar"></i></span>

<input type="text" id="calendar" placeholder="27/07/2017" class="form-control timewidth" Readonly>

</div>

</div>

</div>

<!--time-->

</div>

</div>

<!--学员人数-->

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">学员人数</label>

<div class="col-sm-10 modal-con">

<input type="email" class="form-control modal-con" id="inputEmail3" placeholder="">

</div>

</div>

<!--班主任-->

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">班主任</label>

<div class="col-sm-10 modal-con">

<select class="form-control modal-con">

<option>杨老师</option>

<option>杨老师2</option>

<option>杨老师3</option>

<option>杨老师4</option>

<option>杨老师5</option>

</select>

</div>

</div>

<!--班级介绍-->

<div class="form-group">

<label for="inputEmail3" class="col-sm-2 control-label modal-body">班级介绍</label>

<div class="col-sm-10 modal-con">

<textarea class="form-control " rows="3"></textarea>

<!--<input type="email" class="form-control modal-con" id="inputEmail3" placeholder="">-->

</div>

</div>

</form>

<!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-->

</div>

<div class="modal-footer">

<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>

<button type="button" class="btn btn-primary">保存</button>

</div>

</div>

</div>

</div>

<!--编辑-->

<!--<button style="margin-right:5px;color: white;" class="btn" type="submit">编辑</button>-->

<button style="margin-right:5px;color: white;" class="btn" type="submit" onclick="remove_item(this)">删除</button></td>

</tr>

</tbody>

</table>

<!--表格下边的灰线-->

<div class="gray-line"></div>

<!--注释掉的是用button写的按钮-->

<!--按钮组-->

<!--

<div class="btn-group anniu" role="group" aria-label="...">

<div type="button" class="btn btn-default" role="group"><</div>

<div type="button" class="btn btn-default" role="group">1</div>

<div type="button" class="btn btn-default" role="group">2</div>

<div type="button" class="btn btn-default" role="group">3</div>

<div type="button" class="btn btn-default" role="group">></div>

</div>

</div>-->

<!--默认分页用bootstrap写的-->

<nav aria-label="Page navigation">

<ul class="pagination anniu">

<li>

<a href="#" aria-label="Previous">

<span aria-hidden="true">&laquo;</span>

</a>

</li>

<li><a href="#">1</a></li>

<li><a href="#">2</a></li>

<li><a href="#">3</a></li>

<li>

<a href="#" aria-label="Next">

<span aria-hidden="true">&raquo;</span>

</a>

</li>

</ul>

</nav>

</div>

</div>

<!--左二-->

</div>

<div role="tabpanel" class="tab-pane" id="messages">

</div>

<div role="tabpanel" class="tab-pane" id="settings">...</div>

</div>

</div>

<!--隔开-->

</div>

<script src="jquery-3.2.1.js"></script>

<script src="bootstrap-datetimepicker.js"></script>

<!--<script src="jquery.js"></script>-->

<script src="new.js"></script>

<script src="doc.js"></script>

<script src="bootstrap/js/bootstrap.js"></script>

<script>

</script>

<!--第二个时间插件-->

<!--<script src="src/jquery-1.7.2.min.js"></script>

<script src="src/bootstrap.min.js"></script>

<script src="dist/bootstrapDatepickr-1.0.0.min.js"></script>-->

</body>

</html>

//外副css

.clearfix:after{

content: "";

display: block;

height: 0;

clear: both;

visibility: hidden;

}

.clearfix{

zoom:1;

}

.top{

width: 100%;

height: 60px;

background: black;

position: fixed;

z-index: 999;

top: 0;

}

.top>.container>span{

line-height: 60px;

font-size: 20px;

color: white;

}

.picture{

float: right;

line-height: 60px;

width: 50px;

height: 50px;

}

.picture img{

width: 100%;

height: 100%;

border-radius: 50%;

}

.left1{

height: 600px;

background: gray;

padding: 0;

}

#menu a{

color: white;

padding: 10px 10px 10px 48px;

}

#menu a:hover{

background-color: gray;

}

li{

list-style: none;

}

.left1 li{

padding-top: 25px;

color: lavenderblush;

font-size: 20px;

}

.right1{

background: oldlace;

height: 100%;

margin-top: 60px;

padding-bottom: 175px;

min-height: 600px;

}

.right-top{

width: 100%;

height: 50px;

line-height: 50px;

color: lavenderblush;

}

.shrink{

width: 90%;

margin: auto;

margin-bottom: 7px;

}

.append{

float: right;

display: block;

margin: 2px 0 50px 0;

width: 200px;

}

.shrink span{

color: black;

}

.tb{

background: white;

width: 98%;

margin: auto;

margin-top: 10px;

}

.anniu{

float: right;

display: block;

margin-bottom: 10px;

margin-top: 10px;

margin-right: 20px;

}

.tbackground{

background: white;

}

.gray-line{

border: 1px solid silver;

width: 98%;

margin: auto;

display: block;

margin-top: 10px;

}

.append-class-color{

color: black;

}

@media screen and (max-width:420px){

.append{

width: 100px;

}

}

.beyong-hidden{

overflow: hidden;

}

.tx{

width: 60px;

height: 60px;

border-radius: 50%;

background: url("touxiang.jpg")no-repeat center center;

}

.open{

border-radius: 50%;

}

/*添加班级中的属性*/

/*.modal-body span{

margin-left: 120px;

}

.modal-body select{

width: 250px;

height: 30px;

margin-left: 20px;

}

.modal-body input{

width: 250px;

height: 30px;

margin-left: 20px;

}*/

.modal-body{

/*margin-left: 5px;*/

color: black;

}

.modal-con{

margin-top: 8px;

}

#zuoerbackground{

background: lightcyan;

}

#zuosanbackground{

background: seashell;

}

/*编辑*/

.editor_value{

width: 107px;

}

.active{

width: 100%;

}

/*.aaaaa{

border-left: 3px solid deepskyblue;

}*/

外副js

var express = require(‘express‘);

var app = express();

var fs = require("fs");

var bodyParser = require(‘body-parser‘);

// parse application/x-www-form-urlencoded

app.use(bodyParser.urlencoded({

extended: false

}))

// parse application/json

app.use(bodyParser.json())

app.use(express.static(‘xueyuanguanli1‘));

var Class = require("./class").Class;

//分页

app.get("/list_class", function(req, res) {

var pageSize = parseInt(req.query["pageSize"]);

var pageNo = parseInt(req.query["pageNo"]);

var dbquery = Class.find({});

dbquery.skip(pageSize * pageNo); //跳过多少条

dbquery.limit(pageSize); //页数

dbquery.find({}, function(err, list) {

Class.count({}, function(arr, total) {

if (err) {

res.json({

status: 500,

message: "查询错误"

});

} else {

res.json({

status: 200,

total: total,

pageSize: pageSize,

pageNo: pageNo,

list: list,

})

}

})

})

});

//删除

app.delete("/class", function(req, res) {

var index = req.query["index"] //查询id

console.log(index)

var wherestr = {

"_id": index

}

Class.remove(wherestr, function(err) {

if (err) {

res.json({

code: -1,

message: "删除失败"

})

} else {

res.json({

code: 1,

message: "删除成功"

})

}

})

});

//添加

app.post("/class2", function(req, res) {

var data = req.body;

var c1 = new Class(data);

c1.save(function(err) {

if (err) {

res.json({

code: -1,

message: "添加失败"

})

} else {

res.json({

code: 1,

message: "添加成功"

})

}

});

});

//编辑

app.put("/class1", function(req, res) {

var data = req.body;

// console.log(data)

var index = req.query["index"]

// console.log(index);

var wherestr = {

"_id": index

}

// var updatestr = new Class(data)

// delete updatestr._id

var updatestr = data

console.log(updatestr)

Class.update(wherestr, updatestr, function(err) {

if (err) {

res.json({

code: -1,

message: "编辑失败"

})

} else {

res.json({

code: 1,

message: "编辑成功"

})

}

})

});

console.log("listen to ")

app.listen(8081);

var doc ={

byid : function(id){

return document.getElementById(id);

},

bytag : function(tagname){

return document.getElementsByTagName(tagname);

},

byclass : function(cname){

return document.getElementsByClassName(cname);

},

q:function(selector){

return document.querySelector(selector);

},

qall:function(selector){

return document.querySelectorAll(selector);

},

create:function(tag){

return document.createElement(tag);

},

insert:function(newel,where){

return where.parentNode.insertBefore(newel,where);

},

replace:function(newel,where){

return where.parentNode.replaceChild(newel,where);

},

remove:function(el){

return el.parentNode.removeChild(el);

},

saveData : function(name,data){

if(typeof data == "object"){

data = JSON.stringify(data);

}

localStorage.setItem(name,data);

},

getData : function(name){

var data = localStorage.getItem(name);

try {

data = JSON.parse(data);

} catch (error) {}

return data;

}

}

附加jq库

启动项

var express = require(‘express‘);

var app = express();

var fs = require("fs");

var bodyParser = require(‘body-parser‘)

// parse application/x-www-form-urlencoded

app.use(bodyParser.urlencoded({ extended: false }))

// parse application/json

app.use(bodyParser.json())

app.use(express.static(‘xueyuanguanli1‘));

//查询

app.get("/list_class",function(req,res){

//读取文件

var data = fs.readFileSync(‘index.json‘);

//把文件内容转换为json对象

var jsondata = JSON.parse(data);

res.json(

// status:200,

//json数据

jsondata

);

});

//删除

app.delete("/class",function(req,res){

var index = req.query["index"]//获取url的查询参数串

//读取文件

var data = fs.readFileSync(‘index.json‘);

//把文件内容转换为json对象

var jsondata = JSON.parse(data);

// console.log(jsondata)

jsondata.splice(parseInt(index),1);

fs.writeFileSync(‘index.json‘,JSON.stringify(jsondata))

res.json({

status:200,

message:"删除成功"

});

});

//添加

app.post("/class2",function(req,res){

var data = req.body;

// console.log(data)

// data.date = new Date();

//读取文件

var datastr = fs.readFileSync(‘index.json‘);

//把文件内容转换为json对象

// console.log(typeof datastr)

var jsondata = JSON.parse(datastr);

jsondata.push(data);

// console.log(jsondata)

fs.writeFileSync(‘index.json‘,JSON.stringify(jsondata))

res.json({

status:200,

message:"添加成功"

});

});

//编辑

app.put("/class1",function(req,res){

var index = req.query["index"];

console.log(index);

var data = req.body;

console.log(data)

// data.date = new Date();

//读取文件

var datastr = fs.readFileSync(‘index.json‘);

//把文件内容转换为json对象

var jsondata = JSON.parse(datastr);

jsondata.splice(parseInt(index),1,data);

console.log(jsondata)

fs.writeFileSync(‘index.json‘,JSON.stringify(jsondata))

res.json({

status:200,

message:"修改成功"

});

});

console.log("listen to ")

app.listen(8081);

时间: 2024-11-06 13:57:11

学员管理的相关文章

学员管理示例——班级管理(单表操作)

一.新建views文件夹 1.新建views文件夹目的:给不同管理的操作分类,比如班级操作归为一类.     2.必须删除原来的views,以免路径搜索不到新建views文件夹 3.创建classes.py文件 二.操作流程(URL -> 函数 -> HTML文件 -> URL) URL路由 from django.contrib import admin from django.urls import re_path from app01.views import classes #

学员管理示例——为班级分配老师(多对多)

一.set_teachers.py文件 from django.shortcuts import render,redirect from app01 import models def set_teachers(request): if request.method == "GET": nid = request.GET.get("nid") # 获取后可继续传给HTML文件 cls_obj = models.Classes.objects.filter(id=n

学员管理示例:班级管理

原文地址:https://www.cnblogs.com/jintian/p/11167434.html

学员管理示例:学员管理

url+?+数据 get方式发送 input标签:placeholder=" "   显示在文本框内 {% csrf_token %}  针对post方式发送,要加在html文件内,否则会报错 原文地址:https://www.cnblogs.com/jintian/p/11167447.html

学员管理示例:数据库设计

原文地址:https://www.cnblogs.com/jintian/p/11167429.html

xx学院学员评优评奖管理系统

[勤拂拭软件,软件开发,毕业设计,程序作业,论文写作指导:q-[1215714557]  加好友请注明:勤拂拭)] 之前帮助一个军校学生做的一个评优评奖管理系统,该系统主要用于学校学生评优评先使用. 系统采用java开发,数据库是mysql. 下面简单讲诉一下该系统的设计: 一. 系统设计 1.1 系统目标设计 在对现有系统和现状认真调查分析的基础上,明确了学员信息管理工作本身存在的问题和建立管理信息系统的初步要求,进一步研究确定新系统的目标如下: 1.管理员能够实现对学员信息的添加.修改.删除

培训学校管理系统=互联网+管理(不“安分”校长必看)

培训学校管理系统=互联网+管理(不“安分”校长必看) 不可否认,当今社会已经步入互联网+的时代,李克强总理在今年政府工作报告中提出“互联网+”行动计划,“互联网+”代表一种新的经济形态,即充分发挥互联网在生产要素配置中的优化和集成作用,将互联网的创新成果深度融合于经济社会各领域之中,提升实体产业的创新力和生产力.未来将会达到人人互联网.物物互联网,业业互联网;实体与科技的融合的趋势不可阻挡.教育作为关于国计民生的和民族未来的重要领域和产业,更会加快互联网+的融合,这是个必然的无法阻挡的趋势. 互

Django和pymysql搭建学员管理系统

学员管理系统 项目规划阶段 项目背景 近年来老男孩教育的入学学员数量稳步快速增长,传统的excel统计管理学员信息的方式已经无法满足日渐增长的业务需求.因此公司急需一套方便易用的"学员管理系统",来提高公司在校学员信息的收集和处理能力.鉴于Python学院全栈x期的学员都聪明伶俐可爱至极,因此公司领导经过慎重考虑特决定将此项目交给大家来开发. 项目需求 本次学员管理系统设计开发,时间紧任务重,希望各位开发人员戒骄戒躁戒烟戒酒,尽快完成项目的开发. 具体需求为: 学员管理系统有三个角色:

python3.6+django2.0 一小时学会开发一套学员管理系统demo

1.在pycharm中新建project demo1 添加app01 点击create按钮完成新建 2.在demo项目目录下新建目录static,并在settings.py中追加代码: STATICFILES_DIRS=(os.path.join(BASE_DIR, 'static'),) 3.在setting.py中添加模板路径: TEMPLATES = [ { 'BACKEND': '...', 'DIRS': [os.path.join(BASE_DIR, 'templates'),],