合约全景刷新时自动拉取打分,并同步回写完整合约代码
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -36,17 +36,23 @@ async function reload() {
|
||||
])
|
||||
candles.value = candleData
|
||||
scores.value = scoreData
|
||||
|
||||
// 如果数据库里没有该合约数据,自动拉取并打分
|
||||
if (candleData.length === 0) {
|
||||
await doFetchAndScore(true)
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleFetchAndScore() {
|
||||
async function doFetchAndScore(skipConfirm: boolean) {
|
||||
if (!filter.ts_code) {
|
||||
ElMessage.warning('请输入或选择合约')
|
||||
return
|
||||
}
|
||||
|
||||
if (!skipConfirm) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`即将拉取 ${filter.ts_code} 的全部历史数据并逐日打分,这可能需要一些时间。`,
|
||||
@@ -56,14 +62,17 @@ async function handleFetchAndScore() {
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
fullLoading.value = true
|
||||
fullResult.value = null
|
||||
try {
|
||||
const resp = await runFull({ ts_code: filter.ts_code })
|
||||
fullResult.value = resp
|
||||
// 用后端返回的完整代码(含交易所后缀)更新输入框
|
||||
filter.ts_code = resp.ts_code
|
||||
ElMessage.success(`完成: ${resp.scored_count} 天已打分, ${resp.skipped_count} 天跳过`)
|
||||
await reload()
|
||||
await loadData()
|
||||
} catch (err: any) {
|
||||
const msg = err?.response?.data?.error || err.message || '请求失败'
|
||||
ElMessage.error(msg)
|
||||
@@ -72,6 +81,21 @@ async function handleFetchAndScore() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleFetchAndScore() {
|
||||
await doFetchAndScore(false)
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
if (!filter.ts_code) return
|
||||
const [start, end] = filter.range || []
|
||||
const [candleData, scoreData] = await Promise.all([
|
||||
listCandles(filter.ts_code, start, end),
|
||||
listScores({ ts_code: filter.ts_code, start, end, limit: 1000 }),
|
||||
])
|
||||
candles.value = candleData
|
||||
scores.value = scoreData
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
contracts.value = await listContracts().catch(() => [])
|
||||
if (contracts.value.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user