deploy: 2026-07-15 14:14 部署更新

This commit is contained in:
selfrelease
2026-07-15 14:14:21 +08:00
parent 0a95b41581
commit 5afd145f53
+32 -5
View File
@@ -1006,13 +1006,15 @@ function populateParadigmSelect() {
}).catch(() => {});
}
/** 选择客户时,自动筛选匹配的产品 */
/** 选择客户时,自动筛选匹配的产品(保留已选产品) */
function onParadigmCustomerChange() {
const customerId = document.getElementById('paradigm-customer-select').value;
const productSel = document.getElementById('paradigm-product-select');
const hint = document.getElementById('paradigm-match-hint');
const currentProductId = productSel.value;
if (!customerId) {
// 恢复全部产品
// 恢复全部产品,保留当前选择
const prevVal = currentProductId;
productSel.innerHTML = '<option value="">自动推断产品</option>';
paradigmProducts.forEach(p => {
const opt = document.createElement('option');
@@ -1020,6 +1022,7 @@ function onParadigmCustomerChange() {
opt.textContent = `${p.name} ${p.spec || ''}`;
productSel.appendChild(opt);
});
if (prevVal) productSel.value = prevVal;
hint.textContent = '';
return;
}
@@ -1027,6 +1030,14 @@ function onParadigmCustomerChange() {
if (!customer) return;
const cats = (customer.product_categories || '').split(', ').filter(x => x);
if (cats.length > 0) {
// 如果已选产品匹配当前客户产品线,保留选择不重新筛选
if (currentProductId) {
const currentProduct = paradigmProducts.find(p => String(p.id) === currentProductId);
if (currentProduct && cats.includes(currentProduct.category)) {
hint.textContent = `客户关联产品线: ${cats.join('、')},当前产品已匹配`;
return;
}
}
// 筛选匹配产品线的产品
const matched = paradigmProducts.filter(p => cats.includes(p.category));
productSel.innerHTML = '<option value="">自动推断产品</option>';
@@ -1038,7 +1049,8 @@ function onParadigmCustomerChange() {
});
hint.textContent = `客户关联产品线: ${cats.join('、')},已筛选 ${matched.length} 个匹配产品`;
} else {
// 无关联产品线,显示全部
// 无关联产品线,显示全部,保留当前选择
const prevVal = currentProductId;
productSel.innerHTML = '<option value="">自动推断产品</option>';
paradigmProducts.forEach(p => {
const opt = document.createElement('option');
@@ -1046,17 +1058,20 @@ function onParadigmCustomerChange() {
opt.textContent = `${p.name} ${p.spec || ''}`;
productSel.appendChild(opt);
});
if (prevVal) productSel.value = prevVal;
hint.textContent = '该客户未关联产品线,显示全部产品';
}
}
/** 选择产品时,筛选匹配产品线的客户 */
/** 选择产品时,筛选匹配产品线的客户(保留已选客户) */
function onParadigmProductChange() {
const productId = document.getElementById('paradigm-product-select').value;
const customerSel = document.getElementById('paradigm-customer-select');
const hint = document.getElementById('paradigm-match-hint');
const currentCustomerId = customerSel.value;
if (!productId) {
// 恢复全部客户
// 恢复全部客户,保留当前选择
const prevVal = currentCustomerId;
customerSel.innerHTML = '<option value="">请选择客户</option>';
paradigmCustomers.forEach(c => {
const opt = document.createElement('option');
@@ -1064,11 +1079,23 @@ function onParadigmProductChange() {
opt.textContent = `${c.customer_name} (${c.salesperson_name}, ${c.stage})`;
customerSel.appendChild(opt);
});
if (prevVal) customerSel.value = prevVal;
hint.textContent = '';
return;
}
const product = paradigmProducts.find(p => String(p.id) === productId);
if (!product) return;
// 如果已选客户匹配当前产品线,保留选择不重新筛选
if (currentCustomerId) {
const currentCustomer = paradigmCustomers.find(c => String(c.id) === currentCustomerId);
if (currentCustomer) {
const cats = (currentCustomer.product_categories || '').split(', ').filter(x => x);
if (cats.includes(product.category)) {
hint.textContent = `产品线: ${product.category},当前客户已匹配`;
return;
}
}
}
// 筛选产品线匹配的客户
const matched = paradigmCustomers.filter(c => {
const cats = (c.product_categories || '').split(', ').filter(x => x);