|
@@ -14,13 +14,17 @@ import { MessageFu } from '@/utils/message'
|
|
|
import { useSelector } from 'react-redux'
|
|
|
import { RootState } from '@/store'
|
|
|
import { GoodFileType } from '@/components/Z3upFiles'
|
|
|
+import { C1GoodType } from '@/pages/A3_ledger/C1ledger/type'
|
|
|
+import { API_setGoodsCover } from '@/store/action/C1ledger'
|
|
|
|
|
|
type Props = {
|
|
|
isLook?: boolean
|
|
|
sId: number
|
|
|
+ info: C1GoodType
|
|
|
+ setImgCover?: () => void
|
|
|
}
|
|
|
|
|
|
-function Y33com({ isLook, sId }: Props) {
|
|
|
+function Y33com({ isLook, sId, info, setImgCover }: Props) {
|
|
|
const [fileList, setFileList] = useState<GoodFileType[]>([])
|
|
|
|
|
|
const getListFu = useCallback(async () => {
|
|
@@ -118,62 +122,105 @@ function Y33com({ isLook, sId }: Props) {
|
|
|
// 获取下载权限
|
|
|
const downImg = useSelector((state: RootState) => state.A0Layout.downImg)
|
|
|
|
|
|
+ // 设置封面图
|
|
|
+ const setCoverFu = useCallback(
|
|
|
+ async (thumb: string, thumbPc: string) => {
|
|
|
+ const res = await API_setGoodsCover({
|
|
|
+ id: info.id,
|
|
|
+ thumb,
|
|
|
+ thumbPc
|
|
|
+ })
|
|
|
+ if (res.code === 0) {
|
|
|
+ MessageFu.success('设置成功')
|
|
|
+ setImgCover && setImgCover()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [info.id, setImgCover]
|
|
|
+ )
|
|
|
+
|
|
|
const tableLastBtn = useMemo(() => {
|
|
|
- return [
|
|
|
- {
|
|
|
- title: '操作',
|
|
|
+ let arr: any[] = []
|
|
|
+
|
|
|
+ if (isLook)
|
|
|
+ arr.push({
|
|
|
+ title: '封面图设置',
|
|
|
render: (item: GoodFileType) => {
|
|
|
const fileNameArr = item.fileName.split('.')
|
|
|
const fileNameLast = fileNameArr[fileNameArr.length - 1]
|
|
|
- return (
|
|
|
- <>
|
|
|
- {downImg['图片'] === '原图和缩略图' &&
|
|
|
- fileImgArr.includes(fileNameLast.toLowerCase()) ? (
|
|
|
- <Popconfirm
|
|
|
- title='请选择图片规格'
|
|
|
- onConfirm={() => downFileFu(item.filePath)}
|
|
|
- onCancel={() => downFileFu(item.thumb)}
|
|
|
- okText='原图'
|
|
|
- cancelText='缩略图'
|
|
|
- >
|
|
|
- <Button size='small' type='text'>
|
|
|
- 下载
|
|
|
- </Button>
|
|
|
- </Popconfirm>
|
|
|
- ) : (
|
|
|
+
|
|
|
+ return fileImgArr.includes(fileNameLast.toLowerCase()) ? (
|
|
|
+ item.thumb === info.thumb ? (
|
|
|
+ '封面'
|
|
|
+ ) : (
|
|
|
+ <Button
|
|
|
+ size='small'
|
|
|
+ type='text'
|
|
|
+ onClick={() => setCoverFu(item.thumb, item.filePath)}
|
|
|
+ >
|
|
|
+ 设为封面
|
|
|
+ </Button>
|
|
|
+ )
|
|
|
+ ) : (
|
|
|
+ ' - '
|
|
|
+ )
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ arr.push({
|
|
|
+ title: '操作',
|
|
|
+ render: (item: GoodFileType) => {
|
|
|
+ const fileNameArr = item.fileName.split('.')
|
|
|
+ const fileNameLast = fileNameArr[fileNameArr.length - 1]
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ {downImg['图片'] === '原图和缩略图' &&
|
|
|
+ fileImgArr.includes(fileNameLast.toLowerCase()) ? (
|
|
|
+ <Popconfirm
|
|
|
+ title='请选择图片规格'
|
|
|
+ onConfirm={() => downFileFu(item.filePath)}
|
|
|
+ onCancel={() => downFileFu(item.thumb)}
|
|
|
+ okText='原图'
|
|
|
+ cancelText='缩略图'
|
|
|
+ >
|
|
|
+ <Button size='small' type='text'>
|
|
|
+ 下载
|
|
|
+ </Button>
|
|
|
+ </Popconfirm>
|
|
|
+ ) : (
|
|
|
+ <Button
|
|
|
+ size='small'
|
|
|
+ type='text'
|
|
|
+ onClick={() => downFileFu(item.thumb || item.filePath)}
|
|
|
+ >
|
|
|
+ 下载
|
|
|
+ </Button>
|
|
|
+ )}
|
|
|
+ {isLook ? (
|
|
|
+ <>
|
|
|
<Button
|
|
|
size='small'
|
|
|
type='text'
|
|
|
- onClick={() => downFileFu(item.thumb || item.filePath)}
|
|
|
+ onClick={() =>
|
|
|
+ setTypeMo({
|
|
|
+ ids: [item.id],
|
|
|
+ type: item.type,
|
|
|
+ effect: item.effect,
|
|
|
+ flag: '单个'
|
|
|
+ })
|
|
|
+ }
|
|
|
>
|
|
|
- 下载
|
|
|
+ 设置
|
|
|
</Button>
|
|
|
- )}
|
|
|
- {isLook ? (
|
|
|
- <>
|
|
|
- <Button
|
|
|
- size='small'
|
|
|
- type='text'
|
|
|
- onClick={() =>
|
|
|
- setTypeMo({
|
|
|
- ids: [item.id],
|
|
|
- type: item.type,
|
|
|
- effect: item.effect,
|
|
|
- flag: '单个'
|
|
|
- })
|
|
|
- }
|
|
|
- >
|
|
|
- 设置
|
|
|
- </Button>
|
|
|
- <MyPopconfirm txtK='删除' onConfirm={() => delFu([item.id])} />
|
|
|
- </>
|
|
|
- ) : null}
|
|
|
- </>
|
|
|
- )
|
|
|
- }
|
|
|
+ <MyPopconfirm txtK='删除' onConfirm={() => delFu([item.id])} />
|
|
|
+ </>
|
|
|
+ ) : null}
|
|
|
+ </>
|
|
|
+ )
|
|
|
}
|
|
|
- ]
|
|
|
- }, [delFu, downImg, isLook])
|
|
|
+ })
|
|
|
+
|
|
|
+ return arr
|
|
|
+ }, [delFu, downImg, info.thumb, isLook, setCoverFu])
|
|
|
|
|
|
const [typeMo, setTypeMo] = useState({} as infoType)
|
|
|
|