import { useEffect, useMemo, useState } from 'react'; import { useNavigate, useSearchParams } from 'react-router-dom'; import { Alert, Button, Descriptions, Drawer, Form, Image, Input, InputNumber, Modal, Select, Space, Steps, Table, Tabs, Tag, Typography, message, } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import { FilePdfOutlined, LinkOutlined, EnvironmentOutlined } from '@ant-design/icons'; import { request, type Paginated } from '../lib/api'; import { ADMIN_OPTIONS_PAGE_SIZE, RESOURCE_BIZ_TYPE_LABELS, STORE_AUDIT_STATUS_LABELS, STORE_STATUS_LABELS, fmtTime, } from '../lib/constants'; import { validateStoreCreateStep1, validateStoreCreateStep3, type StoreCreateForm, } from '../lib/storeCreate'; import { useAdminList } from '../lib/useAdminList'; import { resolveRegionBinding } from '../lib/china-region'; import ChinaRegionCascader from '../components/ChinaRegionCascader'; import OssUpload from '../components/OssUpload'; import TencentLocPickerModal from '../components/TencentLocPickerModal'; const CREATE_STEPS = [ { title: '基本信息' }, { title: '照片上传' }, { title: '结算资质' }, ]; function fillGeolocation( setCoords: (lat: number, lng: number) => void, setLoading: (v: boolean) => void, ) { if (!navigator.geolocation) { message.error('当前浏览器不支持定位'); return; } setLoading(true); navigator.geolocation.getCurrentPosition( (pos) => { setCoords(pos.coords.latitude, pos.coords.longitude); message.success( `已获取坐标 ${pos.coords.latitude.toFixed(6)}, ${pos.coords.longitude.toFixed(6)}`, ); setLoading(false); }, (err) => { message.error(err.message || '定位失败'); setLoading(false); }, { enableHighAccuracy: true, timeout: 10000 }, ); } 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 ? (