shaogen1995 2 weeks ago
parent
commit
0fda00b350
2 changed files with 10 additions and 5 deletions
  1. 8 5
      src/components/Z3upFiles/index.tsx
  2. 2 0
      src/pages/Zother/data.ts

+ 8 - 5
src/components/Z3upFiles/index.tsx

@@ -193,6 +193,8 @@ type Props = {
   size?: number
   maxCount?: number
   oneIsCover?: boolean
+  // 默认是修改 files 字段。有可能是下面的附件,使用不同的字段
+  filesKey?: 'files' | 'files2'
 }
 
 // 修复类型检查问题:统一使用dnd-kit管理所有拖拽
@@ -205,17 +207,18 @@ function Z3upFiles({
   tips = '单个附件不得超过500M',
   size = 500,
   maxCount = 999,
-  oneIsCover
+  oneIsCover,
+  filesKey = 'files'
 }: Props) {
   const { info, setInfoFu } = useInfo()
 
   // 修复图片闪动问题:分别管理图片和非图片的排序
   const { imageFiles, otherFiles } = useMemo(() => {
-    const arr = info.files || []
+    const arr = info[filesKey] || []
     const imgArr = arr.filter(v => v.type === 'img')
     const otherArr = arr.filter(v => v.type !== 'img')
     return { imageFiles: imgArr, otherFiles: otherArr }
-  }, [info.files])
+  }, [filesKey, info])
 
   const fileList = useMemo(() => {
     return [...imageFiles, ...otherFiles]
@@ -225,7 +228,7 @@ function Z3upFiles({
   const setFileList = useCallback(
     (newFiles: FileListType[] | ((prev: FileListType[]) => FileListType[])) => {
       setInfoFu((prevInfo: Typetable) => {
-        const currentFiles = prevInfo.files || []
+        const currentFiles = prevInfo[filesKey] || []
         const updatedFiles = typeof newFiles === 'function' ? newFiles(currentFiles) : newFiles
 
         const updatedInfo: Typetable = {
@@ -235,7 +238,7 @@ function Z3upFiles({
         return updatedInfo
       })
     },
-    [setInfoFu]
+    [filesKey, setInfoFu]
   )
 
   const [activeId, setActiveId] = useState<number | null>(null)

+ 2 - 0
src/pages/Zother/data.ts

@@ -162,6 +162,8 @@ export type Typetable = {
   dictIdApply?: any
   fileIds?: any
   files: FileListType[]
+  // 待完善sg
+  files2: FileListType[]
   goodIds: string
   id: number
   nodeProcessId: number