TaoLer/app/admin/view/key_auth/index.html

212 lines
5.5 KiB
HTML
Raw Normal View History

2020-01-09 18:03:33 +08:00
{extend name="public/base" /}
{block name="body"}
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
2020-05-10 18:52:02 +08:00
<div class="layui-card-header">授权管理</div>
2020-01-09 18:03:33 +08:00
<div class="layui-card-body">
<div class="layui-form" wid100 lay-filter="">
<div class="layui-upload">
<button type="button" class="layui-btn layui-btn-normal" id="version-add">添加</button>
<div class="layui-upload-list">
<table class="layui-table">
<thead>
<tr>
<th>ID</th>
<th>用户</th>
<th>域名</th>
<th>Key</th>
<th>等级</th>
<th>状态</th>
<th>申请时间</th>
<th>到期时间</th>
<th>操作</th>
</tr></thead>
<tbody id="demoList">
{volist name="keys" id="vo"}
<tr>
<th>{$vo.id}</th>
<th>{$vo.user}</th>
2020-05-10 18:52:02 +08:00
<th><a href="{$vo.domain}" target="_blank">{$vo.domain}</a></th>
2020-01-09 18:03:33 +08:00
<th>{$vo.key}</th>
<th>{$vo.auth_level}</th>
<th>{$vo.status?'正常':'禁用'}</th>
<th>{$vo.create_time|date='Y-m-d'}</th>
<th>{$vo.end_time|date='Y-m-d'}</th>
<th>
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit" id-data="{$vo.id}"><i class="layui-icon layui-icon-edit"></i>编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" id-data="{$vo.id}"><i class="layui-icon layui-icon-delete"></i>删除</a>
</th>
</tr>
{/volist}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{/block}
{block name="js"}
<script>
layui.config({
base: '/static/admin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'set']);
</script>
<script>
layui.use(['layer','table','form','laydate'], function(){
var $ = layui.jquery
,layer = layui.layer
,table = layui.table
,form = layui.form
,laydate = layui.laydate;
//添加版本
$('#version-add').on('click', function(){
layer.open({
type: 2,
title: '添加授权',
content: 'add.html',
maxmin: true,
area : ['400px' , '450px'],
btn: ['确定', '取消'],
yes: function(index, layero){
var iframeWindow = window['layui-layer-iframe'+ index]
,submitID = 'LAY-keyauth-submit'
,submit = layero.find('iframe').contents().find('#'+ submitID);
//监听提交
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
var field = data.field; //获取提交的字段
//提交 Ajax 成功后,静态更新表格中的数据
$.ajax({
type:"post",
url:"{:url('admin/KeyAuth/add')}",
2020-01-11 17:27:15 +08:00
data:{"user":field.user,"domain":field.domain,"auth_level":field.auth_level,"end_time":field.end_time,"status":field.status},
2020-01-09 18:03:33 +08:00
daType:"json",
success:function (data){
if (data.code == 1) {
layer.msg(data.msg,{
icon:6,
time:2000
}, function(){
location.reload();
});
} else {
layer.open({
tiele:'添加失败',
content:data.msg,
icon:5,
anim:6
});
}
}
});
layer.close(index);
});
submit.trigger('click');
}
});
});
//编辑版本
$('a[lay-event=edit]').on('click', function(){
var id = $(this).attr('id-data');
layer.open({
type: 2,
title: '编辑key',
content: 'edit.html?id='+ id,
maxmin: true,
area : ['400px' , '450px'],
btn: ['确定', '取消'],
yes: function(index, layero){
var iframeWindow = window['layui-layer-iframe'+ index]
,submitID = 'LAY-keyauth-submit'
,submit = layero.find('iframe').contents().find('#'+ submitID);
//监听提交
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
var field = data.field; //获取提交的字段
//提交 Ajax 成功后,静态更新表格中的数据
$.ajax({
type:"post",
url:"{:url('admin/KeyAuth/edit')}",
data:{"id":id,"user":field.user,"domain":field.domain,"auth_level":field.auth_level,"end_time":field.end_time,"status":field.status},
daType:"json",
success:function (data){
if (data.code == 1) {
layer.msg(data.msg,{
icon:6,
time:2000
}, function(){
location.reload();
});
} else {
layer.open({
tiele:'添加失败',
content:data.msg,
icon:5,
anim:6
});
}
}
});
layer.close(index);
});
submit.trigger('click');
}
});
});
2020-01-11 17:27:15 +08:00
//删除授权
2020-01-09 18:03:33 +08:00
$('a[lay-event=del]').on('click', function(){
var id = $(this).attr('id-data');
layer.confirm('确定删除?', {icon: 3, title:'删除版本'}, function(index){
//提交 Ajax 成功后,静态更新表格中的数据
$.ajax({
type:"post",
url:"{:url('admin/KeyAuth/delete')}",
data:{"id":id},
daType:"json",
success:function (data){
if (data.code == 1) {
layer.msg(data.msg,{
icon:6,
time:2000
}, function(){
location.reload();
});
} else {
layer.open({
tiele:'删除失败',
content:data.msg,
icon:5,
anim:6
});
}
}
});
layer.close(index);
});
});
});
</script>
{/block}