From bf4fa243ec7c3ad3d28480a97828b505ac0ec573 Mon Sep 17 00:00:00 2001 From: niannian zheng Date: Mon, 2 Mar 2026 17:13:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=E3=80=81=E7=AD=96=E7=95=A5=E5=92=8C=E4=BA=A4=E6=98=93=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=9A=84=E6=95=B0=E6=8D=AE=E6=98=A0=E5=B0=84=E4=B8=8E?= =?UTF-8?q?API=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor: 重构策略编辑页面,支持创建和更新操作 fix: 修复投资组合详情页的数据显示问题 perf: 优化API请求处理,添加PUT和DELETE方法 docs: 完善API接口文档注释 style: 统一代码格式和命名规范 --- pages/config/config.vue | 81 ++++-- pages/detail/detail.vue | 403 +++++++++++++++++++++++++--- pages/index/index.vue | 28 +- pages/strategies/edit/edit.vue | 458 ++++++++++++++++++++++++++------ pages/strategies/strategies.vue | 26 +- utils/api.js | 119 ++++++++- 6 files changed, 943 insertions(+), 172 deletions(-) diff --git a/pages/config/config.vue b/pages/config/config.vue index 44507d6..be18f36 100644 --- a/pages/config/config.vue +++ b/pages/config/config.vue @@ -95,33 +95,26 @@ diff --git a/pages/detail/detail.vue b/pages/detail/detail.vue index a24f9dc..74a3558 100644 --- a/pages/detail/detail.vue +++ b/pages/detail/detail.vue @@ -17,17 +17,17 @@ ¥ - 156,240.00 + {{ (portfolioData.portfolioValue || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} 历史变化 - +42.82% + {{ (portfolioData.historicalChange || 0) >= 0 ? '+' : '' }}{{ (portfolioData.historicalChange || 0).toFixed(2) }}% 日内波动 - +¥1,240.50 + {{ (portfolioData.dailyVolatility || 0) >= 0 ? '+' : '' }}¥{{ (portfolioData.dailyVolatility || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} @@ -42,16 +42,15 @@ - + - H + {{ portfolioData.logicModel?.charAt(0) || 'S' }} - HFEA 风险平价逻辑 + {{ portfolioData.logicModel || '未设置策略' }} - 目标权重 - 季度调仓 + {{ portfolioData.logicModelDescription }} @@ -59,7 +58,7 @@ - 监控中 + {{ portfolioData.logicModelStatus || '监控中' }} @@ -67,25 +66,25 @@ - 当前记录项 (3) - 占比 100% + 当前记录项 ({{ portfolioData.totalItems || positions.length }}) + 占比 {{ portfolioData.totalRatio || 100 }}% - + - - {{ item.name.charAt(0) }} + + {{ item.stockName?.charAt(0) || item.stockCode?.charAt(0) || 'S' }} - {{ item.name }} - {{ item.code }} · {{ item.shares }}份 + {{ item.stockName || item.stockCode }} + {{ item.stockCode }} · {{ item.amount }}份 - ¥{{ item.marketValue }} - 比例 {{ item.weight }}% + ¥{{ (item.totalValue || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} + 比例 {{ (item.ratio || 0).toFixed(1) }}% @@ -94,14 +93,14 @@ 变动额 - - {{ item.pnl > 0 ? '+' : '' }}{{ item.pnl }} + + {{ (item.changeAmount || 0) >= 0 ? '+' : '' }}¥{{ (item.changeAmount || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} 偏离比例 - - {{ item.pnlPercent > 0 ? '+' : '' }}{{ item.pnlPercent }}% + + {{ (item.deviationRatio || 0) >= 0 ? '+' : '' }}{{ (item.deviationRatio || 0).toFixed(2) }}% @@ -117,18 +116,18 @@ - {{ log.date }} - {{ log.time }} + {{ log.Date }} + {{ log.Time }} - + - {{ log.title }} - {{ log.type === 'buy' ? '录入增加' : '结出减少' }} {{ log.amount }} + {{ log.Title }} + {{ log.Type === 'buy' ? '录入增加' : '结出减少' }} {{ log.Amount }} @@ -145,29 +144,233 @@ + + + + + {{ transactionType === 'buy' ? '录入增加' : '结出减少' }} + + + + + + + + 股票代码 + + + + + 数量 + + + + + 价格 + + + + + 货币 + + {{ transactionForm.currency }} + + + + + + 备注 + + + + + + + + + + + \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index 4e148a2..8266200 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -110,7 +110,15 @@ const fetchAssetData = async () => { console.log('开始获取资产数据...'); const response = await api.assets.getAssetData(); if (response.code === 200) { - assetData.value = response.data; + // 映射资产数据字段 + const data = response.data; + assetData.value = { + totalValue: data.TotalValue, + currency: data.Currency, + todayProfit: data.TodayProfit, + todayProfitCurrency: data.TodayProfitCurrency, + totalReturnRate: data.TotalReturnRate + }; console.log('资产数据获取成功'); } } catch (error) { @@ -124,8 +132,22 @@ const fetchHoldingsData = async () => { console.log('开始获取持仓数据...'); const response = await api.assets.getHoldings(); if (response.code === 200) { - // 处理响应数据结构,获取 items 数组 - holdings.value = response.data.items || []; + // 处理响应数据结构,获取 items 数组并映射字段 + const items = response.data.items || []; + holdings.value = items.map(item => ({ + id: item.Id, + name: item.Name, + tags: item.Tags, + status: item.Status, + statusType: item.StatusType, + iconChar: item.IconChar, + iconBgClass: item.IconBgClass, + iconTextClass: item.IconTextClass, + value: item.Value, + currency: item.Currency, + returnRate: item.ReturnRate, + returnType: item.ReturnType + })); console.log('持仓数据获取成功,items数量:', holdings.value.length); console.log('持仓数据:', holdings.value); } diff --git a/pages/strategies/edit/edit.vue b/pages/strategies/edit/edit.vue index 2fb29b8..f122447 100644 --- a/pages/strategies/edit/edit.vue +++ b/pages/strategies/edit/edit.vue @@ -1,6 +1,13 @@