Merge branch 'main' of github.com:hainatravel/GHHub

main
Ycc 2 months ago
commit de098fef00

@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
import { Upload, List, Modal } from "antd";
import { Upload, List, Popconfirm } from "antd";
import { UploadOutlined } from "@ant-design/icons";
import { Image } from "antd";
import { fetchJSON } from "@/utils/request";
@ -108,30 +109,19 @@ export const ImageUploader = props => {
}, [key]);
//
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: () => {
// fileListUpload
setFileList([...fileList]);
},
});
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("");
}
};
//
@ -176,9 +166,31 @@ export const ImageUploader = props => {
setPreviewOpen(true);
};
const handleRemove = file => {
return (
<Popconfirm
title="Confirm deletion"
description="Confirm deletion of this file?"
onConfirm={() => handleDelete(file)}
onCancel={() => setFileList([...fileList])}
okText="Yes"
cancelText="No"
>
</Popconfirm>
);
// false Popconfirm
return false;
};
const itemRender = (originNode, file, fileList, actions) => {
};
return (
<>
<Upload customRequest={handleUploadFile} multiple={true} onRemove={handleDelete} listType="picture-card" fileList={fileList} onPreview={handlePreview} onChange={handleChange}>
<Upload customRequest={handleUploadFile} multiple={true} onRemove={handleRemove} listType="picture-card" fileList={fileList} onPreview={handlePreview} onChange={handleChange} >
<div>
<UploadOutlined />
<div style={{ marginTop: 8 }}>上传图片</div>
@ -240,4 +252,4 @@ export const ImageViewer = props => {
);
};
export default ImageUploader;
export default ImageUploader;
Loading…
Cancel
Save