From 5920c64bbd4698cb15e6934636e0a1f09f75fdf2 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 17 Nov 2026 16:58:18 +0800 Subject: [PATCH] Update App.jsx via upload script - 2026-11-17 16:57:58 --- App.jsx | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/App.jsx b/App.jsx index c8216dc..ca71497 100644 --- a/App.jsx +++ b/App.jsx @@ -2352,6 +2352,23 @@ const Styles = () => ( .cv-edit { display: grid; gap: 8px; } @media (max-width: 760px) { .cv-grid { grid-template-columns: 1fr; } } /* 沟通记录:聊天样式 */ + .cv-match-btn { background: #0f766e !important; border-color: #0f766e !important; } + .cv-match { border-color: #99d5cc; background: linear-gradient(180deg, #f0fbf8, #fff 60%); } + .cv-match .cv-ai-badge { color: #0f766e; } + .cv-mg { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 10px; background: #fff; } + .cv-mg-h { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; margin-bottom: 4px; } + .cv-mg-h span { color: var(--ink-soft); font-weight: 600; font-size: 12.5px; white-space: nowrap; } + .cv-mg-none { font-size: 12.5px; color: #b54708; margin-top: 4px; } + .cv-mm { border-top: 1px dashed var(--line); padding: 7px 0 4px; } + .cv-mm:first-of-type { border-top: 0; } + .cv-mm-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } + .cv-mm-h b { font-size: 13.5px; } + .cv-mm-h small { color: var(--ink-soft); font-size: 12px; } + .cv-fit { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; white-space: nowrap; } + .cv-fit.f-h { background: #dcfce7; color: #166534; } .cv-fit.f-m { background: #e0f2fe; color: #075985; } .cv-fit.f-l { background: #fef3c7; color: #92400e; } + .cv-mm-r { font-size: 12.8px; line-height: 1.55; margin-top: 3px; } + .cv-mm-c { font-size: 12.5px; color: #0f766e; margin-top: 2px; } + .cv-mm-g { margin: 3px 0 0; padding-left: 18px; font-size: 12.3px; color: #b54708; line-height: 1.5; } .cv-search { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; background: var(--bg); color: var(--ink-soft); height: 30px; } .cv-search input { border: 0; outline: 0; background: transparent; width: 120px; font-size: 12.5px; color: var(--ink); } .cv-search button { border: 0; background: none; cursor: pointer; color: var(--ink-soft); display: inline-flex; padding: 0; } @@ -7350,6 +7367,9 @@ function ConversationPanel({ customer: c, onNotify, onPatchCustomer }) { const [aiBusy, setAiBusy] = useState(false); const [aiSecs, setAiSecs] = useState(0); const [aiOpen, setAiOpen] = useState(true); + const [mBusy, setMBusy] = useState(false); + const [mSecs, setMSecs] = useState(0); + const [mOpen, setMOpen] = useState(true); const [ask, setAsk] = useState(''); const [answer, setAnswer] = useState(null); const [asking, setAsking] = useState(false); @@ -7480,6 +7500,23 @@ function ConversationPanel({ customer: c, onNotify, onPatchCustomer }) { } catch (e) { onNotify('AI 分析失败:' + e.message); } finally { clearInterval(tick); setAiBusy(false); } } + // AI 匹配产品:读产品库,按需求挑出合适 / 接近的型号 + async function matchProducts() { + setMBusy(true); setMSecs(0); setMOpen(true); + const t0 = Date.now(), tick = setInterval(() => setMSecs(Math.round((Date.now() - t0) / 1000)), 1000); + try { + const { jobId } = await convoApi('POST', `/api/convos/${c.id}/match`); + for (;;) { + await new Promise(r => setTimeout(r, 2000)); + const j = await convoApi('GET', `/api/ai/jobs/${jobId}`); + if (j.status === 'running') continue; + if (j.status === 'done' && j.data && j.data.match) { setData(d => ({ ...d, match: j.data.match })); onNotify('AI 匹配产品完成'); } + else throw new Error((j.data && j.data.error) || 'AI 匹配失败'); + break; + } + } catch (e) { onNotify('AI 匹配产品失败:' + e.message); } + finally { clearInterval(tick); setMBusy(false); } + } async function doAsk() { if (!ask.trim()) return; setAsking(true); setAnswer(null); @@ -7515,6 +7552,9 @@ function ConversationPanel({ customer: c, onNotify, onPatchCustomer }) { + @@ -7620,6 +7660,50 @@ function ConversationPanel({ customer: c, onNotify, onPatchCustomer }) { )} + {/* AI 匹配产品结果 */} + {data && data.match && data.match.result && (() => { + const M = data.match.result; + const fitCls = (f) => (/^符合/.test(f || '') ? 'f-h' : /基本/.test(f || '') ? 'f-m' : 'f-l'); + const stale = items.filter(x => (x.createdAt || 0) > data.match.at || (x.updatedAt || 0) > data.match.at).length; + return ( +
+
+ AI 匹配产品 + {new Date(data.match.at).toLocaleString()} · 产品库 {data.match.total} 个型号{data.match.candidates < data.match.total ? `,初选 ${data.match.candidates} 个对比` : ''} + {stale > 0 && 有 {stale} 条新消息,建议重新匹配} + +
+ {mOpen && (<> + {M.summary &&

{M.summary}

} + {(M.groups || []).map((g, gi) => ( +
+
{g.need}{g.qty ? × {g.qty} : null}
+ {(g.matches || []).length === 0 ?
产品库里没有合适的型号{g.noMatch ? `:${g.noMatch}` : ''}
: (g.matches || []).map((m, mi) => ( +
+
+ {m.fit || '接近'} + {m.model} + {[m.type || m.category, m.power].filter(Boolean).join(' · ')} + {onPatchCustomer && } +
+ {m.reason &&
{m.reason}
} + {m.config &&
建议配置:{m.config}
} + {Array.isArray(m.gaps) && m.gaps.length > 0 &&
    {m.gaps.map((x, k) =>
  • {x}
  • )}
} +
+ ))} + {(g.matches || []).length > 0 && g.noMatch &&
{g.noMatch}
} +
+ ))} + {Array.isArray(M.questions) && M.questions.length > 0 && ( +

还需要跟客户确认

    {M.questions.map((x, k) =>
  • {x}
  • )}
+ )} +
匹配结果只根据产品库里录入的参数;没录入的参数会列在"需确认"里,报价前请人工核对。
+ )} +
+ ); + })()} + {/* 问 AI */} {items.length > 0 && (