From 1a97245ee61f5c94735afc9a6aaf5a80dd97a1d5 Mon Sep 17 00:00:00 2001 From: ybc <2483488988@qq.com> Date: Fri, 8 Aug 2025 11:18:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E7=9C=8B=E6=8A=A4?= =?UTF-8?q?=E7=85=A7=E5=9B=BE=E7=89=87=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ImageUploader.jsx | 38 +++++++++++++++++++++----------- src/main.jsx | 2 ++ src/views/ImageViewer.jsx | 37 +++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 src/views/ImageViewer.jsx diff --git a/src/components/ImageUploader.jsx b/src/components/ImageUploader.jsx index 3437e70..eefe4c0 100644 --- a/src/components/ImageUploader.jsx +++ b/src/components/ImageUploader.jsx @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import { Upload, List } from "antd"; +import { Upload, List, Modal } from "antd"; import { UploadOutlined } from "@ant-design/icons"; import { Image } from "antd"; import { fetchJSON } from "@/utils/request"; @@ -108,18 +108,30 @@ const ImageUploader = props => { }, [key]); // 处理删除操作 - const handleDelete = async file => { - const success = await deleteImage(file.encrypt_key); - if (success) { - const newImages = fileList.filter(item => item.encrypt_key !== file.encrypt_key); - if (props.onChange) { - props.onChange(newImages); - } - setFileList(newImages); - console.log("删除成功"); - } else { - console.error("删除失败"); - } + const handleDelete = file => { + Modal.confirm({ + title: '确认删除', + content: '确定要删除这张图片吗?', + okText: '确认', + cancelText: '取消', + onOk: async () => { + const success = await deleteImage(file.encrypt_key); + if (success) { + const newImages = fileList.filter(item => item.encrypt_key !== file.encrypt_key); + if (props.onChange) { + props.onChange(newImages); + } + setFileList(newImages); + console.log("删除成功"); + } else { + console.error("删除失败"); + } + }, + onCancel: () => { + // 用户点击取消,重新设置fileList以刷新Upload组件 + setFileList([...fileList]); + }, + }); }; // 处理上传操作 diff --git a/src/main.jsx b/src/main.jsx index 7a3310c..626f7ae 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -45,6 +45,7 @@ import { isNotEmpty } from '@/utils/commons' import ProductsManage from '@/views/products/Manage'; import ProductsDetail from '@/views/products/Detail'; import ProductsAudit from '@/views/products/Audit'; +import ImageViewer from '@/views/ImageViewer'; import { PERM_ACCOUNT_MANAGEMENT, PERM_ROLE_NEW, PERM_OVERSEA,PERM_TRAIN_TICKET, PERM_AIR_TICKET, PERM_PRODUCTS_MANAGEMENT, PERM_PRODUCTS_OFFER_PUT } from '@/config' import './i18n' @@ -102,6 +103,7 @@ const initRouter = async () => { children: [ { path: '/login', element: }, { path: '/logout', element: }, + { path: '/image-viewer/:GRI_SN/:GRI_No', element: }, ] } ]) diff --git a/src/views/ImageViewer.jsx b/src/views/ImageViewer.jsx new file mode 100644 index 0000000..3330d36 --- /dev/null +++ b/src/views/ImageViewer.jsx @@ -0,0 +1,37 @@ +import React, { useState, useEffect } from 'react'; +import { Input, Button, Card, Typography, Space, Alert } from 'antd'; +import { useParams } from 'react-router-dom'; +import ImageUploader from '@/components/ImageUploader'; + +const { Title, Text } = Typography; + +const ImageViewer = () => { + const { GRI_SN, GRI_No } = useParams(); + const [ossKey, setOssKey] = useState(''); + const [showUploader, setShowUploader] = useState(false); + + useEffect(() => { + if (GRI_SN && GRI_No) { + const key = `ghh/${GRI_SN}-${GRI_No}/passport_image`; + setOssKey(key); + setShowUploader(true); + } + }, [GRI_SN, GRI_No]); + + + return ( +
+ {GRI_SN}-{GRI_No} + + {showUploader && ( + + )} + + {!showUploader && ( + 无法从URL中提取订单信息 + )} +
+ ); +}; + +export default ImageViewer; \ No newline at end of file