fix(移动端-框架): 附件删除(删除不掉) (#1574)

Reviewed-on: daoyoucloud/tachybase#1574
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-09-27 11:51:35 +08:00 committed by bai.zixv
parent 4b5d09a3cf
commit 5cb9529900

View File

@ -7,6 +7,7 @@ import { ImageUploader, ImageUploadItem } from 'antd-mobile';
export const MImageUploader = connect(
(props) => {
const [fileList, setFileList] = useState<ImageUploadItem[]>([]);
const [change, setChange] = useState(false);
const field = props.value || [];
useEffect(() => {
@ -47,6 +48,11 @@ export const MImageUploader = connect(
setChange(true);
props.onChange(field);
}}
onDelete={(file) => {
const fileIndex = field.findIndex((item) => item.id === file.key);
field.splice(fileIndex, 1);
props.onChange(field);
}}
/>
);
},