代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>团队信息</title>
<link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<link rel="stylesheet" href="css/my.css"/>
<style>
</style>
</head>
<body class="container">
<div>
<button class="btn btn-danger" onclick="showTeamDialog()">新增团队</button>
<table class="table">
<thead>
<th>ID</th>
<th>名称</th>
<th>描述</th>
<th>创建人</th>
<th>创建时间</th>
<th width="300px">操作</th>
</thead>
<tbody id="team-body">
</tbody>
</table>
</div>
<!-- 新增或修改的模态框 -->
<div class="modal fade" id="teamModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel">
<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="editModalLabel">团队信息</h4>
</div>
<div class="modal-body">
<form>
<input type="hidden" id="teamId" />
<div class="form-group">
<label for="titleId" class="control-label">团队名称:</label>
<input type="text" name="title" class="form-control" id="titleId">
</div>
<div class="form-group">
<label for="noteId" class="control-label">团队描述:</label>
<textarea class="form-control" name="note" id="noteId"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="button" onclick="submitTeam()" class="btn btn-primary">确认</button>
</div>
</div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/net.js"></script>
<script>
$(()=>{
load_data()
})
function load_data(){
get('/team', data=>{
$('#team-body').html('')
data.data.forEach(item=>{
let tr = '<tr>'
let commond_td = "<td>"+item.id+"</td><td>" +item.title +"</td><td>"+ item.node +"</td><td>"+item.create_person+"</td><td>"+item.create_time+"</td><td>"
commond_td += '<a class="btn btn-primary btn-xs" onclick="editRow(\''+item.id+'\',\''+item.title+'\',\''+item.node+'\')"><i class="glyphicon glyphicon-edit"></i></a>'
commond_td += '<a class="btn btn-danger btn-xs" onclick="delRow('+item.id+')"><i class="glyphicon glyphicon-trash"></i></a>'
tr +=commond_td +"</td></tr>"
$('#team-body').append(tr)
})
})
}
function showTeamDialog(){
$('#teamModal').modal('show')
}
function submitTeam(){
let team_id = $('#teamId').val()
let title = $('#titleId').val()
let note = $('#noteId').val()
if(team_id!==undefined && team_id === ''){
// 新增一个团队
post('/team', {title: title, note: note}, data=>{
if(data.code === 0){
alert(data.msg)
load_data() // 重新加载数据
}else{
alert('添加失败')
}
})
}else{
put('/team?team_id='+team_id, {title: title, note: note}, data=>{
if(data.code === 0){
alert(data.msg)
load_data() // 重新加载数据
}else{
alert('修改失败')
}
})
}
$('#teamModal').modal('hide')
$('#titleId').val('')
$('#teamId').val('')
$('#noteId').val('')
}
function editRow(team_id, team_title, team_note){
console.info(team_id+","+team_title+","+team_note)
$('#titleId').val(team_title)
$('#noteId').val(team_note)
$('#teamId').val(team_id)
$('#teamModal').modal('show')
}
function delRow(team_id){
if(confirm('是否确认删除'+team_id+"?")){
fetch_delete('/team/'+team_id, data=>{
if(data.code === 0){
alert(data.msg)
load_data()
}else{
alert('删除失败')
}
})
}
}
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。