diff --git a/frontend/src/constants/strategy.ts b/frontend/src/constants/strategy.ts index 6fa3380..6fa6ad9 100644 --- a/frontend/src/constants/strategy.ts +++ b/frontend/src/constants/strategy.ts @@ -17,3 +17,21 @@ export function strategyLabel(fileName: string): string { const key = fileName.replace(/\.py$/, '') return STRATEGY_LABELS[key] || key } + +// 标的池显示名(#92 全链路统一:任务列表/模拟盘列表等不显裸值 all/hs300_subset, +// 下拉当时选的什么 label 就显示什么) +export const POOL_LABELS: Record = { + hs300_subset: 'HS300 子集', + all: '全市场', + HS300: '沪深300', + ZZ500: '中证500', + ZZ1000: '中证1000', + ZZ2000: '中证2000', + ALL: '全市场', +} + +/** 池值 → 显示名;非池值(股票代码等)原样返回 */ +export function poolLabel(value: string): string { + const v = (value || '').trim() + return POOL_LABELS[v] || v +} diff --git a/frontend/src/views/backtest/History.vue b/frontend/src/views/backtest/History.vue index 7e6324a..fc9f690 100644 --- a/frontend/src/views/backtest/History.vue +++ b/frontend/src/views/backtest/History.vue @@ -3,6 +3,7 @@ import { ref, computed, watch, onMounted, onUnmounted } from 'vue' import { useRouter, useRoute } from 'vue-router' import { ElMessage, ElMessageBox } from 'element-plus' import { getTasks, getTaskParams, deleteTask, type TaskListItem } from '@/api/backtest' +import { poolLabel } from '@/constants/strategy' const router = useRouter() const route = useRoute() @@ -270,7 +271,9 @@ function durationText(row: TaskListItem): string { - + + + diff --git a/frontend/src/views/paper/List.vue b/frontend/src/views/paper/List.vue index ae2fbba..b9f6f88 100644 --- a/frontend/src/views/paper/List.vue +++ b/frontend/src/views/paper/List.vue @@ -3,6 +3,7 @@ import { ref, reactive, computed, onMounted } from 'vue' import { useRouter, useRoute } from 'vue-router' import { ElMessage, ElMessageBox } from 'element-plus' import CodeSnapshotDrawer from '@/views/strategy/CodeSnapshotDrawer.vue' +import { poolLabel } from '@/constants/strategy' import { listPapers, stopPaper, resumePaper, deletePaper, updatePaper, type PaperAccount, @@ -83,7 +84,9 @@ function symbolsShort(s: string | undefined): string { arr = String(s).split(',').map((x) => x.trim()) } if (!arr.length) return '—' - return arr.length > 3 ? arr.slice(0, 3).join(',') + ` +${arr.length - 3}` : arr.join(',') + // #92: 池值显中文 label(组合账户 symbols=["all"] → 全市场),股票代码原样 + const shown = arr.map(poolLabel) + return shown.length > 3 ? shown.slice(0, 3).join(',') + ` +${shown.length - 3}` : shown.join(',') } const typeLabel: Record = { cta: '个股', portfolio: '组合' } function open(a: PaperAccount): void { diff --git a/frontend/src/views/paper/New.vue b/frontend/src/views/paper/New.vue index 8382cc3..435ed80 100644 --- a/frontend/src/views/paper/New.vue +++ b/frontend/src/views/paper/New.vue @@ -273,6 +273,12 @@ function onSymbols(v: string): void { + +
+ 模拟盘名称 + {{ form.name || '—(选实例后自动生成)' }} +
+ diff --git a/frontend/src/views/strategy/InstanceEdit.vue b/frontend/src/views/strategy/InstanceEdit.vue index 393eafc..975a8e6 100644 --- a/frontend/src/views/strategy/InstanceEdit.vue +++ b/frontend/src/views/strategy/InstanceEdit.vue @@ -115,16 +115,24 @@ async function onSave(): Promise { }) saving.value = true try { - await apiClient.post('/strategy/instances', { - id: editId.value, + const payload = { code_file: form.code_file, name: form.name, + // PUT 全量替换:type 按所选文件判定(漏传会被默认 cta 覆盖组合实例) + type: selectedCode.value?.type || 'cta', params, symbol_or_pool: form.symbol_or_pool, interval: form.interval, match_session: form.match_session, - }) - ElMessage.success(isEdit.value ? '实例已更新(mock)' : '实例已创建(mock)') + } + // #91 编辑必须走 PUT:POST 恒为新建(原实现编辑保存再点就多出一个重复实例) + if (isEdit.value && editId.value) { + await apiClient.put(`/strategy/instances/${editId.value}`, payload) + ElMessage.success('实例已更新') + } else { + await apiClient.post('/strategy/instances', payload) + ElMessage.success('实例已创建') + } router.push('/strategy') } catch { ElMessage.error('保存失败') diff --git a/frontend/src/views/strategy/List.vue b/frontend/src/views/strategy/List.vue index 50d4de2..755b473 100644 --- a/frontend/src/views/strategy/List.vue +++ b/frontend/src/views/strategy/List.vue @@ -318,7 +318,7 @@ const runningRows = computed(() => #{{ i.id }} · {{ i.interval }} · 更新 {{ i.updated_at }}
{{ paramSummary(i.params) }}
-
{{ i.symbol_or_pool || '—(发起时定)' }}
+
{{ pct(latestRet(i)) }}{{ retInfoOf(i).label }}