123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999 |
- let page = 11;
- let pageSize = 20;
- let total = 0;
- let loadedItems = 0;
- let isLoading = false;
- const timeoutDuration = 10000;
- const preLoadDistance = 300;
- const authToken = localStorage.getItem("Authorization");
- const currentUserInfo = fetchUsername();
- let currentUserPermissions;
- const license_info_mainElement = document.querySelector('main');
- const license_info_modal = document.getElementById('license-info-modal');
- const license_info_modalContent = document.querySelector('.license-info-modal-content');
- const license_info_modalDescription = document.getElementById('license-info-modal-description');
- const license_info_modalPrice = document.getElementById('license-info-modal-price');
- const license_info_modalRating = document.getElementById('license-info-modal-rating');
- const license_info_closeModal = document.querySelector('.license-info-close');
- const license_info_loadingIndicator = document.getElementById('loading-indicator');
- let LicApplicationData = [];
- const menuItems = document.querySelectorAll('nav ul li a');
- menuItems.forEach(item => {
- item.addEventListener('click', function() {
-
- menuItems.forEach(i => i.classList.remove('active'));
-
-
- this.classList.add('active');
- });
- });
- const userManagementLink = document.getElementById('user-management-link');
- const licenseInfoLink = document.getElementById('license-info-link');
- const roleManagementLink = document.getElementById('role-management-link');
- userManagementLink.addEventListener('click', function(event) {
- event.preventDefault();
- removeScrollListeners();
-
- fetch('../user/user_management.html')
- .then(response => response.text())
- .then(data => {
-
- license_info_mainElement.innerHTML = data;
-
- const script = document.createElement('script');
- script.src = '../user/user.js';
- document.body.appendChild(script);
-
- })
- .catch(error => console.error('加载用户管理页面失败:', error));
- });
- licenseInfoLink.addEventListener('click', function(event) {
- event.preventDefault();
-
- const licenseInfoHtml = `
- <!-- 包裹搜索框、下拉框、时间选择框和确定按钮的 div -->
- <div class="search-container">
- <!-- License 状态下拉框 -->
- <select id="license-status-filter" aria-label="选择 License 状态">
- <option value="">License 状态</option>
- <option value="已生成">已生成</option>
- <option value="未生成">未生成</option>
- <option value="已失效">已失效</option>
- </select>
-
- <!-- 开始时间选择框,类型改为 date -->
- <input type="date" id="start-date" placeholder="开始时间" />
-
- <!-- 结束时间选择框,类型改为 date -->
- <input type="date" id="end-date" placeholder="结束时间" />
-
- <!-- 搜索框 -->
- <input type="text" id="search-bar" placeholder="搜索..." />
-
- <!-- 确定按钮 -->
- <button id="submit-button">确定</button>
- </div>
- <div class="license-info-container" id="license-info-restaurant-list"> </div>
- `;
-
- license_info_mainElement.innerHTML = licenseInfoHtml;
-
- LicApplicationData = [];
- initializeScrollListeners();
-
- (async function() {
- const data = await fetchLicenseData(1, 10);
- if (data.length > 0) {
- console.log('加载的数据:', data);
- renderLicenseCards(data, true);
-
- } else {
- console.error('未加载到数据');
- }
- })();
- });
- roleManagementLink.addEventListener('click', function(event) {
- event.preventDefault();
- removeScrollListeners();
-
- fetch('../role/role.html')
- .then(response => response.text())
- .then(data => {
-
- license_info_mainElement.innerHTML = data;
-
- const script = document.createElement('script');
- script.src = '../role/role.js';
- document.body.appendChild(script);
-
- })
- .catch(error => console.error('加载用户管理页面失败:', error));
- });
- async function fetchLicenseData(page, pageSize) {
- try {
- const response = await fetch(`http://127.0.0.1:8080/api/admin/GetAllLicenseInfo?page=${page}&pageSize=${pageSize}`, {
- method: 'GET',
- headers: {
- 'Authorization': `Bearer ${authToken}`,
- 'Content-Type': 'application/json'
- }
- });
-
- const result = await response.json();
-
-
- if (total === 0 && result.total) {
- total = result.total;
- }
-
-
- LicApplicationData = LicApplicationData.concat(result.data || []);
- console.log("LicApplicationData: ",LicApplicationData);
- return result.data || [];
- } catch (error) {
- console.error("加载数据失败", error);
- return [];
- }
- }
- function renderLicenseCards(data, clearContainer = false) {
- console.log("-----------渲染次数");
-
- const license_info_container = document.getElementById('license-info-restaurant-list');
-
- if (clearContainer) {
- license_info_container.innerHTML = '';
- isLoading = false;
- loadedItems = 0;
- page = 11;
- pageSize = 20;
- console.log("-----------渲染清除");
- }
- console.log("-----------data:",data);
-
- const childRowCount = data.length;
- data.forEach(group => {
- const firstItem = group[0];
- let statusClass = '';
- if (firstItem.LicenseFlage === '已生成') {
- statusClass = 'license-status-green';
- } else if (firstItem.LicenseFlage === '未生成') {
- statusClass = 'license-status-yellow';
- } else if (firstItem.LicenseFlage === '已失效') {
- statusClass = 'license-status-red';
- }
- const card = document.createElement('div');
- card.className = 'license-info-card';
-
- card.setAttribute('data-oa-request-id', firstItem.oa_request_id);
-
- card.innerHTML = `
- <div class="license-info-card-header">
- <h3 class="card-title">${firstItem.GlxmName}</h3>
- </div>
- <div class="license-info-card-content">
- <p class="card-text">${firstItem.ApplicationDate} ${firstItem.ApplicationTime}</p> <!-- 显示日期和时间 -->
- <p class="card-text">创建者:${firstItem.Creator}</p>
- <p class="card-text">公司:${firstItem.Company}</p>
- <p class="card-text">集群:${childRowCount} 套 共计:${firstItem.TotalNodes} 节点</p>
- <p class="card-text license-status ${statusClass}">许可证状态:${firstItem.LicenseFlage}</p>
- <p class="card-text">oa_request_id:${firstItem.oa_request_id}</p>
- </div>
- `;
-
- card.addEventListener('click', () => {
-
- const oaRequestId = card.getAttribute('data-oa-request-id');
- showModalForCard(group, oaRequestId);
-
- });
-
-
- license_info_container.appendChild(card);
- });
-
- }
- async function loadMoreData() {
- if (isLoading) return;
- isLoading = true;
- console.log('开始加载更多数据');
-
-
-
-
-
- const timeout = setTimeout(() => {
- license_info_loadingIndicator.innerText = '加载超时,请重试';
- isLoading = false;
- license_info_loadingIndicator.style.display = 'none';
- }, timeoutDuration);
-
- const data = await fetchLicenseData(page, pageSize);
- console.log(`加载的新数据 data`,data);
-
- clearTimeout(timeout);
- if (data.length > 0) {
-
-
- page += 10;
- pageSize += 10;
-
- loadedItems += data.length;
-
- renderLicenseCards(data);
- console.log('数据加载完成,更新页面');
- }
-
-
- isLoading = false;
-
-
- checkAndLoadMore();
- }
- function initializeScrollListeners() {
-
- license_info_mainElement.addEventListener('scroll', handleMainScroll);
-
- }
- function removeScrollListeners() {
-
- license_info_mainElement.removeEventListener('scroll', handleMainScroll);
- }
- function handleMainScroll() {
-
- checkAndLoadMore(license_info_mainElement.scrollHeight, license_info_mainElement.scrollTop, license_info_mainElement.clientHeight);
- }
- async function checkAndLoadMore(scrollHeight, scrollTop, clientHeight) {
- if (isLoading || loadedItems >= total) return;
-
- if (scrollTop + clientHeight >= scrollHeight - preLoadDistance) {
- console.log(`触发加载更多数据:page=${page}, pageSize=${pageSize}`);
- await loadMoreData();
- }
- }
- (async function() {
- const data = await fetchLicenseData(1, 10);
- if (data.length > 0) {
- renderLicenseCards(data);
- loadedItems += data.length;
- }
-
-
-
- checkAndLoadMore()
- })();
- initializeScrollListeners()
- function showModalForCard(item,oaRequestId) {
- const modal = document.getElementById('license-info-modal');
- const modalContent = document.querySelector('.license-info-modal-content');
- const modalBody = document.getElementById('license-info-modal-body');
- console.log(`当前点击的卡片 ID: ${oaRequestId}`);
-
-
- let currentPage = 1;
- const itemsPerPage = 2;
-
- const sortedItem = item.sort((a, b) => a.oa_id - b.oa_id);
- const totalPages = Math.ceil(sortedItem.length / itemsPerPage);
-
- const paginationContainer = document.querySelector('.license-info-modal-pagination');
-
- paginationContainer.innerHTML = '';
-
- const prevButton = document.createElement('button');
- prevButton.classList.add('prev-page');
- prevButton.innerText = '上一页';
- paginationContainer.appendChild(prevButton);
-
- const selectPageDropdown = document.createElement('select');
- paginationContainer.appendChild(selectPageDropdown);
-
- const nextButton = document.createElement('button');
- nextButton.classList.add('next-page');
- nextButton.innerText = '下一页';
- paginationContainer.appendChild(nextButton);
-
-
- function initializeHeaderContent(firstItem,sortedItem) {
- console.log("initializeHeaderContent");
-
- const modalHeader = document.querySelector('.license-info-modal-header');
- modalHeader.innerHTML = '';
- let statusClass = '';
- if (firstItem.LicenseFlage === '已生成') {
- statusClass = 'license-status-green';
- } else if (firstItem.LicenseFlage === '未生成') {
- statusClass = 'license-status-yellow';
- } else if (firstItem.LicenseFlage === '已失效') {
- statusClass = 'license-status-red';
- }
-
- const hasGeneratePermission = currentUserPermissions.includes('generate_license');
- const hasDispatchPermission = currentUserPermissions.includes('dispat_license');
- console.log(`当前用户是否有生成权限: ${hasGeneratePermission}, ${hasDispatchPermission}`);
-
- modalHeader.innerHTML = `
- <div class="license-info-card-header">
- <h3 class="card-title">${firstItem.GlxmName}</h3>
- </div>
- <div class="license-info-card-content">
- <p class="card-text">${firstItem.ApplicationDate} ${firstItem.ApplicationTime}</p> <!-- 显示日期和时间 -->
- <p class="card-text">公司:${firstItem.Company}</p>
- <p class="card-text">${firstItem.Project}</p>
- <p class="card-text">创建者:${firstItem.Creator}</p>
- <p class="card-text license-status ${statusClass}">许可证状态:${firstItem.LicenseFlage}</p>
- <div class="license-info-card-buttons">
- ${
- firstItem.LicenseFlage === '已生成' && hasDispatchPermission
- ? `<button class="license-info-modal-button" id="generateOrDistribute">分发</button>`
- : firstItem.LicenseFlage !== '已生成' && hasGeneratePermission
- ? `<button class="license-info-modal-button" id="generateOrDistribute">生成</button>`
- : ''
- }
- <button class="license-info-modal-button" id="downloadAllLicenses-button">打包下载所有license.dat</button>
- </div>
- </div>
- `;
-
- const generateOrDistribute = modalHeader.querySelector('#generateOrDistribute');
- console.log("generateOrDistribute",generateOrDistribute);
- if (generateOrDistribute) {
- generateOrDistribute.addEventListener('click', () => {
- if (firstItem.LicenseFlage === '已生成') {
-
- showDistributeModal(firstItem.oa_request_id, firstItem.SupportEmail, firstItem.SalesEmail, '', firstItem.oa_request_id);
-
- } else {
-
- generateLicense(firstItem.oa_request_id, true);
- }
- console.log('Button 1 clicked');
- });
- }
- ;
-
-
-
- const downloadButton = modalHeader.querySelector('#downloadAllLicenses-button');
-
- if (firstItem.LicenseFlage === '未生成' || firstItem.LicenseFlage === '已失效') {
- downloadButton.disabled = true;
- downloadButton.style.backgroundColor = '#ccc';
- downloadButton.style.cursor = 'not-allowed';
- } else {
-
- downloadButton.addEventListener('click', () => {
- downloadAllLicenses(sortedItem);
- });
- }
- }
-
- function initializeDropdown() {
- selectPageDropdown.innerHTML = '';
- for (let page = 1; page <= totalPages; page++) {
- const option = document.createElement('option');
- option.value = page;
- option.innerText = `第 ${page} 页`;
- selectPageDropdown.appendChild(option);
- }
- selectPageDropdown.value = currentPage;
- }
-
- function ModalForCardRenderPage(page) {
- modalBody.innerHTML = '';
-
- const startIndex = (page - 1) * itemsPerPage;
- const endIndex = Math.min(startIndex + itemsPerPage, sortedItem.length);
-
- const firstItem = sortedItem[0];
- initializeHeaderContent(firstItem,sortedItem);
-
- for (let i = startIndex; i < endIndex; i++) {
- const group = sortedItem[i];
- const groupBox = document.createElement('div');
- groupBox.classList.add('license-info-group-box');
-
- groupBox.innerHTML = `
- <div class="license-info-group-title">组 ${i + 1}</div>
- <p><strong>UniqueID:</strong> ${group.UniqueID}</p>
- <p><strong>oa_id:</strong> ${group.oa_id}</p>
- <p><strong>oa_request_id:</strong> ${group.oa_request_id}</p>
- <p><strong>Creator:</strong> ${group.Creator}</p>
- <p><strong>oa_request_name_new:</strong> ${group.oa_request_name_new}</p>
- `;
-
- modalBody.appendChild(groupBox);
- }
-
- selectPageDropdown.value = page;
-
- prevButton.disabled = (page === 1);
- nextButton.disabled = (page === totalPages);
- }
-
- selectPageDropdown.addEventListener('change', function() {
- currentPage = parseInt(this.value);
- ModalForCardRenderPage(currentPage);
- });
-
- prevButton.addEventListener('click', function() {
- if (currentPage > 1) {
- currentPage--;
- ModalForCardRenderPage(currentPage);
- }
- });
-
- nextButton.addEventListener('click', function() {
- if (currentPage < totalPages) {
- currentPage++;
- ModalForCardRenderPage(currentPage);
- }
- });
-
- function togglePaginationVisibility() {
- if (totalPages <= 1) {
-
- paginationContainer.style.display = 'none';
- } else {
-
- paginationContainer.style.display = 'flex';
- }
- }
-
- initializeDropdown();
-
- ModalForCardRenderPage(currentPage);
-
- togglePaginationVisibility();
-
- modal.style.display = 'flex';
- setTimeout(() => {
- modalContent.classList.add('show');
- }, 10);
-
- const closeModal = document.querySelector('.license-info-close');
- closeModal.addEventListener('click', () => {
- modalContent.classList.remove('show');
- setTimeout(() => {
- modal.style.display = 'none';
- }, 500);
- });
-
- window.addEventListener('click', (event) => {
- if (event.target === modal) {
- modalContent.classList.remove('show');
- setTimeout(() => {
- modal.style.display = 'none';
- }, 500);
- }
- });
- }
- function downloadAllLicenses(sortedApplicationArray) {
- const zip = new JSZip();
- console.log("传进来的 sortedApplicationArray:", sortedApplicationArray);
-
- let idCounter = 1;
- let Project = sortedApplicationArray[0].Project;
- console.log("Project", Project);
-
- sortedApplicationArray.forEach(row => {
- if (row.LicenseFlage === "已生成") {
-
- const mainMac = row.oa_main_mac.replace(/:/g, '.');
- const secondMac = row.oa_second_mac.replace(/:/g, '.');
-
- if (row.lic1) {
- const filename1 = `${idCounter}_license.dat_1_${mainMac}`;
- zip.file(filename1, row.lic1);
- }
- if (row.lic2) {
- const filename2 = `${idCounter}_license.dat_2_${secondMac}`;
- zip.file(filename2, row.lic2);
- }
-
- idCounter++;
- }
- });
-
- zip.generateAsync({ type: "blob" }).then(content => {
- const link = document.createElement('a');
- link.href = URL.createObjectURL(content);
- link.download = `${Project}_license.zip`;
- link.click();
- });
- }
- function showDistributeModal(supportEmail, salesEmail, userOptions) {
- console.log("showDistributeModal", supportEmail);
- const modal = document.getElementById('distribute-modal');
- const emailInputs = document.getElementById('emailInputs');
- const userInputs = document.getElementById('userInputs');
-
- emailInputs.innerHTML = '';
- userInputs.innerHTML = '';
-
- if (supportEmail) {
- emailInputs.innerHTML += `<div><input type="checkbox" id="supportEmail" value="${supportEmail}"> 运维邮箱: ${supportEmail}</div>`;
- }
- if (salesEmail) {
- emailInputs.innerHTML += `<div><input type="checkbox" id="salesEmail" value="${salesEmail}"> 销售邮箱: ${salesEmail}</div>`;
- }
-
-
-
-
-
-
-
-
- modal.style.display = 'flex';
-
- const closeButton = document.querySelector('#distribute-modal .distribute-close');
- closeButton.addEventListener('click', () => {
- modal.style.display = 'none';
- });
-
- window.addEventListener('click', function(event) {
- if (event.target === modal) {
- modal.style.display = 'none';
- }
- });
- }
- async function refreshLicenseDataAndScrollAndOpenModal(selfPage,selfPageSize, targetCardId) {
- const data = await fetchLicenseData(selfPage, selfPageSize);
- if (data.length > 0) {
- isLoading = true;
- console.log('加载的数据:', data);
- renderLicenseCards(data, true);
- page = selfPageSize+1;
- pageSize= selfPageSize +10;
-
- if (targetCardId) {
- const targetCard = document.querySelector(`[data-oa-request-id="${targetCardId}"]`);
- if (targetCard) {
- targetCard.scrollIntoView({ behavior: 'smooth', block: 'center' });
-
-
- setTimeout(() => {
- targetCard.click();
- }, 500);
- }
- }
-
- setTimeout(() => {
- isLoading = false;
- }, 2000);
-
- } else {
- console.error('未加载到数据');
- }
- }
- function generateLicense(id, isParentRow) {
-
- showLoadingModal('正在生成 License...');
- const payload = isParentRow ? { oa_request_id: JSON.stringify(id) } : { uniqueID:JSON.stringify(id) };
-
- console.log("generateLicense",payload ,id, isParentRow)
- fetch('http://127.0.0.1:8080/api/admin/GenerateLicense', {
- method: 'POST',
- headers: {
- 'Authorization': `Bearer ${authToken}`,
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(payload)
- })
- .then(response => response.json())
- .then(data => {
- if (data.success) {
-
- hideLoadingModal();
- alert('License 生成成功!');
-
-
-
-
- refreshLicenseDataAndScrollAndOpenModal(1,pageSize,id);
- } else {
-
- hideLoadingModal();
- alert('License 生成失败:' + data.error);
- }
-
- })
- .catch(error => {
- console.error('生成过程中出现错误Error:', error);
-
- hideLoadingModal();
- alert('生成过程中出现错误,请稍后再试。',error);
- });
- }
- function updateCardAndModalStatus(id, isParentRow) {
-
- const cardSelector = isParentRow ? `[data-oa-request-id="${id}"]` : `[data-unique-id="${id}"]`;
- const card = document.querySelector(cardSelector);
- console.log("generateLicense card", cardSelector, card);
-
- if (card) {
-
- const statusElement = card.querySelector('.license-status');
- console.log("statusElement:", statusElement);
-
- if (statusElement) {
-
- statusElement.innerHTML = '许可证状态:已生成';
-
-
- statusElement.classList.remove('license-status-yellow', 'license-status-red');
- statusElement.classList.add('license-status-green');
- } else {
- console.error('找不到 .license-status 元素');
- }
-
- const modalStatusElement = document.querySelector('.license-info-modal-header .license-status');
- console.log("modalStatusElement:", modalStatusElement);
-
- if (modalStatusElement) {
- modalStatusElement.textContent = '许可证状态:已生成';
- modalStatusElement.classList.remove('license-status-yellow', 'license-status-red');
- modalStatusElement.classList.add('license-status-green');
- } else {
- console.error('找不到 #license-info-modal-body .license-status 元素');
- }
-
- const generateButton = document.getElementById('button1');
- if (generateButton) {
- generateButton.textContent = '分发';
- generateButton.removeEventListener('click', generateLicense);
- generateButton.addEventListener('click', () => {
- distributeLicense(id);
- });
- }
-
- const downloadButton = document.getElementById('downloadAllLicenses-button');
- if (downloadButton) {
- downloadButton.disabled = false;
- downloadButton.style.backgroundColor = '#007aff';
- downloadButton.style.cursor = 'pointer';
- }
- } else {
- console.error(`找不到与 ID ${id} 对应的卡片`);
- }
- }
- async function fetchUsername() {
- try {
- const response = await fetch(`http://127.0.0.1:8080/api/admin/userInfo`, {
- method: 'GET',
- headers: {
- 'Authorization': `Bearer ${authToken}`,
- 'Content-Type': 'application/json'
- }
- });
-
- const data = await response.json();
- currentUserRole = data.data.Role;
- currentUserName = data.data.Username;
-
-
- await fetchPermissionsByRole(currentUserRole);
- return data.data;
-
- } catch (error) {
- console.error('Error fetching user info or permissions:', error);
- }
- }
- async function fetchPermissionsByRole(role) {
- try {
- const response = await fetch(`http://127.0.0.1:8080/api/admin/GetSelfRoles`, {
- method: 'POST',
- headers: {
- 'Authorization': `Bearer ${authToken}`,
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({ name: role })
- });
- const data = await response.json();
- currentUserPermissions = data.data.Permissions;
- console.log('currentUserPermissions:', currentUserPermissions);
-
-
-
-
-
-
-
-
-
-
- } catch (error) {
- console.error('Error fetching permissions:', error);
- }
- }
- function createLoadingModal() {
- const modalHTML = `
- <div id="loadingModal" class="loading-modal" style="display: none;">
- <div class="loading-modal-content">
- <div class="spinner"></div>
- <p id="loadingMessage">加载中...</p>
- </div>
- </div>
- `;
- document.body.insertAdjacentHTML('beforeend', modalHTML);
- }
- function showLoadingModal(message = "加载中...") {
- const loadingModal = document.getElementById('loadingModal');
- const loadingMessage = document.getElementById('loadingMessage');
-
- if (loadingModal && loadingMessage) {
- loadingMessage.textContent = message;
- loadingModal.style.display = 'flex';
- }
- }
- function hideLoadingModal() {
- const loadingModal = document.getElementById('loadingModal');
-
- if (loadingModal) {
- loadingModal.style.display = 'none';
- }
- }
- document.addEventListener('DOMContentLoaded', createLoadingModal);
- const searchBar = document.getElementById('search-bar');
- const statusFilter = document.getElementById('license-status-filter');
- const startDate = document.getElementById('start-date');
- const endDate = document.getElementById('end-date');
- const submitButton = document.getElementById('submit-button');
- const licenseInfoContainer = document.getElementById('license-info-restaurant-list');
- submitButton.addEventListener('click', filterContent);
- function filterContent() {
- console.log('过滤功能触发');
-
- const requestData = {
- license_flag: statusFilter.value || undefined,
- starting_date: startDate.value || undefined,
- end_date: endDate.value || undefined,
- any_search: searchBar.value || undefined,
- };
- console.log("requestData",requestData);
-
- fetch('http://127.0.0.1:8080/api/admin/GetConditionalSearch', {
- method: 'POST',
- headers: {
- 'Authorization': `Bearer ${authToken}`,
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(requestData),
- })
- .then(response => response.json())
- .then(data => {
- console.log('成功获取数据:', data);
-
- displayLicenseInfo(data.data);
- })
- .catch(error => {
- console.error('获取数据时发生错误:', error);
- });
- }
- function displayLicenseInfo(data) {
-
- licenseInfoContainer.innerHTML = '';
- LicApplicationData =[];
-
-
- renderLicenseCards(data, true);
-
- }
|