fix_customer

This commit is contained in:
hangyu.tao 2026-01-16 16:02:34 +08:00
parent 6da510f7ea
commit 21a2d41b10

View File

@ -99,6 +99,15 @@ async function loadCustomersMap() {
} }
} }
// Helper function to get customer name - returns friendly placeholder if not found
function getCustomerName(customerId) {
if (!customerId) return '未知客户';
const name = customersMap[customerId];
if (name) return name;
// If ID not found in map, return shortened ID with indicator
return '(已删除客户)';
}
// Alias for loadCustomersMap - used by main.js when switching to trial periods section // Alias for loadCustomersMap - used by main.js when switching to trial periods section
async function loadCustomersForDropdown() { async function loadCustomersForDropdown() {
return await loadCustomersMap(); return await loadCustomersMap();
@ -173,7 +182,7 @@ function renderExpiryWarnings() {
endTime.setHours(0, 0, 0, 0); // Set to start of day endTime.setHours(0, 0, 0, 0); // Set to start of day
const daysUntilExpiry = Math.ceil((endTime - now) / (1000 * 60 * 60 * 24)); const daysUntilExpiry = Math.ceil((endTime - now) / (1000 * 60 * 60 * 24));
const customerName = customersMap[period.customerId] || period.customerId; const customerName = getCustomerName(period.customerId);
if (daysUntilExpiry >= 0 && daysUntilExpiry <= 3) { if (daysUntilExpiry >= 0 && daysUntilExpiry <= 3) {
warnings.push({ warnings.push({
@ -264,7 +273,7 @@ function renderTrialPeriodsTable() {
row.classList.add('trial-row'); row.classList.add('trial-row');
// 显示客户名称如果找不到则显示ID // 显示客户名称如果找不到则显示ID
const customerName = customersMap[period.customerId] || period.customerId; const customerName = getCustomerName(period.customerId);
// 计算状态和到期天数 // 计算状态和到期天数
const now = new Date(); const now = new Date();