285 lines
12 KiB
HTML
285 lines
12 KiB
HTML
<!DOCTYPE html>
|
||
<html class="x-admin-sm">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>表单管理</title>
|
||
<meta name="renderer" content="webkit">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
|
||
<link rel="stylesheet" href="/x_admin/css/font.css">
|
||
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
|
||
<script src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
|
||
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
|
||
<style>
|
||
/* th{
|
||
min-width:30px;
|
||
} */
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="x-nav">
|
||
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
|
||
<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
|
||
</a>
|
||
</div>
|
||
<div class="layui-fluid">
|
||
<div class="layui-row layui-col-space15">
|
||
<div class="layui-col-md12">
|
||
<div class="layui-card">
|
||
<div class="layui-card-header">
|
||
<!-- <button class="layui-btn" onclick="xadmin.open('添加','/oi/zzt/add_form','90%','80%')"><i class="layui-icon"></i>添加</button> -->
|
||
<button class="layui-btn" onclick="xadmin.open('添加','/oi/zzt/add_form2','90%','80%')"><i class="layui-icon"></i>添加</button>
|
||
</div>
|
||
<div class="layui-card-body layui-table-body layui-table-main">
|
||
<table class="layui-table layui-form">
|
||
<thead>
|
||
<tr>
|
||
<th>活动标题</th>
|
||
<!-- <th>活动封面</th> -->
|
||
<th>报名人数(当前/总计)</th>
|
||
<th>报名日期</th>
|
||
<th>创建时间</th>
|
||
<th>状态</th>
|
||
<th>操作</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id='content'>
|
||
|
||
{volist name="result" id="vo"}
|
||
<tr>
|
||
<td>{$vo.title}</td>
|
||
<!-- <td>{$vo.pic}</td> -->
|
||
<td>{$vo.people_num_now}/{$vo.people_num}</td>
|
||
<td>{$vo.start_time}至{$vo.end_time}</td>
|
||
<td>{$vo.create_time}</td>
|
||
<td class="td-status">
|
||
{if condition="$vo.is_del == 1"}
|
||
<span onclick="app_stop(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>
|
||
{else /}
|
||
<span onclick="app_stop(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>
|
||
{/if}
|
||
</td>
|
||
<td>
|
||
<button class="layui-btn" onclick="xadmin.open('修改','/oi/zzt/edit_form?id={$vo.id}','90%','80%')">修改</button>
|
||
<button class="layui-btn" onclick="down(this,'{$vo.id}')">下载报名信息</button>
|
||
</td>
|
||
</tr>
|
||
{/volist}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div class="layui-card-body ">
|
||
<div id="page" style="text-align: center;">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</body>
|
||
<script>
|
||
var form
|
||
layui.use(['laydate','form'], function(){
|
||
var laydate = layui.laydate;
|
||
form = layui.form;
|
||
});
|
||
var page_num;
|
||
var laypage;
|
||
var all_page = "{$num}";
|
||
layui.use('laypage', function () {
|
||
laypage = layui.laypage;
|
||
|
||
//执行一个laypage实例
|
||
laypage.render({
|
||
elem: 'page',
|
||
count: all_page, //数据总数,从服务端得到
|
||
limit: 10,
|
||
groups:10,
|
||
jump: function (obj, first) {
|
||
//首次不执行
|
||
if (!first) {
|
||
//obj包含了当前分页的所有参数,比如:
|
||
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
|
||
console.log(obj.limit); //得到每页显示的条数
|
||
page_num = obj.curr;
|
||
find("n")
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
/*用户-停用*/
|
||
function app_stop(obj,id){
|
||
|
||
// return
|
||
var title = '',is_del,num
|
||
if($(obj).attr('title')=='启用'){
|
||
title = '停用'
|
||
is_del = 1
|
||
num = 5
|
||
}else{
|
||
title = '启用'
|
||
is_del = 0
|
||
num = 6
|
||
}
|
||
// console.log('点击时'+$(obj).attr('title')+'====='+id+'===传到后台是否删除:'+is_del)
|
||
layer.confirm('确认要'+ title +'吗?',function(index){
|
||
load()
|
||
$.ajax({
|
||
url:"/oi/zzt/del_action", //请求的url地址
|
||
dataType:"json", //返回格式为json
|
||
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||
data:{"id":id,'is_del':is_del}, //参数值
|
||
type:"POST", //请求方式
|
||
success:function(req){
|
||
c_load()
|
||
//请求成功时处理
|
||
if(req['code'] == 0){
|
||
//发异步把用户状态进行更改
|
||
$(obj).attr('title',title)
|
||
if(is_del == 1){
|
||
$(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已'+ title);
|
||
}else{
|
||
$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已'+ title);
|
||
}
|
||
layer.msg('已'+ title,{icon: num});
|
||
}else{
|
||
layer.msg('操作失败!',{icon: 5});
|
||
}
|
||
},
|
||
error:function(){
|
||
//请求出错处理
|
||
}});
|
||
});
|
||
}
|
||
|
||
function find(pd) {
|
||
if(!page_num || pd == 'y'){
|
||
page_num = 1;
|
||
}
|
||
|
||
page({
|
||
"status_num":$('#status_num').val(),
|
||
"tel":$('#tel').val(),
|
||
"email":$('#email').val(),
|
||
"s_time":$('#s_time').val(),
|
||
"e_time":$('#e_time').val(),
|
||
"page_num":page_num,
|
||
"tt":1},pd);
|
||
}
|
||
function page(data,pd) {
|
||
console.log(data)
|
||
load()
|
||
$.ajax({
|
||
url: "/oi/zzt/form_page", //请求的url地址s
|
||
dataType: "json", //返回格式为json
|
||
async: true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||
data: data, //参数值
|
||
type: "POST", //请求方式
|
||
success: function (req) {
|
||
console.log(req)
|
||
c_load();
|
||
if (req['code'] == 0) {
|
||
|
||
var str,str_s,str_c,str_all="";
|
||
|
||
for (let i = 0; i < req['data']['data'].length; i++) {
|
||
if(req['data']['data'][i]['is_del'] == 1){
|
||
str = '<span onclick="app_stop(this,\''+req['data']['data'][i]['id']+'\')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>'
|
||
}else{
|
||
str = '<span onclick="app_stop(this,\''+ req['data']['data'][i]['id'] +'\')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>'
|
||
}
|
||
str_c = "<tr>"+
|
||
'<td>'+req['data']['data'][i]['title']+'</td>'+
|
||
'<td>'+req['data']['data'][i]['people_num_now']+'/'+req['data']['data'][i]['people_num']+'</td>'+
|
||
'<td>'+req['data']['data'][i]['start_time']+'至'+req['data']['data'][i]['end_time']+'</td>'+
|
||
'<td>'+req['data']['data'][i]['create_time']+'</td>'+
|
||
'<td class="td-status">'+
|
||
str+
|
||
'</td>'
|
||
'</tr>'
|
||
str_all = str_all+str_c;
|
||
}
|
||
$('#content').html(str_all);
|
||
|
||
form.render();
|
||
if(pd == 'y'){
|
||
$("#page").html("")
|
||
laypage.render({
|
||
elem: 'page',
|
||
count: req['data']['num'], //数据总数,从服务端得到
|
||
limit: 10,
|
||
groups:10,
|
||
jump: function (obj, first) {
|
||
//首次不执行
|
||
if (!first) {
|
||
//obj包含了当前分页的所有参数,比如:
|
||
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
|
||
console.log(obj.limit); //得到每页显示的条数
|
||
page_num = obj.curr;
|
||
// page({"page":page_num,"tt":1});
|
||
find("n")
|
||
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
} else {
|
||
layer.msg(req['msg'])
|
||
}
|
||
},
|
||
error: function () {
|
||
//请求出错处理
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
function down(obj, id) {
|
||
// 显示加载状态
|
||
obj.innerHTML = '下载中...';
|
||
obj.disabled = true;
|
||
|
||
// 先发送HEAD请求检查状态
|
||
fetch('/oi/zzt/down_data_action?id=' + id, { method: 'HEAD' })
|
||
.then(response => {
|
||
if (response.ok) {
|
||
// 状态正常,直接下载
|
||
window.location.href = '/oi/zzt/down_data_action?id=' + id;
|
||
} else {
|
||
// 检查是否是JSON错误响应
|
||
return response.text().then(text => {
|
||
try {
|
||
const errorData = JSON.parse(text);
|
||
if (errorData.code === 10002) {
|
||
throw new Error('未找到对应活动');
|
||
}
|
||
} catch (e) {
|
||
throw new Error('下载失败:' + (errorData?.message || '未知错误'));
|
||
}
|
||
});
|
||
}
|
||
})
|
||
.catch(error => {
|
||
alert(error.message);
|
||
})
|
||
.finally(() => {
|
||
// 恢复按钮状态
|
||
obj.innerHTML = '下载报名人员';
|
||
obj.disabled = false;
|
||
});
|
||
}
|
||
|
||
//加载提示开启
|
||
function load() {
|
||
var index = layer.load(1, {
|
||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||
});
|
||
}
|
||
// 关闭加载提示
|
||
function c_load() {
|
||
layer.close(layer.index)
|
||
}
|
||
</script>
|
||
</html> |