147 lines
No EOL
5.2 KiB
HTML
147 lines
No EOL
5.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>删除访客信息</title>
|
|
<link href="static/css/bootstarp/5/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
|
<link href="static/css/custom/Common.css" rel="stylesheet" crossorigin="anonymous">
|
|
<style>
|
|
body {
|
|
padding: 20px;
|
|
background-color: #f8f9fa;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
}
|
|
.btn-delete {
|
|
background-color: red;
|
|
color: white;
|
|
padding: 10px 20px;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
}
|
|
.btn-delete:disabled {
|
|
background-color: gray;
|
|
cursor: not-allowed;
|
|
}
|
|
.data-count {
|
|
margin-bottom: 10px;
|
|
font-size: 16px;
|
|
color: #333;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container text-center">
|
|
<div id="dataCount" class="data-count">正在加载数据...</div>
|
|
<button id="deleteVisitorInfo" class="btn-delete" disabled>删除我的访客信息</button>
|
|
</div>
|
|
|
|
<!-- 模态框 -->
|
|
<div class="modal fade" id="confirmDeleteModal" tabindex="-1" aria-labelledby="confirmDeleteModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="confirmDeleteModalLabel">确认删除</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
如果你删除你的信息,任务管理中的所有数据都会被删除,无法找回。你确定要继续吗?
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
|
|
<button type="button" class="btn btn-danger" id="confirmDeleteButton">确定</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="static/js/bootstarp/5/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
|
|
<script src="static/js/jquery/2.1.4/jquery.min.js"></script>
|
|
<script src="static/js/custom/Common.js"></script>
|
|
|
|
<script>
|
|
$(document).ready(function () {
|
|
function showLoading() {
|
|
$('#deleteVisitorInfo').text('加载中...');
|
|
$('#deleteVisitorInfo').prop('disabled', true);
|
|
$('#dataCount').text('正在加载数据...');
|
|
}
|
|
|
|
function hideLoading() {
|
|
$('#deleteVisitorInfo').text('删除我的访客信息');
|
|
$('#deleteVisitorInfo').prop('disabled', false);
|
|
}
|
|
|
|
function fetchData() {
|
|
showLoading();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/GetMyTasks",
|
|
dataType: "json",
|
|
success: function (response) {
|
|
hideLoading();
|
|
if (response.retcode === 0) {
|
|
const data = response.data;
|
|
const dataCount = data.length;
|
|
$('#dataCount').text(`服务器上有 ${dataCount} 条数据`);
|
|
if (dataCount === 0 || data.some(item => item.status === 1)) {
|
|
$('#deleteVisitorInfo').prop('disabled', true);
|
|
$('#dataCount').text((dataCount === 0) ? "服务器上没有存储任何关于你的数据" : "现在有正在运行中的任务, 你现在无法删除你的访客信息");
|
|
} else {
|
|
$('#deleteVisitorInfo').prop('disabled', false);
|
|
}
|
|
} else {
|
|
alert(response.message);
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
hideLoading();
|
|
console.error(error);
|
|
alert("请求失败,请重试");
|
|
}
|
|
});
|
|
}
|
|
|
|
function deleteVisitorInfo() {
|
|
showLoading();
|
|
$.ajax({
|
|
type: "DELETE",
|
|
url: "/VisitorManagement/DeleteInfo",
|
|
dataType: "json",
|
|
success: function (response) {
|
|
hideLoading();
|
|
if (response.retcode === 0) {
|
|
alert("删除成功");
|
|
fetchData(); // 刷新数据
|
|
} else {
|
|
alert(response.message);
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
hideLoading();
|
|
console.error(error);
|
|
alert("请求失败,请重试");
|
|
}
|
|
});
|
|
}
|
|
|
|
fetchData();
|
|
|
|
$('#deleteVisitorInfo').click(function () {
|
|
$('#confirmDeleteModal').modal('show');
|
|
});
|
|
|
|
$('#confirmDeleteButton').click(function () {
|
|
deleteVisitorInfo();
|
|
$('#confirmDeleteModal').modal('hide');
|
|
});
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html> |