|
@@ -2,11 +2,11 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
import { Button, Form, FormInstance, Input, InputNumber, Select } from 'antd'
|
|
|
import { MessageFu } from '@/utils/message'
|
|
|
-import { A1_APIsave } from '@/store/action/A1works'
|
|
|
+import { A1_APIgetFileList, A1_APIsave } from '@/store/action/A1works'
|
|
|
import { A1SelectData, A1tableType } from '../data'
|
|
|
-import ZupOne from '@/components/ZupOne'
|
|
|
import TextArea from 'antd/es/input/TextArea'
|
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
+import ZupTypes from '@/components/ZupTypes'
|
|
|
|
|
|
type Props = {
|
|
|
info: A1tableType
|
|
@@ -20,19 +20,28 @@ function A1add({ type, closeFu, addTableFu, upTableFu, info }: Props) {
|
|
|
// 表单的ref
|
|
|
const FormBoxRef = useRef<FormInstance>(null)
|
|
|
|
|
|
- // 封面图的ref
|
|
|
- const ZupThumbRef = useRef<any>(null)
|
|
|
+ // 多张图片的ref
|
|
|
+ const ZupImgsRef = useRef<any>(null)
|
|
|
|
|
|
// 编辑进来获取详情
|
|
|
const getInfoFu = useCallback(
|
|
|
- (id: number) => {
|
|
|
+ async (id: number) => {
|
|
|
FormBoxRef.current?.setFieldsValue(info)
|
|
|
- // 设置封面图
|
|
|
- ZupThumbRef.current?.setFileComFileFu({
|
|
|
- fileName: '',
|
|
|
- filePath: info.thumbPc,
|
|
|
- thumb: info.thumb
|
|
|
- })
|
|
|
+
|
|
|
+ // 拿附件详情
|
|
|
+ // 设置图片
|
|
|
+ const res = await A1_APIgetFileList(info.id)
|
|
|
+
|
|
|
+ if (res.code === 0) {
|
|
|
+ const file = res.data.file || []
|
|
|
+
|
|
|
+ // 传给 附件 组件的
|
|
|
+ const sonInfo = {
|
|
|
+ type: 'img',
|
|
|
+ fileList: file
|
|
|
+ }
|
|
|
+ ZupImgsRef.current?.setFileComFileFu(sonInfo)
|
|
|
+ }
|
|
|
},
|
|
|
[info]
|
|
|
)
|
|
@@ -55,15 +64,16 @@ function A1add({ type, closeFu, addTableFu, upTableFu, info }: Props) {
|
|
|
async (values: any) => {
|
|
|
setFileCheck(true)
|
|
|
|
|
|
- const coverUrl1 = ZupThumbRef.current?.fileComFileResFu()
|
|
|
- // 没有传 封面图
|
|
|
- if (!coverUrl1.filePath) return MessageFu.warning('请上传作品图片')
|
|
|
+ // 没有传 图片
|
|
|
+ const { sonFileIds, sonIsOk, coverUrl, coverUrlBig } = ZupImgsRef.current?.fileComFileResFu()
|
|
|
+ if (sonIsOk) return MessageFu.warning('请上传作品图片')
|
|
|
|
|
|
const obj = {
|
|
|
...values,
|
|
|
id: info.id > 0 ? info.id : null,
|
|
|
- thumb: coverUrl1.thumb || '',
|
|
|
- thumbPc: coverUrl1.filePath || ''
|
|
|
+ thumb: coverUrl || '',
|
|
|
+ thumbPc: coverUrlBig || '',
|
|
|
+ fileIds: sonFileIds.join(',')
|
|
|
}
|
|
|
|
|
|
// if (1 + 1 === 2) {
|
|
@@ -121,24 +131,23 @@ function A1add({ type, closeFu, addTableFu, upTableFu, info }: Props) {
|
|
|
</Form.Item>
|
|
|
|
|
|
{/* 封面 */}
|
|
|
- <div className='formRow'>
|
|
|
+ <div className='formRow formRow2'>
|
|
|
<div className='formLeft'>
|
|
|
<span>* </span>
|
|
|
作品图片:
|
|
|
</div>
|
|
|
<div className='formRight'>
|
|
|
- <ZupOne
|
|
|
- ref={ZupThumbRef}
|
|
|
+ <ZupTypes
|
|
|
+ ref={ZupImgsRef}
|
|
|
isLook={false}
|
|
|
fileCheck={fileCheck}
|
|
|
- size={10}
|
|
|
+ selecFlag='图片'
|
|
|
+ imgSize={10}
|
|
|
+ imgLength={8}
|
|
|
dirCode={'A1works'}
|
|
|
myUrl='cms/work/upload'
|
|
|
- format={['image/jpeg', 'image/png']}
|
|
|
- formatTxt='png、jpg和jpeg'
|
|
|
- checkTxt='请上传作品图片'
|
|
|
- upTxt='最多1张'
|
|
|
- myType='thumb'
|
|
|
+ isTypeShow={true}
|
|
|
+ oneIsCover={true}
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|