From 40fe09b62fd55023d04f2a0ca8f84aebfe93642b Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Thu, 26 Nov 2026 14:10:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=94=80=E5=94=AE=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=AE=98=E7=BD=91=E5=B0=81=E9=9D=A2=E4=B8=8A=E4=BC=A0=E3=80=81?= =?UTF-8?q?=E7=B2=BE=E9=80=89=E7=BA=BF=E8=B7=AF=20Coverflow=20=E4=B8=8E?= =?UTF-8?q?=E5=B0=81=E9=9D=A2=E5=8D=A1=E6=96=87=E6=A1=88=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- src/api/channel/salesProduct.ts | 23 + src/components/TablePro/index.vue | 14 +- src/components/top-nav/index.vue | 3 +- src/locale/en-US.ts | 18 + src/locale/zh-CN.ts | 18 + src/utils/salesProductCover.ts | 29 + .../components/CoverImageCropModal.vue | 291 ++++++++ src/views/channel/salesProducts/index.vue | 338 +++++++++- src/views/site/SiteAdvisorShell.vue | 1 + src/views/site/SiteFeaturedRoutes.vue | 433 ++++++++---- src/views/site/SiteHeader.vue | 43 +- src/views/site/SiteRoutesPanel.vue | 118 ++-- src/views/site/SiteRunway.vue | 25 +- src/views/site/lib/portal-catalog.ts | 18 +- src/views/site/lib/route-cover.ts | 10 + src/views/site/styles/ai-advisor.css | 620 +++++++++++++----- src/views/site/styles/main.css | 37 +- 17 files changed, 1641 insertions(+), 398 deletions(-) create mode 100644 src/utils/salesProductCover.ts create mode 100644 src/views/channel/salesProducts/components/CoverImageCropModal.vue create mode 100644 src/views/site/lib/route-cover.ts diff --git a/src/api/channel/salesProduct.ts b/src/api/channel/salesProduct.ts index 7d5db84..b3298d3 100644 --- a/src/api/channel/salesProduct.ts +++ b/src/api/channel/salesProduct.ts @@ -1,5 +1,8 @@ import { axiosInstance } from '@/api/rbac' import { assertBusinessOk, omsUrl, parseListPayload, unwrapData } from '@/api/oms/common' +import { resolveSalesProductCoverUrl } from '@/utils/salesProductCover' + +export { resolveSalesProductCoverUrl } from '@/utils/salesProductCover' /** 从 HTTP 响应体取出详情对象:标准 { code, data } 或根级直接返回实体 */ function extractSalesProductDetailFromBody(body: any): any { @@ -52,6 +55,26 @@ export async function getSalesProductDetail(id: number | string) { return normalizeSalesProductDetailPayload(raw) ?? (raw && typeof raw === 'object' ? raw : undefined) } +/** 上传官网线路封面图:multipart 经后端落库,返回 key + 同源预览 URL(非 COS 直传) */ +export async function uploadSalesProductCover( + file: File, +): Promise<{ key: string; previewUrl: string }> { + const form = new FormData() + form.append('file', file) + const res = await axiosInstance.post(omsUrl('/channel/sales-product/upload-cover'), form, { + headers: { 'Content-Type': 'multipart/form-data' }, + }) + assertBusinessOk(res.data) + const data = unwrapData(res.data) + const key = String(data?.key ?? data?.Key ?? data?.fileUrl ?? data?.FileUrl ?? '').trim() + const url = String(data?.url ?? data?.Url ?? '').trim() + if (!key) throw new Error('上传成功但未返回图片 key') + return { + key, + previewUrl: resolveSalesProductCoverUrl(url || key), + } +} + export async function createSalesProduct(body: Record) { const res = await axiosInstance.post(omsUrl('/channel/sales-product/create'), body) assertBusinessOk(res.data) diff --git a/src/components/TablePro/index.vue b/src/components/TablePro/index.vue index e0d085f..3abef04 100644 --- a/src/components/TablePro/index.vue +++ b/src/components/TablePro/index.vue @@ -308,13 +308,13 @@ subtractHeight: 60, // 为分页组件预留空间 }); + // autoHeight=true:跟容器测高;false:只跟 tableConfig.height / setHeight, + // 避免切 Tab(display 变化)触发测高后把外部 setHeight 盖回初始值 watch( height, () => { if (props.autoHeight) { proOptions.height = height.value; - } else { - proOptions.height = props.tableConfig.height; } }, { @@ -323,6 +323,16 @@ } ); + watch( + () => props.tableConfig?.height, + (h) => { + if (!props.autoHeight && h != null && h !== '') { + proOptions.height = h; + } + }, + { immediate: true }, + ); + // 计算最大页码 const maxPage = computed(() => { if (tablePage.total === 0 || tablePage.pageSize === 0) { diff --git a/src/components/top-nav/index.vue b/src/components/top-nav/index.vue index 41af650..2dc5781 100644 --- a/src/components/top-nav/index.vue +++ b/src/components/top-nav/index.vue @@ -1428,9 +1428,8 @@ onUnmounted(() => { scroll-behavior: smooth; background: rgba(255, 255, 255, 0.94); border-radius: 22px; - /* 单层短阴影 + 淡描边,避免多层发糊 */ border: 1px solid rgba(15, 23, 42, 0.06); - box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06); + box-shadow: none; .top-nav-logo { position: relative; diff --git a/src/locale/en-US.ts b/src/locale/en-US.ts index 7abe5db..91290de 100644 --- a/src/locale/en-US.ts +++ b/src/locale/en-US.ts @@ -6522,6 +6522,24 @@ export default { 'channel.salesProducts.form.weightCalculationRule': 'Weight rule', 'channel.salesProducts.form.weightRounding': 'Weight rounding', 'channel.salesProducts.form.productDescription': 'Product description', + 'channel.salesProducts.form.coverImage': 'Site cover image', + 'channel.salesProducts.form.coverImageTip': + 'Used as the featured-lane card background on the website. Prefer landscape or near-square images. Without an image, the glass card style is used.', + 'channel.salesProducts.form.coverImageUpload': 'Upload cover', + 'channel.salesProducts.form.coverImageReplace': 'Replace cover', + 'channel.salesProducts.form.coverImageClear': 'Clear', + 'channel.salesProducts.form.coverImageHint': 'Drag or click · jpg / png / webp · cropped to 16:15', + 'channel.salesProducts.form.coverImageDrop': 'Drop to upload', + 'channel.salesProducts.form.coverImageUploading': 'Uploading…', + 'channel.salesProducts.form.coverImageUploaded': 'Cover uploaded — save to apply', + 'channel.salesProducts.form.coverImageUploadFailed': 'Cover upload failed', + 'channel.salesProducts.form.coverImageType': 'Please choose an image file', + 'channel.salesProducts.form.coverImageSize': 'Image must be ≤ 12MB', + 'channel.salesProducts.form.coverImageCropTitle': 'Crop site cover', + 'channel.salesProducts.form.coverImageCropHint': + 'Drag to reposition, scroll or use the slider to zoom. Cropped to 16:15 for featured lane cards.', + 'channel.salesProducts.form.coverImageCropOk': 'Crop & upload', + 'channel.salesProducts.form.coverImageCropZoom': 'Zoom', 'channel.salesProducts.form.preStorageScript': 'Pre-storage script', 'channel.salesProducts.form.placeholder.input': 'Please enter', 'channel.salesProducts.form.placeholder.min': 'Min', diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index de6211a..74a211d 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -6527,6 +6527,24 @@ export default { 'channel.salesProducts.form.weightCalculationRule': '计重规则', 'channel.salesProducts.form.weightRounding': '计重进位', 'channel.salesProducts.form.productDescription': '产品说明', + 'channel.salesProducts.form.coverImage': '官网封面图', + 'channel.salesProducts.form.coverImageTip': + '用于官网精选线路卡片背景,建议横版或接近正方形图片;未上传时仍显示玻璃底样式。', + 'channel.salesProducts.form.coverImageUpload': '上传封面', + 'channel.salesProducts.form.coverImageReplace': '更换封面', + 'channel.salesProducts.form.coverImageClear': '清除', + 'channel.salesProducts.form.coverImageHint': '拖拽或点击上传 · jpg / png / webp · 按 16:15 裁剪', + 'channel.salesProducts.form.coverImageDrop': '松开鼠标即可上传', + 'channel.salesProducts.form.coverImageUploading': '上传中…', + 'channel.salesProducts.form.coverImageUploaded': '封面已上传,保存后生效', + 'channel.salesProducts.form.coverImageUploadFailed': '封面上传失败', + 'channel.salesProducts.form.coverImageType': '请选择图片文件', + 'channel.salesProducts.form.coverImageSize': '图片不能超过 12MB', + 'channel.salesProducts.form.coverImageCropTitle': '裁剪官网封面', + 'channel.salesProducts.form.coverImageCropHint': + '拖动调整位置,滚轮或滑杆缩放;将按 16:15 裁剪后上传,适配精选线路卡片。', + 'channel.salesProducts.form.coverImageCropOk': '裁剪并上传', + 'channel.salesProducts.form.coverImageCropZoom': '缩放', 'channel.salesProducts.form.preStorageScript': '落库前执行脚本', 'channel.salesProducts.form.placeholder.labelTemplate': '请选择标签模板(未选则用全局默认)', 'channel.salesProducts.form.placeholder.input': '请输入', diff --git a/src/utils/salesProductCover.ts b/src/utils/salesProductCover.ts new file mode 100644 index 0000000..8005b73 --- /dev/null +++ b/src/utils/salesProductCover.ts @@ -0,0 +1,29 @@ +import { resolveOmsAssetUrl } from '@/api/oms/common' + +/** + * 销售产品封面同源预览地址(与品牌 Logo 一致:不签发 COS 直链)。 + * key 为 uploads/sales-product-cover/...;已是 /cover/file 路径则原样解析。 + */ +export function resolveSalesProductCoverUrl(keyOrUrl?: string | null): string { + const raw = String(keyOrUrl ?? '').trim() + if (!raw) return '' + if ( + raw.includes('/channel/sales-product/cover/file') + || /^https?:\/\//i.test(raw) + || raw.startsWith('data:') + || raw.startsWith('blob:') + ) { + return resolveOmsAssetUrl(raw) + } + const stamp = + raw.split('/').pop()?.replace(/\.[^.]+$/, '') + || String(Math.abs(hashString(raw))) + const path = `/channel/sales-product/cover/file?key=${encodeURIComponent(raw)}&v=${encodeURIComponent(stamp)}` + return resolveOmsAssetUrl(path) +} + +function hashString(s: string): number { + let h = 0 + for (let i = 0; i < s.length; i++) h = (Math.imul(31, h) + s.charCodeAt(i)) | 0 + return h +} diff --git a/src/views/channel/salesProducts/components/CoverImageCropModal.vue b/src/views/channel/salesProducts/components/CoverImageCropModal.vue new file mode 100644 index 0000000..028eb2b --- /dev/null +++ b/src/views/channel/salesProducts/components/CoverImageCropModal.vue @@ -0,0 +1,291 @@ + + + + + diff --git a/src/views/channel/salesProducts/index.vue b/src/views/channel/salesProducts/index.vue index cc2d968..4ad8071 100644 --- a/src/views/channel/salesProducts/index.vue +++ b/src/views/channel/salesProducts/index.vue @@ -35,7 +35,9 @@ updateSalesProduct, updateSalesProductCode, updateSalesProductPrice, + uploadSalesProductCover, } from '@/api/channel/salesProduct'; + import { resolveSalesProductCoverUrl } from '@/utils/salesProductCover'; import { getLabelTemplateList } from '@/api/channel/labelTemplate'; import { isDiscountCostItem } from '@/constants/feeCostItems'; import { postForewarningServiceKpiAreaGetKpiAreas } from '@/api/channel/kpiArea'; @@ -57,6 +59,7 @@ } from '@/utils/factorValueTagPreview'; import { IconPlus, IconDelete, IconSearch, IconEdit, IconDragArrow, IconQuestionCircleFill, IconQuestionCircle, IconSync } from '@arco-design/web-vue/es/icon'; import FormLabelWithPreview from './components/FormLabelWithPreview.vue'; + import CoverImageCropModal from './components/CoverImageCropModal.vue'; import BillingConditionEditor from './components/BillingConditionEditor.vue'; import PreScriptEditor from '@/views/channel/serviceChannels/components/PreScriptEditor.vue'; import { @@ -212,9 +215,20 @@ weightCalculationRule: '', weightRounding: '', productDescription: '', + /** 官网封面图 object key */ + coverImage: '', preStorageScript: '', }); + const coverImageUploading = ref(false); + const coverImageInputRef = ref(null); + const coverCropVisible = ref(false); + const coverCropFile = ref(null); + + const coverImagePreviewUrl = computed(() => + resolveSalesProductCoverUrl(formData.coverImage), + ); + const customerGuideMarkdown = ref(''); const customerGuideSaving = ref(false); const customerGuidePanelRef = ref | null>(null); @@ -265,6 +279,7 @@ weightCalculationRule: string; weightRounding: string; productDescription: string; + coverImage: string; preStorageScript: string; }; @@ -287,6 +302,7 @@ weightCalculationRule: formData.weightCalculationRule, weightRounding: formData.weightRounding, productDescription: formData.productDescription, + coverImage: formData.coverImage, preStorageScript: formData.preStorageScript, }; } @@ -1711,6 +1727,7 @@ weightCalculationRule: numStr(p.weightRuleId ?? p.WeightRuleId), weightRounding: numStr(p.weightRoundingId ?? p.WeightRoundingId), productDescription: p.productDescription ?? p.ProductDescription ?? '', + coverImage: String(p.coverImage ?? p.CoverImage ?? '').trim(), preStorageScript: p.preStorageScript ?? p.PreStorageScript ?? '', }); customerGuideMarkdown.value = p.customerGuideMarkdown ?? p.CustomerGuideMarkdown ?? ''; @@ -1993,6 +2010,7 @@ weightRuleId: wrId ?? null, weightRoundingId: roundingId ?? null, productDescription: formData.productDescription, + coverImage: formData.coverImage || null, preStorageScript: formData.preStorageScript, isActive: toEnableStatus(isEnableStatusEnabled(prev.isActive ?? prev.IsActive)), scheme: String(prev.scheme ?? prev.Scheme ?? 'costLowest'), @@ -2000,6 +2018,86 @@ resetConfigFormBaseline(); } + const coverImageDragOver = ref(false); + let coverImageDragDepth = 0; + + function openCoverImagePicker() { + if (coverImageUploading.value) return; + coverImageInputRef.value?.click(); + } + + function clearCoverImage() { + formData.coverImage = ''; + } + + function acceptCoverImageFile(file: File | undefined | null) { + if (!file || coverImageUploading.value) return; + if (!file.type.startsWith('image/')) { + Message.warning(t('channel.salesProducts.form.coverImageType')); + return; + } + if (file.size > 12 * 1024 * 1024) { + Message.warning(t('channel.salesProducts.form.coverImageSize')); + return; + } + coverCropFile.value = file; + coverCropVisible.value = true; + } + + function onCoverImageFileChange(event: Event) { + const input = event.target as HTMLInputElement; + const file = input.files?.[0]; + input.value = ''; + acceptCoverImageFile(file); + } + + function onCoverImageDragEnter(e: DragEvent) { + e.preventDefault(); + if (coverImageUploading.value) return; + coverImageDragDepth += 1; + coverImageDragOver.value = true; + } + + function onCoverImageDragOver(e: DragEvent) { + e.preventDefault(); + if (coverImageUploading.value) return; + coverImageDragOver.value = true; + } + + function onCoverImageDragLeave() { + coverImageDragDepth = Math.max(0, coverImageDragDepth - 1); + if (coverImageDragDepth === 0) coverImageDragOver.value = false; + } + + function onCoverImageDrop(e: DragEvent) { + e.preventDefault(); + coverImageDragDepth = 0; + coverImageDragOver.value = false; + if (coverImageUploading.value) return; + const file = e.dataTransfer?.files?.[0]; + acceptCoverImageFile(file); + } + + function onCoverCropCancel() { + coverCropVisible.value = false; + coverCropFile.value = null; + } + + async function onCoverCropConfirm(file: File) { + coverCropVisible.value = false; + coverCropFile.value = null; + coverImageUploading.value = true; + try { + const { key } = await uploadSalesProductCover(file); + formData.coverImage = key; + Message.success(t('channel.salesProducts.form.coverImageUploaded')); + } catch (e: any) { + Message.error(e?.message || t('channel.salesProducts.form.coverImageUploadFailed')); + } finally { + coverImageUploading.value = false; + } + } + async function persistSalesProductAllocation(pid: number) { await saveSalesProductAllocation({ salesProductId: Number(pid), @@ -4544,18 +4642,37 @@ if (!force && Math.abs(h - priceListTableHeight.value) < 2) return; priceListTableHeight.value = h; // 只改高度,避免强制 recalculate 造成切产品卡顿 - priceListTableRef.value?.setHeight?.(h); + const table = priceListTableRef.value; + table?.setHeight?.(h); } function syncPriceListTableHeight(force = false) { const el = priceTableContainerRef.value; if (!el) return; + // display:none 期间量到 0,不能写回,否则回来会被错误高度卡住 + if (el.offsetParent === null && el.clientHeight === 0) return; const h = Math.floor(el.clientHeight || el.getBoundingClientRect().height); applyPriceListTableHeight(h, force); } + /** 切回卖价后布局可能晚一拍,连补几次高度 */ + function resyncPriceListTableAfterShow() { + const run = (force = true) => { + syncPriceListTableHeight(force); + const grid = priceListTableRef.value?.xGrid; + grid?.recalculate?.(true); + }; + run(true); + requestAnimationFrame(() => { + run(true); + requestAnimationFrame(() => run(true)); + }); + setTimeout(() => run(true), 80); + } + function setupPriceListResizeObserver() { - if (priceListResizeObserver) return; + priceListResizeObserver?.disconnect(); + priceListResizeObserver = null; if (priceListHeightRaf) { cancelAnimationFrame(priceListHeightRaf); priceListHeightRaf = 0; @@ -4570,7 +4687,7 @@ }); }); priceListResizeObserver.observe(el); - nextTick(() => syncPriceListTableHeight(true)); + nextTick(() => resyncPriceListTableAfterShow()); } const priceColumns = computed(() => [ @@ -4634,7 +4751,8 @@ }, ]); - // 高度走 setHeight,数据走 reloadData,避免 computed 随 height/data 重建触发 TablePro 重绑 + // 高度必须跟 priceListTableHeight 走:TablePro 在 autoHeight=false 时仍会用 + // tableConfig.height 覆盖 setHeight(切 Tab 触发 useAutoHeight 重算时尤甚) const priceListTableProps = computed(() => ({ columns: priceColumns.value, showPager: false, @@ -4646,7 +4764,8 @@ autoHeight: false, keepSource: true, size: 'small', - tableConfig: { height: 400 }, + height: priceListTableHeight.value, + tableConfig: { height: priceListTableHeight.value }, toolbarConfig: { setting: false, enabled: false }, rowConfig: { isHover: true, keyField: 'id' }, })); @@ -4672,17 +4791,16 @@ } nextTick(() => { setupPriceListResizeObserver(); - syncPriceListTableHeight(true); const grid = priceListTableRef.value?.xGrid; const visible = grid?.getTableData?.()?.fullData; // display:none 期间表格可能丢行,有缓存就补回去,避免切回看到空表 if (priceTableData.value.length > 0 && (!Array.isArray(visible) || visible.length === 0)) { priceListTableRef.value?.reloadData?.(priceTableData.value); } - grid?.recalculate?.(true); + resyncPriceListTableAfterShow(); }); }, - { immediate: true }, + { immediate: true, flush: 'post' }, ); @@ -5585,7 +5703,7 @@ - +
+ +
+
+ +
+
+ +
+ {{ + coverImageDragOver + ? t('channel.salesProducts.form.coverImageDrop') + : t('channel.salesProducts.form.coverImageUpload') + }} + {{ t('channel.salesProducts.form.coverImageHint') }} +
+
+ {{ t('channel.salesProducts.form.coverImageUploading') }} +
+
+ {{ t('channel.salesProducts.form.coverImageDrop') }} +
+
+
+ + {{ + coverImagePreviewUrl + ? t('channel.salesProducts.form.coverImageReplace') + : t('channel.salesProducts.form.coverImageUpload') + }} + + + {{ t('channel.salesProducts.form.coverImageClear') }} + +
+ +
+
+
+
+ +

{{ heroTitle }}

+

{{ brandCopy.navFullName }}

diff --git a/src/views/site/SiteFeaturedRoutes.vue b/src/views/site/SiteFeaturedRoutes.vue index a63f23d..5833d5f 100644 --- a/src/views/site/SiteFeaturedRoutes.vue +++ b/src/views/site/SiteFeaturedRoutes.vue @@ -9,13 +9,13 @@