diff --git a/apps/admin-web/src/pages/StoresPage.tsx b/apps/admin-web/src/pages/StoresPage.tsx index d4ab23d..411203b 100644 --- a/apps/admin-web/src/pages/StoresPage.tsx +++ b/apps/admin-web/src/pages/StoresPage.tsx @@ -19,8 +19,15 @@ import { message, } from 'antd'; import type { ColumnsType } from 'antd/es/table'; +import { FilePdfOutlined, LinkOutlined } from '@ant-design/icons'; import { request, type Paginated } from '../lib/api'; -import { ADMIN_OPTIONS_PAGE_SIZE, STORE_AUDIT_STATUS_LABELS, STORE_STATUS_LABELS, fmtTime } from '../lib/constants'; +import { + ADMIN_OPTIONS_PAGE_SIZE, + RESOURCE_BIZ_TYPE_LABELS, + STORE_AUDIT_STATUS_LABELS, + STORE_STATUS_LABELS, + fmtTime, +} from '../lib/constants'; import { validateStoreCreateStep1, validateStoreCreateStep3, @@ -37,6 +44,209 @@ const CREATE_STEPS = [ { title: '结算资质' }, ]; +type StoreMediaItem = { + id?: string; + bizType?: string; + mediaType?: string; + url?: string | null; +}; + +function isImageMedia(url: string, mediaType?: string) { + if (mediaType === 'IMAGE') return true; + if (mediaType === 'VIDEO' || mediaType === 'FILE') { + return /\.(png|jpe?g|gif|webp|bmp|heic)(\?|#|$)/i.test(url); + } + return /\.(png|jpe?g|gif|webp|bmp|heic)(\?|#|$)/i.test(url); +} + +function isPdfUrl(url: string) { + return /\.pdf(\?|#|$)/i.test(url); +} + +function collectMediaUrls(detail: Record) { + const media = Array.isArray(detail.media) ? (detail.media as StoreMediaItem[]) : []; + const byType = (bizType: string) => + media + .filter((item) => String(item.bizType || '').toUpperCase() === bizType) + .map((item) => ({ + id: String(item.id || item.url || ''), + url: String(item.url || '').trim(), + mediaType: item.mediaType ? String(item.mediaType) : undefined, + })) + .filter((item) => item.url); + + const covers = byType('COVER'); + const coverUrl = detail.coverUrl ? String(detail.coverUrl).trim() : ''; + if (coverUrl && !covers.some((item) => item.url === coverUrl)) { + covers.unshift({ id: 'cover', url: coverUrl, mediaType: 'IMAGE' }); + } + + return { + covers, + envs: byType('ENV'), + contracts: byType('CONTRACT'), + }; +} + +function StoreAuditMediaSection({ detail }: { detail: Record }) { + const { covers, envs, contracts } = collectMediaUrls(detail); + const [pdfUrl, setPdfUrl] = useState(null); + const gallery = [...covers, ...envs].filter((item) => isImageMedia(item.url, item.mediaType)); + + if (covers.length === 0 && envs.length === 0 && contracts.length === 0) { + return ( + + ); + } + + return ( +
+ + 审核材料 + + + {(covers.length > 0 || envs.length > 0) && ( +
+ + 门头照 / 环境照(点击可放大浏览) + + + + {gallery.map((item) => ( +
+ +
+ {covers.some((c) => c.id === item.id) ? '门头照' : '环境照'} +
+
+ ))} +
+
+
+ )} + + {contracts.length > 0 && ( +
+ + 签约合同 + + + {contracts.map((item, index) => { + const imageLike = isImageMedia(item.url, item.mediaType); + const pdf = isPdfUrl(item.url); + return ( +
+ {imageLike ? ( + + + + ) : ( +
+ +
+ )} + + + {RESOURCE_BIZ_TYPE_LABELS.CONTRACT || '合同'} + {contracts.length > 1 ? ` ${index + 1}` : ''} + + + {item.url} + + + {imageLike ? ( + 点击缩略图放大查看 + ) : null} + {pdf ? ( + + ) : null} + + + +
+ ); + })} +
+
+ )} + + setPdfUrl(null)} + width={900} + footer={[ + , + , + ]} + destroyOnClose + > + {pdfUrl ? ( +