This commit is contained in:
zpc 2025-09-03 04:18:10 +08:00
parent 4a7111fe4c
commit a28b5c801e

View File

@ -108,6 +108,7 @@
<script type="text/html" id="LAY-app-SQReservations-tableBox-bar">
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="viewParticipants">查看参与者</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" data-dropdown="#SQReservationsTbDelDrop{{d.LAY_INDEX}}" no-shade="true">删除</a>
<div class="dropdown-menu-nav dropdown-popconfirm dropdown-top-right layui-hide" id="SQReservationsTbDelDrop{{d.LAY_INDEX}}"
style="max-width: 200px;white-space: normal;min-width: auto;margin-left: 10px;">
@ -401,7 +402,7 @@
return '创建:' + createdTime + '<br/>更新:' + updatedTime + "<br/>备注:" + d.remarks || '无';
}
},
{ width: 162, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-SQReservations-tableBox-bar' }
{ width: 220, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-SQReservations-tableBox-bar' }
]
]
});
@ -447,6 +448,8 @@
doDelete(obj);
} else if (obj.event === 'edit') {
doEdit(obj)
} else if (obj.event === 'viewParticipants') {
doViewParticipants(obj);
}
});
//执行创建操作
@ -574,6 +577,174 @@
}
});
}
//执行查看参与者操作
function doViewParticipants(obj) {
var reservationData = obj.data;
var participants = reservationData.participants || [];
// 弹出查看参与者窗口
layer.open({
type: 1,
title: '查看参与者 - ' + (reservationData.title || '预约' + reservationData.id),
area: ['1000px', '600px'],
content: `
<div style="padding: 20px;">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">
<h3>预约信息</h3>
</div>
<div class="layui-card-body">
<div class="layui-row">
<div class="layui-col-md6">
<p><strong>组局名称:</strong>${reservationData.title || '无'}</p>
<p><strong>房间:</strong>${reservationData.room_name || '无'}</p>
<p><strong>开始时间:</strong>${reservationData.start_time || '无'}</p>
</div>
<div class="layui-col-md6">
<p><strong>玩法类型:</strong>${reservationData.game_type || '无'}</p>
<p><strong>具体规则:</strong>${reservationData.game_rule || '无'}</p>
<p><strong>结束时间:</strong>${reservationData.end_time || '无'}</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="layui-row" style="margin-top: 20px;">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">
<h3>参与者列表 (${participants.length}人)</h3>
</div>
<div class="layui-card-body">
<table id="participantsTable" lay-filter="participantsTable"></table>
</div>
</div>
</div>
</div>
</div>
`,
success: function(layero, index) {
// 初始化参与者表格
layui.use(['table'], function() {
var table = layui.table;
// 处理参与者数据并排序
var tableData = participants.map(function(p) {
var roleText = p.role == 1 ? '发起者' : '参与者';
var statusText = p.status == 0 ? '正常' : '已退出';
var statusColor = p.status == 0 ? '#5FB878' : '#FF5722';
var refundText = '';
var refundColor = '';
if (p.is_refund !== undefined && p.is_refund !== null) {
switch (p.is_refund) {
case 0:
refundText = '无需退款';
refundColor = '#999';
break;
case 1:
refundText = '已付鸽子费';
refundColor = '#1E9FFF';
break;
case 2:
refundText = '退款中';
refundColor = '#FFB800';
break;
case 3:
refundText = '退款成功';
refundColor = '#5FB878';
break;
case 9:
refundText = '退款失败';
refundColor = '#FF5722';
break;
default:
refundText = '未知状态';
refundColor = '#999';
}
}
return {
id: p.id,
user_id: p.user_id,
userName: p.UserName || p.userName || '用户' + p.user_id,
role: roleText,
roleValue: p.role, // 用于排序
status: statusText,
statusValue: p.status, // 用于排序
statusColor: statusColor,
join_time: p.join_time || '无',
quit_time: p.quit_time || '无',
refund_status: refundText,
refund_color: refundColor,
remarks: p.remarks || '无'
};
});
// 排序:发起者 > 正常参与者 > 已退出参与者(按退出时间倒序)
tableData.sort(function(a, b) {
// 首先按角色排序:发起者(1) > 参与者(0)
if (a.roleValue !== b.roleValue) {
return b.roleValue - a.roleValue; // 发起者在前
}
// 然后按状态排序:正常(0) > 已退出(1)
if (a.statusValue !== b.statusValue) {
return a.statusValue - b.statusValue; // 正常在前
}
// 最后按退出时间排序(已退出的参与者)
if (a.statusValue === 1 && b.statusValue === 1) {
var quitTimeA = a.quit_time === '无' ? '1970-01-01' : a.quit_time;
var quitTimeB = b.quit_time === '无' ? '1970-01-01' : b.quit_time;
return new Date(quitTimeB) - new Date(quitTimeA); // 退出时间倒序
}
return 0;
});
table.render({
elem: '#participantsTable',
data: tableData,
page: false,
height: '280px',
cols: [[
{field: 'id', title: 'ID', width: 60},
{field: 'user_id', title: '用户ID', width: 80},
{field: 'userName', title: '用户名', width: 120},
{field: 'role', title: '角色', width: 80},
{
field: 'status',
title: '状态',
width: 80,
templet: function(d) {
return '<span style="background: ' + d.statusColor + '; color: white; padding: 2px 6px; border-radius: 3px; font-size: 12px;">' + d.status + '</span>';
}
},
{field: 'join_time', title: '参与时间', width: 150},
{field: 'quit_time', title: '退出时间', width: 150},
{
field: 'refund_status',
title: '鸽子费状态',
width: 100,
templet: function(d) {
if (d.refund_status) {
return '<span style="background: ' + d.refund_color + '; color: white; padding: 2px 6px; border-radius: 3px; font-size: 12px;">' + d.refund_status + '</span>';
}
return '无';
}
},
{field: 'remarks', title: '备注', width: 200}
]]
});
});
}
});
}
//执行单个删除
function doDelete(obj) {
coreHelper.Post("Api/SQReservations/DoDelete", { id: obj.data.id }, function (e) {