|
@@ -16,11 +16,12 @@ import { GoodFileType } from './type'
|
|
|
import { baseURL } from '@/utils/http'
|
|
|
import { fileImgArr, fileVideoArr } from '@/store/action/layout'
|
|
|
import { API_C2dels } from '@/store/action/C2files'
|
|
|
-import { API_goodsAdd, API_goodsInfo } from '@/store/action/C1ledger'
|
|
|
+import { API_goodsAdd, API_goodsInfo, API_setThumb } from '@/store/action/C1ledger'
|
|
|
import { C1GoodType } from '@/pages/A3_ledger/C1ledger/type'
|
|
|
import { MessageFu } from '@/utils/message'
|
|
|
import history, { cascaderObjFu } from '@/utils/history'
|
|
|
import ZGaddNow from '@/components/ZGaddNow'
|
|
|
+import ZupOne from '@/components/ZupOne'
|
|
|
|
|
|
// 级联的数据转换成字符串
|
|
|
export const cascaderChArr = [
|
|
@@ -78,7 +79,7 @@ function AddGoods({ nowSta, closeFu, succFu, isEdit, editSnap }: Props) {
|
|
|
// 编辑进来获取详情
|
|
|
const getInfo = useCallback(
|
|
|
async (id: number) => {
|
|
|
- const res = await API_goodsInfo(id, 17)
|
|
|
+ const res = await API_goodsInfo(id, 310)
|
|
|
if (res.code === 0) {
|
|
|
// 藏品编辑信息保存
|
|
|
objOld.current = { ...res.data }
|
|
@@ -131,7 +132,7 @@ function AddGoods({ nowSta, closeFu, succFu, isEdit, editSnap }: Props) {
|
|
|
const [ageAc, setAgeAc] = useState(false)
|
|
|
|
|
|
// 封面图的ref
|
|
|
- // const ZupThumbRef = useRef<any>(null)
|
|
|
+ const ZupThumbRef = useRef<any>(null)
|
|
|
|
|
|
// 富文本的ref
|
|
|
const ZRichTextRef = useRef<any>(null)
|
|
@@ -269,7 +270,7 @@ function AddGoods({ nowSta, closeFu, succFu, isEdit, editSnap }: Props) {
|
|
|
const onFinish = useCallback(
|
|
|
async (values: any) => {
|
|
|
// 封面图
|
|
|
- // const coverUrl1 = ZupThumbRef.current?.fileComFileResFu()
|
|
|
+ const coverUrl1 = ZupThumbRef.current?.fileComFileResFu()
|
|
|
|
|
|
// 富文本
|
|
|
const rtf = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
|
|
@@ -295,19 +296,19 @@ function AddGoods({ nowSta, closeFu, succFu, isEdit, editSnap }: Props) {
|
|
|
if (values.dateMaking) dateMaking = dayjs(values.dateMaking).format('YYYY-MM-DD')
|
|
|
|
|
|
// 默认以第一个附件为img的作为封面图
|
|
|
- const imgArr = table.filter(v => {
|
|
|
- const txtArr = v.fileName.split('.')
|
|
|
- const txt = txtArr[txtArr.length - 1]
|
|
|
- return v.type === 'img' && fileImgArr.includes(txt.toLowerCase())
|
|
|
- })
|
|
|
-
|
|
|
- let thumb = ''
|
|
|
- let thumbPc = ''
|
|
|
-
|
|
|
- if (imgArr && imgArr.length) {
|
|
|
- thumb = imgArr[0].thumb
|
|
|
- thumbPc = imgArr[0].filePath
|
|
|
- }
|
|
|
+ // const imgArr = table.filter(v => {
|
|
|
+ // const txtArr = v.fileName.split('.')
|
|
|
+ // const txt = txtArr[txtArr.length - 1]
|
|
|
+ // return v.type === 'img' && fileImgArr.includes(txt.toLowerCase())
|
|
|
+ // })
|
|
|
+
|
|
|
+ // let thumb = ''
|
|
|
+ // let thumbPc = ''
|
|
|
+
|
|
|
+ // if (imgArr && imgArr.length) {
|
|
|
+ // thumb = imgArr[0].thumb
|
|
|
+ // thumbPc = imgArr[0].filePath
|
|
|
+ // }
|
|
|
|
|
|
let idRes = nowSta.id === 'null' ? null : Number(nowSta.id)
|
|
|
|
|
@@ -315,8 +316,6 @@ function AddGoods({ nowSta, closeFu, succFu, isEdit, editSnap }: Props) {
|
|
|
|
|
|
const obj = {
|
|
|
...values,
|
|
|
- thumb,
|
|
|
- thumbPc,
|
|
|
rtf: JSON.stringify(rtf.val || ''),
|
|
|
fileIds,
|
|
|
fileSet,
|
|
@@ -358,6 +357,19 @@ function AddGoods({ nowSta, closeFu, succFu, isEdit, editSnap }: Props) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (objOld.current.thumb !== coverUrl1.thumb) {
|
|
|
+ // 只修改封面图
|
|
|
+ coverUrl1 &&
|
|
|
+ (await API_setThumb({
|
|
|
+ id: objOld.current.id,
|
|
|
+ thumb: coverUrl1.thumb,
|
|
|
+ thumbPc: coverUrl1.thumb
|
|
|
+ }))
|
|
|
+ MessageFu.success(`${staTxt.current}成功`)
|
|
|
+ closeFu()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if (flag) return MessageFu.warning('未修改藏品信息')
|
|
|
|
|
|
// -----------藏品编辑模块进来---------------
|
|
@@ -380,6 +392,12 @@ function AddGoods({ nowSta, closeFu, succFu, isEdit, editSnap }: Props) {
|
|
|
|
|
|
const res = await API_goodsAdd(obj, idRes ? '编辑' : '新增')
|
|
|
if (res.code === 0) {
|
|
|
+ coverUrl1 &&
|
|
|
+ (await API_setThumb({
|
|
|
+ id: res.data.id,
|
|
|
+ thumb: coverUrl1.thumb,
|
|
|
+ thumbPc: coverUrl1.thumb
|
|
|
+ }))
|
|
|
MessageFu.success(nowSta.id === 'null' ? `${staTxt.current}成功` : '编辑成功')
|
|
|
succFu(res.data, nowSta.id === 'null' ? '新增' : '编辑', staTxt.current as '提交')
|
|
|
closeFu()
|
|
@@ -658,26 +676,6 @@ function AddGoods({ nowSta, closeFu, succFu, isEdit, editSnap }: Props) {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- {/* 封面 */}
|
|
|
- {/* <div className='formRow'>
|
|
|
- <div className='formLeft'>封面图:</div>
|
|
|
- <div className='formRight'>
|
|
|
- <ZupOne
|
|
|
- ref={ZupThumbRef}
|
|
|
- isLook={false}
|
|
|
- fileCheck={false}
|
|
|
- size={5}
|
|
|
- dirCode='goodsAdd'
|
|
|
- myUrl='cms/goods/upload'
|
|
|
- format={['image/jpeg', 'image/png']}
|
|
|
- formatTxt='png、jpg和jpeg'
|
|
|
- checkTxt='请上传封面图!'
|
|
|
- upTxt='最多1张'
|
|
|
- myType='thumb'
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div> */}
|
|
|
-
|
|
|
<div className='B3Nrow'>
|
|
|
<Form.Item label='完残情况' name='torn'>
|
|
|
<TextArea maxLength={500} showCount placeholder='请输入内容' />
|
|
@@ -953,8 +951,24 @@ function AddGoods({ nowSta, closeFu, succFu, isEdit, editSnap }: Props) {
|
|
|
<div className='B3Nbox B3Nbox1' hidden={tabTxt !== '附件信息'}>
|
|
|
<div className='B3Ntit'>
|
|
|
<div className='B3Ntitll'>
|
|
|
- <span>附件类型为图像并且格式为图片的第一份数据为封面图</span>
|
|
|
+ {/* 封面 */}
|
|
|
+ <div className='B3NtitLeft'>封面图:</div>
|
|
|
+ <div className='B3NtitRight'>
|
|
|
+ <ZupOne
|
|
|
+ ref={ZupThumbRef}
|
|
|
+ isLook={false}
|
|
|
+ fileCheck={false}
|
|
|
+ dirCode='goodsAdd'
|
|
|
+ myUrl='cms/goods/upload'
|
|
|
+ format={['image/jpeg', 'image/png']}
|
|
|
+ formatTxt='png、jpg和jpeg'
|
|
|
+ checkTxt='请上传封面图!'
|
|
|
+ upTxt='最多1张'
|
|
|
+ myType='thumb'
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+
|
|
|
<Z3upFiles
|
|
|
max={10000}
|
|
|
isLook={false}
|