flyzto před 7 měsíci
rodič
revize
671017ae4f

+ 1 - 1
server/models/Games.js

@@ -322,7 +322,7 @@ const setSolutions = (solutions) => {
  * 获取中单方案
  */
 const getSolutions = async () => {
-  const gamesRelations = await getGamesRelation(true);
+  const gamesRelations = await getGamesRelation();
   const relationsMap = new Map(gamesRelations.map(item => [item.id, item.rel]));
   const solutions = Object.values(GAMES.Solutions).sort((a, b) => b.sol.win_average - a.sol.win_average);
   return solutions.map(item => {

+ 57 - 0
web/apps/web-antd/src/views/match/components/match_card.vue

@@ -0,0 +1,57 @@
+<script setup>
+defineProps({
+  eventId: {
+    type: Number,
+    required: true
+  },
+  platform: {
+    type: String,
+    required: true
+  },
+  leagueName: {
+    type: String,
+    required: true
+  },
+  teamHomeName: {
+    type: String,
+    required: true
+  },
+  teamAwayName: {
+    type: String,
+    required: true
+  },
+  dateTime: {
+    type: String,
+    required: true
+  },
+  eventInfo: {
+    type: Object,
+    required: true
+  },
+  solutionKey: {
+    type: String,
+    required: true
+  }
+})
+</script>
+
+<template>
+  <div class="match-card">
+    <div class="match-card-header">
+      <div class="league-name">{{ leagueName }}</div>
+      <div class="date-time">{{ dateTime }}</div>
+    </div>
+    <div class="team-name">
+      <span class="home-name">{{ teamHomeName }}</span>
+      <em>VS</em>
+      <span class="away-name">{{ teamAwayName }}</span>
+    </div>
+  </div>
+</template>
+
+<style lang="scss" scoped>
+.match-card {
+  display: flex;
+  flex-direction: column;
+}
+</style>

+ 99 - 8
web/apps/web-antd/src/views/match/solutions/index.vue

@@ -5,6 +5,10 @@ import { Button, message } from 'ant-design-vue';
 import { ref, reactive, computed, onMounted, useTemplateRef } from 'vue';
 import dayjs from 'dayjs';
 
+import MatchCard from '../components/match_card.vue';
+
+const solutions = ref([]);
+
 const getSolutions = async () => {
   try {
     const data = await requestClient.get('/triangle/get_solutions');
@@ -17,9 +21,53 @@ const getSolutions = async () => {
   }
 }
 
+const getGamesEvents = async () => {
+  try {
+    const data = await requestClient.get('/triangle/get_games_events');
+    return data;
+  }
+  catch (error) {
+    console.error('Failed to fetch games events:', error);
+    message.error('获取比赛盘口失败');
+    return {};
+  }
+}
+
+
+const moveToFront = (arr, index) => {
+  if (index <= 0 || index >= arr.length) {
+    return arr;
+  }
+  const item = arr.splice(index, 1)[0];
+  arr.unshift(item);
+  return arr;
+}
+
 const updateSolutions = async () => {
-  const solutions = await getSolutions();
-  console.log(solutions);
+  const [solutionsList, eventsList] = await Promise.all([getSolutions(), getGamesEvents()]);
+  solutions.value = solutionsList.map(item => {
+    const { cpr, info, sol: { cross_type, jc_index, gold_side_a, gold_side_b, gold_side_m, win_side_a, win_side_b, win_side_m, win_average } } = item;
+    const cprKeys = cpr.map(item => item.k);
+    const jcEvents = eventsList.jc[info.jc.eventId];
+    const psEvents = eventsList.ps[info.ps.eventId];
+    const obEvents = eventsList.ob[info.ob.eventId];
+
+
+
+    cpr[0].g = gold_side_a;
+    cpr[0].w = win_side_a;
+    cpr[1].g = gold_side_b;
+    cpr[1].w = win_side_b;
+    cpr[2].g = gold_side_m;
+    cpr[2].w = win_side_m;
+    const newCpr = moveToFront(cpr, jc_index);
+    return { ...item, cpr: newCpr, sol: { cross_type, jc_index, win_average }, events };
+  });
+}
+
+const updateGamesEvents = async () => {
+  const events = await getGamesEvents();
+  gamesEvents.value = events;
 }
 
 onMounted(() => {
@@ -28,13 +76,56 @@ onMounted(() => {
 
 </script>
 
+<!-- eventId
+platform
+leagueName
+teamHomeName
+teamAwayName
+dateTime
+eventInfo
+solutionKey -->
+
 <template>
-  <Page>
-    <h3>中单记录</h3>
-    <Button type="primary" @click="updateSolutions">刷新</Button>
-  </Page>
+  <div class="solution-container">
+    <div class="solution-header">
+      <span>JC</span>
+      <span>PS</span>
+      <span>OB</span>
+      <em>利润</em>
+    </div>
+    <div class="solution-list">
+      <!-- <div class="solution-item" v-for="solution in solutions" :key="solution.sid">
+        <MatchCard />
+        <MatchCard />
+        <MatchCard />
+        <div class="solution-profit"></div>
+      </div> -->
+    </div>
+  </div>
 </template>
 
 <style lang="scss" scoped>
-
-</style>
+.solution-container {
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+}
+.solution-header {
+  display: flex;
+  align-items: center;
+  height: 40px;
+  background: #fff;
+  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
+  span, em {
+    display: block;
+    text-align: center;
+  }
+  span {
+    flex: 1;
+  }
+  em {
+    width: 80px;
+    font-style: normal;
+  }
+}
+</style>