From 12554eda2716cc31098adc9cf140976c2d33f019 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 17 Nov 2026 17:28:01 +0800 Subject: [PATCH] Update App.jsx via upload script - 2026-11-17 17:27:41 --- App.jsx | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/App.jsx b/App.jsx index ca71497..badb28b 100644 --- a/App.jsx +++ b/App.jsx @@ -2352,6 +2352,10 @@ const Styles = () => ( .cv-edit { display: grid; gap: 8px; } @media (max-width: 760px) { .cv-grid { grid-template-columns: 1fr; } } /* 沟通记录:聊天样式 */ + .cv-q-qty { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; font-weight: 500; } + .cv-q-qty .input { width: 76px; height: 28px; font-size: 12.5px; } + .cv-q-chk { width: 16px; height: 16px; accent-color: #0f766e; cursor: pointer; } + .cv-q-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #e6f6f3; border: 1px solid #99d5cc; font-size: 12.5px; color: #0f5e57; } .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; } @@ -3912,6 +3916,18 @@ function MainApp({ username, onLogout }) { setQuoteDraft(draft); setQuoteSubView('editor'); } + // 从"AI 匹配产品"一键生成报价单:带上客户、型号、数量,单价留空手动填(以前报过的型号沿用当时的描述) + function createQuoteFromMatch(cust, picks) { + const draft = blankQuote('quote'); + draft.number = suggestDocNumber(draft.date, quotes, 'quote'); + if (cust) { draft.customerId = cust.id; draft.billToName = billPartyName(cust); } + draft.lineItems = picks.map((p, i) => { + const h = (priceHistory || []).find(x => x.description.split('\n')[0].trim().toUpperCase() === String(p.model).trim().toUpperCase()); + return { ...blankLineItem(), id: 'li_' + Date.now() + '_' + i + Math.random().toString(36).slice(2, 5), description: h ? h.description : p.model, quantity: p.qty || '', rate: '' }; + }); + setQuoteDraft(draft); setQuoteSubView('editor'); setView('quotes'); + notify(`已生成报价单草稿(${picks.length} 项),请填写单价后保存`); + } function startEditQuote(q) { setQuoteDraft({ ...q, lineItems: q.lineItems.map(li => ({ ...li })) }); setQuoteSubView('editor'); @@ -4411,6 +4427,7 @@ function MainApp({ username, onLogout }) { onToggleOrdered={() => toggleOrdered(selected.id)} onNotify={notify} onPatchCustomer={(patch) => setCustomers(prev => prev.map(x => (x.id === selected.id ? { ...x, ...patch } : x)))} + onCreateQuote={(picks) => createQuoteFromMatch(selected, picks)} attachmentNote={attachmentNote} setAttachmentNote={setAttachmentNote} attachmentCategory={attachmentCategory} @@ -7346,7 +7363,7 @@ function CvBlocks({ blocks }) { } const cvBlocksSummary = (bl) => { const t = (bl || []).find(b => b.t === 'table'); return t ? `表格 ${t.rows.length} 行 × ${Math.max(...t.rows.map(r => r.reduce((a, c) => a + (c.cs || 1), 0)))} 列` : ''; }; -function ConversationPanel({ customer: c, onNotify, onPatchCustomer }) { +function ConversationPanel({ customer: c, onNotify, onPatchCustomer, onCreateQuote }) { const custName = String(c.contact || '').replace(/\s*[((].*$/, '').trim() || c.company || '客户'; const [data, setData] = useState(null); const [from, setFrom] = useState('customer'); @@ -7370,6 +7387,7 @@ function ConversationPanel({ customer: c, onNotify, onPatchCustomer }) { const [mBusy, setMBusy] = useState(false); const [mSecs, setMSecs] = useState(0); const [mOpen, setMOpen] = useState(true); + const [qPick, setQPick] = useState({ at: 0, sel: {}, qty: {} }); // 生成报价单:勾选的型号、每组数量(换了一次匹配结果就重置) const [ask, setAsk] = useState(''); const [answer, setAnswer] = useState(null); const [asking, setAsking] = useState(false); @@ -7663,6 +7681,13 @@ function ConversationPanel({ customer: c, onNotify, onPatchCustomer }) { {/* AI 匹配产品结果 */} {data && data.match && data.match.result && (() => { const M = data.match.result; + const gq = (g) => { const m = String(g.qty || '').replace(/,/g, '').match(/\d+(\.\d+)?/); return m ? m[0] : ''; }; + const pk = qPick.at === data.match.at ? qPick : { at: data.match.at, sel: {}, qty: {} }; + const isSel = (gi, mi) => (pk.sel[`${gi}-${mi}`] !== undefined ? pk.sel[`${gi}-${mi}`] : mi === 0); + const qtyOf = (gi, g) => (pk.qty[gi] !== undefined ? pk.qty[gi] : gq(g)); + const setPk = (fn) => setQPick(() => fn(pk)); + const picks = []; + (M.groups || []).forEach((g, gi) => (g.matches || []).forEach((m, mi) => { if (isSel(gi, mi)) picks.push({ model: m.model, qty: qtyOf(gi, g), productId: m.productId }); })); 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 ( @@ -7677,10 +7702,13 @@ function ConversationPanel({ customer: c, onNotify, onPatchCustomer }) { {M.summary &&

{M.summary}

} {(M.groups || []).map((g, gi) => (
-
{g.need}{g.qty ? × {g.qty} : null}
+
{g.need}{g.qty ? × {g.qty} : null} + {(g.matches || []).length > 0 && onCreateQuote && } +
{(g.matches || []).length === 0 ?
产品库里没有合适的型号{g.noMatch ? `:${g.noMatch}` : ''}
: (g.matches || []).map((m, mi) => (
+ {onCreateQuote && { const v = e.target.checked; setPk(p => ({ ...p, sel: { ...p.sel, [`${gi}-${mi}`]: v } })); }} />} {m.fit || '接近'} {m.model} {[m.type || m.category, m.power].filter(Boolean).join(' · ')} @@ -7698,6 +7726,12 @@ function ConversationPanel({ customer: c, onNotify, onPatchCustomer }) { {Array.isArray(M.questions) && M.questions.length > 0 && (

还需要跟客户确认

    {M.questions.map((x, k) =>
  • {x}
  • )}
)} + {onCreateQuote && ( +
+ 勾选要报价的型号(默认每项需求的第一个),数量可以改 + +
+ )}
匹配结果只根据产品库里录入的参数;没录入的参数会列在"需确认"里,报价前请人工核对。
)}
@@ -7860,7 +7894,7 @@ function CustomerDetail({ attachmentFileNames, onPickAttachment, uploading, fileInputKey, onUploadAttachment, onDeleteAttachment, onMoveAttachment, onCreateFolder, onRenameFolder, onDeleteFolder, fileDragActive, onFileDragOver, onFileDragLeave, onFileDrop, - onNotify, onPatchCustomer, + onNotify, onPatchCustomer, onCreateQuote, }) { const lt = localTimeInfo(c.country, now); const preferred = c.preferredContacts || []; @@ -7956,7 +7990,7 @@ function CustomerDetail({ {c.notes &&
客户背景信息调查
{c.notes}
} - {})} onPatchCustomer={onPatchCustomer} /> + {})} onPatchCustomer={onPatchCustomer} onCreateQuote={onCreateQuote} />
客户文件管理