shaogen1995 пре 10 часа
родитељ
комит
452e530663

+ 4 - 0
src/pages/Benter/B1collect/B1edit/index.tsx

@@ -6,6 +6,7 @@ import { InfoProvider } from '@/pages/Zother/InfoContext'
 import { rowArrTemp } from '@/pages/Zother/data'
 import { B1API_obj } from '@/store/action/Benter/B1collect'
 import SonClueList from '@/pages/Zother/SonClueList'
+import FileArchive from '@/pages/Zother/FileArchive'
 
 const rowArr = rowArrTemp('征集')
 
@@ -27,6 +28,9 @@ function B1edit() {
             fileUpInfo={{ myUrl: 'cms/order/collect/son/upload', dirCode: 'collectClues' }}
           />
 
+          {/* 附件归档 */}
+          <FileArchive />
+
           {/* 底部按钮 */}
           <EditBtn path='/collect' APIobj={B1API_obj} checkListTxt='请添加线索' />
         </div>

+ 3 - 1
src/pages/Benter/B2enterGuan/B2edit/index.tsx

@@ -6,6 +6,7 @@ import EditTop from '@/pages/Zother/EditTop'
 import { B2_APIgetClueList, B2_APIgoodsSave, B2API_obj } from '@/store/action/Benter/B2enterGuan'
 import EditBtn from '@/pages/Zother/EditBtn'
 import SonGoodsList from '@/pages/Zother/SonGoodsList'
+import FileArchive from '@/pages/Zother/FileArchive'
 
 const rowArr = rowArrTemp('入馆')
 
@@ -29,7 +30,8 @@ function B2edit() {
             addGoodsApi={B2_APIgoodsSave}
             isClueSelect={true}
           />
-
+          {/* 附件归档 */}
+          <FileArchive />
           {/* 底部按钮 */}
           <EditBtn path='/enterGuan' APIobj={B2API_obj} checkListTxt='请添加藏品' />
         </div>

+ 6 - 1
src/pages/Benter/B3auth/B3edit/index.tsx

@@ -6,13 +6,14 @@ import EditTop from '@/pages/Zother/EditTop'
 import { B3_APIgetClueList, B3API_obj } from '@/store/action/Benter/B3auth'
 import EditBtn from '@/pages/Zother/EditBtn'
 import { B3moreList } from '../data'
+import FileArchive from '@/pages/Zother/FileArchive'
 
 const rowArr = [
   {
     name: `鉴定入藏`,
     type: 'txt'
   },
-  ...rowArrTemp('入藏').slice(1)
+  ...rowArrTemp('入藏', undefined, '藏品鉴定').slice(1)
 ]
 
 function B3edit() {
@@ -36,11 +37,15 @@ function B3edit() {
             }}
           />
 
+          {/* 附件归档 */}
+          <FileArchive />
+
           {/* 底部按钮 */}
           <EditBtn
             path='/auth'
             APIobj={B3API_obj}
             checkListTxt='请选择关联藏品'
+            isTow={true}
             verifyBackFu={info => {
               const res = { flag: false, txt: '' }
               if (!info.member) {

+ 4 - 0
src/pages/Benter/B4enterCang/B4edit/index.tsx

@@ -6,6 +6,7 @@ import EditTop from '@/pages/Zother/EditTop'
 import { B4_APIgetClueList, B4API_obj } from '@/store/action/Benter/B4enterCang'
 import EditBtn from '@/pages/Zother/EditBtn'
 import SonGoodsList from '@/pages/Zother/SonGoodsList'
+import FileArchive from '@/pages/Zother/FileArchive'
 
 const rowArr = rowArrTemp('入藏')
 
@@ -30,6 +31,9 @@ function B4edit() {
             addShow={false}
           />
 
+          {/* 附件归档 */}
+          <FileArchive />
+
           {/* 底部按钮 */}
           <EditBtn path='/enterCang' APIobj={B4API_obj} checkListTxt='请添加藏品' />
         </div>

+ 4 - 0
src/pages/Dmanage/D1register/D1edit/index.tsx

@@ -6,6 +6,7 @@ import { D1_APIgetClueList, D1_APIgoodsSave, D1API_obj } from '@/store/action/Dm
 import { InfoProvider } from '@/pages/Zother/InfoContext'
 import { rowArrTemp } from '@/pages/Zother/data'
 import SonGoodsList from '@/pages/Zother/SonGoodsList'
+import FileArchive from '@/pages/Zother/FileArchive'
 
 const rowArr = rowArrTemp('登记')
 
@@ -30,6 +31,9 @@ function D1edit() {
             isClueSelect={true}
           />
 
+          {/* 附件归档 */}
+          <FileArchive />
+
           {/* 底部按钮 */}
           <EditBtn path='/register' APIobj={D1API_obj} checkListTxt='请添加藏品' />
         </div>

+ 4 - 0
src/pages/Dmanage/D3writeOff/D3edit/index.tsx

@@ -6,6 +6,7 @@ import EditTop from '@/pages/Zother/EditTop'
 import { D3_APIgetClueList, D3API_obj } from '@/store/action/Dmanage/D3writeOff'
 import SonGoodsList from '@/pages/Zother/SonGoodsList'
 import EditBtn from '@/pages/Zother/EditBtn'
+import FileArchive from '@/pages/Zother/FileArchive'
 
 const rowArr = rowArrTemp('注销')
 
@@ -30,6 +31,9 @@ function D3edit() {
             addShow={false}
           />
 
+          {/* 附件归档 */}
+          <FileArchive />
+
           {/* 底部按钮 */}
           <EditBtn path='/writeOff' APIobj={D3API_obj} checkListTxt='请添加藏品' />
         </div>

+ 4 - 0
src/pages/Fstorehouse/F1inStorage/F1edit/index.tsx

@@ -15,6 +15,7 @@ import {
 } from '@/store/action/Fstorehouse/F1inStorage'
 import { Button, Select } from 'antd'
 import { selectObj } from '@/utils/dataChange'
+import FileArchive from '@/pages/Zother/FileArchive'
 
 const rowArr = rowArrTemp('入库')
 
@@ -204,6 +205,9 @@ function F1editContent() {
           isClueSelect={false}
         />
 
+        {/* 附件归档 */}
+        <FileArchive />
+
         {/* 底部按钮 */}
         <EditBtn
           path='/inStorage'

+ 4 - 0
src/pages/Gmaintain/G1accident/G1edit/index.tsx

@@ -6,6 +6,7 @@ import EditTop from '@/pages/Zother/EditTop'
 import { G1_APIgetClueList, G1API_obj } from '@/store/action/Gmaintain/G1accident'
 import EditBtn from '@/pages/Zother/EditBtn'
 import { G1moreList } from '../data'
+import FileArchive from '@/pages/Zother/FileArchive'
 
 const rowArr = [
   {
@@ -36,6 +37,9 @@ function G1edit() {
             }}
           />
 
+          {/* 附件归档 */}
+          <FileArchive />
+
           {/* 底部按钮 */}
           <EditBtn path='/accident' APIobj={G1API_obj} checkListTxt='请选择关联藏品' isTow={true} />
         </div>

+ 22 - 5
src/pages/Zother/EditBtn/index.tsx

@@ -123,6 +123,7 @@ function EditBtn({
               snapSon.fileIds2 = info.files2.map(v => v.id).join(',')
             }
           }
+          // console.log('xxxxxxxx', snapSon)
 
           snapsArr.push({
             goodId: v.isNew || flag ? null : v.id,
@@ -131,6 +132,22 @@ function EditBtn({
           })
         })
 
+        // 没有选择关联藏品的时候,只存下面的字段 待完善sg--等后端确定
+        if (snaps.length === 0) {
+          let snapSon: any = {}
+          snapSon = {
+            ...info2
+          }
+          if (info.files2 && info.files2.length) {
+            snapSon.fileIds2 = info.files2.map(v => v.id).join(',')
+          }
+
+          snapsArr.push({
+            orderId: info.id,
+            snap: JSON.stringify(snapSon)
+          })
+        }
+
         let obj = {
           ...info,
           fileIds: fileIdsResFu(info.files),
@@ -211,16 +228,16 @@ function EditBtn({
 
           // 其他自己制定的校验函数
           if (verifyBackFu) {
-            const flagObj = verifyBackFu(info)
+            const flagObj = verifyBackFu(info2)
             if (flagObj.flag) {
               if (isLook) history.replace(`${path}_edit/2/${info.id}`)
               MessageFu.warning(flagObj.txt + txt)
               return
             }
-            // 如果需要传递数据
-            if (flagObj.info) {
-              // 自己把数据加到obj里面 给后端
-            }
+            // // 如果需要传递数据
+            // if (flagObj.info) {
+            //   // 自己把数据加到obj里面 给后端
+            // }
           }
 
           // console.log('xxxxxx', obj)

+ 2 - 0
src/pages/Zother/EditTop/index.tsx

@@ -82,6 +82,7 @@ function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo, moreDom }: Props) {
         // 设置有关藏品的信息
         // 藏品清单快照信息id对比
         const arrTemp: any = []
+
         const snapsTemp = data.snaps || []
         snapsTemp.forEach(async (v: any, i: number) => {
           const obj = JSON.parse(v.snap || '{}')
@@ -117,6 +118,7 @@ function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo, moreDom }: Props) {
             }
           }
         })
+
         // console.log('-------', arrTemp)
 
         setSnapsFu(arrTemp)

+ 16 - 0
src/pages/Zother/FileArchive/index.module.scss

@@ -0,0 +1,16 @@
+.FileArchive {
+  margin-top: 20px;
+  border-top: 1px solid #ccc;
+  :global {
+    .FAtop {
+      padding: 15px;
+      font-weight: 700;
+      font-size: 18px;
+      display: flex;
+      justify-content: space-between;
+    }
+    .ant-table-cell {
+      padding: 8px !important;
+    }
+  }
+}

+ 147 - 0
src/pages/Zother/FileArchive/index.tsx

@@ -0,0 +1,147 @@
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import styles from './index.module.scss'
+import { useInfo } from '../InfoContext'
+import { Button } from 'antd'
+import MyTable from '@/components/MyTable'
+import { baseURL } from '@/utils/http'
+import { FileListType } from '@/components/Z3upFiles/data'
+import MyPopconfirm from '@/components/MyPopconfirm'
+import { getTokenInfo } from '@/utils/storage'
+import { API_delFiles } from '@/store/action/Cledger/C4file'
+import { MessageFu } from '@/utils/message'
+import { API_upFile } from '@/store/action/layout'
+import { fileDomInitialFu } from '@/utils/domShow'
+
+const userInfo = getTokenInfo().user || {}
+
+type Props = {
+  dirCode?: string //文件的code码
+  myUrl?: string //请求地址
+  fromData?: any
+}
+
+// 附件归档-待完善sg
+function FileArchive({ dirCode = '', myUrl = '', fromData }: Props) {
+  const { info } = useInfo()
+
+  const [list, setList] = useState<FileListType[]>([])
+
+  useEffect(() => {
+    setList(info.filing || [])
+  }, [info.filing])
+
+  // 点击上传附件按钮
+  const myInput = useRef<HTMLInputElement>(null)
+
+  // 上传附件的处理函数
+  const handeUpPhoto = useCallback(
+    async (e: React.ChangeEvent<HTMLInputElement>) => {
+      if (e.target.files) {
+        // 拿到files信息
+        const filesInfo = e.target.files[0]
+
+        // 校验大小
+        // if (filesInfo.size > size * 1024 * 1024) {
+        //   e.target.value = ''
+        //   return MessageFu.warning(`最大支持${size}M!`)
+        // }
+        // 创建FormData对象
+        const fd = new FormData()
+        // 把files添加进FormData对象(‘photo’为后端需要的字段)
+        fd.append('dirCode', dirCode)
+        fd.append('isDb', 'true')
+        fd.append('type', 'doc')
+        fd.append('binding', '1')
+        fd.append('file', filesInfo)
+
+        if (fromData) {
+          for (const k in fromData) {
+            if (fromData[k]) fd.append(k, fromData[k])
+          }
+        }
+
+        // 开启压缩图片
+        fd.append('isCompress', 'true')
+
+        e.target.value = ''
+
+        const res = await API_upFile(fd, myUrl)
+
+        try {
+          if (res.code === 0) {
+            MessageFu.success('上传成功!')
+            setList([...list, res.data])
+          }
+          fileDomInitialFu()
+        } catch (error) {
+          fileDomInitialFu()
+        }
+      }
+    },
+    [dirCode, fromData, list, myUrl]
+  )
+
+  // 点击删除
+  const delFu = useCallback(
+    async (data: number[]) => {
+      const res = await API_delFiles(data)
+      if (res.code === 0) {
+        MessageFu.success('删除成功')
+        setList(list.filter(v => v.id !== data[0]))
+      }
+    },
+    [list]
+  )
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: '操作',
+        render: (item: FileListType) => (
+          <>
+            <Button size='small' type='text'>
+              <a href={baseURL + item.filePath} download target='_blank' rel='noreferrer'>
+                下载
+              </a>
+            </Button>
+            {userInfo.id === info.creatorId ? (
+              <MyPopconfirm txtK='删除' onConfirm={() => delFu([item.id])} />
+            ) : null}
+          </>
+        )
+      }
+    ]
+  }, [delFu, info.creatorId])
+
+  return info.status === 4 ? (
+    <div className={styles.FileArchive}>
+      <input id='upInput' type='file' accept='*' ref={myInput} onChange={e => handeUpPhoto(e)} />
+      <div className='FAtop'>
+        <div>归档附件</div>
+        {userInfo.id === info.creatorId ? (
+          <Button type='primary' onClick={() => myInput.current?.click()}>
+            上传归档
+          </Button>
+        ) : (
+          <div></div>
+        )}
+      </div>
+
+      {/* 表格 */}
+      <MyTable
+        list={list}
+        columnsTemp={[
+          ['txt', '附件名称', 'fileName'],
+          ['txt', '归档人', 'creatorName'],
+          ['txt', '归档日期', 'createTime']
+        ]}
+        lastBtn={tableLastBtn}
+        pagingInfo={false}
+      />
+    </div>
+  ) : null
+}
+
+const MemoFileArchive = React.memo(FileArchive)
+
+export default MemoFileArchive

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

@@ -182,6 +182,9 @@ export type Typetable = {
 
   // 库房列表
   name: string
+
+  // 附件归档
+  filing: FileListType[]
 }
 
 // 上传的附近路径和文件夹名字

+ 7 - 0
src/store/action/Cledger/C4file.ts

@@ -38,3 +38,10 @@ export const API_getFileLog = (fileId: number) => {
 export const API_downloadFiles = (ids: number[]) => {
   return http.post('cms/good/file/downloadBatchZip', ids)
 }
+
+/**
+ * 藏品附件 -真删除附件
+ */
+export const API_delFiles = (ids: number[]) => {
+  return http.post('cms/file/removes', ids)
+}