This commit is contained in:
hangyu.tao 2026-01-14 20:31:08 +08:00
parent 932cc7a06a
commit 611c83304a
3 changed files with 18 additions and 30 deletions

View File

@ -397,20 +397,15 @@ document.addEventListener('DOMContentLoaded', function () {
pageTitle.textContent = '客户试用时间';
currentSection = 'trialPeriods';
console.log('loadCustomersForDropdown exists?', typeof loadCustomersForDropdown);
if (typeof loadCustomersForDropdown === 'function') {
console.log('Calling loadCustomersForDropdown');
loadCustomersForDropdown();
} else {
console.error('loadCustomersForDropdown is not a function!');
}
console.log('loadAllTrialPeriods exists?', typeof loadAllTrialPeriods);
if (typeof loadAllTrialPeriods === 'function') {
console.log('Calling loadAllTrialPeriods');
// Load customers first, then trial periods
if (typeof loadCustomersForDropdown === 'function' && typeof loadAllTrialPeriods === 'function') {
console.log('Loading customers first, then trial periods');
loadCustomersForDropdown().then(() => {
console.log('Customers loaded, now loading trial periods');
loadAllTrialPeriods();
});
} else {
console.error('loadAllTrialPeriods is not a function!');
console.error('Required functions not available!');
}
} else if (section === 'dashboard') {
dashboardSection.classList.add('active');

View File

@ -111,6 +111,7 @@ async function loadAllTrialPeriods() {
renderTrialPeriodsTable();
updateTrialPagination();
renderExpiryWarnings();
} catch (error) {
console.error('Error loading trial periods:', error);
trialPeriodsData = [];

View File

@ -277,28 +277,20 @@ func (h *FollowUpHandler) GetCustomerList(w http.ResponseWriter, r *http.Request
CustomerName string `json:"customerName"`
}
// Use a map to deduplicate customers by name
customerMap := make(map[string]CustomerInfo)
// Return all customers (including duplicates with same name but different IDs)
// This is needed so that trial periods can map all customer IDs to names
var customerList []CustomerInfo
for _, customer := range customers {
if customer.CustomerName != "" {
// Only keep the first occurrence of each customer name
if _, exists := customerMap[customer.CustomerName]; !exists {
customerMap[customer.CustomerName] = CustomerInfo{
customerList = append(customerList, CustomerInfo{
ID: customer.ID,
CustomerName: customer.CustomerName,
}
})
fmt.Printf("DEBUG: Added customer: ID=%s, Name=%s\n", customer.ID, customer.CustomerName)
}
}
}
// Convert map to slice
var customerList []CustomerInfo
for _, customer := range customerMap {
customerList = append(customerList, customer)
}
fmt.Printf("DEBUG: Total unique customer list items: %d\n", len(customerList))
fmt.Printf("DEBUG: Total customer list items: %d\n", len(customerList))
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]interface{}{