deploy: 2026-07-15 14:09 部署更新
This commit is contained in:
+108
-15
@@ -230,14 +230,15 @@ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-
|
||||
<div class="bg-white rounded-lg shadow p-4 mb-4">
|
||||
<p class="text-sm text-gray-500 mb-2">选择客户和产品,基于产品详情和真实对话生成标准范式对话模板</p>
|
||||
<div class="flex gap-3 items-center">
|
||||
<select id="paradigm-customer-select" class="border rounded px-3 py-2 text-sm flex-1">
|
||||
<select id="paradigm-customer-select" onchange="onParadigmCustomerChange()" class="border rounded px-3 py-2 text-sm flex-1">
|
||||
<option value="">请选择客户</option>
|
||||
</select>
|
||||
<select id="paradigm-product-select" class="border rounded px-3 py-2 text-sm flex-1">
|
||||
<select id="paradigm-product-select" onchange="onParadigmProductChange()" class="border rounded px-3 py-2 text-sm flex-1">
|
||||
<option value="">自动推断产品</option>
|
||||
</select>
|
||||
<button onclick="generateParadigm()" id="paradigm-btn" class="bg-green-600 text-white px-6 py-2 rounded text-sm hover:bg-green-700">生成范式对话</button>
|
||||
</div>
|
||||
<p id="paradigm-match-hint" class="text-xs text-gray-400 mt-2"></p>
|
||||
</div>
|
||||
<div id="paradigm-result"></div>
|
||||
</div>
|
||||
@@ -976,29 +977,121 @@ function renderAnalysisList() {
|
||||
`).join('');
|
||||
}
|
||||
|
||||
let paradigmCustomers = [];
|
||||
let paradigmProducts = [];
|
||||
|
||||
function populateParadigmSelect() {
|
||||
const sel = document.getElementById('paradigm-customer-select');
|
||||
if (!sel) return;
|
||||
const currentVal = sel.value;
|
||||
paradigmCustomers = conversationsData;
|
||||
// 填充客户下拉
|
||||
sel.innerHTML = '<option value="">请选择客户</option>';
|
||||
conversationsData.forEach(c => {
|
||||
paradigmCustomers.forEach(c => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = c.id;
|
||||
opt.textContent = `${c.customer_name} (${c.salesperson_name}, ${c.stage})`;
|
||||
sel.appendChild(opt);
|
||||
});
|
||||
if (currentVal) sel.value = currentVal;
|
||||
// 填充产品选择
|
||||
// 填充产品下拉
|
||||
const productSel = document.getElementById('paradigm-product-select');
|
||||
if (productSel && productSel.options.length <= 1) {
|
||||
api('/products?status=active').then(products => {
|
||||
products.forEach(p => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = p.id;
|
||||
opt.textContent = `${p.name} ${p.spec || ''}`;
|
||||
productSel.appendChild(opt);
|
||||
});
|
||||
}).catch(() => {});
|
||||
productSel.innerHTML = '<option value="">自动推断产品</option>';
|
||||
api('/products?status=active').then(products => {
|
||||
paradigmProducts = products;
|
||||
products.forEach(p => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = p.id;
|
||||
opt.textContent = `${p.name} ${p.spec || ''}`;
|
||||
productSel.appendChild(opt);
|
||||
});
|
||||
}).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');
|
||||
if (!customerId) {
|
||||
// 恢复全部产品
|
||||
productSel.innerHTML = '<option value="">自动推断产品</option>';
|
||||
paradigmProducts.forEach(p => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = p.id;
|
||||
opt.textContent = `${p.name} ${p.spec || ''}`;
|
||||
productSel.appendChild(opt);
|
||||
});
|
||||
hint.textContent = '';
|
||||
return;
|
||||
}
|
||||
const customer = paradigmCustomers.find(c => String(c.id) === customerId);
|
||||
if (!customer) return;
|
||||
const cats = (customer.product_categories || '').split(', ').filter(x => x);
|
||||
if (cats.length > 0) {
|
||||
// 筛选匹配产品线的产品
|
||||
const matched = paradigmProducts.filter(p => cats.includes(p.category));
|
||||
productSel.innerHTML = '<option value="">自动推断产品</option>';
|
||||
matched.forEach(p => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = p.id;
|
||||
opt.textContent = `${p.name} ${p.spec || ''}`;
|
||||
productSel.appendChild(opt);
|
||||
});
|
||||
hint.textContent = `客户关联产品线: ${cats.join('、')},已筛选 ${matched.length} 个匹配产品`;
|
||||
} else {
|
||||
// 无关联产品线,显示全部
|
||||
productSel.innerHTML = '<option value="">自动推断产品</option>';
|
||||
paradigmProducts.forEach(p => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = p.id;
|
||||
opt.textContent = `${p.name} ${p.spec || ''}`;
|
||||
productSel.appendChild(opt);
|
||||
});
|
||||
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');
|
||||
if (!productId) {
|
||||
// 恢复全部客户
|
||||
customerSel.innerHTML = '<option value="">请选择客户</option>';
|
||||
paradigmCustomers.forEach(c => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = c.id;
|
||||
opt.textContent = `${c.customer_name} (${c.salesperson_name}, ${c.stage})`;
|
||||
customerSel.appendChild(opt);
|
||||
});
|
||||
hint.textContent = '';
|
||||
return;
|
||||
}
|
||||
const product = paradigmProducts.find(p => String(p.id) === productId);
|
||||
if (!product) return;
|
||||
// 筛选产品线匹配的客户
|
||||
const matched = paradigmCustomers.filter(c => {
|
||||
const cats = (c.product_categories || '').split(', ').filter(x => x);
|
||||
return cats.includes(product.category);
|
||||
});
|
||||
if (matched.length > 0) {
|
||||
customerSel.innerHTML = '<option value="">请选择客户</option>';
|
||||
matched.forEach(c => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = c.id;
|
||||
opt.textContent = `${c.customer_name} (${c.salesperson_name}, ${c.stage})`;
|
||||
customerSel.appendChild(opt);
|
||||
});
|
||||
hint.textContent = `产品线: ${product.category},已筛选 ${matched.length} 个匹配客户`;
|
||||
} else {
|
||||
customerSel.innerHTML = '<option value="">请选择客户</option>';
|
||||
paradigmCustomers.forEach(c => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = c.id;
|
||||
opt.textContent = `${c.customer_name} (${c.salesperson_name}, ${c.stage})`;
|
||||
customerSel.appendChild(opt);
|
||||
});
|
||||
hint.textContent = `产品线: ${product.category},无匹配客户,显示全部`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user