平仓盈亏

This commit is contained in:
杨 2026-05-11 14:24:47 +08:00
parent ca9f4b2862
commit a4978f8ed3
2 changed files with 29 additions and 13 deletions

View File

@ -35,18 +35,27 @@ import { search, tradeOrderTableColumns, positionOrderTableColumns } from './opt
import { getCustomTradeOrderListApi, getSubAccountListApi } from '@/api/modules/agent/customerTradeOrder'
// 本地存储
import { getStorage } from '@/utils/storage'
// 日期处理
import dayjs from 'dayjs'
// 公用方法
/**
* @description: 定义搜索数据
*/
// 获取近一周的时间范围
const dateRange = {
start: dayjs().subtract(7, 'day').format('YYYY-MM-DD'),
end: dayjs().format('YYYY-MM-DD'),
}
const searchForm = ref({
accountName: '',
orderId: '2',
tradeType: '',
startTime: '',
endTime: '',
start_time: dateRange.start,
end_time: dateRange.end,
startTime: dateRange.start,
endTime: dateRange.end,
subAccountName: '',
})
const searchOptions = ref(search)
@ -78,8 +87,8 @@ const getCustomerTradeOrderList = async () => {
account_id: searchForm.value.subAccountName,
order_no: '',
type: searchForm.value.tradeType,
start_time: '',
end_time: '',
start_time: dateRange.start,
end_time: dateRange.end,
}
console.log(params)
const data: any = await getCustomTradeOrderListApi(params)
@ -94,6 +103,7 @@ const getCustomerTradeOrderList = async () => {
quantity: item.num,
openPrice: item.build_price,
closePrice: item.close_price,
closeProfitLoss: item.profit_loss,
amount: item.amount,
createdTime: item.created_at,
}))
@ -147,8 +157,10 @@ const handleReset = () => {
accountName: '',
orderId: '',
tradeType: '',
startTime: '',
endTime: '',
startTime: dateRange.start,
endTime: dateRange.end,
start_time: dateRange.start,
end_time: dateRange.end,
subAccountName: '',
}
getCustomerTradeOrderList()

View File

@ -355,8 +355,8 @@ const handleMarketFormLinkage = async (type: 'level' | 'parentAccountName', valu
}))
}
// 2. 上级账户变更:获取点差列表
if (type === 'parentAccountName') {
// 2. 上级账户变更:获取点差列表(仅添加模式)
if (type === 'parentAccountName' && dialogType.value === 'add') {
// 清空点差数据
marketPointTree.value = []
@ -379,7 +379,8 @@ const handleMarketFormLinkage = async (type: 'level' | 'parentAccountName', valu
...item,
varietyName: item.name,
varietyCode: item.code,
pointDifference: dialogType.value === 'add' ? 0 : item.target_point_diff, // 添加时初始化为0,编辑时继承上级值
point_diff: item.target_point_diff, // 添加时:可分配点差取 target_point_diff
pointDifference: 0, // 添加时已分配点差初始化为0
assignedPointDifference: '',
}))
}
@ -523,6 +524,9 @@ const handleEditMarket = async () => {
console.log(marketForm.value)
try {
// 先设置编辑模式,避免 watch 触发获取点差接口
dialogType.value = 'edit'
// 先加载上级选项
await handleMarketFormLinkage('level', marketForm.value.level)
if (parentId) {
@ -536,15 +540,15 @@ const handleEditMarket = async () => {
...item,
varietyName: item.name,
varietyCode: item.code,
pointDifference: item.point_diff,
assignedPointDifference: item.target_point_diff || '', // 确保赋值正确
point_diff: item.point_diff, // 编辑时:可分配点差取 point_diff
pointDifference: item.target_point_diff,
assignedPointDifference: item.target_point_diff || '',
}))
}
// 所有数据加载完成后,再打开抽屉
dialogVisible.value = true
dialogTitle.value = '编辑'
dialogType.value = 'edit'
} catch (error) {
console.error('编辑数据加载失败:', error)
}
@ -556,7 +560,7 @@ const handleEditMarket = async () => {
// 查看点差
const handleViewPointDiff = async (row: any) => {
try {
const data = await getPointDiffConfigListApi({ user_id: row.role_id })
const data = await getPointDiffConfigListApi({ user_id: row.id })
marketPointTree.value = data.map((item: any) => ({
...item,
varietyName: item.name,