1
This commit is contained in:
53
src/api/admin/line-api-user-group.js
Normal file
53
src/api/admin/line-api-user-group.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询LineApiUserGroup列表
|
||||||
|
export function listLineApiUserGroup(query) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-api-user-group',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询LineApiUserGroup详细
|
||||||
|
export function getLineApiUserGroup(id) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-api-user-group/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增LineApiUserGroup
|
||||||
|
export function addLineApiUserGroup(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-api-user-group',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改LineApiUserGroup
|
||||||
|
export function updateLineApiUserGroup(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-api-user-group/' + data.id,
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除LineApiUserGroup
|
||||||
|
export function delLineApiUserGroup(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-api-user-group',
|
||||||
|
method: 'delete',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLineApiUserGroupList(query) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-api-user-group/options',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
367
src/views/admin/line-api-user-group/index.vue
Normal file
367
src/views/admin/line-api-user-group/index.vue
Normal file
@ -0,0 +1,367 @@
|
|||||||
|
<template>
|
||||||
|
<BasicLayout>
|
||||||
|
<template #wrapper>
|
||||||
|
<el-card class="box-card">
|
||||||
|
<el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px">
|
||||||
|
<el-form-item label="分组名称" prop="groupName"><el-input
|
||||||
|
v-model="queryParams.groupName"
|
||||||
|
placeholder="请输入分组名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
v-permisaction="['admin:lineApiUserGroup:add']"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
>新增
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
v-permisaction="['admin:lineApiUserGroup:edit']"
|
||||||
|
type="success"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
>修改
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
v-permisaction="['admin:lineApiUserGroup:remove']"
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
>删除
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="lineApiUserGroupList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
|
||||||
|
<el-table-column label="交易所" align="center" prop="exchangeType" :show-overflow-tooltip="true">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ exchangeTypeFormat(row) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="分组名称" align="center" prop="groupName" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="数量" align="center" prop="count" />
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-popconfirm
|
||||||
|
class="delete-popconfirm"
|
||||||
|
title="确认要修改吗?"
|
||||||
|
confirm-button-text="修改"
|
||||||
|
@confirm="handleUpdate(scope.row)"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
slot="reference"
|
||||||
|
v-permisaction="['admin:lineApiUserGroup:edit']"
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
>修改
|
||||||
|
</el-button>
|
||||||
|
</el-popconfirm>
|
||||||
|
<el-popconfirm
|
||||||
|
class="delete-popconfirm"
|
||||||
|
title="确认要删除吗?"
|
||||||
|
confirm-button-text="删除"
|
||||||
|
@confirm="handleDelete(scope.row)"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
slot="reference"
|
||||||
|
v-permisaction="['admin:lineApiUserGroup:remove']"
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
>删除
|
||||||
|
</el-button>
|
||||||
|
</el-popconfirm>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total > 0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageIndex"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px">
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="交易所" prop="exchangeType">
|
||||||
|
<el-select
|
||||||
|
v-model="form.exchangeType"
|
||||||
|
style="width: 100%;"
|
||||||
|
placeholder="请选择交易所"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
size="small"
|
||||||
|
@change="exchangeTypeChange"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in exchangeTypes"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="分组名称" prop="groupName">
|
||||||
|
<el-input v-model="form.groupName" show-word-limit maxlength="30" placeholder="请输入分组名称" />
|
||||||
|
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="api用户" prop="userIds">
|
||||||
|
<el-select
|
||||||
|
v-model="form.userIds"
|
||||||
|
multiple
|
||||||
|
style="width: 100%;"
|
||||||
|
placeholder="请选择api用户"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in lineUsers"
|
||||||
|
:key="dict.id"
|
||||||
|
:label="dict.apiName"
|
||||||
|
:value="dict.id"
|
||||||
|
:disabled="dict.openStatus === 0"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio :label="1">开启</el-radio>
|
||||||
|
<el-radio :label="0">关闭</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button v-loading="loading" type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</el-card>
|
||||||
|
</template>
|
||||||
|
</BasicLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { addLineApiUserGroup, delLineApiUserGroup, getLineApiUserGroup, listLineApiUserGroup, updateLineApiUserGroup } from '@/api/admin/line-api-user-group'
|
||||||
|
import { listLineApiUser } from '@/api/admin/line-api-user'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'LineApiUserGroup',
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 弹出层标题
|
||||||
|
title: '',
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
isEdit: false,
|
||||||
|
// 类型数据字典
|
||||||
|
typeOptions: [],
|
||||||
|
lineApiUserGroupList: [],
|
||||||
|
lineUsers: [],
|
||||||
|
lineTotal: 0,
|
||||||
|
// 关系表类型
|
||||||
|
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
groupName: undefined
|
||||||
|
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {
|
||||||
|
},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
groupName: [{ required: true, message: '分组名称不能为空', trigger: 'blur' }],
|
||||||
|
userIds: [{ required: true, message: '用户不能为空', trigger: 'blur' }]
|
||||||
|
},
|
||||||
|
exchangeTypes: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList()
|
||||||
|
// 获取交易所字典数据
|
||||||
|
this.getDicts('exchange_type').then(response => {
|
||||||
|
this.exchangeTypes = response.data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
exchangeTypeFormat(row) {
|
||||||
|
return this.selectDictLabel(this.exchangeTypes || [], row.exchangeType)
|
||||||
|
},
|
||||||
|
/** 查询参数列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true
|
||||||
|
listLineApiUserGroup(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||||
|
this.lineApiUserGroupList = response.data.list
|
||||||
|
this.total = response.data.count
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false
|
||||||
|
this.reset()
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: undefined,
|
||||||
|
exchangeType: this.exchangeTypes.length ? this.exchangeTypes[0].value : '',
|
||||||
|
groupName: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
status: 1,
|
||||||
|
userIds: []
|
||||||
|
}
|
||||||
|
this.resetForm('form')
|
||||||
|
},
|
||||||
|
getImgList: function() {
|
||||||
|
this.form[this.fileIndex] = this.$refs['fileChoose'].resultList[0].fullUrl
|
||||||
|
},
|
||||||
|
fileClose: function() {
|
||||||
|
this.fileOpen = false
|
||||||
|
},
|
||||||
|
getLineApiUser() {
|
||||||
|
listLineApiUser({ pageIndex: 1, pageSize: 999, exchangeType: this.form.exchangeType }).then(response => {
|
||||||
|
this.lineUsers = response.data.list
|
||||||
|
this.lineTotal = response.data.count
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 关系
|
||||||
|
// 文件
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageIndex = 1
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dateRange = []
|
||||||
|
this.resetForm('queryForm')
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset()
|
||||||
|
this.open = true
|
||||||
|
this.title = '添加api用户分组'
|
||||||
|
this.isEdit = false
|
||||||
|
|
||||||
|
this.getLineApiUser()
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length !== 1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset()
|
||||||
|
this.getLineApiUser()
|
||||||
|
const id =
|
||||||
|
row.id || this.ids
|
||||||
|
getLineApiUserGroup(id).then(response => {
|
||||||
|
this.form = response.data
|
||||||
|
this.open = true
|
||||||
|
this.title = '修改api用户分组'
|
||||||
|
this.isEdit = true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
exchangeTypeChange() {
|
||||||
|
this.form.userIds = []
|
||||||
|
this.getLineApiUser()
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm: function() {
|
||||||
|
this.$refs['form'].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id !== undefined) {
|
||||||
|
updateLineApiUserGroup(this.form).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.msgSuccess(response.msg)
|
||||||
|
this.open = false
|
||||||
|
this.getList()
|
||||||
|
} else {
|
||||||
|
this.msgError(response.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
addLineApiUserGroup(this.form).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.msgSuccess(response.msg)
|
||||||
|
this.open = false
|
||||||
|
this.getList()
|
||||||
|
} else {
|
||||||
|
this.msgError(response.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
var Ids = (row.id && [row.id]) || this.ids
|
||||||
|
|
||||||
|
this.$confirm('是否确认删除编号为"' + Ids + '"的数据项?', '警告', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(function() {
|
||||||
|
return delLineApiUserGroup({ 'ids': Ids })
|
||||||
|
}).then((response) => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.msgSuccess(response.msg)
|
||||||
|
this.open = false
|
||||||
|
this.getList()
|
||||||
|
} else {
|
||||||
|
this.msgError(response.msg)
|
||||||
|
}
|
||||||
|
}).catch(function() {
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -97,14 +97,14 @@
|
|||||||
>
|
>
|
||||||
<template #default="{row}">{{ ['现货','合约','现货合约'][row.affiliation-1] }}</template>
|
<template #default="{row}">{{ ['现货','合约','现货合约'][row.affiliation-1] }}</template>
|
||||||
</el-table-column> -->
|
</el-table-column> -->
|
||||||
<el-table-column
|
<!-- <el-table-column
|
||||||
label="是否超管可见"
|
label="是否超管可见"
|
||||||
align="center"
|
align="center"
|
||||||
prop="adminShow"
|
prop="adminShow"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
>
|
>
|
||||||
<template #default="{row}">{{ ['否','是'][row.adminShow] }}</template>
|
<template #default="{row}">{{ ['否','是'][row.adminShow] }}</template>
|
||||||
</el-table-column>
|
</el-table-column> -->
|
||||||
<!-- <el-table-column
|
<!-- <el-table-column
|
||||||
label="允许下单的方向"
|
label="允许下单的方向"
|
||||||
align="center"
|
align="center"
|
||||||
@ -113,7 +113,7 @@
|
|||||||
>
|
>
|
||||||
<template #default="{row}">{{ ['多','空','多空'][row.site-1] }}</template>
|
<template #default="{row}">{{ ['多','空','多空'][row.site-1] }}</template>
|
||||||
</el-table-column> -->
|
</el-table-column> -->
|
||||||
<el-table-column
|
<!-- <el-table-column
|
||||||
label="从属关系"
|
label="从属关系"
|
||||||
align="center"
|
align="center"
|
||||||
prop="subordinate"
|
prop="subordinate"
|
||||||
@ -124,7 +124,8 @@
|
|||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
{{ groupIdFormat(scope.row) }}
|
{{ groupIdFormat(scope.row) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column><el-table-column
|
</el-table-column> -->
|
||||||
|
<el-table-column
|
||||||
label="开启状态"
|
label="开启状态"
|
||||||
align="center"
|
align="center"
|
||||||
prop="openStatus"
|
prop="openStatus"
|
||||||
@ -300,7 +301,7 @@
|
|||||||
import { addLineApiUser, delLineApiUser, getLineApiUser, listLineApiUser, updateLineApiUser } from '@/api/admin/line-api-user'
|
import { addLineApiUser, delLineApiUser, getLineApiUser, listLineApiUser, updateLineApiUser } from '@/api/admin/line-api-user'
|
||||||
|
|
||||||
import { listLineUser } from '@/api/admin/line-user'
|
import { listLineUser } from '@/api/admin/line-user'
|
||||||
import { listLineApiGroup } from '@/api/admin/line-api-group'
|
// import { listLineApiGroup } from '@/api/admin/line-api-group'
|
||||||
export default {
|
export default {
|
||||||
name: 'LineApiUser',
|
name: 'LineApiUser',
|
||||||
components: {
|
components: {
|
||||||
@ -349,7 +350,7 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.getList()
|
this.getList()
|
||||||
this.getLineUserItems()
|
this.getLineUserItems()
|
||||||
this.getLineApiGroupItems()
|
// this.getLineApiGroupItems()
|
||||||
// 获取交易所字典数据
|
// 获取交易所字典数据
|
||||||
this.getDicts('exchange_type').then(response => {
|
this.getDicts('exchange_type').then(response => {
|
||||||
this.exchangeTypes = response.data
|
this.exchangeTypes = response.data
|
||||||
@ -414,11 +415,11 @@ export default {
|
|||||||
this.userIdOptions = this.setItems(res, 'id', 'username')
|
this.userIdOptions = this.setItems(res, 'id', 'username')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getLineApiGroupItems() {
|
// getLineApiGroupItems() {
|
||||||
this.getItems(listLineApiGroup, undefined).then(res => {
|
// this.getItems(listLineApiGroup, undefined).then(res => {
|
||||||
this.groupIdOptions = this.setItems(res, 'id', 'groupName')
|
// this.groupIdOptions = this.setItems(res, 'id', 'groupName')
|
||||||
})
|
// })
|
||||||
},
|
// },
|
||||||
// 文件
|
// 文件
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
|
|||||||
@ -48,17 +48,11 @@
|
|||||||
>新增
|
>新增
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col> -->
|
</el-col> -->
|
||||||
<el-col :span="1.5">
|
<!-- <el-col :span="1.5">
|
||||||
<el-button
|
<el-button v-permisaction="['admin:lineOrderTemplateLogs:edit']" type="success" icon="el-icon-edit"
|
||||||
v-permisaction="['admin:lineOrderTemplateLogs:edit']"
|
size="mini" :disabled="single" @click="handleUpdate">修改
|
||||||
type="success"
|
|
||||||
icon="el-icon-edit"
|
|
||||||
size="mini"
|
|
||||||
:disabled="single"
|
|
||||||
@click="handleUpdate"
|
|
||||||
>修改
|
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col> -->
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
v-permisaction="['admin:lineOrderTemplateLogs:remove']"
|
v-permisaction="['admin:lineOrderTemplateLogs:remove']"
|
||||||
@ -196,6 +190,13 @@
|
|||||||
<el-radio :label="2">合约</el-radio>
|
<el-radio :label="2">合约</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="api用户类型" prop="api_id_type">
|
||||||
|
<el-radio-group v-model="inForm.api_id_type" @change="apiIdTypeChange">
|
||||||
|
<el-radio :label="1">单个</el-radio>
|
||||||
|
<el-radio :label="2">分组</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
<!-- <el-form-item label="对冲类型" prop="cover_type">
|
<!-- <el-form-item label="对冲类型" prop="cover_type">
|
||||||
<el-radio-group v-model="inForm.cover_type">
|
<el-radio-group v-model="inForm.cover_type">
|
||||||
<el-radio :label="1" :disabled="inForm.order_type==2">现货对合约</el-radio>
|
<el-radio :label="1" :disabled="inForm.order_type==2">现货对合约</el-radio>
|
||||||
@ -203,7 +204,7 @@
|
|||||||
<el-radio :label="3" :disabled="inForm.order_type==1">合约对现货</el-radio>
|
<el-radio :label="3" :disabled="inForm.order_type==1">合约对现货</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item> -->
|
</el-form-item> -->
|
||||||
<el-form-item label="api用户" prop="api_id">
|
<el-form-item v-if="inForm.api_id_type === 1" label="api用户" prop="api_id">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="21">
|
<el-col :span="21">
|
||||||
<el-select
|
<el-select
|
||||||
@ -228,6 +229,24 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item v-if="inForm.api_id_type === 2" label="api用户组" prop="api_user_group_id">
|
||||||
|
<el-select
|
||||||
|
v-model="inForm.api_user_group_id"
|
||||||
|
size="small"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
@change="apiUserGroupChange"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(op, index) in apiUserGroupList"
|
||||||
|
:key="'op_user_group' + index"
|
||||||
|
:label="op.label"
|
||||||
|
:value="op.id"
|
||||||
|
:disabled="op.disabled"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item v-if="form.type === 2" label="交易对组" prop="symbol_group_id">
|
<el-form-item v-if="form.type === 2" label="交易对组" prop="symbol_group_id">
|
||||||
<el-select
|
<el-select
|
||||||
v-if="form.type === 2"
|
v-if="form.type === 2"
|
||||||
@ -330,8 +349,10 @@
|
|||||||
<el-button type="primary" style="margin-left: 50px;" @click="onCalc">计算</el-button>
|
<el-button type="primary" style="margin-left: 50px;" @click="onCalc">计算</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-form-item label="止盈百分比" prop="profit">
|
<el-form-item :label="inForm.price_pattern === 'mixture' ? '止盈价格' : '止盈百分比'" prop="profit">
|
||||||
<el-input v-model="inForm.profit" placeholder="止盈百分比" />
|
<el-input v-model="inForm.profit" :placeholder="inForm.price_pattern === 'mixture' ? '止盈价格' : '止盈百分比'">
|
||||||
|
<template v-if="inForm.price_pattern === 'mixture'" slot="append">{{ comTakePrice }}</template>
|
||||||
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="止盈数量百分比" prop="profit_num_ratio">
|
<el-form-item label="止盈数量百分比" prop="profit_num_ratio">
|
||||||
<el-input v-model="inForm.profit_num_ratio" placeholder="止盈数量百分比" />
|
<el-input v-model="inForm.profit_num_ratio" placeholder="止盈数量百分比" />
|
||||||
@ -418,8 +439,14 @@
|
|||||||
<el-radio label="0">直接执行</el-radio>
|
<el-radio label="0">直接执行</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="主单亏损百分比" prop="reduce_price">
|
<el-form-item :label="inForm.price_pattern === 'mixture' ? '主单亏损价格' : '主单亏损百分比'" prop="reduce_price">
|
||||||
<el-input v-model.number="inForm.reduce_price" type="number" placeholder="主单亏损百分比" />
|
<el-input
|
||||||
|
v-model="inForm.reduce_price"
|
||||||
|
type="number"
|
||||||
|
:placeholder="inForm.price_pattern === 'mixture' ? '主单亏损价格' : '主单亏损百分比'"
|
||||||
|
>
|
||||||
|
<template v-if="inForm.price_pattern === 'mixture'" slot="append">{{ comReducePrice }}</template>
|
||||||
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="主单减仓数量百分比" prop="reduce_num">
|
<el-form-item label="主单减仓数量百分比" prop="reduce_num">
|
||||||
<el-input v-model.number="inForm.reduce_num" type="number" placeholder="主单减仓数量百分比" />
|
<el-input v-model.number="inForm.reduce_num" type="number" placeholder="主单减仓数量百分比" />
|
||||||
@ -636,6 +663,8 @@ import { addLineOrderTemplateLogs, delLineOrderTemplateLogs, getLineOrderTemplat
|
|||||||
import { listLineSymbolGroup } from '@/api/admin/line-symbol-group'
|
import { listLineSymbolGroup } from '@/api/admin/line-symbol-group'
|
||||||
import { getMainUser, listLineApiUser } from '@/api/admin/line-api-user'
|
import { getMainUser, listLineApiUser } from '@/api/admin/line-api-user'
|
||||||
import { calculate, aicoinSymbol, quickAddPreOrder } from '@/api/admin/line-pre-order'
|
import { calculate, aicoinSymbol, quickAddPreOrder } from '@/api/admin/line-pre-order'
|
||||||
|
import { getLineApiUserGroupList } from '@/api/admin/line-api-user-group'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'LineOrderTemplateLogs',
|
name: 'LineOrderTemplateLogs',
|
||||||
components: {
|
components: {
|
||||||
@ -675,6 +704,7 @@ export default {
|
|||||||
|
|
||||||
// 关系表类型
|
// 关系表类型
|
||||||
userIdOptions: [],
|
userIdOptions: [],
|
||||||
|
apiUserGroupList: [],
|
||||||
|
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
@ -706,10 +736,10 @@ export default {
|
|||||||
price: [{ required: true, message: '请输入下单百分比不能为空', trigger: 'blur' },
|
price: [{ required: true, message: '请输入下单百分比不能为空', trigger: 'blur' },
|
||||||
{ validator: this.validatePercentage, trigger: 'blur' }
|
{ validator: this.validatePercentage, trigger: 'blur' }
|
||||||
],
|
],
|
||||||
profit: [{ required: true, message: '请输入止盈百分比', trigger: 'blur' },
|
profit: [{ required: true, message: '请输入', trigger: 'blur' },
|
||||||
{ validator: this.validateProfit, trigger: 'blur' }],
|
{ validator: this.validateProfit, trigger: 'blur' }],
|
||||||
reduce_price: [
|
reduce_price: [
|
||||||
{ required: true, message: '主单亏损减仓百分比不能为空', trigger: 'blur' },
|
{ required: true, message: '主单亏损不能为空', trigger: 'blur' },
|
||||||
{ validator: this.validateReducePrice, trigger: 'blur' }],
|
{ validator: this.validateReducePrice, trigger: 'blur' }],
|
||||||
reduce_num: [
|
reduce_num: [
|
||||||
{ required: true, message: '主单减仓数量百分比不能为空', trigger: 'blur' },
|
{ required: true, message: '主单减仓数量百分比不能为空', trigger: 'blur' },
|
||||||
@ -754,7 +784,9 @@ export default {
|
|||||||
],
|
],
|
||||||
tpTpPriceRatio: [{ required: true, message: '第二止盈价格百分比不能为空', trigger: 'blur' }],
|
tpTpPriceRatio: [{ required: true, message: '第二止盈价格百分比不能为空', trigger: 'blur' }],
|
||||||
slSlPriceRatio: [{ required: true, message: '第二止损价格百分比不能为空', trigger: 'blur' }],
|
slSlPriceRatio: [{ required: true, message: '第二止损价格百分比不能为空', trigger: 'blur' }],
|
||||||
expirateHour: [{ required: true, message: '请输入过期时间(H)', trigger: 'blur' }]
|
expirateHour: [{ required: true, message: '请输入过期时间(H)', trigger: 'blur' }],
|
||||||
|
api_id_type: [{ required: true, message: '请选择用户类型', trigger: 'blur' }],
|
||||||
|
api_user_group_id: [{ required: true, message: '请选择用户组', trigger: 'blur' }]
|
||||||
},
|
},
|
||||||
inForm: {},
|
inForm: {},
|
||||||
searchLoding: false,
|
searchLoding: false,
|
||||||
@ -779,10 +811,45 @@ export default {
|
|||||||
const s = this.comSymbols.find(item => item.symbol === symbol)
|
const s = this.comSymbols.find(item => item.symbol === symbol)
|
||||||
if (s) {
|
if (s) {
|
||||||
const res = ((price - s.lastPrice) / s.lastPrice) * 100
|
const res = ((price - s.lastPrice) / s.lastPrice) * 100
|
||||||
return `${res}%`
|
return `${res.toFixed(2)}%`
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
return 0
|
||||||
|
},
|
||||||
|
/* 计算止盈百分比 */
|
||||||
|
comTakePrice() {
|
||||||
|
// console.log('this.form', this.form)
|
||||||
|
const { profit, price, price_pattern, site } = this.inForm
|
||||||
|
|
||||||
|
if (price_pattern === 'mixture' && Number(price) > 0 && Number(profit) > 0) {
|
||||||
|
let res = 0
|
||||||
|
|
||||||
|
if (site === 'BUY') {
|
||||||
|
res = ((Number(profit) - Number(price)) / Number(price)) * 100
|
||||||
|
} else {
|
||||||
|
res = ((Number(price) - Number(profit)) / Number(price)) * 100
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${res.toFixed(2)}%` // 取绝对值并保留两位小数
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
},
|
||||||
|
/* 计算减仓百分比 */
|
||||||
|
comReducePrice() {
|
||||||
|
const { reduce_price, price, price_pattern, site } = this.inForm
|
||||||
|
|
||||||
|
if (price_pattern === 'mixture' && Number(price) > 0 && Number(reduce_price) > 0) {
|
||||||
|
let res = 0
|
||||||
|
if (site === 'BUY') {
|
||||||
|
res = ((Number(price) - Number(reduce_price)) / Number(price)) * 100
|
||||||
|
} else {
|
||||||
|
res = ((Number(reduce_price) - Number(price)) / Number(price)) * 100
|
||||||
|
}
|
||||||
|
return `${res.toFixed(2)}%` // 取绝对值并保留两位小数
|
||||||
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -812,7 +879,7 @@ export default {
|
|||||||
},
|
},
|
||||||
validateReducePrice(rule, value, callback) {
|
validateReducePrice(rule, value, callback) {
|
||||||
if (value === 0 || value === undefined || value === null || value === '') {
|
if (value === 0 || value === undefined || value === null || value === '') {
|
||||||
callback(new Error('亏损百分比必须大于0'))
|
callback(new Error('必须大于0'))
|
||||||
} else {
|
} else {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
@ -866,9 +933,9 @@ export default {
|
|||||||
},
|
},
|
||||||
validateProfit(rule, value, callback) {
|
validateProfit(rule, value, callback) {
|
||||||
if (this.inForm.profit === '' || this.inForm.profit === undefined || this.inForm.profit === null) {
|
if (this.inForm.profit === '' || this.inForm.profit === undefined || this.inForm.profit === null) {
|
||||||
callback(new Error('止盈百分比不能为空'))
|
callback(new Error('不能为空'))
|
||||||
} else if (this.inForm.profit <= 0) {
|
} else if (this.inForm.profit <= 0) {
|
||||||
callback(new Error('止盈百分比不能小于0'))
|
callback(new Error('不能小于0'))
|
||||||
} else {
|
} else {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
@ -990,7 +1057,7 @@ export default {
|
|||||||
this.inForm.ext.splice(index, 1)
|
this.inForm.ext.splice(index, 1)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
console.log('ext', this.inForm.ext)
|
|
||||||
this.inForm.ext.push({
|
this.inForm.ext.push({
|
||||||
// 类型 订单类型 加仓类型 加仓数值 价格百分比 止盈百分比 止损百分比
|
// 类型 订单类型 加仓类型 加仓数值 价格百分比 止盈百分比 止损百分比
|
||||||
addType: type === 0 ? 1 : 2,
|
addType: type === 0 ? 1 : 2,
|
||||||
@ -1032,11 +1099,17 @@ export default {
|
|||||||
},
|
},
|
||||||
// 获取杠杆api用户
|
// 获取杠杆api用户
|
||||||
getListLineApiUser(exchangeType) {
|
getListLineApiUser(exchangeType) {
|
||||||
listLineApiUser({ pageIndex: 1, pageSize: 999, exchangeType: exchangeType || this.inForm.exchange_type }).then(response => {
|
listLineApiUser({ pageIndex: 1, pageSize: 999, exchangeType: exchangeType || this.inForm.exchange_type, openStatus: 1 }).then(response => {
|
||||||
this.lineUsers = response.data.list
|
this.lineUsers = response.data.list
|
||||||
this.lineTotal = response.data.count
|
this.lineTotal = response.data.count
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 获取api用户分组
|
||||||
|
getApiUserGroupList(exchangeType) {
|
||||||
|
getLineApiUserGroupList({ exchangeType: exchangeType || this.inForm.exchange_type }).then(response => {
|
||||||
|
this.apiUserGroupList = response.data
|
||||||
|
})
|
||||||
|
},
|
||||||
// 交易对列表
|
// 交易对列表
|
||||||
getSymbol(e, type, exchangeType) {
|
getSymbol(e, type, exchangeType) {
|
||||||
this.searchLoding = true
|
this.searchLoding = true
|
||||||
@ -1095,6 +1168,27 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/* 切换用户选择 */
|
||||||
|
apiIdTypeChange() {
|
||||||
|
this.inForm.api_id = undefined
|
||||||
|
this.inForm.api_user_group_id = undefined
|
||||||
|
},
|
||||||
|
/* 用户分组选中 */
|
||||||
|
apiUserGroupChange(selection) {
|
||||||
|
console.log(selection)
|
||||||
|
if (selection) {
|
||||||
|
// 过滤出匹配的项
|
||||||
|
const matchedGroup = this.apiUserGroupList.find(x => x.id === selection)
|
||||||
|
|
||||||
|
console.log(matchedGroup)
|
||||||
|
// 确保 matchedGroup 存在,并且有 value 数组
|
||||||
|
if (matchedGroup && matchedGroup.value) {
|
||||||
|
this.inForm.api_id = matchedGroup.value // 转字符串
|
||||||
|
} else {
|
||||||
|
this.inForm.api_id = undefined // 处理未找到的情况
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.open = false
|
this.open = false
|
||||||
@ -1182,11 +1276,19 @@ export default {
|
|||||||
this.ext = []
|
this.ext = []
|
||||||
const id =
|
const id =
|
||||||
row.id || this.ids
|
row.id || this.ids
|
||||||
|
|
||||||
getLineOrderTemplateLogs(id).then(response => {
|
getLineOrderTemplateLogs(id).then(response => {
|
||||||
this.form = response.data
|
this.form = response.data
|
||||||
const x = JSON.parse(response.data.params)
|
const x = JSON.parse(response.data.params)
|
||||||
this.inForm = { ...x, api_id: x.api_id.split(','), symbol_group_id: x.symbol_group_id ? Number(x.symbol_group_id) : undefined }
|
this.inForm = {
|
||||||
// this.getSymbol(undefined, x.symbol_type, x.exchange_type)
|
...x,
|
||||||
|
api_id: x.api_id.split(','),
|
||||||
|
api_id_type: x.api_id_type ? x.api_id_type : 1,
|
||||||
|
api_user_group_id: x.api_user_group_id ? x.api_user_group_id : undefined,
|
||||||
|
symbol_group_id: x.symbol_group_id ? Number(x.symbol_group_id) : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getApiUserGroupList()
|
||||||
this.onchangePattern(false)
|
this.onchangePattern(false)
|
||||||
this.getListLineApiUser()
|
this.getListLineApiUser()
|
||||||
this.form.type === 2 && this.getSymbolGroup(this.inForm.symbol_type)
|
this.form.type === 2 && this.getSymbolGroup(this.inForm.symbol_type)
|
||||||
@ -1210,6 +1312,10 @@ export default {
|
|||||||
if (formValid.every(valid => valid)) {
|
if (formValid.every(valid => valid)) {
|
||||||
this.inForm.price = this.inForm.price ? String(this.inForm.price) : ''
|
this.inForm.price = this.inForm.price ? String(this.inForm.price) : ''
|
||||||
|
|
||||||
|
if (this.inForm.api_user_group_id && this.inForm.api_id_type === 2) {
|
||||||
|
this.apiUserGroupChange(this.inForm.api_user_group_id)
|
||||||
|
}
|
||||||
|
|
||||||
const params = JSON.stringify({
|
const params = JSON.stringify({
|
||||||
...this.inForm,
|
...this.inForm,
|
||||||
reduce_price: this.inForm.reduce_price || 0,
|
reduce_price: this.inForm.reduce_price || 0,
|
||||||
@ -1293,9 +1399,17 @@ export default {
|
|||||||
return quickAddPreOrder({ ids: Ids.toString() })
|
return quickAddPreOrder({ ids: Ids.toString() })
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
|
if (response.data !== '') {
|
||||||
|
this.$notify({
|
||||||
|
title: '部分失败',
|
||||||
|
message: response.data,
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.msgSuccess(response.msg)
|
||||||
|
}
|
||||||
this.ids = []
|
this.ids = []
|
||||||
this.$refs.table?.clearSelection()
|
this.$refs.table?.clearSelection()
|
||||||
this.msgSuccess(response.msg)
|
|
||||||
} else {
|
} else {
|
||||||
this.msgError(response.msg)
|
this.msgError(response.msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,15 +110,15 @@
|
|||||||
>加仓
|
>加仓
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col> -->
|
</el-col> -->
|
||||||
<el-col :span="1.5">
|
<el-col v-permisaction="['admin:linePreOrder:lever']" :span="1.5">
|
||||||
<el-button type="warning" size="mini" @click="onMode('设置杠杆')">设置杠杆
|
<el-button type="warning" size="mini" @click="onMode('设置杠杆')">设置杠杆
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col v-permisaction="['admin:linePreOrder:margin']" :span="1.5">
|
||||||
<el-button type="warning" size="mini" @click="onMode('设置保证金模式')">设置保证金模式
|
<el-button type="warning" size="mini" @click="onMode('设置保证金模式')">设置保证金模式
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col v-permisaction="['admin:linePreOrder:cancel']" :span="1.5">
|
||||||
<el-button type="warning" size="mini" @click="onCancel">取消委托
|
<el-button type="warning" size="mini" @click="onCancel">取消委托
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -144,7 +144,7 @@
|
|||||||
>删除
|
>删除
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col> -->
|
</el-col> -->
|
||||||
<el-col :span="1.5">
|
<el-col v-permisaction="['admin:linePreOrder:clearAll']" :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
icon="el-icon-delete"
|
icon="el-icon-delete"
|
||||||
@ -154,7 +154,7 @@
|
|||||||
>一键清除数据
|
>一键清除数据
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col v-permisaction="['admin:linePreOrder:clearUnTrigger']" :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
icon="el-icon-delete"
|
icon="el-icon-delete"
|
||||||
@ -440,7 +440,13 @@
|
|||||||
<el-radio :label="3" :disabled="form.symbol_type==1">合约对现货</el-radio>
|
<el-radio :label="3" :disabled="form.symbol_type==1">合约对现货</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item> -->
|
</el-form-item> -->
|
||||||
<el-form-item label="api用户" prop="api_id">
|
<el-form-item label="api用户类型" prop="api_id_type">
|
||||||
|
<el-radio-group v-model="form.api_id_type" @change="apiIdTypeChange">
|
||||||
|
<el-radio :label="1">单个</el-radio>
|
||||||
|
<el-radio :label="2">分组</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="form.api_id_type === 1" label="api用户" prop="api_id">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="21">
|
<el-col :span="21">
|
||||||
<el-select
|
<el-select
|
||||||
@ -460,6 +466,23 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item v-if="form.api_id_type === 2" label="api用户组" prop="api_user_group_id">
|
||||||
|
<el-select
|
||||||
|
v-model="form.api_user_group_id"
|
||||||
|
size="small"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
@change="apiUserGroupChange"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(op, index) in apiUserGroupList"
|
||||||
|
:key="'op_user_group' + index"
|
||||||
|
:label="op.label"
|
||||||
|
:value="op.id"
|
||||||
|
:disabled="op.disabled"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<!-- <el-form-item label="交易对组id" prop="groupId">
|
<!-- <el-form-item label="交易对组id" prop="groupId">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.groupId"
|
v-model="form.groupId"
|
||||||
@ -568,8 +591,10 @@
|
|||||||
<el-button type="primary" style="margin-left: 50px;" @click="onCalc">计算</el-button>
|
<el-button type="primary" style="margin-left: 50px;" @click="onCalc">计算</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-form-item label="止盈百分比" prop="profit">
|
<el-form-item :label="form.price_pattern === 'mixture' ? '止盈价格' : '止盈百分比'" prop="profit">
|
||||||
<el-input v-model="form.profit" placeholder="止盈百分比" />
|
<el-input v-model="form.profit" :placeholder="form.price_pattern === 'mixture' ? '止盈价格' : '止盈百分比'">
|
||||||
|
<template v-if="form.price_pattern === 'mixture'" slot="append">{{ comTakePrice }}</template>
|
||||||
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="止盈数量百分比" prop="profit_num_ratio">
|
<el-form-item label="止盈数量百分比" prop="profit_num_ratio">
|
||||||
<el-input v-model="form.profit_num_ratio" placeholder="止盈数量百分比" />
|
<el-input v-model="form.profit_num_ratio" placeholder="止盈数量百分比" />
|
||||||
@ -686,8 +711,15 @@
|
|||||||
<el-radio label="0">直接执行</el-radio>
|
<el-radio label="0">直接执行</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="主单亏损百分比" prop="reduce_price">
|
<el-form-item :label="form.price_pattern === 'mixture' ? '主单亏损价格' : '主单亏损百分比'" prop="reduce_price">
|
||||||
<el-input v-model.number="form.reduce_price" min="0" max="99.9" type="number" placeholder="主单亏损百分比" />
|
<el-input
|
||||||
|
v-model="form.reduce_price"
|
||||||
|
min="0"
|
||||||
|
type="number"
|
||||||
|
:placeholder="form.price_pattern === 'mixture' ? '主单亏损价格' : '主单亏损百分比'"
|
||||||
|
>
|
||||||
|
<template v-if="form.price_pattern === 'mixture'" slot="append">{{ comReducePrice }}</template>
|
||||||
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="主单减仓数量百分比" prop="reduce_num">
|
<el-form-item label="主单减仓数量百分比" prop="reduce_num">
|
||||||
<el-input v-model.number="form.reduce_num" type="number" placeholder="主单减仓数量百分比" />
|
<el-input v-model.number="form.reduce_num" type="number" placeholder="主单减仓数量百分比" />
|
||||||
@ -1243,6 +1275,7 @@ import { listLineSymbol, getSameSymbol } from '@/api/admin/line-symbol'
|
|||||||
import { calculate, aicoinSymbol, clearUnTriggered, clearAll, closePosition, manuallyCover, orderMarginType, orderLever, batchAddOrder, addOrder, delLinePreOrder, getLinePreOrder, listLinePreOrder, updateLinePreOrder, getChildOrder, cancelOpenOrder } from '@/api/admin/line-pre-order'
|
import { calculate, aicoinSymbol, clearUnTriggered, clearAll, closePosition, manuallyCover, orderMarginType, orderLever, batchAddOrder, addOrder, delLinePreOrder, getLinePreOrder, listLinePreOrder, updateLinePreOrder, getChildOrder, cancelOpenOrder } from '@/api/admin/line-pre-order'
|
||||||
import { getMainUser, listLineApiUser } from '@/api/admin/line-api-user'
|
import { getMainUser, listLineApiUser } from '@/api/admin/line-api-user'
|
||||||
import { listLineSymbolGroup } from '@/api/admin/line-symbol-group'
|
import { listLineSymbolGroup } from '@/api/admin/line-symbol-group'
|
||||||
|
import { getLineApiUserGroupList } from '@/api/admin/line-api-user-group'
|
||||||
export default {
|
export default {
|
||||||
name: 'LinePreOrder',
|
name: 'LinePreOrder',
|
||||||
data() {
|
data() {
|
||||||
@ -1355,7 +1388,8 @@ export default {
|
|||||||
|
|
||||||
// 关系表类型
|
// 关系表类型
|
||||||
apiIdOptions: [],
|
apiIdOptions: [],
|
||||||
|
// api用户分组
|
||||||
|
apiUserGroupList: [],
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
@ -1381,9 +1415,9 @@ export default {
|
|||||||
price: [{ required: true, message: '请输入下单百分比不能为空', trigger: 'blur' },
|
price: [{ required: true, message: '请输入下单百分比不能为空', trigger: 'blur' },
|
||||||
{ validator: this.validatePercentage, trigger: 'blur' }
|
{ validator: this.validatePercentage, trigger: 'blur' }
|
||||||
],
|
],
|
||||||
profit: [{ required: true, message: '请输入止盈百分比', trigger: 'blur' }, { validator: this.validateProfit, trigger: 'blur' }],
|
profit: [{ required: true, message: '请输入', trigger: 'blur' }, { validator: this.validateProfit, trigger: 'blur' }],
|
||||||
reduce_price: [
|
reduce_price: [
|
||||||
{ required: true, message: '主单亏损减仓百分比不能为空', trigger: 'blur' },
|
{ required: true, message: '主单亏损不能为空', trigger: 'blur' },
|
||||||
{ validator: this.validateReducePrice, trigger: 'blur' }],
|
{ validator: this.validateReducePrice, trigger: 'blur' }],
|
||||||
reduce_num: [
|
reduce_num: [
|
||||||
{ required: true, message: '主单减仓数量百分比不能为空', trigger: 'blur' },
|
{ required: true, message: '主单减仓数量百分比不能为空', trigger: 'blur' },
|
||||||
@ -1427,7 +1461,9 @@ export default {
|
|||||||
],
|
],
|
||||||
tpTpPriceRatio: [{ required: true, message: '第二止盈价格百分比不能为空', trigger: 'blur' }],
|
tpTpPriceRatio: [{ required: true, message: '第二止盈价格百分比不能为空', trigger: 'blur' }],
|
||||||
slSlPriceRatio: [{ required: true, message: '第二止损价格百分比不能为空', trigger: 'blur' }],
|
slSlPriceRatio: [{ required: true, message: '第二止损价格百分比不能为空', trigger: 'blur' }],
|
||||||
expirateHour: [{ required: true, message: '请输入过期时间(H)', trigger: 'blur' }]
|
expirateHour: [{ required: true, message: '请输入过期时间(H)', trigger: 'blur' }],
|
||||||
|
api_id_type: [{ required: true, message: '请选择用户类型', trigger: 'blur' }],
|
||||||
|
api_user_group_id: [{ required: true, message: '请选择用户组', trigger: 'blur' }]
|
||||||
},
|
},
|
||||||
currentExpandId: undefined,
|
currentExpandId: undefined,
|
||||||
cacheRefresh: {},
|
cacheRefresh: {},
|
||||||
@ -1514,10 +1550,45 @@ export default {
|
|||||||
const s = this.comSymbols.find(item => item.symbol === symbol)
|
const s = this.comSymbols.find(item => item.symbol === symbol)
|
||||||
if (s) {
|
if (s) {
|
||||||
const res = ((price - s.lastPrice) / s.lastPrice) * 100
|
const res = ((price - s.lastPrice) / s.lastPrice) * 100
|
||||||
return `${res}%`
|
return `${res.toFixed(2)}%`
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
return 0
|
||||||
|
},
|
||||||
|
/* 计算止盈百分比 */
|
||||||
|
comTakePrice() {
|
||||||
|
// console.log('this.form', this.form)
|
||||||
|
const { profit, price, price_pattern, site } = this.form
|
||||||
|
|
||||||
|
if (price_pattern === 'mixture' && Number(price) > 0 && Number(profit) > 0) {
|
||||||
|
let res = 0
|
||||||
|
|
||||||
|
if (site === 'BUY') {
|
||||||
|
res = ((Number(profit) - Number(price)) / Number(price)) * 100
|
||||||
|
} else {
|
||||||
|
res = ((Number(price) - Number(profit)) / Number(price)) * 100
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${res.toFixed(2)}%` // 取绝对值并保留两位小数
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
},
|
||||||
|
/* 计算减仓百分比 */
|
||||||
|
comReducePrice() {
|
||||||
|
const { reduce_price, price, price_pattern, site } = this.form
|
||||||
|
|
||||||
|
if (price_pattern === 'mixture' && Number(price) > 0 && Number(reduce_price) > 0) {
|
||||||
|
let res = 0
|
||||||
|
if (site === 'BUY') {
|
||||||
|
res = ((Number(price) - Number(reduce_price)) / Number(price)) * 100
|
||||||
|
} else {
|
||||||
|
res = ((Number(reduce_price) - Number(price)) / Number(price)) * 100
|
||||||
|
}
|
||||||
|
return `${res.toFixed(2)}%` // 取绝对值并保留两位小数
|
||||||
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1658,11 +1729,17 @@ export default {
|
|||||||
},
|
},
|
||||||
// 获取杠杆api用户
|
// 获取杠杆api用户
|
||||||
getListLineApiUser(exchangeType) {
|
getListLineApiUser(exchangeType) {
|
||||||
listLineApiUser({ pageIndex: 1, pageSize: 999, exchangeType: exchangeType || this.form.exchange_type }).then(response => {
|
listLineApiUser({ pageIndex: 1, pageSize: 999, exchangeType: exchangeType || this.form.exchange_type, openStatus: 1 }).then(response => {
|
||||||
this.lineUsers = response.data.list
|
this.lineUsers = response.data.list
|
||||||
this.lineTotal = response.data.count
|
this.lineTotal = response.data.count
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 获取api用户分组
|
||||||
|
getApiUserGroupList(exchangeType) {
|
||||||
|
getLineApiUserGroupList({ exchangeType: exchangeType || this.form.exchange_type }).then(response => {
|
||||||
|
this.apiUserGroupList = response.data
|
||||||
|
})
|
||||||
|
},
|
||||||
// 交易对列表
|
// 交易对列表
|
||||||
getSymbol(e, type, exchangeType) {
|
getSymbol(e, type, exchangeType) {
|
||||||
this.searchLoding = true
|
this.searchLoding = true
|
||||||
@ -1866,6 +1943,7 @@ export default {
|
|||||||
this.getListLineApiUser(this.modeForm.exchangeType)
|
this.getListLineApiUser(this.modeForm.exchangeType)
|
||||||
this.getSymbol({}, 2, this.modeForm.exchangeType)
|
this.getSymbol({}, 2, this.modeForm.exchangeType)
|
||||||
this.getSymbolGroup(2, this.modeForm.exchangeType)
|
this.getSymbolGroup(2, this.modeForm.exchangeType)
|
||||||
|
// this.getApiUserGroupList()
|
||||||
this.mode.modeOpen = true
|
this.mode.modeOpen = true
|
||||||
},
|
},
|
||||||
modeCancel() {
|
modeCancel() {
|
||||||
@ -1947,7 +2025,8 @@ export default {
|
|||||||
is_auto_scale: undefined,
|
is_auto_scale: undefined,
|
||||||
close_type: undefined,
|
close_type: undefined,
|
||||||
direction: undefined,
|
direction: undefined,
|
||||||
|
api_id_type: 1,
|
||||||
|
api_user_group_id: undefined,
|
||||||
reduce_price: 0,
|
reduce_price: 0,
|
||||||
reduce_num: 0,
|
reduce_num: 0,
|
||||||
reduce_take_profit: 0,
|
reduce_take_profit: 0,
|
||||||
@ -2004,7 +2083,7 @@ export default {
|
|||||||
},
|
},
|
||||||
validateReducePrice(rule, value, callback) {
|
validateReducePrice(rule, value, callback) {
|
||||||
if (value === 0 || value === undefined || value === null || value === '') {
|
if (value === 0 || value === undefined || value === null || value === '') {
|
||||||
callback(new Error('亏损百分比必须大于0'))
|
callback(new Error('必须大于0'))
|
||||||
} else {
|
} else {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
@ -2059,9 +2138,9 @@ export default {
|
|||||||
validateProfit(rule, value, callback) {
|
validateProfit(rule, value, callback) {
|
||||||
console.log(this.form)
|
console.log(this.form)
|
||||||
if (this.form.profit === '' || this.form.profit === undefined || this.form.profit === null) {
|
if (this.form.profit === '' || this.form.profit === undefined || this.form.profit === null) {
|
||||||
callback(new Error('止盈百分比不能为空'))
|
callback(new Error('不能为空'))
|
||||||
} else if (this.form.profit <= 0) {
|
} else if (this.form.profit <= 0) {
|
||||||
callback(new Error('止盈百分比不能小于0'))
|
callback(new Error('不能小于0'))
|
||||||
} else {
|
} else {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
@ -2170,6 +2249,7 @@ export default {
|
|||||||
this.title = title || '添加委托管理'
|
this.title = title || '添加委托管理'
|
||||||
this.reset()
|
this.reset()
|
||||||
this.getListLineApiUser()
|
this.getListLineApiUser()
|
||||||
|
this.getApiUserGroupList()
|
||||||
this.open = true
|
this.open = true
|
||||||
this.isEdit = false
|
this.isEdit = false
|
||||||
},
|
},
|
||||||
@ -2179,6 +2259,27 @@ export default {
|
|||||||
this.single = selection.length !== 1
|
this.single = selection.length !== 1
|
||||||
this.multiple = !selection.length
|
this.multiple = !selection.length
|
||||||
},
|
},
|
||||||
|
/* 切换用户选择 */
|
||||||
|
apiIdTypeChange() {
|
||||||
|
this.form.api_id = undefined
|
||||||
|
this.form.api_user_group_id = undefined
|
||||||
|
},
|
||||||
|
/* 用户分组选中 */
|
||||||
|
apiUserGroupChange(selection) {
|
||||||
|
if (selection) {
|
||||||
|
// 过滤出匹配的项
|
||||||
|
const matchedGroup = this.apiUserGroupList.find(x => x.id === selection)
|
||||||
|
|
||||||
|
console.log(matchedGroup)
|
||||||
|
console.log(this.form.api_user_group_id)
|
||||||
|
// 确保 matchedGroup 存在,并且有 value 数组
|
||||||
|
if (matchedGroup && matchedGroup.value) {
|
||||||
|
this.form.api_id = matchedGroup.value // 转字符串
|
||||||
|
} else {
|
||||||
|
this.form.api_id = undefined // 处理未找到的情况
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.title = '修改委托管理'
|
this.title = '修改委托管理'
|
||||||
@ -2230,7 +2331,16 @@ export default {
|
|||||||
delete params.symbol
|
delete params.symbol
|
||||||
batchAddOrder(params).then(response => {
|
batchAddOrder(params).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.msgSuccess(response.msg)
|
if (response.data !== '') {
|
||||||
|
this.$notify({
|
||||||
|
title: '部分失败',
|
||||||
|
message: response.data,
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.msgSuccess(response.msg)
|
||||||
|
}
|
||||||
|
|
||||||
this.open = false
|
this.open = false
|
||||||
this.getList()
|
this.getList()
|
||||||
} else {
|
} else {
|
||||||
@ -2253,7 +2363,16 @@ export default {
|
|||||||
api_id: this.form.api_id.toString()
|
api_id: this.form.api_id.toString()
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.msgSuccess(response.msg)
|
if (response.data !== '') {
|
||||||
|
this.$notify({
|
||||||
|
title: '部分失败',
|
||||||
|
message: response.data,
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.msgSuccess(response.msg)
|
||||||
|
}
|
||||||
|
|
||||||
this.open = false
|
this.open = false
|
||||||
this.getList()
|
this.getList()
|
||||||
} else {
|
} else {
|
||||||
@ -2265,11 +2384,6 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// this.$refs['form'].validate(valid => {
|
|
||||||
// if (valid) {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
},
|
},
|
||||||
onCancel() {
|
onCancel() {
|
||||||
this.cancelOpen = true
|
this.cancelOpen = true
|
||||||
@ -2393,13 +2507,13 @@ export default {
|
|||||||
// 转换为年
|
// 转换为年
|
||||||
const diffInYears = diffInMilliseconds / (1000 * 60 * 60 * 24 * 365.25)
|
const diffInYears = diffInMilliseconds / (1000 * 60 * 60 * 24 * 365.25)
|
||||||
|
|
||||||
console.log('2222', diffInYears)
|
// console.log('2222', diffInYears)
|
||||||
console.log('xxxx', diffInYears > 1)
|
// console.log('xxxx', diffInYears > 1)
|
||||||
if (diffInYears > 1) {
|
if (diffInYears > 1) {
|
||||||
return ''
|
return ''
|
||||||
} else {
|
} else {
|
||||||
const dateStr = this.parseTime(expirateTime)
|
const dateStr = this.parseTime(expirateTime)
|
||||||
console.log('3333', dateStr)
|
// console.log('3333', dateStr)
|
||||||
return dateStr
|
return dateStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -315,7 +315,8 @@ export default {
|
|||||||
paths: undefined,
|
paths: undefined,
|
||||||
action: undefined,
|
action: undefined,
|
||||||
parentId: undefined,
|
parentId: undefined,
|
||||||
sort: undefined
|
sort: undefined,
|
||||||
|
type: 'BUS'
|
||||||
}
|
}
|
||||||
this.resetForm('form')
|
this.resetForm('form')
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user