update export request

This commit is contained in:
2026-11-10 11:01:24 +07:00
parent 63866b14a1
commit 00122e5b4a
16 changed files with 1108 additions and 382 deletions

File diff suppressed because one or more lines are too long

View File

@@ -153,57 +153,39 @@ textarea {
z-index: 0;
}
/* Keep saved export files and both actions visible beside wide history rows. */
#assetExportHistoryModal .asset-export-history-dialog {
width: min(1600px, calc(100vw - 2rem));
max-width: none;
max-height: calc(100dvh - 2rem);
}
.asset-export-history-scroll {
max-height: calc(100dvh - 10rem);
overflow: auto;
overscroll-behavior: contain;
scrollbar-width: thin;
}
.asset-export-history-table {
min-width: 1280px;
table-layout: fixed;
/* Keep project export decisions and saved files accessible in wide tables. */
.asset-exports-page table {
border-collapse: separate;
border-spacing: 0;
}
.asset-export-history-table th,
.asset-export-history-table td {
border-bottom: 1px solid #f1f5f9;
.asset-exports-page th,
.asset-exports-page td {
overflow-wrap: anywhere;
}
.asset-export-history-table thead th {
position: sticky;
top: 0;
z-index: 2;
background: #f8fafc;
overflow-wrap: normal;
}
@media (min-width: 901px) {
.asset-exports-page thead th {
position: sticky;
top: 0;
z-index: 2;
background: #f8fafc;
}
.asset-export-history-table .asset-export-history-document {
position: sticky;
right: 0;
z-index: 1;
background: #fff;
border-left: 1px solid #e2e8f0;
box-shadow: -6px 0 12px -10px rgb(15 23 42 / 0.3);
}
.asset-exports-page tbody td:last-child {
position: sticky;
right: 0;
z-index: 1;
min-width: 190px;
background: #fff;
border-left: 1px solid #e2e8f0;
box-shadow: -6px 0 12px -10px rgb(15 23 42 / 0.3);
}
.asset-export-history-table thead .asset-export-history-document {
z-index: 3;
background: #f8fafc;
}
.asset-export-history-table tr:hover .asset-export-history-document {
background: #f8fafc;
.asset-exports-page thead th:last-child {
right: 0;
z-index: 3;
}
}
.asset-export-history-file-actions {

View File

@@ -152,6 +152,13 @@ class AccountManager {
this.assetProjects = [];
this.assetProjectSearchTerm = '';
this.assetExportHistories = [];
this.assetExportRequests = [];
this.assetExportTab = 'requests';
this.assetExportSearchTerm = '';
this.assetExportStatusFilter = '';
this.assetExportPage = 1;
this.assetExportLoading = false;
this.assetExportLoadError = '';
this.assetDamageHistories = [];
this.consumableExportHistories = [];
this.consumableBorrowRequests = [];
@@ -387,6 +394,10 @@ class AccountManager {
mainContent.innerHTML = this.getAssetBorrowsContent();
this.setupAssetBorrowListeners();
this.setupAddButtonListeners();
} else if (page === 'asset-exports') {
mainContent.innerHTML = this.getAssetExportsContent();
this.setupAssetExportsListeners();
this.refreshAssetExportsPage();
} else if (page === 'my-borrowed-assets') {
mainContent.innerHTML = this.getMyBorrowedAssetsContent();
this.setupMyBorrowedAssetsListeners();
@@ -1338,10 +1349,8 @@ class AccountManager {
}
refreshBorrowAssetUserOptions(selectedValue = '') {
this.populateUserSelectOptions('borrowAssetUserInput', {
selectedValue,
emptyLabel: '-- Chọn người mượn --'
});
const input = document.getElementById('borrowAssetUserInput');
if (input) input.value = this.getCurrentUserDisplayName();
}
refreshConsumableExportUserOptions(selectedValue = '') {
@@ -2086,21 +2095,176 @@ class AccountManager {
}
}
async fetchAssetExportHistories(limit = 300) {
try {
const safeLimit = Number.isFinite(Number(limit)) ? Math.max(1, Math.min(Number(limit), 2000)) : 300;
const res = await fetch(`${this.apiBase}/asset-export-history?limit=${safeLimit}`, {
headers: this.getAuthHeaders(false)
});
const data = await res.json();
if (data.success) {
this.assetExportHistories = Array.isArray(data.data) ? data.data : [];
} else {
console.error('Load asset export history failed:', data.message);
}
} catch (err) {
console.error('Fetch asset export history error:', err);
getAssetExportsContent() {
const manager = this.canCurrentUserManageAssets();
return `<div class="asset-exports-page flex flex-col p-4 md:p-6 overflow-hidden h-full">
<div class="page-header flex items-center justify-between gap-4 mb-5 shrink-0">
<div><h1 class="text-2xl font-extrabold text-on-surface tracking-tight">Xuất tài sản vào dự án</h1>
<p class="text-sm text-on-surface-variant">${manager ? 'Duyệt đề xuất và theo dõi tài sản đã xuất cho các dự án.' : 'Theo dõi các đơn xuất dự án do bạn đề xuất.'} Tài sản đã xuất không hoàn lại kho.</p></div>
<div class="compact-page-actions flex flex-wrap gap-2">
<button id="refreshAssetExportsBtn" class="border border-slate-200 rounded-lg px-3 py-2 text-xs font-bold">Làm mới</button>
<button id="createAssetExportBtn" class="bg-primary text-on-primary rounded-lg px-4 py-2 text-xs font-bold">Tạo đơn xuất dự án</button>
</div>
</div>
<div class="flex flex-wrap items-center gap-2 mb-4 shrink-0" role="tablist" aria-label="Danh sách xuất tài sản">
<button id="assetExportRequestsTab" role="tab" aria-controls="assetExportsPanel" aria-selected="${this.assetExportTab === 'requests'}" class="px-4 py-2 rounded-lg text-sm font-bold border border-slate-200">Đơn đề xuất</button>
<button id="assetExportHistoryTab" role="tab" aria-controls="assetExportsPanel" aria-selected="${this.assetExportTab === 'history'}" class="px-4 py-2 rounded-lg text-sm font-bold border border-slate-200">Lịch sử đã xuất</button>
</div>
<div class="page-filters flex flex-wrap items-center gap-3 mb-4 shrink-0">
<input id="assetExportSearchInput" aria-label="Tìm đơn xuất" placeholder="Tìm mã đơn, tài sản, dự án, người đề xuất..." class="flex-1 min-w-0 border border-slate-200 rounded-lg px-3 py-2 text-sm" value="${this.escapeHtml(this.assetExportSearchTerm)}">
<select id="assetExportStatusFilter" aria-label="Trạng thái đơn xuất" class="border border-slate-200 rounded-lg px-3 py-2 text-sm">
<option value="">Tất cả trạng thái</option><option value="pending">Chờ duyệt</option><option value="approved">Đã duyệt / Đã xuất</option><option value="rejected">Đã từ chối</option>
</select>
</div>
<p id="assetExportsFeedback" class="mb-3 text-sm text-slate-600" role="status"></p>
<div id="assetExportsPanel" role="tabpanel" aria-labelledby="assetExportRequestsTab" class="flex flex-col min-h-0 bg-white rounded-xl border border-slate-200 overflow-hidden flex-1">
<div class="overflow-auto flex-1"><table class="w-full text-left text-sm" style="min-width: 1080px;">
<thead id="assetExportsTableHead" class="bg-slate-50 text-xs text-slate-500"></thead>
<tbody id="assetExportsTableBody" class="divide-y divide-slate-100"></tbody>
</table></div>
<div id="assetExportsPager" class="page-pager flex items-center justify-between gap-2 px-4 py-2 border-t border-slate-200 bg-slate-50 text-xs text-slate-600"></div>
</div>
</div>`;
}
getFilteredAssetExportRows() {
const history = this.assetExportTab === 'history';
const search = String(this.assetExportSearchTerm || '').trim().toLocaleLowerCase('vi');
return (history ? this.assetExportHistories : this.assetExportRequests).filter(row => {
// The API also enforces ownership, including saved document URLs.
if (!this.canCurrentUserManageAssets() && Number(row.CreatedBy) !== Number(this.getUserId())) return false;
if (!history && this.assetExportStatusFilter && row.RequestStatus !== this.assetExportStatusFilter) return false;
const values = history ? [row.AssetCode, row.AssetName, row.ProjectName, row.ExportedByName, row.ExportNote]
: [row.ExportRequestId, row.RequesterName, row.ProcessedByName, row.RequestNote, row.RejectReason,
...(row.Items || []).flatMap(item => [item.assetCode, item.assetName, item.model, ...item.allocations.map(allocation => allocation.projectName)])];
return !search || values.some(value => String(value || '').toLocaleLowerCase('vi').includes(search));
});
}
renderAssetExportRequestsRows(rows) {
const safe = value => this.escapeHtml(String(value || '-'));
const manager = this.canCurrentUserManageAssets();
return rows.map(row => {
const pending = row.RequestStatus === 'pending';
const status = { pending: ['Chờ duyệt', 'bg-amber-50 text-amber-700'], approved: ['Đã duyệt / Đã xuất', 'bg-emerald-50 text-emerald-700'], rejected: ['Đã từ chối', 'bg-red-50 text-red-700'] }[row.RequestStatus] || ['Không xác định', 'bg-slate-50'];
const items = (row.Items || []).map(item => `<div class="mb-2"><div class="font-semibold">${safe(item.assetCode)} · ${safe(item.assetName)}</div>
${item.allocations.map(allocation => `<div class="text-xs text-slate-600 mt-1">${safe(allocation.projectName)}: <strong>${Number(allocation.quantity)}</strong> ${safe(item.unit)}</div>`).join('')}</div>`).join('');
return `<tr>
<td class="px-4 py-3 whitespace-nowrap font-semibold">#${Number(row.ExportRequestId)}<div class="mt-1 text-xs font-normal text-slate-500">${this.formatDateTime(row.CreatedDate)}</div></td>
<td class="px-4 py-3">${safe(row.RequesterName)}</td>
<td class="px-4 py-3">${items}</td>
<td class="px-4 py-3"><span class="inline-block rounded-lg px-2 py-1 text-xs font-bold ${status[1]}">${status[0]}</span></td>
<td class="px-4 py-3 whitespace-pre-line text-slate-600">${safe(row.RequestNote)}${row.RejectReason ? `<div class="mt-2 text-red-700">Lý do từ chối: ${safe(row.RejectReason)}</div>` : ''}</td>
<td class="px-4 py-3 text-slate-600">${safe(row.ProcessedByName)}${row.ProcessedDate ? `<div class="mt-1 text-xs">${this.formatDateTime(row.ProcessedDate)}</div>` : ''}</td>
<td class="px-4 py-3">${manager && pending ? `<div class="flex gap-2">
<button class="process-asset-export rounded-lg bg-primary text-on-primary px-3 py-2 text-xs font-bold" data-request-id="${Number(row.ExportRequestId)}" data-action="approved">Duyệt xuất</button>
<button class="process-asset-export rounded-lg border border-red-200 text-red-700 px-3 py-2 text-xs font-bold" data-request-id="${Number(row.ExportRequestId)}" data-action="rejected">Từ chối</button></div>` : ''}
${row.ExportDocumentId ? `<div class="flex gap-2 mt-2"><button class="view-asset-export-document rounded-lg border border-slate-200 px-2 py-1 text-xs text-primary" data-document-id="${safe(row.ExportDocumentId)}">Xem phiếu</button><button class="download-asset-export-document rounded-lg border border-slate-200 px-2 py-1 text-xs text-primary" data-document-id="${safe(row.ExportDocumentId)}" data-file-name="${safe(row.DocumentFileName || 'phieu-xuat.xlsx')}">Tải Excel</button></div>` : pending && !manager ? '<span class="text-xs text-slate-500">Chờ admin/asset duyệt</span>' : ''}
</td></tr>`;
}).join('');
}
renderAssetExportsTable() {
if (this.currentPage !== 'asset-exports') return;
const tbody = document.getElementById('assetExportsTableBody');
if (!tbody) return;
const history = this.assetExportTab === 'history';
const columns = history ? ['Ngày xuất', 'Tài sản', 'Số lượng', 'Dự án', 'Người phụ trách', 'Người duyệt xuất', 'Ghi chú', 'Phiếu Excel']
: ['Đơn / Ngày tạo', 'Người đề xuất', 'Tài sản / Dự án / Số lượng', 'Trạng thái', 'Ghi chú', 'Người xử lý', 'Thao tác'];
document.getElementById('assetExportsTableHead').innerHTML = `<tr>${columns.map(label => `<th class="px-4 py-3 font-bold whitespace-nowrap">${label}</th>`).join('')}</tr>`;
const page = this.getPaged(this.getFilteredAssetExportRows(), this.assetExportPage, 10);
this.assetExportPage = page.current;
tbody.innerHTML = this.assetExportLoading ? `<tr><td colspan="${columns.length}" class="px-4 py-8 text-center text-slate-500">Đang tải đơn xuất...</td></tr>`
: !page.total ? `<tr><td colspan="${columns.length}" class="px-4 py-8 text-center text-slate-500">${this.assetExportLoadError ? 'Chưa tải được dữ liệu. Bấm Làm mới để thử lại.' : 'Chưa có đơn xuất phù hợp.'}</td></tr>`
: history ? this.buildAssetExportHistoryRowsHtml(page.data) : this.renderAssetExportRequestsRows(page.data);
document.getElementById('assetExportsFeedback').textContent = this.assetExportLoadError;
document.getElementById('assetExportStatusFilter').hidden = history;
document.getElementById('assetExportsPanel').setAttribute('aria-labelledby', history ? 'assetExportHistoryTab' : 'assetExportRequestsTab');
for (const [id, selected] of [['assetExportRequestsTab', !history], ['assetExportHistoryTab', history]]) {
const button = document.getElementById(id);
button.setAttribute('aria-selected', String(selected));
button.classList.toggle('bg-primary', selected);
button.classList.toggle('text-on-primary', selected);
}
document.getElementById('assetExportsPager').innerHTML = `<span>Hiển thị ${page.start}-${page.end} / ${page.total}</span><div class="flex items-center gap-2">
<button class="asset-export-page-btn border border-slate-200 rounded px-2 py-1" data-page="${page.current - 1}" ${page.current === 1 ? 'disabled' : ''}>Trước</button><span>Trang ${page.current} / ${page.totalPages}</span><button class="asset-export-page-btn border border-slate-200 rounded px-2 py-1" data-page="${page.current + 1}" ${page.current === page.totalPages ? 'disabled' : ''}>Sau</button></div>`;
this.enhanceResponsiveTables(document.getElementById('assetExportsPanel'));
}
async refreshAssetExportsPage() {
if (this.assetExportLoading) return;
this.assetExportLoading = true;
this.assetExportLoadError = '';
this.renderAssetExportsTable();
try {
const [requests, history] = await Promise.all([
fetch(`${this.apiBase}/asset-export-requests`, { headers: this.getAuthHeaders(false), cache: 'no-store' }),
fetch(`${this.apiBase}/asset-export-history?limit=2000`, { headers: this.getAuthHeaders(false), cache: 'no-store' })
]);
const [requestData, historyData] = await Promise.all([requests.json(), history.json()]);
if (!requests.ok || !requestData.success || !history.ok || !historyData.success) throw new Error(requestData.message || historyData.message || 'Không tải được danh sách đơn xuất.');
this.assetExportRequests = requestData.data || [];
this.assetExportHistories = historyData.data || [];
} catch (err) {
this.assetExportRequests = [];
this.assetExportHistories = [];
this.assetExportLoadError = err.message || 'Không tải được danh sách đơn xuất.';
} finally {
this.assetExportLoading = false;
this.renderAssetExportsTable();
}
}
setupAssetExportsListeners() {
document.getElementById('assetExportStatusFilter').value = this.assetExportStatusFilter;
document.getElementById('assetExportStatusFilter').onchange = event => { this.assetExportStatusFilter = event.target.value; this.assetExportPage = 1; this.renderAssetExportsTable(); };
document.getElementById('assetExportSearchInput').oninput = event => { this.assetExportSearchTerm = event.target.value; this.assetExportPage = 1; this.renderAssetExportsTable(); };
document.getElementById('refreshAssetExportsBtn').onclick = () => this.refreshAssetExportsPage();
document.getElementById('createAssetExportBtn').onclick = () => { location.hash = '#assets'; this.notifyWarning('Chọn một hoặc nhiều tài sản, sau đó bấm Tạo đơn xuất dự án.'); };
for (const [id, tab] of [['assetExportRequestsTab', 'requests'], ['assetExportHistoryTab', 'history']]) {
document.getElementById(id).onclick = () => { this.assetExportTab = tab; this.assetExportPage = 1; this.renderAssetExportsTable(); };
}
document.getElementById('assetExportsPanel').onclick = event => {
const button = event.target.closest('button');
if (!button) return;
if (button.matches('.asset-export-page-btn')) { this.assetExportPage = Number(button.dataset.page); this.renderAssetExportsTable(); }
if (button.matches('.view-asset-export-document')) this.openSavedAssetExportPreview(button.dataset.documentId);
if (button.matches('.download-asset-export-document')) this.downloadSavedAssetExport(button.dataset.documentId, button.dataset.fileName, button);
if (button.matches('.process-asset-export')) this.openAssetExportProcessModal(Number(button.dataset.requestId), button.dataset.action);
};
this.renderAssetExportsTable();
}
openAssetExportProcessModal(requestId, action) {
if (!this.canCurrentUserManageAssets() || this.assetExportProcessing) return;
const modal = document.getElementById('assetExportProcessModal');
const rejected = action === 'rejected';
const reason = document.getElementById('assetExportRejectReason');
reason.value = '';
reason.required = rejected;
document.getElementById('assetExportRejectField').hidden = !rejected;
document.getElementById('assetExportProcessTitle').textContent = `${rejected ? 'Từ chối' : 'Duyệt xuất dự án'} — Đơn #${requestId}`;
document.getElementById('assetExportProcessMessage').textContent = rejected ? 'Nhập lý do để người đề xuất biết và điều chỉnh.' : 'Khi duyệt, toàn bộ số lượng trong đơn sẽ được xuất vào các dự án đã chọn và trừ tồn kho. Tài sản đã xuất không hoàn lại kho.';
document.getElementById('assetExportProcessSubmit').textContent = rejected ? 'Từ chối đơn' : 'Duyệt và xuất vào dự án';
document.getElementById('assetExportProcessForm').onsubmit = event => { event.preventDefault(); this.processAssetExportRequest(requestId, action, reason.value.trim()); };
modal.classList.add('open');
if (rejected) reason.focus();
}
async processAssetExportRequest(requestId, action, rejectReason) {
if (!this.canCurrentUserManageAssets() || this.assetExportProcessing) return;
const button = document.getElementById('assetExportProcessSubmit');
this.assetExportProcessing = true;
button.disabled = true;
try {
const response = await fetch(`${this.apiBase}/asset-export-requests/${requestId}/process`, { method: 'POST', headers: this.getAuthHeaders(true), body: JSON.stringify({ action, rejectReason }) });
const data = await response.json();
if (!response.ok || !data.success) { this.notifyFailure(data.message || 'Không xử lý được đơn xuất.'); return; }
document.getElementById('assetExportProcessModal').classList.remove('open');
this.notifySuccess(data.message);
await Promise.all([this.refreshAssetExportsPage(), this.fetchAssets()]);
} catch (err) { this.notifyFailure(err.message || 'Không xử lý được đơn xuất.'); }
finally { this.assetExportProcessing = false; button.disabled = false; }
}
buildAssetExportHistoryRowsHtml(rows = []) {
@@ -2139,42 +2303,8 @@ class AccountManager {
}).join('');
}
renderAssetExportHistoryModal() {
const tbody = document.getElementById('assetExportHistoryTableBody');
if (!tbody) {
return;
}
tbody.innerHTML = this.buildAssetExportHistoryRowsHtml(this.assetExportHistories);
tbody.querySelectorAll('.view-asset-export-document').forEach(button => {
button.onclick = () => this.openSavedAssetExportPreview(button.dataset.documentId);
});
tbody.querySelectorAll('.download-asset-export-document').forEach(button => {
button.onclick = () => this.downloadSavedAssetExport(button.dataset.documentId, button.dataset.fileName, button);
});
}
async openAssetExportHistoryModal() {
if (!this.ensureAssetManagePermission('xem lich su xuat tai san')) {
return;
}
const modal = document.getElementById('assetExportHistoryModal');
const tbody = document.getElementById('assetExportHistoryTableBody');
if (!modal || !tbody) {
this.notifyFailure('Không tìm thấy biểu mẫu lịch sử xuất tài sản.');
return;
}
tbody.innerHTML = `
<tr>
<td colspan="8" class="px-4 py-8 text-sm text-center text-slate-500">Đang tải lịch sử xuất...</td>
</tr>
`;
modal.classList.add('open');
await this.fetchAssetExportHistories();
this.renderAssetExportHistoryModal();
openAssetExportsPage() {
location.hash = '#asset-exports';
}
buildSavedAssetExportPreviewHtml(snapshot) {
@@ -2198,7 +2328,7 @@ class AccountManager {
return `<div class="grid grid-cols-1 md:grid-cols-2 gap-3 rounded-lg bg-slate-50 p-4 text-sm text-slate-700">
<p><span class="font-semibold">Ngày xuất:</span> ${this.formatDateTime(snapshot.exportedDate)}</p>
<p><span class="font-semibold">Người xuất:</span> ${safe(snapshot.exportedByName)}</p>
<p><span class="font-semibold">Người mượn:</span> ${safe(snapshot.borrowerName)}</p>
<p><span class="font-semibold">Người đề xuất:</span> ${safe(snapshot.requesterName || snapshot.borrowerName)}</p>
<p><span class="font-semibold">Số tài sản:</span> ${(snapshot.items || []).length}</p>
<p class="md:col-span-2 whitespace-pre-line"><span class="font-semibold">Ghi chú:</span> ${safe(snapshot.note)}</p>
</div>
@@ -2211,7 +2341,6 @@ class AccountManager {
}
async openSavedAssetExportPreview(documentId) {
if (!this.ensureAssetManagePermission('xem phiếu xuất tài sản')) return;
const modal = document.getElementById('assetExportPreviewModal');
const content = document.getElementById('assetExportPreviewContent');
const downloadButton = document.getElementById('assetExportPreviewDownloadBtn');
@@ -2236,7 +2365,6 @@ class AccountManager {
}
async downloadSavedAssetExport(documentId, fileName, button) {
if (!this.ensureAssetManagePermission('tải phiếu xuất tài sản')) return;
if (button?.disabled) return;
if (button) button.disabled = true;
try {
@@ -7683,7 +7811,7 @@ class AccountManager {
<article class="asset-mobile-card rounded-xl border border-slate-200 bg-white p-3 shadow-sm">
<div class="flex items-start justify-between gap-3">
<div class="flex min-w-0 items-start gap-2">
<input type="checkbox" class="asset-row-checkbox mt-1 w-4 h-4 shrink-0" data-asset-id="${asset?.AssetId}" ${isSelected ? 'checked' : ''} ${canManageAssets ? '' : 'disabled'} aria-label="Chọn tài sản ${safe(asset?.AssetCode)}">
<input type="checkbox" class="asset-row-checkbox mt-1 w-4 h-4 shrink-0" data-asset-id="${asset?.AssetId}" ${isSelected ? 'checked' : ''} aria-label="Chọn tài sản ${safe(asset?.AssetCode)}">
<div class="min-w-0">
<div class="text-[10px] font-bold uppercase tracking-wider text-slate-400">#${rowNumber} · ${safe(asset?.AssetCode)}</div>
<h3 class="mt-0.5 text-sm font-extrabold text-slate-800">${safe(asset?.AssetName)}</h3>
@@ -7734,12 +7862,12 @@ class AccountManager {
const canManageAssets = this.canCurrentUserManageAssets();
const filteredAssets = this.getFilteredAssets();
const pageInfo = this.getPaged(filteredAssets, this.assetPage, this.assetPageSize);
const selectedCount = canManageAssets ? this.selectedAssetIds.size : 0;
const selectedCount = this.selectedAssetIds.size;
const pageAssetIds = pageInfo.data
.map(asset => Number(asset.AssetId))
.filter(id => Number.isFinite(id));
const selectedOnPageCount = pageAssetIds.filter(id => this.selectedAssetIds.has(id)).length;
const allOnPageSelected = canManageAssets && pageAssetIds.length > 0 && selectedOnPageCount === pageAssetIds.length;
const allOnPageSelected = pageAssetIds.length > 0 && selectedOnPageCount === pageAssetIds.length;
this.assetPage = pageInfo.current;
return `
@@ -7766,7 +7894,7 @@ class AccountManager {
<span class="material-symbols-outlined text-base">download</span>
Xuất Excel
</button>
<button id="openAssetExportHistoryBtn" class="border border-amber-300 text-amber-700 px-3 py-2 rounded-lg text-xs font-bold flex items-center gap-1.5 transition-all active:scale-95 ${canManageAssets ? 'hover:bg-amber-50' : 'opacity-50 cursor-not-allowed'}" ${canManageAssets ? '' : 'disabled'}>
<button id="openAssetExportHistoryBtn" class="border border-amber-300 text-amber-700 px-3 py-2 rounded-lg text-xs font-bold flex items-center gap-1.5 transition-all active:scale-95 hover:bg-amber-50">
<span class="material-symbols-outlined text-base">history</span>
Lịch sử xuất
</button>
@@ -7778,9 +7906,9 @@ class AccountManager {
<span class="material-symbols-outlined text-base">add_box</span>
Thêm tài sản
</button>
<button id="borrowAssetBtn" class="border border-primary text-primary px-4 py-2 rounded-lg text-xs font-bold flex items-center gap-1.5 transition-all active:scale-95 ${(canManageAssets && selectedCount > 0) ? 'hover:bg-primary/5' : 'opacity-50 cursor-not-allowed'}" ${(canManageAssets && selectedCount > 0) ? '' : 'disabled'}>
<button id="borrowAssetBtn" class="border border-primary text-primary px-4 py-2 rounded-lg text-xs font-bold flex items-center gap-1.5 transition-all active:scale-95 ${(selectedCount > 0) ? 'hover:bg-primary/5' : 'opacity-50 cursor-not-allowed'}" ${(selectedCount > 0) ? '' : 'disabled'}>
<span class="material-symbols-outlined text-base">handshake</span>
Xuất tài sản
Tạo đơn xuất dự án
</button>
<button id="damageAssetBtn" class="border border-red-300 text-red-700 px-4 py-2 rounded-lg text-xs font-bold flex items-center gap-1.5 transition-all active:scale-95 ${(canManageAssets && selectedCount === 1) ? 'hover:bg-red-50' : 'opacity-50 cursor-not-allowed'}" ${(canManageAssets && selectedCount === 1) ? '' : 'disabled'}>
<span class="material-symbols-outlined text-base">broken_image</span>
@@ -7817,7 +7945,7 @@ class AccountManager {
<thead class="sticky top-0 z-50 bg-slate-50 border-b border-slate-200">
<tr>
<th class="px-4 py-2.5 text-center">
<input type="checkbox" id="selectAllAssetsCheckbox" class="w-4 h-4" ${allOnPageSelected ? 'checked' : ''} ${canManageAssets ? '' : 'disabled'} title="Chọn tất cả dòng trong trang hiện tại">
<input type="checkbox" id="selectAllAssetsCheckbox" class="w-4 h-4" ${allOnPageSelected ? 'checked' : ''} title="Chọn tất cả dòng trong trang hiện tại">
</th>
<th class="px-4 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500">STT</th>
<th class="px-4 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500">Mã</th>
@@ -7855,7 +7983,7 @@ class AccountManager {
return `
<tr class="group hover:bg-slate-50/80 transition-colors">
<td class="px-4 py-3 text-center">
<input type="checkbox" class="asset-row-checkbox w-4 h-4" data-asset-id="${asset.AssetId}" ${isSelected ? 'checked' : ''} ${canManageAssets ? '' : 'disabled'}>
<input type="checkbox" class="asset-row-checkbox w-4 h-4" data-asset-id="${asset.AssetId}" ${isSelected ? 'checked' : ''}>
</td>
<td class="px-4 py-3 text-sm text-slate-600">${rowNumber}</td>
<td class="px-4 py-3 text-sm font-semibold text-slate-700">${asset.AssetCode || '-'}</td>
@@ -7946,7 +8074,7 @@ class AccountManager {
return `
<tr class="group hover:bg-slate-50/80 transition-colors">
<td class="px-4 py-3 text-center">
<input type="checkbox" class="asset-row-checkbox w-4 h-4" data-asset-id="${asset.AssetId}" ${isSelected ? 'checked' : ''} ${canManageAssets ? '' : 'disabled'}>
<input type="checkbox" class="asset-row-checkbox w-4 h-4" data-asset-id="${asset.AssetId}" ${isSelected ? 'checked' : ''}>
</td>
<td class="px-4 py-3 text-sm text-slate-600">${rowNumber}</td>
<td class="px-4 py-3 text-sm font-semibold text-slate-700">${asset.AssetCode || '-'}</td>
@@ -8015,22 +8143,6 @@ class AccountManager {
}
setupAssetSelectionListeners() {
if (!this.canCurrentUserManageAssets()) {
this.selectedAssetIds.clear();
document.querySelectorAll('.asset-row-checkbox').forEach(checkbox => {
checkbox.checked = false;
checkbox.disabled = true;
});
const selectAllCheckbox = document.getElementById('selectAllAssetsCheckbox');
if (selectAllCheckbox) {
selectAllCheckbox.checked = false;
selectAllCheckbox.indeterminate = false;
selectAllCheckbox.disabled = true;
}
this.updateAssetBulkActionState();
return;
}
document.querySelectorAll('.asset-row-checkbox').forEach(checkbox => {
checkbox.addEventListener('change', () => {
const assetId = Number(checkbox.dataset.assetId);
@@ -8099,23 +8211,17 @@ class AccountManager {
});
const selectedOnPage = Array.from(assetSelectionById.values()).filter(Boolean).length;
if (!canManageAssets) {
this.selectedAssetIds.clear();
}
rowCheckboxes.forEach(checkbox => {
checkbox.disabled = !canManageAssets;
});
const selectAllCheckbox = document.getElementById('selectAllAssetsCheckbox');
if (selectAllCheckbox) {
const assetCountOnPage = assetSelectionById.size;
const hasRows = assetCountOnPage > 0;
selectAllCheckbox.checked = canManageAssets && hasRows && selectedOnPage === assetCountOnPage;
selectAllCheckbox.indeterminate = canManageAssets && selectedOnPage > 0 && selectedOnPage < assetCountOnPage;
selectAllCheckbox.disabled = !canManageAssets;
selectAllCheckbox.checked = hasRows && selectedOnPage === assetCountOnPage;
selectAllCheckbox.indeterminate = selectedOnPage > 0 && selectedOnPage < assetCountOnPage;
selectAllCheckbox.disabled = !hasRows;
}
const selectedCount = canManageAssets ? this.selectedAssetIds.size : 0;
const selectedCount = this.selectedAssetIds.size;
const selectedCountNode = document.getElementById('selectedAssetCount');
if (selectedCountNode) {
selectedCountNode.textContent = String(selectedCount);
@@ -8131,7 +8237,7 @@ class AccountManager {
const borrowAssetBtn = document.getElementById('borrowAssetBtn');
if (borrowAssetBtn) {
const disabled = !canManageAssets || selectedCount === 0;
const disabled = selectedCount === 0;
borrowAssetBtn.disabled = disabled;
borrowAssetBtn.classList.toggle('opacity-50', disabled);
borrowAssetBtn.classList.toggle('cursor-not-allowed', disabled);
@@ -8251,9 +8357,16 @@ class AccountManager {
return (this.archivedAssets || []).map(asset => {
const borrowerQuantity = this.parseBorrowerEntries(asset.Borrower)
.reduce((sum, entry) => sum + this.parseNonNegativeInteger(entry.quantity, 0), 0);
let allocations = asset.ProjectAllocations || [];
if (typeof allocations === 'string') {
try { allocations = JSON.parse(allocations); } catch { allocations = []; }
}
const permanentQuantity = (Array.isArray(allocations) ? allocations : [])
.filter(row => row.allocationType === 'export')
.reduce((sum, row) => sum + this.parseNonNegativeInteger(row.quantity, 0), 0);
return {
...asset,
OutstandingQuantity: Math.max(borrowerQuantity, this.parseNonNegativeInteger(asset.ExportInPeriod, 0))
OutstandingQuantity: Math.max(borrowerQuantity, this.parseNonNegativeInteger(asset.ExportInPeriod, 0) - permanentQuantity)
};
}).filter(asset => !search || [
asset.AssetId, asset.AssetCode, asset.AssetName, asset.Model, asset.SerialNumber,
@@ -8883,7 +8996,6 @@ class AccountManager {
}
async openBatchAssetExportModal() {
if (!this.ensureAssetManagePermission('xuất nhiều tài sản')) return;
const assets = this.assets.filter(asset => this.selectedAssetIds.has(Number(asset.AssetId)));
if (!assets.length || assets.length > 100) {
this.notifyWarning('Vui lòng chọn từ 1 đến 100 tài sản để xuất.');
@@ -8894,12 +9006,11 @@ class AccountManager {
this.notifyWarning(`${unavailable.AssetCode || unavailable.AssetName}: đã hết tồn, hãy bỏ chọn tài sản này.`);
return;
}
if (!this.users.length) await this.fetchUsers();
if (!this.assetProjects.length) await this.fetchAssetProjects();
const modal = document.getElementById('batchAssetExportModal');
const form = document.getElementById('batchAssetExportForm');
if (!modal || !form) { this.notifyFailure('Không tìm thấy biểu mẫu xuất nhiều tài sản.'); return; }
this.populateUserSelectOptions('batchAssetExportUserInput', { selectedValue: '', emptyLabel: '-- Chọn người mượn --' });
document.getElementById('batchAssetExportUserInput').value = this.getCurrentUserDisplayName();
const commonProject = document.getElementById('batchAssetExportCommonProject');
commonProject.innerHTML = '<option value="">-- Áp dụng dự án cho tất cả --</option>'
+ this.getUniqueAssetProjectNames().map(name => `<option value="${this.escapeHtml(name)}">${this.escapeHtml(name)}</option>`).join('');
@@ -8921,11 +9032,11 @@ class AccountManager {
async handleBatchAssetExportSubmit(event) {
event.preventDefault();
if (!this.ensureAssetManagePermission('xuất nhiều tài sản') || this.assetExportSubmitting) return;
if (this.assetExportSubmitting) return;
const items = this.collectBatchAssetExportItems();
const borrowerName = String(document.getElementById('batchAssetExportUserInput')?.value || '').trim();
const note = String(document.getElementById('batchAssetExportNoteInput')?.value || '').trim();
if (!borrowerName) { this.notifyWarning('Vui lòng chọn người mượn.'); return; }
if (!borrowerName) { this.notifyWarning('Không xác định được người đề xuất.'); return; }
if (!items.length || items.length > 100) { this.notifyWarning('Vui lòng chọn từ 1 đến 100 tài sản.'); return; }
for (const item of items) {
const asset = this.assets.find(asset => Number(asset.AssetId) === item.assetId);
@@ -8940,20 +9051,23 @@ class AccountManager {
if (button) button.disabled = true;
let exportSucceeded = false;
try {
const response = await fetch(`${this.apiBase}/assets/export`, {
const response = await fetch(`${this.apiBase}/asset-export-requests`, {
method: 'POST', headers: this.getAuthHeaders(true), body: JSON.stringify({ borrowerName, note, items })
});
const data = await response.json();
if (!response.ok || !data.success) { this.notifyFailure(data.message || 'Xuất tài sản thất bại.'); return; }
exportSucceeded = true;
this.selectedAssetIds.clear();
this.notifySuccess(`Đã xuất ${items.length} tài sản và lưu phiếu Excel vào lịch sử.`);
this.notifySuccess('Đã gửi đơn xuất vào dự án, chờ admin/asset duyệt.');
this.closeModals();
this.showExportRequestDocument(data.document);
await this.refreshAssetsUI();
this.assetExportTab = 'requests';
this.assetExportPage = 1;
this.assetExportSearchTerm = '';
this.assetExportStatusFilter = '';
location.hash = '#asset-exports';
} catch (err) {
console.error(err);
if (exportSucceeded) this.notifyWarning('Đã xuất tài sản thành công. Chưa cập nhật được danh sách; hãy tải lại trang.');
if (exportSucceeded) this.notifyWarning('Đã gửi đơn xuất. Hãy mở danh sách đơn xuất để kiểm tra.');
else this.notifyFailure('Xuất tài sản thất bại.');
} finally {
this.assetExportSubmitting = false;
@@ -9005,19 +9119,12 @@ class AccountManager {
}
async openBorrowAssetModal() {
if (!this.ensureAssetManagePermission('xuat tai san')) {
return;
}
if (this.selectedAssetIds.size > 1) return this.openBatchAssetExportModal();
const asset = this.getSingleSelectedAssetForBorrowing(true);
if (!asset) {
return;
}
if (!this.users.length) {
await this.fetchUsers();
}
if (!this.assetProjects.length) {
await this.fetchAssetProjects();
}
@@ -9036,8 +9143,6 @@ class AccountManager {
const quantityInput = document.getElementById('borrowQuantityInput');
const projectInput = document.getElementById('borrowAssetProjectInput');
const noteInput = document.getElementById('borrowAssetNoteInput');
const borrowByInput = document.getElementById('borrowByInput');
const borrowRoleInput = document.getElementById('borrowRoleInput');
const modal = document.getElementById('borrowAssetModal');
if (!modal || !assetNameInput || !endingInput || !quantityInput || !projectInput || !noteInput) {
@@ -9055,7 +9160,7 @@ class AccountManager {
quantityInput.min = '1';
quantityInput.max = String(available);
this.refreshBorrowAssetUserOptions('');
document.getElementById('borrowAssetUserInput').value = this.getCurrentUserDisplayName();
this.refreshBorrowAssetProjectOptions(String(asset?.Project || '').trim());
noteInput.value = '';
document.getElementById('borrowAdditionalProjects').innerHTML = '';
@@ -9065,24 +9170,12 @@ class AccountManager {
document.getElementById('borrowAssetForm').oninput = () => this.updateBorrowAllocationSummary();
this.updateBorrowAllocationSummary();
if (borrowByInput) {
borrowByInput.value = this.getCurrentUserDisplayName();
}
if (borrowRoleInput) {
borrowRoleInput.value = String(this.getCurrentUserRoleRaw() || '').trim() || '-';
}
modal.classList.add('open');
}
async handleBorrowAssetSubmit(e) {
e.preventDefault();
if (!this.ensureAssetManagePermission('xuat tai san')) {
return;
}
const assetIdInput = document.getElementById('borrowAssetIdInput');
const borrowerInput = document.getElementById('borrowAssetUserInput');
const noteInput = document.getElementById('borrowAssetNoteInput');
@@ -9101,7 +9194,7 @@ class AccountManager {
const borrowerName = String(borrowerInput?.value || '').trim();
if (!borrowerName) {
this.notifyWarning('Vui lòng chọn người mượn.');
this.notifyWarning('Không xác định được người đề xuất.');
return;
}
@@ -9134,14 +9227,11 @@ class AccountManager {
if (submitButton) submitButton.disabled = true;
let exportSucceeded = false;
try {
const response = await fetch(`${this.apiBase}/assets/${selectedAssetId}/export`, {
const response = await fetch(`${this.apiBase}/asset-export-requests`, {
method: 'POST',
headers: this.getAuthHeaders(true),
body: JSON.stringify({
quantity: borrowQuantity,
borrowerName,
custodianName: borrowerName,
allocations,
items: [{ assetId: selectedAssetId, allocations }],
note: exportNote
})
});
@@ -9154,18 +9244,17 @@ class AccountManager {
exportSucceeded = true;
this.pendingBorrowAssetId = undefined;
this.notifySuccess('Xuất tài sản thành công');
this.selectedAssetIds.clear();
this.notifySuccess('Đã gửi đơn xuất vào dự án, chờ admin/asset duyệt.');
this.closeModals();
this.showExportRequestDocument(data.document);
await this.refreshAssetsUI();
const exportHistoryModal = document.getElementById('assetExportHistoryModal');
if (exportHistoryModal?.classList.contains('open')) {
await this.fetchAssetExportHistories();
this.renderAssetExportHistoryModal();
}
this.assetExportTab = 'requests';
this.assetExportPage = 1;
this.assetExportSearchTerm = '';
this.assetExportStatusFilter = '';
location.hash = '#asset-exports';
} catch (err) {
console.error(err);
if (exportSucceeded) this.notifyWarning('Đã xuất tài sản thành công. Chưa cập nhật được danh sách; hãy tải lại trang.');
if (exportSucceeded) this.notifyWarning('Đã gửi đơn xuất. Hãy mở danh sách đơn xuất để kiểm tra.');
else this.notifyFailure('Xuất tài sản thất bại');
} finally {
this.assetExportSubmitting = false;
@@ -11980,7 +12069,7 @@ class AccountManager {
}
if (openAssetExportHistoryBtn && !openAssetExportHistoryBtn.dataset.boundClick) {
openAssetExportHistoryBtn.addEventListener('click', () => this.openAssetExportHistoryModal());
openAssetExportHistoryBtn.addEventListener('click', () => this.openAssetExportsPage());
openAssetExportHistoryBtn.dataset.boundClick = 'true';
}
@@ -13310,13 +13399,6 @@ function closeAssetDamageModal() {
}
}
function closeAssetExportHistoryModal() {
const modal = document.getElementById('assetExportHistoryModal');
if (modal) {
modal.classList.remove('open');
}
}
function closeAssetDamageHistoryModal() {
const modal = document.getElementById('assetDamageHistoryModal');
if (modal) {

View File

@@ -702,13 +702,14 @@
<div class="modal-backdrop fixed inset-0 z-[100] flex items-center justify-center bg-black/40 backdrop-blur-sm" id="borrowAssetModal">
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
<h3 class="text-base font-extrabold text-slate-900">Xuất tài sản</h3>
<h3 class="text-base font-extrabold text-slate-900">Tạo đơn xuất tài sản vào dự án</h3>
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="borrowAssetModal">
<span class="material-symbols-outlined">close</span>
</button>
</div>
<form id="borrowAssetForm" class="p-6 space-y-4 overflow-y-auto" style="max-height: 80vh;">
<input type="hidden" id="borrowAssetIdInput">
<p class="text-sm text-slate-600">Xuất vào dự án, không hoàn lại kho. Số lượng chỉ trừ khi admin/asset duyệt đơn.</p>
<p id="borrowAssetStockSummary" class="text-sm font-semibold text-slate-700"></p>
<div>
<label class="text-[10px] font-bold uppercase text-slate-500 tracking-widest block mb-1">Tài sản</label>
@@ -720,10 +721,8 @@
<input type="number" id="borrowCurrentEndingInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3 bg-slate-50" readonly>
</div>
<div>
<label for="borrowAssetUserInput" class="text-xs font-bold text-slate-500 block mb-1">Người mượn</label>
<select id="borrowAssetUserInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3" required>
<option value="">-- Chọn người mượn --</option>
</select>
<label for="borrowAssetUserInput" class="text-xs font-bold text-slate-500 block mb-1">Người đề xuất</label>
<input type="text" id="borrowAssetUserInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3 bg-slate-50" readonly required>
</div>
<div class="md:col-span-2 space-y-3">
<div class="flex items-end gap-2">
@@ -740,22 +739,14 @@
<button type="button" id="addBorrowProjectBtn" class="mt-2 px-3 py-2 text-xs font-bold text-primary border border-slate-200 rounded-lg">+ Thêm dự án</button>
<p id="borrowAllocationSummary" class="mt-2 text-sm font-semibold" aria-live="polite"></p>
</div>
<div>
<label for="borrowByInput" class="text-xs font-bold text-slate-500 block mb-1">Người xuất</label>
<input type="text" id="borrowByInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3 bg-slate-50" readonly>
</div>
<div>
<label for="borrowRoleInput" class="text-xs font-bold text-slate-500 block mb-1">Role người thao tác</label>
<input type="text" id="borrowRoleInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3 bg-slate-50" readonly>
</div>
<div class="md:col-span-2">
<label for="borrowAssetNoteInput" class="text-xs font-bold text-slate-500 block mb-1">Ghi chú xuất</label>
<textarea id="borrowAssetNoteInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3 h-20 resize-none" placeholder="Nhập ghi chú (nếu có)"></textarea>
<textarea id="borrowAssetNoteInput" maxlength="1000" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3 h-20 resize-none" placeholder="Nhập ghi chú (nếu có)"></textarea>
</div>
</div>
<div class="flex gap-3 pt-2">
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="borrowAssetModal">Hủy</button>
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Xuất và tải Excel</button>
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Gửi đơn chờ duyệt</button>
</div>
</form>
</div>
@@ -765,12 +756,12 @@
<div class="modal-backdrop fixed inset-0 z-[110] flex items-center justify-center bg-black/40 backdrop-blur-sm" id="batchAssetExportModal">
<div class="modal-content w-full max-w-5xl bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4 flex flex-col" style="max-height: calc(100vh - 2rem);">
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
<div><h3 class="text-base font-extrabold text-slate-900">Xuất nhiều tài sản</h3><p class="mt-1 text-xs text-slate-500">Chọn số lượng và dự án cho từng tài sản trong một phiếu.</p></div>
<div><h3 class="text-base font-extrabold text-slate-900">Tạo đơn xuất nhiều tài sản vào dự án</h3><p class="mt-1 text-xs text-slate-500">Chọn số lượng và dự án cho từng tài sản. Chỉ trừ kho khi được duyệt; tài sản xuất không hoàn lại kho.</p></div>
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400" data-close-modal="batchAssetExportModal" aria-label="Đóng"><span class="material-symbols-outlined">close</span></button>
</div>
<form id="batchAssetExportForm" class="p-6 space-y-4 overflow-y-auto">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<label class="text-xs font-semibold text-slate-600">Người mượn<select id="batchAssetExportUserInput" class="mt-1 w-full border border-slate-200 rounded-lg px-3 py-2 text-sm" required><option value="">-- Chọn người mượn --</option></select></label>
<label class="text-xs font-semibold text-slate-600">Người đề xuất<input id="batchAssetExportUserInput" class="mt-1 w-full border border-slate-200 rounded-lg px-3 py-2 text-sm bg-slate-50" readonly required></label>
<label class="text-xs font-semibold text-slate-600">Dự án chung (tùy chọn)<select id="batchAssetExportCommonProject" class="mt-1 w-full border border-slate-200 rounded-lg px-3 py-2 text-sm"><option value="">-- Áp dụng dự án cho tất cả --</option></select></label>
</div>
<p id="batchAssetExportSummary" class="text-sm font-semibold text-slate-700" aria-live="polite"></p>
@@ -783,7 +774,7 @@
<label class="block text-xs font-semibold text-slate-600">Ghi chú xuất<textarea id="batchAssetExportNoteInput" class="mt-1 w-full border border-slate-200 rounded-lg px-3 py-2 text-sm h-20 resize-none" maxlength="1000" placeholder="Nhập ghi chú (nếu có)"></textarea></label>
<div class="flex gap-3 pt-2">
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="batchAssetExportModal">Hủy</button>
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Xuất và tải Excel</button>
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Gửi đơn chờ duyệt</button>
</div>
</form>
</div>
@@ -864,48 +855,24 @@
</div>
</div>
<!-- Asset Export History Modal -->
<div class="modal-backdrop fixed inset-0 z-[110] flex items-center justify-center bg-black/40 backdrop-blur-sm" id="assetExportHistoryModal" style="z-index: 125;">
<div class="modal-content asset-export-history-dialog bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden flex flex-col">
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50 shrink-0">
<h3 class="text-base font-extrabold text-slate-900">Lịch sử xuất tài sản</h3>
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetExportHistoryModal">
<span class="material-symbols-outlined">close</span>
</button>
<!-- Approve/reject a project export proposal -->
<div class="modal-backdrop fixed inset-0 z-[110] flex items-center justify-center bg-black/40 backdrop-blur-sm" id="assetExportProcessModal">
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
<h3 id="assetExportProcessTitle" class="text-base font-extrabold text-slate-900">Duyệt xuất dự án</h3>
<button type="button" class="p-1.5 rounded-lg text-slate-500" data-close-modal="assetExportProcessModal" aria-label="Đóng"><span class="material-symbols-outlined">close</span></button>
</div>
<div class="p-6 pt-4 min-h-0">
<div class="asset-export-history-scroll rounded-xl border border-slate-200">
<table class="asset-export-history-table w-full text-left">
<colgroup>
<col style="width: 180px;">
<col>
<col style="width: 88px;">
<col style="width: 144px;">
<col style="width: 156px;">
<col style="width: 140px;">
<col style="width: 168px;">
<col style="width: 248px;">
</colgroup>
<thead class="bg-slate-50 border-b border-slate-200">
<tr>
<th class="px-4 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500">Ngày giờ</th>
<th class="px-4 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500">Tài sản</th>
<th class="px-4 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500">Số lượng</th>
<th class="px-4 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500">Dự án</th>
<th class="px-4 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500">Người phụ trách</th>
<th class="px-4 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500">Người xuất</th>
<th class="px-4 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500">Ghi chú</th>
<th class="asset-export-history-document px-4 py-2.5 text-[10px] font-bold uppercase tracking-wider text-slate-500 whitespace-nowrap">Phiếu Excel</th>
</tr>
</thead>
<tbody id="assetExportHistoryTableBody" class="divide-y divide-slate-100">
<tr>
<td colspan="8" class="px-4 py-8 text-sm text-center text-slate-500">Chưa có dữ liệu lịch sử xuất.</td>
</tr>
</tbody>
</table>
<form id="assetExportProcessForm" class="p-6 space-y-4">
<p id="assetExportProcessMessage" class="text-sm text-slate-600"></p>
<div id="assetExportRejectField" hidden>
<label for="assetExportRejectReason" class="block mb-1 text-sm font-bold text-slate-700">Lý do từ chối</label>
<textarea id="assetExportRejectReason" maxlength="1000" class="w-full border border-slate-200 rounded-lg px-3 py-2 text-sm h-24"></textarea>
</div>
</div>
<div class="flex gap-3 pt-2">
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold border border-slate-200 rounded-lg" data-close-modal="assetExportProcessModal">Hủy</button>
<button id="assetExportProcessSubmit" type="submit" class="flex-1 px-4 py-2 bg-primary text-on-primary rounded-lg text-xs font-bold">Duyệt và xuất vào dự án</button>
</div>
</form>
</div>
</div>

View File

@@ -305,6 +305,10 @@
<span class="material-symbols-outlined" aria-hidden="true">assignment_returned</span>
<span class="sidebar-text">Mượn/Trả tài sản</span>
</a></li>
<li><a href="#asset-exports" data-nav="asset-exports" class="sidebar-link">
<span class="material-symbols-outlined" aria-hidden="true">outbox</span>
<span class="sidebar-text">Xuất vào dự án</span>
</a></li>
<li><a href="#my-borrowed-assets" data-nav="my-borrowed-assets" class="sidebar-link">
<span class="material-symbols-outlined" aria-hidden="true">inventory</span>
<span class="sidebar-text">Tài sản đang mượn</span>