|
|
@ -1,24 +1,28 @@ |
|
|
|
import {FC, useCallback, useEffect, useState} from "react"; |
|
|
|
import {FC, useCallback, useEffect, useState} from "react"; |
|
|
|
import {View} from "@tarojs/components"; |
|
|
|
import {View} from "@tarojs/components"; |
|
|
|
import {Meeting, meetingAPi} from "@/api"; |
|
|
|
import {brandApi, BrandRecord, Meeting} from "@/api"; |
|
|
|
import styles from './meetings.module.scss' |
|
|
|
import styles from './list.module.scss' |
|
|
|
import Taro, {useReachBottom} from "@tarojs/taro"; |
|
|
|
import Taro, {useReachBottom} from "@tarojs/taro"; |
|
|
|
import Empty from "@/components/empty/empty"; |
|
|
|
import Empty from "@/components/empty/empty"; |
|
|
|
import {formatDate} from "@/utils/time"; |
|
|
|
import {formatDate} from "@/utils/time"; |
|
|
|
|
|
|
|
import brandView from "@/pages/brand/list/components/BrandView"; |
|
|
|
|
|
|
|
|
|
|
|
const MeetingsConfig: FC = () => { |
|
|
|
const MeetingsConfig: FC = () => { |
|
|
|
const [page, setPage] = useState(1) |
|
|
|
const [page, setPage] = useState(1) |
|
|
|
const [meeting, setMeeting] = useState<Meeting[]>([]) |
|
|
|
const [brands, setBrands] = useState<BrandRecord[]>([]) |
|
|
|
const [total, setTotal] = useState(0) |
|
|
|
const [total, setTotal] = useState(0) |
|
|
|
|
|
|
|
|
|
|
|
const getData = useCallback(async () => { |
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
getData() |
|
|
|
|
|
|
|
}, [page]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getData = useCallback( async () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const res = await meetingAPi.setList(1, 10) |
|
|
|
// const res = await brandApi.list(1, 10)
|
|
|
|
setTotal(res.total) |
|
|
|
// setTotal(res.total)
|
|
|
|
setMeeting([ |
|
|
|
// setBrands([
|
|
|
|
...(meeting || []), |
|
|
|
// ...res.data
|
|
|
|
...res.data |
|
|
|
// ])
|
|
|
|
]) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
} |
|
|
|
} |
|
|
|
}, [page]) |
|
|
|
}, [page]) |
|
|
@ -31,9 +35,9 @@ const MeetingsConfig: FC = () => { |
|
|
|
if (confirm) { |
|
|
|
if (confirm) { |
|
|
|
await meetingAPi.del(id) |
|
|
|
await meetingAPi.del(id) |
|
|
|
|
|
|
|
|
|
|
|
const oldMeeting: Meeting[] = JSON.parse(JSON.stringify(meeting)) |
|
|
|
const oldMeeting: Meeting[] = JSON.parse(JSON.stringify(brandView)) |
|
|
|
oldMeeting.splice(index, 1) |
|
|
|
oldMeeting.splice(index, 1) |
|
|
|
setMeeting(oldMeeting) |
|
|
|
setBrands(oldMeeting) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
@ -49,21 +53,19 @@ const MeetingsConfig: FC = () => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useReachBottom(useCallback(() => { |
|
|
|
useReachBottom(useCallback(() => { |
|
|
|
if (meeting?.length < total) { |
|
|
|
if (brands?.length < total) { |
|
|
|
setPage(page + 1) |
|
|
|
setPage(page + 1) |
|
|
|
} |
|
|
|
} |
|
|
|
}, [total, meeting])) |
|
|
|
}, [total, brands])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
getData() |
|
|
|
|
|
|
|
}, [page]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<View className='p-2'> |
|
|
|
<View className='p-2'> |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
meeting.length ? |
|
|
|
brands.length ? |
|
|
|
meeting.map((d, index) => <View className={styles.meeting} key={d.id}> |
|
|
|
brands.map((d, index) => <View className={styles.meeting} key={d.id}> |
|
|
|
<View className={styles.title} onClick={() => jumpInfo(d)}> |
|
|
|
<View className={styles.title} onClick={() => jumpInfo(d)}> |
|
|
|
<View className='font-weight mb-1'>{d.name}</View> |
|
|
|
<View className='font-weight mb-1'>{d.name}</View> |
|
|
|
<View>{formatDate(new Date(d.estimate_start_time), "MM-dd")} 至 {formatDate(new Date(d.estimate_start_time), "MM-dd")}</View> |
|
|
|
<View>{formatDate(new Date(d.estimate_start_time), "MM-dd")} 至 {formatDate(new Date(d.estimate_start_time), "MM-dd")}</View> |
|
|
@ -75,7 +77,7 @@ const MeetingsConfig: FC = () => { |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
<View className={styles.del} onClick={() => del(d.id, index)}>删除</View> |
|
|
|
<View className={styles.del} onClick={() => del(d.id, index)}>删除</View> |
|
|
|
</View>) |
|
|
|
</View>) |
|
|
|
: <Empty name='无历史记录'/> |
|
|
|
: <Empty name='空空如也'/> |
|
|
|
} |
|
|
|
} |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
) |
|
|
|
) |
|
|
|