|
|
@@ -1,43 +1,127 @@
|
|
|
-import React, { useEffect } from 'react'
|
|
|
+import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
-function GItab4() {
|
|
|
+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'
|
|
|
+
|
|
|
+const baseFormData = {
|
|
|
+ searchKey: '',
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10
|
|
|
+}
|
|
|
+
|
|
|
+type Props = {
|
|
|
+ goodId: number
|
|
|
+}
|
|
|
+
|
|
|
+function GItab4({ goodId }: Props) {
|
|
|
+ const [tableObj, setTableObj] = useState<{ list: Typetable[]; total: number }>({
|
|
|
+ list: [],
|
|
|
+ total: 0
|
|
|
+ })
|
|
|
+
|
|
|
+ const [formData, setFormData] = useState({ ...baseFormData })
|
|
|
+
|
|
|
+ const formDataRef = useRef({ ...baseFormData })
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
- console.log('GItab4')
|
|
|
+ formDataRef.current = formData
|
|
|
+ }, [formData])
|
|
|
+
|
|
|
+ // 点击搜索的 时间戳
|
|
|
+ const [timeKey, setTimeKey] = useState(0)
|
|
|
+
|
|
|
+ // 点击搜索
|
|
|
+ const clickSearch = useCallback(() => {
|
|
|
+ setFormData({ ...formData, pageNum: 1 })
|
|
|
+ setTimeout(() => {
|
|
|
+ setTimeKey(Date.now())
|
|
|
+ }, 50)
|
|
|
+ }, [formData])
|
|
|
+
|
|
|
+ // 封装发送请求的函数
|
|
|
+ const getListFu = useCallback(async () => {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ setTableObj(obj)
|
|
|
+ }
|
|
|
+ }, [goodId])
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ getListFu()
|
|
|
+ }, [getListFu, timeKey])
|
|
|
+
|
|
|
+ // 输入框的改变
|
|
|
+ const txtChangeFu = useCallback(
|
|
|
+ (txt: string, key: any) => {
|
|
|
+ setFormData({
|
|
|
+ ...formData,
|
|
|
+ [key]: txt
|
|
|
+ })
|
|
|
+ },
|
|
|
+ [formData]
|
|
|
+ )
|
|
|
+ // 点击重置
|
|
|
+ const resetSelectFu = useCallback(() => {
|
|
|
+ setFormData({ ...baseFormData })
|
|
|
+ setTimeout(() => {
|
|
|
+ setTimeKey(Date.now())
|
|
|
+ }, 50)
|
|
|
}, [])
|
|
|
|
|
|
+ // 页码变化
|
|
|
+ const paginationChange = useCallback(
|
|
|
+ (pageNum: number, pageSize: number) => {
|
|
|
+ setFormData({ ...formData, pageNum, pageSize })
|
|
|
+ setTimeout(() => {
|
|
|
+ setTimeKey(Date.now())
|
|
|
+ }, 50)
|
|
|
+ },
|
|
|
+ [formData]
|
|
|
+ )
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles.GItab4}>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
- <h1>GItab4</h1>
|
|
|
+ <div className='GI4top'>
|
|
|
+ <div>
|
|
|
+ <Input
|
|
|
+ style={{ width: 300 }}
|
|
|
+ placeholder='请输入故事名称'
|
|
|
+ maxLength={30}
|
|
|
+ value={formData.searchKey}
|
|
|
+ onChange={e => txtChangeFu(e.target.value, 'searchKey')}
|
|
|
+ />
|
|
|
+ <Button type='primary' onClick={clickSearch}>
|
|
|
+ 查询
|
|
|
+ </Button>
|
|
|
+ <Button onClick={resetSelectFu}>重置</Button>
|
|
|
+ </div>
|
|
|
+ <Button type='primary'>新增故事</Button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <MyTable
|
|
|
+ classKey='GItab4'
|
|
|
+ yHeight={510}
|
|
|
+ list={tableObj.list}
|
|
|
+ columnsTemp={GI4tableC}
|
|
|
+ lastBtn={[]}
|
|
|
+ pageNum={formData.pageNum}
|
|
|
+ pageSize={formData.pageSize}
|
|
|
+ total={tableObj.total}
|
|
|
+ onChange={(pageNum, pageSize) => paginationChange(pageNum, pageSize)}
|
|
|
+ widthSet={{ remark: 800 }}
|
|
|
+ />
|
|
|
</div>
|
|
|
)
|
|
|
}
|