|
@@ -28,6 +28,27 @@ const license_info_loadingIndicator = document.getElementById('loading-indicator
|
|
|
let LicApplicationData = [];
|
|
|
|
|
|
|
|
|
+
|
|
|
+function openModal(modalId) {
|
|
|
+ const modal = document.getElementById(modalId);
|
|
|
+ if (modal) {
|
|
|
+ modal.style.display = "block";
|
|
|
+ } else {
|
|
|
+ console.error('模态框不存在,ID:', modalId);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function closeModal(modalId) {
|
|
|
+ const modal = document.getElementById(modalId);
|
|
|
+ if (modal) {
|
|
|
+ modal.style.display = "none";
|
|
|
+ } else {
|
|
|
+ console.error('模态框不存在,ID:', modalId);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -184,12 +205,14 @@ function renderLicenseCards(data, clearContainer = false) {
|
|
|
console.log("-----------渲染清除");
|
|
|
}
|
|
|
console.log("-----------data:",data);
|
|
|
-
|
|
|
- const childRowCount = data.length;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
data.forEach(group => {
|
|
|
const firstItem = group[0];
|
|
|
-
|
|
|
+
|
|
|
+ const childRowCount = group.length;
|
|
|
let statusClass = '';
|
|
|
if (firstItem.LicenseFlage === '已生成') {
|
|
|
statusClass = 'license-status-green';
|
|
@@ -327,6 +350,12 @@ function removeScrollListeners() {
|
|
|
license_info_mainElement.removeEventListener('scroll', handleMainScroll);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+function restartScrollListeners() {
|
|
|
+
|
|
|
+ initializeScrollListeners();
|
|
|
+}
|
|
|
+
|
|
|
function handleMainScroll() {
|
|
|
|
|
|
checkAndLoadMore(license_info_mainElement.scrollHeight, license_info_mainElement.scrollTop, license_info_mainElement.clientHeight);
|
|
@@ -375,7 +404,7 @@ function showModalForCard(item,oaRequestId) {
|
|
|
|
|
|
|
|
|
let currentPage = 1;
|
|
|
- const itemsPerPage = 2;
|
|
|
+ const itemsPerPage = 3;
|
|
|
|
|
|
|
|
|
const sortedItem = item.sort((a, b) => a.oa_id - b.oa_id);
|
|
@@ -446,9 +475,11 @@ console.log(`当前用户是否有生成权限: ${hasGeneratePermission}, ${hasD
|
|
|
: ''
|
|
|
}
|
|
|
<button class="license-info-modal-button" id="downloadAllLicenses-button">打包下载所有license.dat</button>
|
|
|
+ <button id="viewDistributionHistory-button">查看分发历史</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
`;
|
|
|
+
|
|
|
|
|
|
const generateOrDistribute = modalHeader.querySelector('#generateOrDistribute');
|
|
|
console.log("generateOrDistribute",generateOrDistribute);
|
|
@@ -456,11 +487,12 @@ console.log(`当前用户是否有生成权限: ${hasGeneratePermission}, ${hasD
|
|
|
generateOrDistribute.addEventListener('click', () => {
|
|
|
if (firstItem.LicenseFlage === '已生成') {
|
|
|
|
|
|
- showDistributeModal(firstItem.oa_request_id, firstItem.SupportEmail, firstItem.SalesEmail, '', firstItem.oa_request_id);
|
|
|
+ showDistributeModal(firstItem);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- generateLicense(firstItem.oa_request_id, true);
|
|
|
+ const oaRequestID = parseInt(firstItem.oa_request_id, 10);
|
|
|
+ generateLicense(oaRequestID, true);
|
|
|
}
|
|
|
console.log('Button 1 clicked');
|
|
|
});
|
|
@@ -483,6 +515,13 @@ console.log(`当前用户是否有生成权限: ${hasGeneratePermission}, ${hasD
|
|
|
downloadAllLicenses(sortedItem);
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ const viewDistributionHistoryButton = document.getElementById('viewDistributionHistory-button');
|
|
|
+ if (viewDistributionHistoryButton) {
|
|
|
+ viewDistributionHistoryButton.addEventListener('click', () => {
|
|
|
+ showDistributionHistory(firstItem);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -519,12 +558,15 @@ console.log(`当前用户是否有生成权限: ${hasGeneratePermission}, ${hasD
|
|
|
|
|
|
|
|
|
groupBox.innerHTML = `
|
|
|
- <div class="license-info-group-title">组 ${i + 1}</div>
|
|
|
- <p><strong>UniqueID:</strong> ${group.UniqueID}</p>
|
|
|
+ <div class="license-info-group-title">集群 ${i + 1} :</div>
|
|
|
+
|
|
|
+ <p><strong>节点数:</strong> ${group.NodeCount}</p>
|
|
|
+ <p><strong>数据库版本: </strong> ${group.ProductName}${group.ProductVersion}</p>
|
|
|
+ <p><strong>CPU 型号:</strong> ${group.oa_cpu}</p>
|
|
|
+ <p><strong>操作系统环境:</strong> ${group.oa_operating_system}</p>
|
|
|
+ <p><strong>以下为测试显示:</strong> </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>
|
|
|
`;
|
|
|
|
|
|
|
|
@@ -648,32 +690,88 @@ function downloadAllLicenses(sortedApplicationArray) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+let userMap = {};
|
|
|
+
|
|
|
|
|
|
-function showDistributeModal(supportEmail, salesEmail, userOptions) {
|
|
|
- console.log("showDistributeModal", supportEmail);
|
|
|
+function showDistributeModal(firstItem) {
|
|
|
+ console.log("showDistributeModal firstItem", firstItem);
|
|
|
const modal = document.getElementById('distribute-modal');
|
|
|
const emailInputs = document.getElementById('emailInputs');
|
|
|
const userInputs = document.getElementById('userInputs');
|
|
|
+ let usedUsernames = [];
|
|
|
|
|
|
|
|
|
emailInputs.innerHTML = '';
|
|
|
userInputs.innerHTML = '';
|
|
|
|
|
|
|
|
|
- if (supportEmail) {
|
|
|
- emailInputs.innerHTML += `<div><input type="checkbox" id="supportEmail" value="${supportEmail}"> 运维邮箱: ${supportEmail}</div>`;
|
|
|
+ if (firstItem.SupportEmail) {
|
|
|
+ emailInputs.innerHTML += `<div><input type="checkbox" id="supportEmail" value="${firstItem.SupportEmail}"> 运维邮箱: ${firstItem.SupportEmail}</div>`;
|
|
|
}
|
|
|
- if (salesEmail) {
|
|
|
- emailInputs.innerHTML += `<div><input type="checkbox" id="salesEmail" value="${salesEmail}"> 销售邮箱: ${salesEmail}</div>`;
|
|
|
+ if (firstItem.SalesEmail) {
|
|
|
+ emailInputs.innerHTML += `<div><input type="checkbox" id="salesEmail" value="${firstItem.SalesEmail}"> 销售邮箱: ${firstItem.SalesEmail}</div>`;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ fetch('http://127.0.0.1:8080/api/admin/distributeLicenseByUserInfo', {
|
|
|
+ method: 'GET',
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${authToken}`,
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(data => {
|
|
|
+
|
|
|
+ userMap = {};
|
|
|
+
|
|
|
+ const availableUsers = data.data
|
|
|
+ .map(user => {
|
|
|
+
|
|
|
+ userMap[user.Username] = {
|
|
|
+ Account: user.Account,
|
|
|
+ UniqueID: user.UniqueID,
|
|
|
+ Username: user.Username,
|
|
|
+ Email: user.Email,
|
|
|
+ Role: user.Role,
|
|
|
+ Telephone: user.Telephone
|
|
|
+ };
|
|
|
+ return user.Username;
|
|
|
+ })
|
|
|
+ .filter(user => user !== 'admin');
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const addButton = document.createElement('button');
|
|
|
+ addButton.className = 'distribute-add-user-button';
|
|
|
+ addButton.textContent = '添加用户';
|
|
|
+ addButton.addEventListener('click', () => {
|
|
|
+ createUserSelect(userInputs, availableUsers, usedUsernames);
|
|
|
+ });
|
|
|
+ userInputs.appendChild(addButton);
|
|
|
+
|
|
|
+
|
|
|
+ const distributeButton = document.createElement('button');
|
|
|
+ distributeButton.className = 'distribute-confirm-button';
|
|
|
+ distributeButton.textContent = '确定分发';
|
|
|
+ distributeButton.addEventListener('click', () => {
|
|
|
+
|
|
|
+ if (confirm('确定要分发许可证吗?')) {
|
|
|
+
|
|
|
+ const selectedUserInputs = Array.from(document.querySelectorAll('select.distribute-user-select'));
|
|
|
+
|
|
|
+ const userIds = selectedUserInputs.map(select => userMap[select.value].UniqueID);
|
|
|
+ const userAccounts = selectedUserInputs.map(select => userMap[select.value].Account);
|
|
|
+ const userNames = selectedUserInputs.map(select => userMap[select.value].Username);
|
|
|
+
|
|
|
+
|
|
|
+ distributeLicenseToUsers(firstItem, userIds, userAccounts, userNames);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ userInputs.appendChild(distributeButton);
|
|
|
+ })
|
|
|
+ .catch(error => console.error('获取用户信息失败:', error));
|
|
|
|
|
|
|
|
|
modal.style.display = 'flex';
|
|
@@ -693,6 +791,151 @@ function showDistributeModal(supportEmail, salesEmail, userOptions) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+function distributeLicenseToUsers(selectedRowData, userIds, userAccounts, userNames) {
|
|
|
+ console.log('Distribute button clicked');
|
|
|
+ console.log('userIds', userIds);
|
|
|
+ console.log('userAccounts', userAccounts);
|
|
|
+ console.log('userNames', userNames);
|
|
|
+
|
|
|
+
|
|
|
+ showLoadingModal('正在分发 License...');
|
|
|
+
|
|
|
+ const operatorUniqueID = userMap[currentUserName].UniqueID;
|
|
|
+
|
|
|
+ if (userIds.length === 0) {
|
|
|
+ alert('请至少选择一个用户。');
|
|
|
+ hideLoadingModal();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const requestData = {
|
|
|
+ LicenseUniqueID: selectedRowData.UniqueID,
|
|
|
+ Oa_request_id: selectedRowData.oa_request_id,
|
|
|
+ UserUniqueIDs: userIds,
|
|
|
+ UserAccounts: userAccounts,
|
|
|
+ UserNames: userNames,
|
|
|
+ Emails: '',
|
|
|
+ OperatorUniqueID: operatorUniqueID
|
|
|
+ };
|
|
|
+
|
|
|
+ console.log('requestData:', requestData);
|
|
|
+
|
|
|
+
|
|
|
+ fetch('http://127.0.0.1:8080/api/admin/DistributeLicenseToUser', {
|
|
|
+ method: 'POST',
|
|
|
+ headers: {
|
|
|
+ 'Authorization': `Bearer ${authToken}`,
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ },
|
|
|
+ body: JSON.stringify(requestData)
|
|
|
+ })
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(data => {
|
|
|
+ hideLoadingModal();
|
|
|
+
|
|
|
+ if (data.success) {
|
|
|
+ alert('分发成功!');
|
|
|
+ closeModal('distribute-modal');
|
|
|
+ } else {
|
|
|
+ const errorMessage = data.error || '分发失败。';
|
|
|
+ alert(`分发失败: ${errorMessage}`);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ hideLoadingModal();
|
|
|
+ console.error('Error occurred during license distribution:', error);
|
|
|
+ alert('分发失败,请检查网络或后端服务。');
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function createUserSelect(container, availableUsers, usedUsernames) {
|
|
|
+
|
|
|
+ const userSelectContainer = document.createElement('div');
|
|
|
+ userSelectContainer.className = 'distribute-modal-user-select-container';
|
|
|
+
|
|
|
+
|
|
|
+ const userSelect = document.createElement('select');
|
|
|
+ userSelect.className = 'distribute-modal-user-select';
|
|
|
+
|
|
|
+
|
|
|
+ const filteredUsers = availableUsers.filter(user => !usedUsernames.includes(user));
|
|
|
+
|
|
|
+
|
|
|
+ filteredUsers.forEach(user => {
|
|
|
+ const option = document.createElement('option');
|
|
|
+ option.value = user;
|
|
|
+ option.textContent = user;
|
|
|
+ userSelect.appendChild(option);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ const closeButton = document.createElement('span');
|
|
|
+ closeButton.textContent = 'X';
|
|
|
+ closeButton.className = 'distribute-modal-close-select';
|
|
|
+ closeButton.style.cursor = 'pointer';
|
|
|
+ closeButton.style.marginLeft = '10px';
|
|
|
+
|
|
|
+
|
|
|
+ closeButton.addEventListener('click', function() {
|
|
|
+
|
|
|
+ const selectedValue = userSelect.value;
|
|
|
+ const index = usedUsernames.indexOf(selectedValue);
|
|
|
+ if (index > -1) {
|
|
|
+ usedUsernames.splice(index, 1);
|
|
|
+ }
|
|
|
+ container.removeChild(userSelectContainer);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ userSelectContainer.appendChild(userSelect);
|
|
|
+ userSelectContainer.appendChild(closeButton);
|
|
|
+
|
|
|
+
|
|
|
+ container.appendChild(userSelectContainer);
|
|
|
+
|
|
|
+
|
|
|
+ userSelect.addEventListener('change', function() {
|
|
|
+ const previousValue = usedUsernames.find(u => u === this.defaultValue);
|
|
|
+ if (previousValue) {
|
|
|
+
|
|
|
+ usedUsernames.splice(usedUsernames.indexOf(previousValue), 1);
|
|
|
+ }
|
|
|
+ usedUsernames.push(this.value);
|
|
|
+ this.defaultValue = this.value;
|
|
|
+ console.log('已选择的用户:', usedUsernames);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function updateUserSelectOptions(availableUsers, usedUsernames, container) {
|
|
|
+ const allSelects = container.querySelectorAll('.distribute-modal-user-select');
|
|
|
+
|
|
|
+ allSelects.forEach(select => {
|
|
|
+ const currentValue = select.value;
|
|
|
+
|
|
|
+ select.innerHTML = '';
|
|
|
+
|
|
|
+
|
|
|
+ availableUsers.forEach(user => {
|
|
|
+ if (!usedUsernames.includes(user) || user === currentValue) {
|
|
|
+ const option = document.createElement('option');
|
|
|
+ option.value = user;
|
|
|
+ option.textContent = user;
|
|
|
+ if (user === currentValue) {
|
|
|
+ option.selected = true;
|
|
|
+ }
|
|
|
+ select.appendChild(option);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -736,8 +979,11 @@ async function refreshLicenseDataAndScrollAndOpenModal(selfPage,selfPageSize, ta
|
|
|
function generateLicense(id, isParentRow) {
|
|
|
|
|
|
showLoadingModal('正在生成 License...');
|
|
|
- const payload = isParentRow ? { oa_request_id: JSON.stringify(id) } : { uniqueID:JSON.stringify(id) };
|
|
|
-
|
|
|
+
|
|
|
+ const payload = isParentRow
|
|
|
+ ? { oa_request_id: parseInt(id, 10) }
|
|
|
+ : { uniqueID: parseInt(id, 10) };
|
|
|
+
|
|
|
console.log("generateLicense",payload ,id, isParentRow)
|
|
|
fetch('http://127.0.0.1:8080/api/admin/GenerateLicense', {
|
|
|
method: 'POST',
|
|
@@ -934,7 +1180,13 @@ document.addEventListener('DOMContentLoaded', createLoadingModal);
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -951,12 +1203,12 @@ 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,
|
|
@@ -996,4 +1248,29 @@ function displayLicenseInfo(data) {
|
|
|
renderLicenseCards(data, true);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+submitButton.addEventListener('click', function() {
|
|
|
+
|
|
|
+ filterContent();
|
|
|
+
|
|
|
+
|
|
|
+ removeScrollListeners();
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+const resetButton = document.getElementById('reset-button');
|
|
|
+resetButton.addEventListener('click', function() {
|
|
|
+
|
|
|
+ location.reload();
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+searchBar.addEventListener('input', function() {
|
|
|
+ if (!searchBar.value && !statusFilter.value && !startDate.value && !endDate.value) {
|
|
|
+ console.log("搜索条件清空,重新启动滚动监听");
|
|
|
+ restartScrollListeners();
|
|
|
+ }
|
|
|
+});
|
|
|
|