|
@@ -0,0 +1,131 @@
|
|
|
|
+import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
|
|
+import styles from './index.module.scss'
|
|
|
|
+import { Button, Modal, Radio } from 'antd'
|
|
|
|
+import ZupOne from '@/components/ZupOne'
|
|
|
|
+import { A3_APIS_getInfo, A3_APIS_save } from '@/store/action/A3relation'
|
|
|
|
+import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
|
+import { MessageFu } from '@/utils/message'
|
|
|
|
+
|
|
|
|
+type Props = {
|
|
|
|
+ closeFu: () => void
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function A3show({ closeFu }: Props) {
|
|
|
|
+ // 封面图的ref
|
|
|
|
+ const ZupThumbRef = useRef<any>(null)
|
|
|
|
+
|
|
|
|
+ const infoRef = useRef({})
|
|
|
|
+
|
|
|
|
+ // 进来获取详情
|
|
|
|
+ const getInfoFu = useCallback(async () => {
|
|
|
|
+ const res = await A3_APIS_getInfo()
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ const info = res.data || {}
|
|
|
|
+ infoRef.current = info
|
|
|
|
+ setValue(res.data.typeSon || '1')
|
|
|
|
+
|
|
|
|
+ // 设置封面图
|
|
|
|
+ ZupThumbRef.current?.setFileComFileFu({
|
|
|
|
+ fileName: '',
|
|
|
|
+ filePath: info.thumbPc || info.thumb,
|
|
|
|
+ thumb: info.thumb
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }, [])
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ getInfoFu()
|
|
|
|
+ }, [getInfoFu])
|
|
|
|
+
|
|
|
|
+ const [value, setValue] = useState('0')
|
|
|
|
+
|
|
|
|
+ // 图片是否为必填
|
|
|
|
+ const [imgFlag, setImgFlag] = useState(false)
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ setImgFlag(value === '1')
|
|
|
|
+ }, [value])
|
|
|
|
+
|
|
|
|
+ // 点击确定
|
|
|
|
+ const btnOk = useCallback(async () => {
|
|
|
|
+ const coverUrl1 = ZupThumbRef.current?.fileComFileResFu()
|
|
|
|
+ // 没有传 图片
|
|
|
|
+ if (!coverUrl1.filePath && imgFlag) return MessageFu.warning('请上传图片')
|
|
|
|
+
|
|
|
|
+ const obj = {
|
|
|
|
+ ...infoRef.current,
|
|
|
|
+ typeSon: value,
|
|
|
|
+ thumb: coverUrl1.filePath || ''
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const res = await A3_APIS_save(obj)
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ MessageFu.success('设置成功')
|
|
|
|
+ closeFu()
|
|
|
|
+ }
|
|
|
|
+ }, [closeFu, imgFlag, value])
|
|
|
|
+
|
|
|
|
+ return (
|
|
|
|
+ <Modal
|
|
|
|
+ wrapClassName={styles.A3show}
|
|
|
|
+ open={true}
|
|
|
|
+ title='用户端展示设置'
|
|
|
|
+ footer={
|
|
|
|
+ [] // 设置footer为空,去掉 取消 确定默认按钮
|
|
|
|
+ }
|
|
|
|
+ >
|
|
|
|
+ <div className='A3aMain'>
|
|
|
|
+ <div className='formRow'>
|
|
|
|
+ <div className='formLeft'>
|
|
|
|
+ <span>* </span>
|
|
|
|
+ 展示类型:
|
|
|
|
+ </div>
|
|
|
|
+ <div className='formRight'>
|
|
|
|
+ <Radio.Group
|
|
|
|
+ value={value}
|
|
|
|
+ onChange={e => setValue(e.target.value)}
|
|
|
|
+ options={[
|
|
|
|
+ { value: '1', label: '图片' },
|
|
|
|
+ { value: '2', label: '动态关系图' }
|
|
|
|
+ ]}
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ {/* 图片 */}
|
|
|
|
+ <div className='formRow'>
|
|
|
|
+ <div className='formLeft'>
|
|
|
|
+ <span hidden={!imgFlag}>* </span>
|
|
|
|
+ 图片:
|
|
|
|
+ </div>
|
|
|
|
+ <div className='formRight'>
|
|
|
|
+ <ZupOne
|
|
|
|
+ ref={ZupThumbRef}
|
|
|
|
+ isLook={false}
|
|
|
|
+ fileCheck={imgFlag}
|
|
|
|
+ size={10}
|
|
|
|
+ dirCode='A3relationShow'
|
|
|
|
+ myUrl='cms/person/upload'
|
|
|
|
+ format={['image/jpeg', 'image/png']}
|
|
|
|
+ formatTxt='png、jpg和jpeg'
|
|
|
|
+ checkTxt='请上传头像'
|
|
|
|
+ upTxt='最多1张'
|
|
|
|
+ myType='thumb'
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div className='A3aBtn'>
|
|
|
|
+ <Button type='primary' onClick={btnOk}>
|
|
|
|
+ 提交
|
|
|
|
+ </Button>
|
|
|
|
+  
|
|
|
|
+ <MyPopconfirm txtK='取消' onConfirm={closeFu} />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </Modal>
|
|
|
|
+ )
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const MemoA3show = React.memo(A3show)
|
|
|
|
+
|
|
|
|
+export default MemoA3show
|