diff --git a/frontend/js/trial-periods-page.js b/frontend/js/trial-periods-page.js index 5e7e7a8..1845d7b 100644 --- a/frontend/js/trial-periods-page.js +++ b/frontend/js/trial-periods-page.js @@ -72,8 +72,11 @@ async function loadCustomersForDropdown() { console.log('Customers data:', data); const customers = data.customers || []; - console.log('Number of customers:', customers.length); - customersMap = {}; + // Use the complete customer map for ID->Name lookups + customersMap = data.customerMap || {}; + + console.log('Number of unique customers:', customers.length); + console.log('Number of customer ID mappings:', Object.keys(customersMap).length); const select = document.getElementById('trialCustomerSelect'); if (!select) { @@ -84,15 +87,15 @@ async function loadCustomersForDropdown() { // Keep the first option (请选择客户) select.innerHTML = ''; + // Use the deduplicated list for dropdown options customers.forEach(customer => { - customersMap[customer.id] = customer.customerName; const option = document.createElement('option'); option.value = customer.id; option.textContent = customer.customerName; select.appendChild(option); }); - console.log('Customers loaded successfully. Total:', customers.length); + console.log('Customers loaded successfully. Dropdown options:', customers.length); } catch (error) { console.error('Error loading customers:', error); }