From 394e04ba31f0822255862033b8dffef17530495c Mon Sep 17 00:00:00 2001
From: zhangyongtian <1181606322@qq.com>
Date: Fri, 13 Sep 2024 22:49:01 +0800
Subject: [PATCH] fix: 受理跳转办理页面为空白的bug
---
gz-customerSystem/src/components/ArcoUpload/index.jsx | 37 ++++++++++++++++++++++++++++++-------
1 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/gz-customerSystem/src/components/ArcoUpload/index.jsx b/gz-customerSystem/src/components/ArcoUpload/index.jsx
index e9f5cca..7f87aa1 100644
--- a/gz-customerSystem/src/components/ArcoUpload/index.jsx
+++ b/gz-customerSystem/src/components/ArcoUpload/index.jsx
@@ -23,22 +23,36 @@
* label *, // form的label名
* editData *, // 编辑回显数据
* handleDelFile *,//删除文件接口
+ * ownerType,//用于回显文件
*/
export default function ArcoUpload(props) {
const [myFileList, setMyFileList] = useState([])
const handleFileListChange = (fileList) => {
- setMyFileList(fileList);
if (props.onFileListChange) {
- props.onFileListChange(fileList.length);
+ props.onFileListChange(fileList);
}
};
useEffect(() => {
if (props.editData) {
- console.log(props.editData[props.field]);
- setMyFileList(props.editData[props.field])
+ if(props.editData[props.field]) {
+ //新增的时候有file数据,可以这样子回显
+ setMyFileList(props.editData[props.field])
+ } else {
+ //编辑的时候,文件统一放在filInfoList了,需要设置ownerType获取到该材料文件回显
+ const fileInfoList = props.editData.fileInfoList
+ if(fileInfoList && fileInfoList.length != 0) {
+ let file = [];
+ fileInfoList.forEach(item => {
+ if(item.ownerType == props.ownerType) {
+ file.push(item.fileList[0])
+ }
+ })
+ setMyFileList(file)
+ }
+ }
}
}, [props.editData])
@@ -61,7 +75,8 @@
}}
headers={{ Authorization: $$.getSessionStorage('customerSystemToken') }}
onChange={(fileList, file) => {
- const { status, response } = file
+ const { status, response, uid } = file
+ console.log(fileList, file);
//因为字节upLoad组件有bug,不能区分添加文件还是删除文件,所以用这种办法来判断是不是删除
const isDel = myFileList && myFileList.length > fileList.length
//上传失败
@@ -80,10 +95,18 @@
}
//删除文件
if (isDel && props.handleDelFile) {
- props.handleDelFile(response.data[0].id)
+ if(response) {
+ //删除的是新提交的
+ props.handleDelFile(response.data[0].id)
+ } else {
+ //删除的是回显的文件
+ props.handleDelFile(uid)
+ }
+
}
- // setMyFileList(fileList)
handleFileListChange(fileList);
+ setMyFileList(fileList)
+
}}
{...props.params}//自定义
/>
--
Gitblit v1.8.0