Update App.jsx via upload script - 2026-10-22 14:56:30

This commit is contained in:
mike 2026-10-22 14:56:34 +08:00
parent 1b714399c3
commit f71a8be81a
1 changed files with 37 additions and 0 deletions

37
App.jsx
View File

@ -857,6 +857,7 @@ function upsertProductByName(list, product) {
webDetailImages: existing.webDetailImages,
webDetailTemplateIds: existing.webDetailTemplateIds,
webSockets: existing.webSockets,
webPack: existing.webPack,
youtubeUrl: product.youtubeUrl ?? existing.youtubeUrl,
webDescription: product.webDescription ?? existing.webDescription,
webSale: product.webSale ?? existing.webSale,
@ -1043,6 +1044,7 @@ const blankProduct = () => ({
webImages: [], // 网站主图文件名,最多6张,第一张为封面;为空时网站用 productImageFileName
webDetailImages: [], // 网站产品详情图,最多20张,显示在规格表下方
webSockets: [], // 离线式/在线互动式UPS:网站展示的默认插座 [{ type, count }]
webPack: { per: '', nw: '', gw: '', l: '', w: '', h: '' }, // 箱规:每箱数量、每箱净重/毛重(kg)、外箱长宽高(mm),网站按数量自动生成箱单
webDetailTemplateIds: [], // 引用的详情模板id,按顺序显示在详情图下方(模板改了,所有引用它的产品下次更新网站时一起变)
youtubeUrl: '', // 网站产品视频(YouTube链接)
webDescription: { en: '', es: '', ru: '' }, // 网站产品介绍:只需填英文,其他语言在网站构建时用DeepSeek自动翻译;es/ru填了就用手动译文
@ -6368,6 +6370,39 @@ function HtmlTemplateEditor({ tpl, update, products, onNotify }) {
);
}
// 箱规(所有品类通用):填了每箱数量、每箱毛重和外箱尺寸,网站产品页就按客户选的数量自动生成箱单
function WebPackEditor({ value, onChange }) {
const v = { per: '', nw: '', gw: '', l: '', w: '', h: '', ...(value || {}) };
const set = (patch) => onChange({ ...v, ...patch });
const n = (x) => parseFloat(String(x).replace(',', '.')) || 0;
const per = n(v.per), nw = n(v.nw), gw = n(v.gw), box = n(v.l) * n(v.w) * n(v.h) / 1e9;
const ready = per > 0 && gw > 0 && box > 0;
const num = (k, label, ph) => (
<label className="field" style={{ marginBottom: 0 }}>
<span className="field-label">{label}</span>
<input className="input" inputMode="decimal" value={v[k]} placeholder={ph} onChange={e => set({ [k]: e.target.value })} />
</label>
);
return (
<div className="field">
<span className="field-label">箱规(网站按客户选的数量自动生成箱单;不填则网站不显示箱单)</span>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(120px, 1fr))', gap: 10 }}>
{num('per', '每箱数量(台)', '20')}
{num('nw', '每箱净重(kg)', '19.00')}
{num('gw', '每箱毛重(kg)', '19.61')}
{num('l', '外箱长(mm)', '465')}
{num('w', '外箱宽(mm)', '375')}
{num('h', '外箱高(mm)', '240')}
</div>
<div style={{ fontSize: 12.5, marginTop: 6, color: ready && !(nw && gw < nw) ? 'var(--ink-soft)' : '#9a6700' }}>
{!ready ? '每箱数量、每箱毛重、外箱尺寸都填上,网站才显示箱单'
: nw && gw < nw ? '! 毛重比净重还小,请检查'
: `每箱体积 ${box.toFixed(4)} m³${nw ? ` · 单台净重 ${(nw / per).toFixed(3)} kg · 纸箱 ${(gw - nw).toFixed(2)} kg` : ''} · 1000 台 = ${Math.ceil(1000 / per)} 箱 / ${(Math.ceil(1000 / per) * box).toFixed(2)} m³`}
</div>
</div>
);
}
// 离线式 / 在线互动式 UPS:网站上只做询价(不填价格),改为配置默认插座
const isQuoteOnlyType = (t) => isOfflineFamily(t);
const WEB_SOCKET_TYPES = [
@ -6483,6 +6518,8 @@ function WebPublishSection({ draft, set, onNotify, templates, setTemplates, prod
</div>
))}
<WebPackEditor value={draft.webPack} onChange={(v) => set({ webPack: v })} />
{isQuoteOnlyType(draft.type) ? (
<WebSocketsEditor value={draft.webSockets} onChange={(v) => set({ webSockets: v })} />
) : (