You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
467 lines
14 KiB
467 lines
14 KiB
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
|
<title>用户公司信息管理</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
background: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.header {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
padding: 40px 30px;
|
|
text-align: center;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 32px;
|
|
margin-bottom: 15px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.header p {
|
|
font-size: 16px;
|
|
opacity: 0.95;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.header .total-count {
|
|
font-size: 18px;
|
|
font-weight: 600;
|
|
margin-top: 15px;
|
|
padding: 10px 20px;
|
|
background: rgba(255, 255, 255, 0.2);
|
|
border-radius: 20px;
|
|
display: inline-block;
|
|
}
|
|
|
|
.table-container {
|
|
padding: 30px;
|
|
overflow-x: auto;
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
background: white;
|
|
}
|
|
|
|
th, td {
|
|
padding: 16px;
|
|
text-align: left;
|
|
border-bottom: 1px solid #e8e8e8;
|
|
}
|
|
|
|
th {
|
|
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
|
|
font-weight: 600;
|
|
color: #495057;
|
|
font-size: 14px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
td {
|
|
color: #212529;
|
|
font-size: 14px;
|
|
}
|
|
|
|
tr:hover {
|
|
background-color: #f8f9fa;
|
|
}
|
|
|
|
tr:last-child td {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.search-btn {
|
|
padding: 8px 20px;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
transition: all 0.3s;
|
|
box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
|
|
}
|
|
|
|
.search-btn:hover {
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
|
|
}
|
|
|
|
.search-btn:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
/* 弹窗样式 */
|
|
.modal {
|
|
display: none;
|
|
position: fixed;
|
|
z-index: 1000;
|
|
left: 0;
|
|
top: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgba(0, 0, 0, 0.6);
|
|
backdrop-filter: blur(4px);
|
|
}
|
|
|
|
.modal-content {
|
|
background-color: white;
|
|
margin: 3% auto;
|
|
padding: 0;
|
|
border-radius: 12px;
|
|
width: 90%;
|
|
max-width: 900px;
|
|
max-height: 85vh;
|
|
overflow: hidden;
|
|
display: flex;
|
|
flex-direction: column;
|
|
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.modal-header {
|
|
padding: 25px 30px;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.modal-header h2 {
|
|
margin: 0;
|
|
font-size: 22px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.close {
|
|
color: white;
|
|
font-size: 32px;
|
|
font-weight: bold;
|
|
cursor: pointer;
|
|
line-height: 1;
|
|
transition: opacity 0.3s;
|
|
width: 32px;
|
|
height: 32px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.close:hover {
|
|
opacity: 0.7;
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 30px;
|
|
overflow-y: auto;
|
|
flex: 1;
|
|
}
|
|
|
|
.search-input-group {
|
|
margin-bottom: 25px;
|
|
}
|
|
|
|
.search-input-group input {
|
|
width: 100%;
|
|
padding: 12px 16px;
|
|
border: 2px solid #e0e0e0;
|
|
border-radius: 8px;
|
|
font-size: 15px;
|
|
transition: border-color 0.3s;
|
|
}
|
|
|
|
.search-input-group input:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
}
|
|
|
|
.company-list {
|
|
list-style: none;
|
|
padding: 0;
|
|
}
|
|
|
|
.company-item {
|
|
padding: 18px;
|
|
border: 2px solid #e8e8e8;
|
|
border-radius: 8px;
|
|
margin-bottom: 12px;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
background: #fafafa;
|
|
}
|
|
|
|
.company-item:hover {
|
|
background-color: #f0f4ff;
|
|
border-color: #667eea;
|
|
transform: translateX(4px);
|
|
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
|
|
}
|
|
|
|
.company-name {
|
|
font-weight: 600;
|
|
color: #212529;
|
|
margin-bottom: 8px;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.company-info {
|
|
font-size: 13px;
|
|
color: #6c757d;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.loading {
|
|
text-align: center;
|
|
padding: 60px 20px;
|
|
color: #999;
|
|
font-size: 15px;
|
|
}
|
|
|
|
.no-results {
|
|
text-align: center;
|
|
padding: 60px 20px;
|
|
color: #999;
|
|
font-size: 15px;
|
|
}
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 40px;
|
|
color: #999;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>📋 用户公司信息管理</h1>
|
|
<p>管理用户的公司信息,支持搜索和更新公司名称</p>
|
|
<div class="total-count">总用户数:{{ $totalCount }}</div>
|
|
</div>
|
|
|
|
<div class="table-container">
|
|
@if($users->count() > 0)
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>用户姓名</th>
|
|
<th>公司名称</th>
|
|
<th>关联公司ID</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($users as $user)
|
|
<tr data-user-id="{{ $user->id }}">
|
|
<td>{{ $user->id }}</td>
|
|
<td>{{ $user->username ?: '-' }}</td>
|
|
<td class="company-name-cell">{{ $user->company_name }}</td>
|
|
<td>{{ $user->company_id ?? '-' }}</td>
|
|
<td>
|
|
<button class="search-btn" onclick="openSearchModal({{ $user->id }}, '{{ addslashes($user->company_name) }}')">🔍 搜索公司</button>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
@else
|
|
<div class="empty-state">
|
|
<p>暂无用户数据</p>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 搜索弹窗 -->
|
|
<div id="searchModal" class="modal">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h2>🔍 搜索公司</h2>
|
|
<span class="close" onclick="closeModal()">×</span>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="search-input-group">
|
|
<input
|
|
type="text"
|
|
id="searchCompanyInput"
|
|
placeholder="请输入公司名称进行搜索..."
|
|
onkeypress="if(event.key === 'Enter') searchCompany()"
|
|
>
|
|
</div>
|
|
<div id="companyListContainer">
|
|
<div class="loading">查询中...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let currentUserId = null;
|
|
|
|
function openSearchModal(userId, currentCompanyName) {
|
|
currentUserId = userId;
|
|
document.getElementById('searchModal').style.display = 'block';
|
|
const input = document.getElementById('searchCompanyInput');
|
|
input.value = currentCompanyName;
|
|
|
|
// 自动执行搜索
|
|
if (currentCompanyName) {
|
|
searchCompany();
|
|
} else {
|
|
document.getElementById('companyListContainer').innerHTML = '<div class="loading">请输入公司名称进行查询</div>';
|
|
}
|
|
}
|
|
|
|
function closeModal() {
|
|
document.getElementById('searchModal').style.display = 'none';
|
|
currentUserId = null;
|
|
}
|
|
|
|
// 点击弹窗外部关闭
|
|
window.onclick = function(event) {
|
|
const modal = document.getElementById('searchModal');
|
|
if (event.target == modal) {
|
|
closeModal();
|
|
}
|
|
}
|
|
|
|
function searchCompany() {
|
|
const companyName = document.getElementById('searchCompanyInput').value.trim();
|
|
if (!companyName) {
|
|
document.getElementById('companyListContainer').innerHTML = '<div class="no-results">请输入公司名称</div>';
|
|
return;
|
|
}
|
|
|
|
const container = document.getElementById('companyListContainer');
|
|
container.innerHTML = '<div class="loading">查询中,请稍候...</div>';
|
|
|
|
fetch(`/api/mobile/other/company?company_name=${encodeURIComponent(companyName)}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
let companies = null;
|
|
|
|
if (Array.isArray(data)) {
|
|
companies = data;
|
|
} else if (data.code === 200 && Array.isArray(data.data)) {
|
|
companies = data.data;
|
|
} else {
|
|
container.innerHTML = '<div class="no-results">查询失败,请稍后重试</div>';
|
|
return;
|
|
}
|
|
|
|
if (companies && companies.length > 0) {
|
|
displayCompanies(companies);
|
|
} else {
|
|
container.innerHTML = '<div class="no-results">未找到相关公司信息</div>';
|
|
}
|
|
})
|
|
.catch(error => {
|
|
container.innerHTML = '<div class="no-results">查询失败,请稍后重试</div>';
|
|
console.error('Error:', error);
|
|
});
|
|
}
|
|
|
|
function displayCompanies(companies) {
|
|
const container = document.getElementById('companyListContainer');
|
|
let html = '<ul class="company-list">';
|
|
|
|
companies.forEach(company => {
|
|
const companyName = company.name || '';
|
|
html += `
|
|
<li class="company-item" onclick="selectCompany('${escapeHtml(companyName)}')">
|
|
<div class="company-name">${escapeHtml(companyName)}</div>
|
|
<div class="company-info">
|
|
${company.creditCode ? '统一社会信用代码: ' + escapeHtml(company.creditCode) + '<br>' : ''}
|
|
${company.operName ? '法人代表: ' + escapeHtml(company.operName) + '<br>' : ''}
|
|
${company.status ? '注册状态: ' + escapeHtml(company.status) : ''}
|
|
</div>
|
|
</li>
|
|
`;
|
|
});
|
|
|
|
html += '</ul>';
|
|
container.innerHTML = html;
|
|
}
|
|
|
|
function selectCompany(companyName) {
|
|
if (!currentUserId) {
|
|
alert('用户ID不存在');
|
|
return;
|
|
}
|
|
|
|
if (!confirm(`确定要将公司名称更新为"${companyName}"吗?`)) {
|
|
return;
|
|
}
|
|
|
|
// 调用更新接口
|
|
fetch('/company/update-user-company', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || ''
|
|
},
|
|
body: JSON.stringify({
|
|
user_id: currentUserId,
|
|
company_name: companyName
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.code === 200) {
|
|
// 更新页面上的数据
|
|
const row = document.querySelector(`tr[data-user-id="${currentUserId}"]`);
|
|
if (row) {
|
|
const companyNameCell = row.querySelector('.company-name-cell');
|
|
const companyIdCell = companyNameCell.nextElementSibling;
|
|
companyNameCell.textContent = companyName;
|
|
companyIdCell.textContent = '-';
|
|
}
|
|
alert('更新成功!');
|
|
closeModal();
|
|
} else {
|
|
alert('更新失败: ' + (data.msg || data.message || '未知错误'));
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
alert('更新失败,请稍后重试');
|
|
});
|
|
}
|
|
|
|
function escapeHtml(text) {
|
|
const div = document.createElement('div');
|
|
div.textContent = text;
|
|
return div.innerHTML;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|