|
@@ -1,17 +1,50 @@
|
|
|
-import React, { useCallback, useMemo, useRef } from 'react'
|
|
|
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
import { Button } from 'antd'
|
|
|
import { MessageFu } from '@/utils/message'
|
|
|
import { fileDomInitialFu } from '@/utils/domShow'
|
|
|
import { API_upFile } from '@/store/action/layout'
|
|
|
import MyTable from '@/components/MyTable'
|
|
|
-import { C4tableCImg } from '@/utils/tableData'
|
|
|
+import { C4zipResDtaFu, C4zipType } from '../data'
|
|
|
+import C4imgModal from '../C4imgModal'
|
|
|
+import { C4tableCFu } from '@/utils/tableData'
|
|
|
+import { A3m_APIdel, A3m_APIgetList, A3m_APIlookInfo } from '@/store/action/A3machineReg'
|
|
|
+import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
|
|
|
type Props = {
|
|
|
hidden: boolean
|
|
|
}
|
|
|
|
|
|
function C4impImg({ hidden }: Props) {
|
|
|
+ const [formData, setFormData] = useState({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10
|
|
|
+ })
|
|
|
+
|
|
|
+ // 列表数据
|
|
|
+ const [tableObj, setTableObj] = useState({
|
|
|
+ list: [],
|
|
|
+ total: 0
|
|
|
+ })
|
|
|
+
|
|
|
+ // 获取列表信息
|
|
|
+ const getListFu = useCallback(async () => {
|
|
|
+ const res = await A3m_APIgetList({
|
|
|
+ ...formData,
|
|
|
+ type: '3'
|
|
|
+ })
|
|
|
+ if (res.code === 0) {
|
|
|
+ setTableObj({
|
|
|
+ list: res.data.records || [],
|
|
|
+ total: res.data.total
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, [formData])
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ getListFu()
|
|
|
+ }, [getListFu])
|
|
|
+
|
|
|
// 上传表格数据
|
|
|
const upBiaoGeRef = useRef<HTMLInputElement>(null)
|
|
|
|
|
@@ -35,7 +68,7 @@ function C4impImg({ hidden }: Props) {
|
|
|
|
|
|
fd.append('file', filesInfo)
|
|
|
fd.append('type', 'doc')
|
|
|
- fd.append('dirCode', 'C4machineRegImg')
|
|
|
+ // fd.append('dirCode', 'C4machineRegImg')
|
|
|
fd.append('isDb', 'true')
|
|
|
|
|
|
// 开启压缩图片
|
|
@@ -48,8 +81,16 @@ function C4impImg({ hidden }: Props) {
|
|
|
|
|
|
if (res.code === 0) {
|
|
|
MessageFu.success('上传成功!')
|
|
|
- const arrAll: any[] = res.data || []
|
|
|
- console.log('-------', res)
|
|
|
+ const { succArr, errArr } = C4zipResDtaFu(res.data.img || [])
|
|
|
+ setZipList({
|
|
|
+ type: '上传',
|
|
|
+ succ: succArr,
|
|
|
+ err: errArr,
|
|
|
+ file: {
|
|
|
+ fileName: res.data.fileName,
|
|
|
+ filePath: res.data.filePath
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
fileDomInitialFu()
|
|
|
} catch (error) {
|
|
@@ -60,12 +101,35 @@ function C4impImg({ hidden }: Props) {
|
|
|
}
|
|
|
}, [])
|
|
|
|
|
|
+ const lookFu = useCallback(async (id: number) => {
|
|
|
+ const res = await A3m_APIlookInfo('3', id)
|
|
|
+ if (res.code === 0) {
|
|
|
+ const { succArr, errArr } = C4zipResDtaFu(res.data || [], true)
|
|
|
+ setZipList({
|
|
|
+ type: '查看',
|
|
|
+ succ: succArr,
|
|
|
+ err: errArr
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ const delFu = useCallback(
|
|
|
+ async (id: number) => {
|
|
|
+ const res = await A3m_APIdel(id)
|
|
|
+ if (res.code === 0) {
|
|
|
+ MessageFu.success('删除成功')
|
|
|
+ getListFu()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [getListFu]
|
|
|
+ )
|
|
|
+
|
|
|
const tableLastBtn = useMemo(() => {
|
|
|
return [
|
|
|
{
|
|
|
title: '导入结果',
|
|
|
render: (item: any) => (
|
|
|
- <Button size='small' type='text'>
|
|
|
+ <Button size='small' type='text' onClick={() => lookFu(item.id)}>
|
|
|
查看
|
|
|
</Button>
|
|
|
)
|
|
@@ -74,13 +138,31 @@ function C4impImg({ hidden }: Props) {
|
|
|
title: '操作',
|
|
|
render: (item: any) => {
|
|
|
return (
|
|
|
- <Button size='small' type='text' danger>
|
|
|
- 删除记录
|
|
|
- </Button>
|
|
|
+ <MyPopconfirm
|
|
|
+ txtK='删除'
|
|
|
+ onConfirm={() => delFu(item.id)}
|
|
|
+ Dom={
|
|
|
+ <Button size='small' type='text' danger>
|
|
|
+ 删除记录
|
|
|
+ </Button>
|
|
|
+ }
|
|
|
+ />
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
+ }, [delFu, lookFu])
|
|
|
+
|
|
|
+ // zip上传成功
|
|
|
+ const [zipList, setZipList] = useState<C4zipType>({
|
|
|
+ type: '',
|
|
|
+ succ: [],
|
|
|
+ err: []
|
|
|
+ })
|
|
|
+
|
|
|
+ // 页码变化
|
|
|
+ const paginationChange = useCallback((pageNum: number, pageSize: number) => {
|
|
|
+ setFormData({ pageNum, pageSize })
|
|
|
}, [])
|
|
|
|
|
|
return (
|
|
@@ -108,12 +190,30 @@ function C4impImg({ hidden }: Props) {
|
|
|
|
|
|
<MyTable
|
|
|
classKey='C4impImg'
|
|
|
- yHeight={638}
|
|
|
- list={[]}
|
|
|
- columnsTemp={C4tableCImg}
|
|
|
+ yHeight={590}
|
|
|
+ list={tableObj.list}
|
|
|
+ columnsTemp={C4tableCFu('')}
|
|
|
lastBtn={tableLastBtn}
|
|
|
- pagingInfo={false}
|
|
|
+ pageNum={formData.pageNum}
|
|
|
+ pageSize={formData.pageSize}
|
|
|
+ total={tableObj.total}
|
|
|
+ onChange={(pageNum, pageSize) => paginationChange(pageNum, pageSize)}
|
|
|
/>
|
|
|
+
|
|
|
+ {zipList.type ? (
|
|
|
+ <C4imgModal
|
|
|
+ succFu={getListFu}
|
|
|
+ againUpFu={() => upBiaoGeRef.current?.click()}
|
|
|
+ info={zipList}
|
|
|
+ closeFu={() =>
|
|
|
+ setZipList({
|
|
|
+ type: '',
|
|
|
+ succ: [],
|
|
|
+ err: []
|
|
|
+ })
|
|
|
+ }
|
|
|
+ />
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
)
|
|
|
}
|