mem_list.html
5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<include file="public@header" />
</head>
<body>
<button type="button" class="btn btn-default" style="margin:10px 10px;" data-toggle="modal" data-target="#myModal">添加会员</button>
<table class="table table-bordered" style="margin:10px 10px;">
<caption>会员列表</caption>
<thead>
<tr>
<th>用户名</th>
<th>操作</th>
</tr>
</thead>
<tbody class="zhuijia">
<volist name="data" id="vo">
<tr class="tr{$vo.id}">
<td>{$vo.name}</td>
<td>
<button type="button" class="btn btn-default" data-toggle='modal' data-target='#editModal' onclick="edit({$vo.id})">编辑</button>
<button type="button" class="btn btn-default" onclick="del({$vo.id})">删除</button>
</td>
</tr>
</volist>
</tbody>
</table>
<!-- 添加模态框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">添加会员</h4>
</div>
<div class="modal-body">
<div class="input-group">
<span class="input-group-addon">用户名:</span>
<input type="text" name="name" class="form-control">
</div>
<div class="input-group" style="margin-top: 5px;">
<span class="input-group-addon">密码:</span>
<input type="text" name="passwd" class="form-control">
</div>
<div class="input-group" style="margin-top: 5px;">
<span class="input-group-addon">积分:</span>
<input type="text" name="jifen" class="form-control">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default guanbi" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" onclick="add()">提交</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
<!-- 编辑模态框(Modal) -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">编辑会员</h4>
</div>
<div class="modal-body">
<div class="input-group">
<span class="input-group-addon">用户名:</span>
<input type="text" name="ename" class="form-control">
</div>
<div class="input-group" style="margin-top: 5px;">
<span class="input-group-addon">密码:</span>
<input type="text" name="epasswd" class="form-control">
</div>
<div class="input-group" style="margin-top: 5px;">
<span class="input-group-addon">积分:</span>
<input type="text" name="ejifen" class="form-control">
</div>
<input type="hidden" name="id" value="">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default eguanbi" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" onclick="tjedit()">提交</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
<script>
//添加会员
function add(){
name = $("input[name='name']").val();
passwd = $("input[name='passwd']").val();
jifen = $("input[name='jifen']").val();
$.post("{:url('Members/mem_add')}",{name:name,passwd:passwd,jifen:jifen},function(data){
$('.guanbi').trigger('click');
$('.zhuijia').append("<tr class='tr"+data+"'><td>"+name+"</td><td><button type='button' class='btn btn-default' data-toggle='modal' data-target='#editModal' onclick='edit("+data+")'>编辑</button><button type='button' class='btn btn-default' onclick='del("+data+")'>删除</button></td></tr>");
$('.form-control').val('');
});
}
//编辑会员
function edit(id){
$.post("{:url('Members/mem_edit_show')}",{id:id},function(data){
shuju = JSON.parse(data);
$("input[name='ename']").val(shuju.name);
$("input[name='epasswd']").val(shuju.passwd);
$("input[name='ejifen']").val(shuju.jifen);
$("input[name='id']").val(shuju.id);
});
}
//编辑模态框提交
function tjedit(){
id = $("input[name='id']").val();
name = $("input[name='ename']").val();
passed = $("input[name='epasswd']").val();
jifen = $("input[name='ejifen']").val();
$.post("{:url('Members/mem_edit_up')}",{id:id,name:name,passed:passed,jifen:jifen},function(data){
$('.eguanbi').trigger('click');
});
}
//删除数据
function del(id){
ccc = window.confirm('是否删除?');
if(ccc){
$.post("{:url('Members/mem_del')}",{id:id},function(data){
$('.tr'+id).remove();
});
}
}
</script>
</body>
</html>