|
@@ -7,33 +7,49 @@ import { MessageFu } from '@/utils/message'
|
|
|
import { E2_APIgetInfo, E2_APIsave } from '@/store/action/Eculture/E2story'
|
|
import { E2_APIgetInfo, E2_APIsave } from '@/store/action/Eculture/E2story'
|
|
|
import TextArea from 'antd/es/input/TextArea'
|
|
import TextArea from 'antd/es/input/TextArea'
|
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
-import { storyAndGoodsTableC } from '@/utils/tableData'
|
|
|
|
|
|
|
+import { storyAndGoodsTableC, goodsSonTableC } from '@/utils/tableData'
|
|
|
import { Button, Input } from 'antd'
|
|
import { Button, Input } from 'antd'
|
|
|
import history, { backPageFu } from '@/utils/history'
|
|
import history, { backPageFu } from '@/utils/history'
|
|
|
import { useParams } from 'react-router-dom'
|
|
import { useParams } from 'react-router-dom'
|
|
|
|
|
+import { API_getFileListByIds } from '@/store/action/Cledger/C4file'
|
|
|
|
|
+import { API_getGoodsList } from '@/store/action/Cledger/C1ledger'
|
|
|
|
|
+import SelectGoods from '@/pages/Zother/SelectGoods'
|
|
|
|
|
+import { sgBaseFormDataGood, sgTopSelectDomGood } from '@/pages/Zother/SonGoodsList/data'
|
|
|
|
|
|
|
|
function E2edit() {
|
|
function E2edit() {
|
|
|
const [storyInfo, setStoryInfo] = useState({} as any)
|
|
const [storyInfo, setStoryInfo] = useState({} as any)
|
|
|
- // const [storyGoodsInfo, setStoryGoodsInfo] = useState([] as any[])
|
|
|
|
|
|
|
+ const [showSelectGoods, setShowSelectGoods] = useState(false)
|
|
|
const ZRichTextRef = useRef<any>(null)
|
|
const ZRichTextRef = useRef<any>(null)
|
|
|
const fileRef = useRef<any>(null)
|
|
const fileRef = useRef<any>(null)
|
|
|
const { key, id } = useParams<any>()
|
|
const { key, id } = useParams<any>()
|
|
|
const isEdit = useMemo(() => {
|
|
const isEdit = useMemo(() => {
|
|
|
- return ['4'].includes(key)
|
|
|
|
|
|
|
+ return ['2'].includes(key)
|
|
|
}, [key])
|
|
}, [key])
|
|
|
|
|
|
|
|
- // 获取详情
|
|
|
|
|
- const getInfoFu = useCallback(async (id: number) => {
|
|
|
|
|
- const res = await E2_APIgetInfo(id)
|
|
|
|
|
|
|
+ // 保存附件
|
|
|
|
|
+ const getFileListByIdsFu = useCallback(async (ids: string[]) => {
|
|
|
|
|
+ const res = await API_getFileListByIds(ids)
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
- // 设置数据和富文本和附件
|
|
|
|
|
- setStoryInfo(res.data)
|
|
|
|
|
- ZRichTextRef.current?.ritxtShowFu(res.data.rtf || '')
|
|
|
|
|
- fileRef.current?.sonSetListFu(res.data.file)
|
|
|
|
|
- console.log(res.data)
|
|
|
|
|
|
|
+ // 设置附件
|
|
|
|
|
+ fileRef.current?.sonSetListFu(res.data)
|
|
|
}
|
|
}
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
+ // 获取详情
|
|
|
|
|
+ const getInfoFu = useCallback(
|
|
|
|
|
+ async (id: number) => {
|
|
|
|
|
+ const res = await E2_APIgetInfo(id)
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ // 设置数据和富文本和附件
|
|
|
|
|
+ setStoryInfo(res.data)
|
|
|
|
|
+ ZRichTextRef.current?.ritxtShowFu(res.data.rtf || '')
|
|
|
|
|
+ getFileListByIdsFu(res.data.fileIds.split(',') || [])
|
|
|
|
|
+ console.log(res.data)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ [getFileListByIdsFu]
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
// 保存或修改
|
|
// 保存或修改
|
|
|
const saveFu = useCallback(async () => {
|
|
const saveFu = useCallback(async () => {
|
|
|
if (!storyInfo.name) return MessageFu.warning('请输入故事标题')
|
|
if (!storyInfo.name) return MessageFu.warning('请输入故事标题')
|
|
@@ -46,6 +62,7 @@ function E2edit() {
|
|
|
const obj: any = {
|
|
const obj: any = {
|
|
|
name: storyInfo.name,
|
|
name: storyInfo.name,
|
|
|
remark: storyInfo.remark,
|
|
remark: storyInfo.remark,
|
|
|
|
|
+ goodIds: storyInfo.goods.map((v: any) => v.id).join(','),
|
|
|
id: storyInfo.id > 0 ? storyInfo.id : null,
|
|
id: storyInfo.id > 0 ? storyInfo.id : null,
|
|
|
fileIds: flieList.map((v: any) => v.id).join(','),
|
|
fileIds: flieList.map((v: any) => v.id).join(','),
|
|
|
rtf: rtf.val
|
|
rtf: rtf.val
|
|
@@ -80,15 +97,23 @@ function E2edit() {
|
|
|
title: '操作',
|
|
title: '操作',
|
|
|
render: (item: any) => (
|
|
render: (item: any) => (
|
|
|
<>
|
|
<>
|
|
|
- <Button size='small' type='text' onClick={() => tableBtnFu(item.id, '4')}>
|
|
|
|
|
|
|
+ <Button size='small' type='text' onClick={() => console.log('查看藏品')}>
|
|
|
查看
|
|
查看
|
|
|
</Button>
|
|
</Button>
|
|
|
- <MyPopconfirm txtK='删除' onConfirm={() => tableBtnFu(item.id, '2')} />
|
|
|
|
|
|
|
+ <MyPopconfirm
|
|
|
|
|
+ txtK='删除'
|
|
|
|
|
+ onConfirm={() =>
|
|
|
|
|
+ setStoryInfo({
|
|
|
|
|
+ ...storyInfo,
|
|
|
|
|
+ goods: storyInfo.goods.filter((v: any) => v.id !== item.id)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ />
|
|
|
</>
|
|
</>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
- }, [tableBtnFu])
|
|
|
|
|
|
|
+ }, [storyInfo])
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.D1edit} id='editBox'>
|
|
<div className={styles.D1edit} id='editBox'>
|
|
|
<div className='editMain'>
|
|
<div className='editMain'>
|
|
@@ -117,7 +142,7 @@ function E2edit() {
|
|
|
<div className='Edtop1row Edtop1rowFull'>
|
|
<div className='Edtop1row Edtop1rowFull'>
|
|
|
<div className='Edtop1ll'>关联产品 :</div>
|
|
<div className='Edtop1ll'>关联产品 :</div>
|
|
|
<div className='Edtop1rr'>
|
|
<div className='Edtop1rr'>
|
|
|
- <Button type='primary' onClick={() => console.log('添加藏品')}>
|
|
|
|
|
|
|
+ <Button type='primary' onClick={() => setShowSelectGoods(true)}>
|
|
|
添加藏品
|
|
添加藏品
|
|
|
</Button>
|
|
</Button>
|
|
|
<MyTable
|
|
<MyTable
|
|
@@ -129,11 +154,24 @@ function E2edit() {
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ {/* 添加藏品 */}
|
|
|
|
|
+ {showSelectGoods && (
|
|
|
|
|
+ <SelectGoods
|
|
|
|
|
+ myType='藏品'
|
|
|
|
|
+ API_getList={API_getGoodsList}
|
|
|
|
|
+ closeFu={() => setShowSelectGoods(false)}
|
|
|
|
|
+ baseFormData={sgBaseFormDataGood}
|
|
|
|
|
+ topSelectDom={sgTopSelectDomGood}
|
|
|
|
|
+ columnsTemp={goodsSonTableC(true)}
|
|
|
|
|
+ oldCheckArr={storyInfo.goods || []}
|
|
|
|
|
+ dataResFu={res => setStoryInfo({ ...storyInfo, goods: res || [] })}
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
<div className='Edtop1row Edtop1rowFull'>
|
|
<div className='Edtop1row Edtop1rowFull'>
|
|
|
<div className='Edtop1ll'>故事正文 :</div>
|
|
<div className='Edtop1ll'>故事正文 :</div>
|
|
|
<div className='Edtop1rr'>
|
|
<div className='Edtop1rr'>
|
|
|
<ZRichTextOne
|
|
<ZRichTextOne
|
|
|
- moduleId={1}
|
|
|
|
|
|
|
+ moduleId={id !== 'null' ? Number(id) : 0}
|
|
|
dirCode='guShiText'
|
|
dirCode='guShiText'
|
|
|
check={false}
|
|
check={false}
|
|
|
myUrl='cms/story/upload'
|
|
myUrl='cms/story/upload'
|
|
@@ -159,8 +197,8 @@ function E2edit() {
|
|
|
<div className='Edtop1ll'>上传附件 :</div>
|
|
<div className='Edtop1ll'>上传附件 :</div>
|
|
|
<div className='Edtop1rr'>
|
|
<div className='Edtop1rr'>
|
|
|
<Z3upFilesRef
|
|
<Z3upFilesRef
|
|
|
|
|
+ moduleId={id !== 'null' ? Number(id) : 0}
|
|
|
ref={fileRef}
|
|
ref={fileRef}
|
|
|
- moduleId={1}
|
|
|
|
|
dirCode='guShiTextFile'
|
|
dirCode='guShiTextFile'
|
|
|
myUrl='cms/story/upload'
|
|
myUrl='cms/story/upload'
|
|
|
/>
|
|
/>
|