|
|
@@ -1,10 +1,12 @@
|
|
|
-import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
|
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
import { Button, Input } from 'antd'
|
|
|
import { E2_APIgetList } from '@/store/action/Eculture/E2story'
|
|
|
-import { Typetable } from '@/pages/Zother/data'
|
|
|
import MyTable from '@/components/MyTable'
|
|
|
import { GI4tableC } from '@/utils/tableData'
|
|
|
+import { GuShiType } from '@/pages/Zother/GuShi/data'
|
|
|
+import GuShiMo from '@/pages/Zother/GuShi/GuShiMo'
|
|
|
+import history from '@/utils/history'
|
|
|
|
|
|
const baseFormData = {
|
|
|
searchKey: '',
|
|
|
@@ -17,7 +19,7 @@ type Props = {
|
|
|
}
|
|
|
|
|
|
function GItab4({ goodId }: Props) {
|
|
|
- const [tableObj, setTableObj] = useState<{ list: Typetable[]; total: number }>({
|
|
|
+ const [tableObj, setTableObj] = useState<{ list: GuShiType[]; total: number }>({
|
|
|
list: [],
|
|
|
total: 0
|
|
|
})
|
|
|
@@ -43,18 +45,20 @@ function GItab4({ goodId }: Props) {
|
|
|
|
|
|
// 封装发送请求的函数
|
|
|
const getListFu = useCallback(async () => {
|
|
|
- const params = {
|
|
|
- ...formDataRef.current,
|
|
|
- goodId
|
|
|
- }
|
|
|
+ if (goodId) {
|
|
|
+ const params = {
|
|
|
+ ...formDataRef.current,
|
|
|
+ goodId
|
|
|
+ }
|
|
|
|
|
|
- const res = await E2_APIgetList(params, true)
|
|
|
- if (res.code === 0) {
|
|
|
- const obj = {
|
|
|
- list: res.data.records || [],
|
|
|
- total: res.data.total
|
|
|
+ const res = await E2_APIgetList(params, true)
|
|
|
+ if (res.code === 0) {
|
|
|
+ const obj = {
|
|
|
+ list: res.data.records || [],
|
|
|
+ total: res.data.total
|
|
|
+ }
|
|
|
+ setTableObj(obj)
|
|
|
}
|
|
|
- setTableObj(obj)
|
|
|
}
|
|
|
}, [goodId])
|
|
|
|
|
|
@@ -91,6 +95,31 @@ function GItab4({ goodId }: Props) {
|
|
|
[formData]
|
|
|
)
|
|
|
|
|
|
+ const tableLastBtn = useMemo(() => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ render: (item: GuShiType) => (
|
|
|
+ <>
|
|
|
+ <Button size='small' type='text' onClick={() => setAddInfo(item)}>
|
|
|
+ 编辑
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ size='small'
|
|
|
+ type='text'
|
|
|
+ onClick={() => history.push(`/story_edit/4/${item.id}`)}
|
|
|
+ >
|
|
|
+ 查看
|
|
|
+ </Button>
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ // 打开弹窗
|
|
|
+ const [addInfo, setAddInfo] = useState({} as GuShiType)
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles.GItab4}>
|
|
|
<div className='GI4top'>
|
|
|
@@ -107,7 +136,9 @@ function GItab4({ goodId }: Props) {
|
|
|
</Button>
|
|
|
<Button onClick={resetSelectFu}>重置</Button>
|
|
|
</div>
|
|
|
- <Button type='primary'>新增故事</Button>
|
|
|
+ <Button type='primary' onClick={() => setAddInfo({ id: -1 } as GuShiType)}>
|
|
|
+ 新增故事
|
|
|
+ </Button>
|
|
|
</div>
|
|
|
|
|
|
<MyTable
|
|
|
@@ -115,13 +146,26 @@ function GItab4({ goodId }: Props) {
|
|
|
yHeight={510}
|
|
|
list={tableObj.list}
|
|
|
columnsTemp={GI4tableC}
|
|
|
- lastBtn={[]}
|
|
|
+ lastBtn={tableLastBtn}
|
|
|
pageNum={formData.pageNum}
|
|
|
pageSize={formData.pageSize}
|
|
|
total={tableObj.total}
|
|
|
onChange={(pageNum, pageSize) => paginationChange(pageNum, pageSize)}
|
|
|
widthSet={{ remark: 800 }}
|
|
|
/>
|
|
|
+
|
|
|
+ {addInfo.id ? (
|
|
|
+ <GuShiMo
|
|
|
+ goodIds={goodId}
|
|
|
+ moduleId=''
|
|
|
+ guShiInfo={addInfo}
|
|
|
+ closeFu={() => setAddInfo({} as GuShiType)}
|
|
|
+ succFu={(val, info) => {
|
|
|
+ if (val === '新增') resetSelectFu()
|
|
|
+ else clickSearch()
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
)
|
|
|
}
|