This commit is contained in:
2026-04-25 15:15:49 +08:00
parent 9fdf0e1c25
commit db0d46009c
3 changed files with 124 additions and 60 deletions
+80 -58
View File
@@ -17,7 +17,7 @@
style="width: 140px"
/>
</div>
<div class="filter-item">
<span class="label-text">结束日期:</span>
<el-date-picker
@@ -29,21 +29,21 @@
style="width: 140px"
/>
</div>
<el-button
type="primary"
@click="fetchData"
:loading="loading"
<el-button
type="primary"
@click="fetchData"
:loading="loading"
style="margin-left: 12px"
>
查询数据
</el-button>
</div>
<el-table
:data="tableData"
v-loading="loading"
stripe
<el-table
:data="tableData"
v-loading="loading"
stripe
style="width: 100%; margin-top: 20px"
:header-cell-style="{ background: '#f5f7fa', color: '#606266' }"
:default-sort="{ prop: 'drop_pct', order: 'descending' }"
@@ -51,21 +51,48 @@
<el-table-column prop="code" label="代码" width="100" />
<el-table-column prop="name" label="名称" width="120" />
<el-table-column prop="day_open" label="当日开盘" align="right" />
<el-table-column prop="max_high" label="区间最高" sortable align="right" />
<el-table-column prop="max_date" label="最高日期" width="120" align="center" />
<el-table-column
prop="max_high"
label="区间最高"
sortable
align="right"
/>
<el-table-column
prop="max_date"
label="最高日期"
width="120"
align="center"
/>
<el-table-column prop="post_min_low" label="见顶后最低" align="right" />
<el-table-column prop="drop_pct" label="最大回落幅度%" sortable align="right">
<el-table-column
prop="drop_pct"
label="最大回落幅度%"
sortable
align="right"
>
<template #default="scope">
<span class="text-success">{{ scope.row.drop_pct.toFixed(2) }}%</span>
<span v-if="scope.row.drop_pct !== null" class="text-success">
{{ scope.row.drop_pct.toFixed(2) }}%
</span>
<span v-else class="text-gray">--</span>
</template>
</el-table-column>
<el-table-column prop="rebound_pct" label="低位反弹%" sortable align="right">
<el-table-column
prop="rebound_pct"
label="低位反弹%"
sortable
align="right"
>
<template #default="scope">
<span :class="scope.row.rebound_pct > 0 ? 'text-danger' : 'text-gray'">
<span
v-if="scope.row.rebound_pct !== null"
:class="scope.row.rebound_pct > 0 ? 'text-danger' : 'text-gray'"
>
{{ scope.row.rebound_pct.toFixed(2) }}%
</span>
<span v-else class="text-gray">--</span>
</template>
</el-table-column>
</el-table>
@@ -74,57 +101,56 @@
</template>
<script setup>
import { ref } from 'vue'
import { getAnalyzeData } from '@/api/stock'
import { ElMessage } from 'element-plus'
import { ref } from "vue";
import { getAnalyzeData } from "@/api/stock";
import { ElMessage } from "element-plus";
// 修改默认日期为 2026-04-22
const startDate = ref('2026-04-22')
const endDate = ref('2026-04-23')
const tableData = ref([])
const loading = ref(false)
const startDate = ref("2026-03-02");
const endDate = ref("2026-04-23");
const tableData = ref([]);
const loading = ref(false);
const fetchData = async () => {
if (!startDate.value || !endDate.value) {
return ElMessage.warning('请选择日期')
}
if (new Date(startDate.value) > new Date(endDate.value)) {
return ElMessage.warning('选定日期不能晚于结束日期')
return ElMessage.warning("请选择日期");
}
loading.value = true
if (new Date(startDate.value) > new Date(endDate.value)) {
return ElMessage.warning("选定日期不能晚于结束日期");
}
loading.value = true;
try {
const res = await getAnalyzeData({
start_date: startDate.value,
end_date: endDate.value
})
tableData.value = res.data
ElMessage.success(`加载成功: ${res.data.length} 条数据`)
end_date: endDate.value,
});
tableData.value = res.data;
ElMessage.success(`加载成功: ${res.data.length} 条数据`);
} catch (err) {
ElMessage.error('数据获取失败')
ElMessage.error("数据获取失败");
} finally {
loading.value = false
loading.value = false;
}
}
};
</script>
<style scoped>
.analyze-container {
padding: 24px;
.analyze-container {
padding: 24px;
background-color: #f0f2f5;
min-height: calc(100vh - 48px);
}
.header-title {
font-weight: 600;
font-size: 18px;
.header-title {
font-weight: 600;
font-size: 18px;
color: #303133;
}
.filter-section {
display: flex;
align-items: center;
.filter-section {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 20px;
gap: 20px;
}
.filter-item {
display: flex;
@@ -135,22 +161,18 @@ const fetchData = async () => {
color: #606266;
margin-right: 8px;
}
.text-success {
color: #67c23a;
.text-success {
color: #67c23a;
font-weight: bold;
}
.text-danger {
color: #f56c6c;
font-weight: bold;
.text-danger {
color: #f56c6c;
font-weight: bold;
}
.text-gray {
color: #909399;
}
:deep(.el-table .cell) {
padding: 0 12px;
}
</style>
</style>