fix: 投资交易记录,功能优化
This commit is contained in:
@@ -60,7 +60,7 @@
|
||||
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||
<el-form ref="accountDealRecordRef" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="投资账户" prop="accountId">
|
||||
<el-select v-model="form.accountId" placeholder="请选择投资账户" clearable>
|
||||
<el-select v-model="form.accountId" placeholder="请选择投资账户" @change="handleAccountChange" clearable>
|
||||
<el-option v-for="account in accountList" :key="account.id" :label="account.nameCodeAvailableLimit" :value="account.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -72,10 +72,16 @@
|
||||
<el-form-item label="交易时间" prop="createTime">
|
||||
<el-date-picker clearable v-model="form.createTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择交易时间"> </el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="交易金额" prop="amount">
|
||||
<el-form-item label="交易金额" v-show="!futuresShow" prop="amount">
|
||||
<el-input v-model="form.amount" type="number" placeholder="请输入交易金额" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-form-item v-show="futuresShow" label="平仓盈亏" prop="closedPosition">
|
||||
<el-input v-model="form.closedPosition" type="number" placeholder="请输入平仓盈亏" />
|
||||
</el-form-item>
|
||||
<el-form-item v-show="futuresShow" label="手续费" prop="commission">
|
||||
<el-input v-model="form.commission" type="number" placeholder="请输入手续费" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" v-show="!futuresShow" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -99,6 +105,7 @@ import {
|
||||
} from '@/api/invest/accountDealRecord'
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import { listAccounts } from '@/api/invest/accounts'
|
||||
import { getFutureStocks } from '@/api/invest/futureStocks'
|
||||
import dayjs from 'dayjs'
|
||||
import { require } from '@/utils/require'
|
||||
const { proxy } = getCurrentInstance()
|
||||
@@ -113,6 +120,9 @@ const single = ref(true)
|
||||
const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
const title = ref('')
|
||||
const futuresShow = ref(false)
|
||||
//账户类型
|
||||
const accountType = ref(0)
|
||||
const accountList = ref([])
|
||||
const operateList = ref([
|
||||
{ id: 'view', icon: 'View', title: '查看', hasPermi: ['invest:accountDealRecord:query'] },
|
||||
@@ -141,6 +151,8 @@ const data = reactive({
|
||||
accountId: [{ required: true, message: '投资账户不能为空', trigger: 'blur' }],
|
||||
amount: [{ required: true, message: '交易金额不能为空', trigger: 'blur' }],
|
||||
dealType: [{ required: true, message: '交易类型不能为空', trigger: 'change' }],
|
||||
closedPosition: [{ required: true, message: '平仓盈亏不能为空', trigger: 'blur' }],
|
||||
commission: [{ required: true, message: '手续费不能为空', trigger: 'blur' }],
|
||||
createTime: [{ required: true, message: '交易时间不能为空', trigger: 'blur' }]
|
||||
}
|
||||
})
|
||||
@@ -163,6 +175,26 @@ const handleOperate = (operate, row) => {
|
||||
|
||||
const { queryParams, queryAccountParams, queryAddAccountParams, form, rules } = toRefs(data)
|
||||
|
||||
const handleAccountChange = (accountId) => {
|
||||
if (accountId != null && accountId != '') {
|
||||
getFutureStocks(accountId).then((response) => {
|
||||
const account = response.data
|
||||
accountType.value = account.type
|
||||
if (account.type == '1') {
|
||||
futuresShow.value = true
|
||||
form.value.amount = 0
|
||||
form.value.closedPosition = null
|
||||
form.value.commission = null
|
||||
} else {
|
||||
futuresShow.value = false
|
||||
form.value.amount = null
|
||||
form.value.closedPosition = 0
|
||||
form.value.commission = 0
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询账户管理列表 */
|
||||
function getAccountList() {
|
||||
listAccounts(queryAccountParams.value).then((response) => {
|
||||
@@ -250,6 +282,7 @@ const handleView = (row) => {
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
futuresShow.value = false
|
||||
open.value = true
|
||||
title.value = '添加投资交易记录'
|
||||
}
|
||||
@@ -269,6 +302,11 @@ function handleUpdate(row) {
|
||||
function submitForm() {
|
||||
proxy.$refs.accountDealRecordRef.validate((valid) => {
|
||||
if (valid) {
|
||||
//如果是期货,给备注
|
||||
if (accountType.value == '1') {
|
||||
form.value.remark = '平仓盈亏' + form.value.closedPosition + ',手续费' + form.value.commission
|
||||
form.value.amount = form.value.closedPosition - form.value.commission
|
||||
}
|
||||
if (form.value.id != null) {
|
||||
updateAccountDealRecord(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess('修改成功')
|
||||
|
||||
Reference in New Issue
Block a user