|
@@ -11,6 +11,7 @@ import {
|
|
|
Empty,
|
|
Empty,
|
|
|
Input,
|
|
Input,
|
|
|
message,
|
|
message,
|
|
|
|
|
+ Pagination,
|
|
|
Radio,
|
|
Radio,
|
|
|
RadioGroup,
|
|
RadioGroup,
|
|
|
Spin,
|
|
Spin,
|
|
@@ -47,6 +48,13 @@ type HistoryGame = {
|
|
|
updatedAt?: string;
|
|
updatedAt?: string;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+type HistoryGamesResponse = {
|
|
|
|
|
+ list: HistoryGame[];
|
|
|
|
|
+ page: number;
|
|
|
|
|
+ pageSize: number;
|
|
|
|
|
+ total: number;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
const MARKET_GROUPS = [
|
|
const MARKET_GROUPS = [
|
|
|
{
|
|
{
|
|
|
keys: [
|
|
keys: [
|
|
@@ -101,7 +109,11 @@ const selectedMarkets = ref<string[]>([]);
|
|
|
const loadingGames = ref(false);
|
|
const loadingGames = ref(false);
|
|
|
const loadingHistory = ref(false);
|
|
const loadingHistory = ref(false);
|
|
|
const marketType = ref(-1);
|
|
const marketType = ref(-1);
|
|
|
|
|
+const pageSize = 50;
|
|
|
|
|
+const currentPage = ref(1);
|
|
|
const searchValue = ref('');
|
|
const searchValue = ref('');
|
|
|
|
|
+const searchTimer = ref<ReturnType<typeof setTimeout>>();
|
|
|
|
|
+const totalGames = ref(0);
|
|
|
|
|
|
|
|
const availableMarketKeys = computed(() => {
|
|
const availableMarketKeys = computed(() => {
|
|
|
const markets = history.value?.markets ?? {};
|
|
const markets = history.value?.markets ?? {};
|
|
@@ -114,26 +126,6 @@ const selectedGame = computed(() => {
|
|
|
return games.value.find((item) => item.eventId === selectedEventId.value);
|
|
return games.value.find((item) => item.eventId === selectedEventId.value);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-const filteredGames = computed(() => {
|
|
|
|
|
- const keyword = searchValue.value.trim();
|
|
|
|
|
- const now = Date.now();
|
|
|
|
|
- return games.value.filter((item) => {
|
|
|
|
|
- if (marketType.value === 1 && item.endTime < now) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- if (marketType.value === 2 && item.endTime >= now) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- if (keyword) {
|
|
|
|
|
- const text = `${item.eventId} ${item.leagueName} ${item.teamHomeName} ${item.teamAwayName}`;
|
|
|
|
|
- if (!text.includes(keyword)) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return true;
|
|
|
|
|
- });
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
const historyTitle = computed(() => {
|
|
const historyTitle = computed(() => {
|
|
|
const source = history.value ?? selectedGame.value;
|
|
const source = history.value ?? selectedGame.value;
|
|
|
if (!source) {
|
|
if (!source) {
|
|
@@ -296,8 +288,16 @@ const renderChart = () => {
|
|
|
const fetchGames = async () => {
|
|
const fetchGames = async () => {
|
|
|
loadingGames.value = true;
|
|
loadingGames.value = true;
|
|
|
try {
|
|
try {
|
|
|
- const data = await requestClient.get<HistoryGame[]>('/pstery/get_odds_history_games');
|
|
|
|
|
- games.value = data ?? [];
|
|
|
|
|
|
|
+ const data = await requestClient.get<HistoryGamesResponse>('/pstery/get_odds_history_games', {
|
|
|
|
|
+ params: {
|
|
|
|
|
+ keyword: searchValue.value.trim() || undefined,
|
|
|
|
|
+ page: currentPage.value,
|
|
|
|
|
+ page_size: pageSize,
|
|
|
|
|
+ status: marketType.value,
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ games.value = data?.list ?? [];
|
|
|
|
|
+ totalGames.value = data?.total ?? 0;
|
|
|
if (!selectedEventId.value && games.value.length) {
|
|
if (!selectedEventId.value && games.value.length) {
|
|
|
selectedEventId.value = games.value[0]?.eventId;
|
|
selectedEventId.value = games.value[0]?.eventId;
|
|
|
}
|
|
}
|
|
@@ -344,6 +344,20 @@ const selectGame = (id: number) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
watch(marketType, () => {
|
|
watch(marketType, () => {
|
|
|
|
|
+ selectedEventId.value = undefined;
|
|
|
|
|
+ history.value = null;
|
|
|
|
|
+ selectedMarkets.value = [];
|
|
|
|
|
+ currentPage.value = 1;
|
|
|
|
|
+ fetchGames();
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+watch(searchValue, () => {
|
|
|
|
|
+ currentPage.value = 1;
|
|
|
|
|
+ clearTimeout(searchTimer.value);
|
|
|
|
|
+ searchTimer.value = setTimeout(fetchGames, 300);
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+watch(currentPage, () => {
|
|
|
selectedEventId.value = undefined;
|
|
selectedEventId.value = undefined;
|
|
|
history.value = null;
|
|
history.value = null;
|
|
|
selectedMarkets.value = [];
|
|
selectedMarkets.value = [];
|
|
@@ -377,9 +391,9 @@ onMounted(() => {
|
|
|
placeholder="搜索联赛/球队/赛事ID"
|
|
placeholder="搜索联赛/球队/赛事ID"
|
|
|
/>
|
|
/>
|
|
|
<Spin :spinning="loadingGames">
|
|
<Spin :spinning="loadingGames">
|
|
|
- <div class="match-list" v-if="filteredGames.length">
|
|
|
|
|
|
|
+ <div class="match-list" v-if="games.length">
|
|
|
<button
|
|
<button
|
|
|
- v-for="game in filteredGames"
|
|
|
|
|
|
|
+ v-for="game in games"
|
|
|
:key="game.eventId"
|
|
:key="game.eventId"
|
|
|
class="match-item"
|
|
class="match-item"
|
|
|
:class="{ active: game.eventId === selectedEventId }"
|
|
:class="{ active: game.eventId === selectedEventId }"
|
|
@@ -396,6 +410,15 @@ onMounted(() => {
|
|
|
</div>
|
|
</div>
|
|
|
<Empty v-else class="list-empty" description="暂无比赛" />
|
|
<Empty v-else class="list-empty" description="暂无比赛" />
|
|
|
</Spin>
|
|
</Spin>
|
|
|
|
|
+ <Pagination
|
|
|
|
|
+ v-if="totalGames > pageSize"
|
|
|
|
|
+ v-model:current="currentPage"
|
|
|
|
|
+ class="match-pagination"
|
|
|
|
|
+ :page-size="pageSize"
|
|
|
|
|
+ :show-size-changer="false"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ :total="totalGames"
|
|
|
|
|
+ />
|
|
|
</aside>
|
|
</aside>
|
|
|
|
|
|
|
|
<main class="curve-panel">
|
|
<main class="curve-panel">
|
|
@@ -471,11 +494,18 @@ onMounted(() => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.match-list {
|
|
.match-list {
|
|
|
- height: calc(100vh - 230px);
|
|
|
|
|
|
|
+ height: calc(100vh - 274px);
|
|
|
overflow: auto;
|
|
overflow: auto;
|
|
|
padding: 0 10px 10px;
|
|
padding: 0 10px 10px;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+.match-pagination {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ padding: 10px;
|
|
|
|
|
+ border-top: 1px solid hsl(var(--border));
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
.match-item {
|
|
.match-item {
|
|
|
display: grid;
|
|
display: grid;
|
|
|
width: 100%;
|
|
width: 100%;
|