1、减仓策略
2、下单策略模板 3、缓存交易对价格
This commit is contained in:
@ -82,13 +82,6 @@ export function orderMarginType(data) {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export function manuallyCover(data) {
|
|
||||||
return request({
|
|
||||||
url: '/api/v1/line-pre-order/manuallyCover',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export function closePosition(data) {
|
export function closePosition(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/v1/line-pre-order/closePosition',
|
url: '/api/v1/line-pre-order/closePosition',
|
||||||
|
|||||||
46
src/api/admin/line-reduce-strategy.js
Normal file
46
src/api/admin/line-reduce-strategy.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询LineReduceStrategy列表
|
||||||
|
export function listLineReduceStrategy(query) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-reduce-strategy',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询LineReduceStrategy详细
|
||||||
|
export function getLineReduceStrategy(id) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-reduce-strategy/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增LineReduceStrategy
|
||||||
|
export function addLineReduceStrategy(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-reduce-strategy',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改LineReduceStrategy
|
||||||
|
export function updateLineReduceStrategy(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-reduce-strategy/' + data.id,
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除LineReduceStrategy
|
||||||
|
export function delLineReduceStrategy(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-reduce-strategy',
|
||||||
|
method: 'delete',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
46
src/api/admin/line-strategy-template.js
Normal file
46
src/api/admin/line-strategy-template.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询LineStrategyTemplate列表
|
||||||
|
export function listLineStrategyTemplate(query) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-strategy-template',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询LineStrategyTemplate详细
|
||||||
|
export function getLineStrategyTemplate(id) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-strategy-template/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增LineStrategyTemplate
|
||||||
|
export function addLineStrategyTemplate(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-strategy-template',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改LineStrategyTemplate
|
||||||
|
export function updateLineStrategyTemplate(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-strategy-template/' + data.id,
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除LineStrategyTemplate
|
||||||
|
export function delLineStrategyTemplate(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-strategy-template',
|
||||||
|
method: 'delete',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
46
src/api/admin/line-symbol-price.js
Normal file
46
src/api/admin/line-symbol-price.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询LineSymbolPrice列表
|
||||||
|
export function listLineSymbolPrice(query) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-symbol-price',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询LineSymbolPrice详细
|
||||||
|
export function getLineSymbolPrice(id) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-symbol-price/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增LineSymbolPrice
|
||||||
|
export function addLineSymbolPrice(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-symbol-price',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改LineSymbolPrice
|
||||||
|
export function updateLineSymbolPrice(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-symbol-price/' + data.id,
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除LineSymbolPrice
|
||||||
|
export function delLineSymbolPrice(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/line-symbol-price',
|
||||||
|
method: 'delete',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@ -301,6 +301,48 @@
|
|||||||
<el-form-item label="购买金额(U)" prop="buy_price">
|
<el-form-item label="购买金额(U)" prop="buy_price">
|
||||||
<el-input v-model="inForm.buy_price" placeholder="购买金额(U)" />
|
<el-input v-model="inForm.buy_price" placeholder="购买金额(U)" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="策略类型">
|
||||||
|
<el-radio-group v-model="inForm.strategy_template_type" @input="changeStrategyTemplateType">
|
||||||
|
<el-radio
|
||||||
|
v-for="(item, index) in strategyTemplateTypeOptions"
|
||||||
|
:key="'strategyTemplateType' + index"
|
||||||
|
:label="item.value"
|
||||||
|
:disabled="item.value === 1"
|
||||||
|
>{{ item.label }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="inForm.strategy_template_type === 1" label="策略模板">
|
||||||
|
<el-select
|
||||||
|
v-model="inForm.strategy_template_id"
|
||||||
|
style="width: 100%;"
|
||||||
|
placeholder="请选择策略"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
:remote-method="queryStrategyTemplate"
|
||||||
|
:loading="searchLoding"
|
||||||
|
remote
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in strategyTemplateOptions"
|
||||||
|
:key="'strategyTemplateId' + dict.id"
|
||||||
|
:label="dict.name"
|
||||||
|
:value="dict.id"
|
||||||
|
/>
|
||||||
|
<div class="page">
|
||||||
|
<pagination
|
||||||
|
v-show="strategyTemplatePagition.total > 0"
|
||||||
|
:background="false"
|
||||||
|
:total="strategyTemplatePagition.total"
|
||||||
|
layout="prev, pager, next"
|
||||||
|
:page.sync="strategyTemplatePagition.pageIndex"
|
||||||
|
:limit.sync="strategyTemplatePagition.pageSize"
|
||||||
|
@pagination="queryStrategyTemplate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="价格模式" prop="price_pattern">
|
<el-form-item label="价格模式" prop="price_pattern">
|
||||||
<el-radio-group v-model="inForm.price_pattern" @change="onchangePattern">
|
<el-radio-group v-model="inForm.price_pattern" @change="onchangePattern">
|
||||||
<el-radio label="percentage">百分比</el-radio>
|
<el-radio label="percentage">百分比</el-radio>
|
||||||
@ -439,6 +481,45 @@
|
|||||||
<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="inForm.price_pattern === 'mixture' ? '止损价格' : '止损价百分比'" prop="stop_loss">
|
||||||
|
<el-input
|
||||||
|
v-model="inForm.stop_loss"
|
||||||
|
min="0"
|
||||||
|
type="number"
|
||||||
|
:placeholder="inForm.price_pattern === 'mixture' ? '止损价格' : '止损价百分比'"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="减仓策略">
|
||||||
|
<el-select
|
||||||
|
v-model="inForm.reduce_strategy_id"
|
||||||
|
style="width: 100%;"
|
||||||
|
placeholder="请选择策略"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
:remote-method="queryReduceStrategy"
|
||||||
|
:loading="searchLoding"
|
||||||
|
remote
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in reduceStrategyPagition.reduceStrategyList"
|
||||||
|
:key="'reduce_stratefy.' + dict.id"
|
||||||
|
:label="dict.name"
|
||||||
|
:value="dict.id"
|
||||||
|
/>
|
||||||
|
<div class="page">
|
||||||
|
<pagination
|
||||||
|
v-show="reduceStrategyPagition.total > 0"
|
||||||
|
:background="false"
|
||||||
|
:total="reduceStrategyPagition.total"
|
||||||
|
layout="prev, pager, next"
|
||||||
|
:page.sync="reduceStrategyPagition.pageIndex"
|
||||||
|
:limit.sync="reduceStrategyPagition.pageSize"
|
||||||
|
@pagination="queryReduceStrategy"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="inForm.price_pattern === 'mixture' ? '主单亏损价格' : '主单亏损百分比'" prop="reduce_price">
|
<el-form-item :label="inForm.price_pattern === 'mixture' ? '主单亏损价格' : '主单亏损百分比'" prop="reduce_price">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="inForm.reduce_price"
|
v-model="inForm.reduce_price"
|
||||||
@ -664,6 +745,8 @@ 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'
|
import { getLineApiUserGroupList } from '@/api/admin/line-api-user-group'
|
||||||
|
import { listLineStrategyTemplate } from '@/api/admin/line-strategy-template'
|
||||||
|
import { listLineReduceStrategy } from '@/api/admin/line-reduce-strategy'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'LineOrderTemplateLogs',
|
name: 'LineOrderTemplateLogs',
|
||||||
@ -796,7 +879,28 @@ export default {
|
|||||||
aicoins: {},
|
aicoins: {},
|
||||||
aicoinPrice: undefined,
|
aicoinPrice: undefined,
|
||||||
ext: [],
|
ext: [],
|
||||||
re_take_profit_ratio: 0
|
re_take_profit_ratio: 0,
|
||||||
|
strategyTemplateOptions: [],
|
||||||
|
// 策略分页数据
|
||||||
|
strategyTemplatePagition: {
|
||||||
|
total: 0,
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10
|
||||||
|
},
|
||||||
|
reduceStrategyPagition: {
|
||||||
|
total: 0,
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
// 减仓策略信息
|
||||||
|
reduceStrategyList: []
|
||||||
|
},
|
||||||
|
strategyTemplateTypeOptions: [{
|
||||||
|
value: 0,
|
||||||
|
label: '无'
|
||||||
|
}, {
|
||||||
|
value: 1,
|
||||||
|
label: '波段涨跌幅'
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -855,6 +959,7 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList()
|
this.getList()
|
||||||
|
this.queryReduceStrategy()
|
||||||
// this.getLineApiUserItems()
|
// this.getLineApiUserItems()
|
||||||
this.getSymbolGroup()
|
this.getSymbolGroup()
|
||||||
// 获取交易所字典数据
|
// 获取交易所字典数据
|
||||||
@ -987,7 +1092,7 @@ export default {
|
|||||||
callback(new Error('必须输入数字'))
|
callback(new Error('必须输入数字'))
|
||||||
} else if (item.takeProfitRatio < 0 || item.stopLossRatio < 0) {
|
} else if (item.takeProfitRatio < 0 || item.stopLossRatio < 0) {
|
||||||
callback(new Error('百分比不能小于 0'))
|
callback(new Error('百分比不能小于 0'))
|
||||||
} else if (item.takeProfitRatio === 0) {
|
} else if (item.addType === 2 && item.addPositionVal < 100 && item.takeProfitRatio === 0) {
|
||||||
callback(new Error('止盈百分比不能为0'))
|
callback(new Error('止盈百分比不能为0'))
|
||||||
} else {
|
} else {
|
||||||
callback() // 校验通过
|
callback() // 校验通过
|
||||||
@ -1072,17 +1177,6 @@ export default {
|
|||||||
tpTpPriceRatio: 0,
|
tpTpPriceRatio: 0,
|
||||||
tpSlPriceRatio: 0,
|
tpSlPriceRatio: 0,
|
||||||
expirateHour: 0
|
expirateHour: 0
|
||||||
|
|
||||||
// reducePriceRatio: undefined,
|
|
||||||
// reduceNumRatio: undefined,
|
|
||||||
// reduceTakeProfitRatio: undefined,
|
|
||||||
// reduceStopLossRatio: undefined,
|
|
||||||
|
|
||||||
// takeProfitRatio: undefined,
|
|
||||||
// addPositionPriceRatio: undefined,
|
|
||||||
// addPositionOrderType: 'LIMIT',
|
|
||||||
// addPositionType: 1,
|
|
||||||
// addPositionVal: undefined
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onchangeForm() {
|
onchangeForm() {
|
||||||
@ -1223,6 +1317,36 @@ export default {
|
|||||||
this.userIdOptions = this.setItems(res, 'id', 'apiName')
|
this.userIdOptions = this.setItems(res, 'id', 'apiName')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
changeStrategyTemplateType(val) {
|
||||||
|
if (val === 1) {
|
||||||
|
this.queryStrategyTemplate()
|
||||||
|
} else {
|
||||||
|
this.form.strategy_template_id = undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
|
queryStrategyTemplate() {
|
||||||
|
this.searchLoding = true
|
||||||
|
|
||||||
|
listLineStrategyTemplate({ pageIndex: this.strategyTemplatePagition.pageIndex, pageSize: this.strategyTemplatePagition.pageSize }).then(res => {
|
||||||
|
this.strategyTemplatePagition.total = res.data.count
|
||||||
|
this.strategyTemplateOptions = res.data.list
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.searchLoding = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 查询减仓策略
|
||||||
|
queryReduceStrategy() {
|
||||||
|
this.searchLoding = true
|
||||||
|
listLineReduceStrategy({ pageIndex: this.reduceStrategyPagition.pageIndex, pageSize: this.reduceStrategyPagition.pageSize }).then(res => {
|
||||||
|
this.reduceStrategyPagition.reduceStrategyList = res.data.list
|
||||||
|
this.reduceStrategyPagition.total = res.data.count
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.searchLoding = false
|
||||||
|
})
|
||||||
|
},
|
||||||
// 文件
|
// 文件
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
@ -1288,6 +1412,10 @@ export default {
|
|||||||
symbol_group_id: x.symbol_group_id ? Number(x.symbol_group_id) : undefined
|
symbol_group_id: x.symbol_group_id ? Number(x.symbol_group_id) : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.inForm.price_pattern === 'aicoin') {
|
||||||
|
this.inForm.price = null
|
||||||
|
}
|
||||||
|
|
||||||
this.getApiUserGroupList()
|
this.getApiUserGroupList()
|
||||||
this.onchangePattern(false)
|
this.onchangePattern(false)
|
||||||
this.getListLineApiUser()
|
this.getListLineApiUser()
|
||||||
@ -1302,8 +1430,6 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm: function() {
|
submitForm: function() {
|
||||||
console.log('this.form', this.form)
|
|
||||||
console.log('this.inForm', this.inForm)
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
this.$refs['inForm'].validate(), // 验证第一个表单
|
this.$refs['inForm'].validate(), // 验证第一个表单
|
||||||
this.$refs['extForm'].validate() // 验证第二个表单
|
this.$refs['extForm'].validate() // 验证第二个表单
|
||||||
|
|||||||
@ -98,10 +98,29 @@
|
|||||||
v-model="queryParams.status"
|
v-model="queryParams.status"
|
||||||
placeholder="请选择状态"
|
placeholder="请选择状态"
|
||||||
size="small"
|
size="small"
|
||||||
|
clearable
|
||||||
>
|
>
|
||||||
<el-option v-for="dict in statuss" :key="dict.k" :label="dict.l" :value="dict.v" />
|
<el-option v-for="dict in statuss" :key="dict.k" :label="dict.l" :value="dict.v" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="下单百分比">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.percentStart"
|
||||||
|
placeholder="下单百分比"
|
||||||
|
style="width: 100px;"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
-
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.percentEnd"
|
||||||
|
placeholder="下单百分比"
|
||||||
|
style="width: 100px;"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<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-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
@ -964,7 +983,9 @@ export default {
|
|||||||
idOrder: 'desc',
|
idOrder: 'desc',
|
||||||
addPositionStatus: -1,
|
addPositionStatus: -1,
|
||||||
hedgeStatus: -1,
|
hedgeStatus: -1,
|
||||||
status: ''
|
status: '',
|
||||||
|
percentStart: undefined,
|
||||||
|
percentEnd: undefined
|
||||||
},
|
},
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {
|
form: {
|
||||||
|
|||||||
@ -69,13 +69,27 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status"><el-select
|
<el-form-item label="状态" prop="status">
|
||||||
v-model="queryParams.status"
|
<el-select v-model="queryParams.status" placeholder="请选择状态" size="small" clearable>
|
||||||
placeholder="请选择状态"
|
<el-option v-for="dict in statuss" :key="dict.k" :label="dict.l" :value="dict.v" />
|
||||||
size="small"
|
</el-select>
|
||||||
>
|
</el-form-item>
|
||||||
<el-option v-for="dict in statuss" :key="dict.k" :label="dict.l" :value="dict.v" />
|
<el-form-item label="下单百分比">
|
||||||
</el-select>
|
<el-input
|
||||||
|
v-model="queryParams.percentStart"
|
||||||
|
placeholder="下单百分比"
|
||||||
|
style="width: 100px;"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
-
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.percentEnd"
|
||||||
|
placeholder="下单百分比"
|
||||||
|
style="width: 100px;"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
@ -301,44 +315,12 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="订单描述" align="center" prop="desc" :show-overflow-tooltip="true" />
|
<el-table-column label="订单描述" align="center" prop="desc" :show-overflow-tooltip="true" />
|
||||||
<!-- <el-table-column
|
|
||||||
label="对冲状态"
|
|
||||||
align="center"
|
|
||||||
prop="status"
|
|
||||||
width="100"
|
|
||||||
:show-overflow-tooltip="true"
|
|
||||||
>
|
|
||||||
<template #default="{row}">
|
|
||||||
<el-tag v-if="row.pid===0" size="mini" :type="row.hedgeStatus===1?'success':'danger'">
|
|
||||||
{{ ['未对冲','已对冲'][row.hedgeStatus] }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column
|
|
||||||
label="加仓状态"
|
|
||||||
align="center"
|
|
||||||
prop="status"
|
|
||||||
width="100"
|
|
||||||
:show-overflow-tooltip="true"
|
|
||||||
>
|
|
||||||
<template #default="{row}">
|
|
||||||
<el-tag v-if="row.pid===0" size="mini" :type="row.addPositionStatus===1?'success':'danger'">
|
|
||||||
{{ ['未加仓','已加仓'][row.addPositionStatus] }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column> -->
|
|
||||||
<el-table-column label="计价货币" align="center" prop="quoteSymbol" :show-overflow-tooltip="true" />
|
<el-table-column label="计价货币" align="center" prop="quoteSymbol" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="交易所" align="center" prop="exchangeType" :show-overflow-tooltip="true">
|
<el-table-column label="交易所" align="center" prop="exchangeType" :show-overflow-tooltip="true">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{ exchangeTypeFormat(row) }}
|
{{ exchangeTypeFormat(row) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<!-- <el-table-column
|
|
||||||
label="预估方向"
|
|
||||||
align="center"
|
|
||||||
prop="direction"
|
|
||||||
:show-overflow-tooltip="true"
|
|
||||||
/> -->
|
|
||||||
<el-table-column label="订单号" align="center" prop="orderSn" width="200" :show-overflow-tooltip="true" />
|
<el-table-column label="订单号" align="center" prop="orderSn" width="200" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="触发时间" align="center" prop="triggerTime" width="150" :show-overflow-tooltip="true">
|
<el-table-column label="触发时间" align="center" prop="triggerTime" width="150" :show-overflow-tooltip="true">
|
||||||
<template #default="{ row }">{{ row.triggerTime && parseTime(row.triggerTime) }}</template>
|
<template #default="{ row }">{{ row.triggerTime && parseTime(row.triggerTime) }}</template>
|
||||||
@ -351,21 +333,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150" fixed="right">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150" fixed="right">
|
||||||
<template v-if="scope.row.pid === 0" slot-scope="scope">
|
<template v-if="scope.row.pid === 0" slot-scope="scope">
|
||||||
<!-- <el-popconfirm
|
|
||||||
class="delete-popconfirm"
|
|
||||||
title="确认要修改吗?"
|
|
||||||
confirm-button-text="修改"
|
|
||||||
@confirm="handleUpdate(scope.row)"
|
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
slot="reference"
|
|
||||||
v-permisaction="['admin:linePreOrder:edit']"
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-edit"
|
|
||||||
>修改
|
|
||||||
</el-button>
|
|
||||||
</el-popconfirm> -->
|
|
||||||
<el-popconfirm
|
<el-popconfirm
|
||||||
class="delete-popconfirm"
|
class="delete-popconfirm"
|
||||||
title="确认要取消委托吗?"
|
title="确认要取消委托吗?"
|
||||||
@ -432,14 +400,6 @@
|
|||||||
<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="对冲类型" prop="cover_type">
|
|
||||||
<el-radio-group v-model="form.cover_type">
|
|
||||||
<el-radio :label="0">无对冲</el-radio>
|
|
||||||
<el-radio :label="1" :disabled="form.symbol_type==2">现货对合约</el-radio>
|
|
||||||
<el-radio :label="2" :disabled="form.symbol_type==1">合约对合约</el-radio>
|
|
||||||
<el-radio :label="3" :disabled="form.symbol_type==1">合约对现货</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item> -->
|
|
||||||
<el-form-item label="api用户类型" prop="api_id_type">
|
<el-form-item label="api用户类型" prop="api_id_type">
|
||||||
<el-radio-group v-model="form.api_id_type" @change="apiIdTypeChange">
|
<el-radio-group v-model="form.api_id_type" @change="apiIdTypeChange">
|
||||||
<el-radio :label="1">单个</el-radio>
|
<el-radio :label="1">单个</el-radio>
|
||||||
@ -543,6 +503,47 @@
|
|||||||
<el-form-item label="购买金额(U)" prop="buy_price">
|
<el-form-item label="购买金额(U)" prop="buy_price">
|
||||||
<el-input v-model="form.buy_price" placeholder="购买金额(U)" />
|
<el-input v-model="form.buy_price" placeholder="购买金额(U)" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="策略类型">
|
||||||
|
<el-radio-group v-model="form.strategy_template_type" @input="changeStrategyTemplateType">
|
||||||
|
<el-radio
|
||||||
|
v-for="(item, index) in strategyTemplateTypeOptions"
|
||||||
|
:key="'strategyTemplateType' + index"
|
||||||
|
:label="item.value"
|
||||||
|
:disabled="item.value === 1"
|
||||||
|
>{{ item.label }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="form.strategy_template_type === 1" label="策略模板">
|
||||||
|
<el-select
|
||||||
|
v-model="form.strategy_template_id"
|
||||||
|
style="width: 100%;"
|
||||||
|
placeholder="请选择策略"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
:remote-method="queryStrategyTemplate"
|
||||||
|
:loading="searchLoding"
|
||||||
|
remote
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in strategyTemplateOptions"
|
||||||
|
:key="'strategyTemplateId' + dict.id"
|
||||||
|
:label="dict.name"
|
||||||
|
:value="dict.id"
|
||||||
|
/>
|
||||||
|
<div class="page">
|
||||||
|
<pagination
|
||||||
|
v-show="strategyTemplatePagition.total > 0"
|
||||||
|
:background="false"
|
||||||
|
:total="strategyTemplatePagition.total"
|
||||||
|
layout="prev, pager, next"
|
||||||
|
:page.sync="strategyTemplatePagition.pageIndex"
|
||||||
|
:limit.sync="strategyTemplatePagition.pageSize"
|
||||||
|
@pagination="queryStrategyTemplate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="价格模式" prop="price_pattern">
|
<el-form-item label="价格模式" prop="price_pattern">
|
||||||
<el-radio-group v-model="form.price_pattern">
|
<el-radio-group v-model="form.price_pattern">
|
||||||
<el-radio label="percentage">百分比</el-radio>
|
<el-radio label="percentage">百分比</el-radio>
|
||||||
@ -605,91 +606,13 @@
|
|||||||
<el-form-item label="第二止损价百分比" prop="profit_tp_sl_price_ratio">
|
<el-form-item label="第二止损价百分比" prop="profit_tp_sl_price_ratio">
|
||||||
<el-input v-model="form.profit_tp_sl_price_ratio" placeholder="第二止损价百分比" />
|
<el-input v-model="form.profit_tp_sl_price_ratio" placeholder="第二止损价百分比" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-form-item label="亏损百分比" prop="stop_price">
|
|
||||||
<el-input
|
|
||||||
v-model="form.stop_price"
|
|
||||||
placeholder="亏损百分比"
|
|
||||||
/>
|
|
||||||
</el-form-item> -->
|
|
||||||
<!-- <template v-if="form.cover_type!=0">
|
|
||||||
<el-form-item label="对冲单购买类型" prop="hedge_buy_type">
|
|
||||||
<el-radio-group v-model="form.hedge_buy_type">
|
|
||||||
<el-radio :label="1">百分比</el-radio>
|
|
||||||
<el-radio :label="2">实际金额</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="对冲总购买金额" prop="HedgeBuyTotal">
|
|
||||||
<el-input
|
|
||||||
v-model.number="form.HedgeBuyTotal"
|
|
||||||
type="number"
|
|
||||||
placeholder="对冲总购买金额"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="对冲止盈百分比" prop="HedgeTakeProfit">
|
|
||||||
<el-input
|
|
||||||
v-model.number="form.HedgeTakeProfit"
|
|
||||||
type="number"
|
|
||||||
placeholder="对冲止盈百分比"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="对冲止损百分比" prop="HedgeStopLoss">
|
|
||||||
<el-input
|
|
||||||
v-model.number="form.HedgeStopLoss"
|
|
||||||
type="number"
|
|
||||||
placeholder="对冲止损百分比
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template> -->
|
|
||||||
<!-- <el-form-item label="对冲百分比" prop="cover_rate">
|
|
||||||
<el-input
|
|
||||||
v-model="form.cover_rate"
|
|
||||||
placeholder="对冲百分比"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="加仓后盈利比例" prop="profit_rate">
|
|
||||||
<el-input
|
|
||||||
v-model="form.profit_rate"
|
|
||||||
placeholder="加仓后盈利比例"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="对冲平仓最大次数" prop="hedge_close_count">
|
|
||||||
<el-input
|
|
||||||
v-model.number="form.hedge_close_count"
|
|
||||||
type="number"
|
|
||||||
placeholder="对冲平仓最大次数"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="随机对冲百分比" prop="hedge_trigger_percent">
|
|
||||||
<el-row :gutter="20">
|
|
||||||
<el-col :span="11"><el-input v-model.number="form.hedge_trigger_percent" type="number" placeholder="最小值"><template #append>最小值</template></el-input></el-col>
|
|
||||||
<el-col :span="11"><el-input v-model.number="form.hedge_trigger_percent_max" type="number" placeholder="最大值"><template #append>最大值</template></el-input></el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form-item> -->
|
|
||||||
<el-form-item label="主单类型" prop="main_order_type">
|
<el-form-item label="主单类型" prop="main_order_type">
|
||||||
<el-radio-group v-model="form.main_order_type">
|
<el-radio-group v-model="form.main_order_type">
|
||||||
<el-radio label="LIMIT">限价</el-radio>
|
<el-radio label="LIMIT">限价</el-radio>
|
||||||
<el-radio label="MARKET">市价</el-radio>
|
<el-radio label="MARKET">市价</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-form-item label="对冲单下单类型" prop="hedge_order_type">
|
|
||||||
<el-radio-group v-model="form.hedge_order_type">
|
|
||||||
<el-radio label="LIMIT">限价</el-radio>
|
|
||||||
<el-radio label="MARKET">市价</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item> -->
|
|
||||||
<!-- <el-form-item label="加仓主单类型" prop="add_position_main_type">
|
|
||||||
<el-radio-group v-model="form.add_position_main_type">
|
|
||||||
<el-radio label="LIMIT">限价</el-radio>
|
|
||||||
<el-radio label="MARKET">市价</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="加仓对冲单类型" prop="add_position_hedge_type">
|
|
||||||
<el-radio-group v-model="form.add_position_hedge_type">
|
|
||||||
<el-radio label="LIMIT">限价</el-radio>
|
|
||||||
<el-radio label="MARKET">市价</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item> -->
|
|
||||||
<el-form-item label="对标价类型" prop="price_type">
|
<el-form-item label="对标价类型" prop="price_type">
|
||||||
<el-radio-group v-model="form.price_type">
|
<el-radio-group v-model="form.price_type">
|
||||||
<el-radio label="new">最新价</el-radio>
|
<el-radio label="new">最新价</el-radio>
|
||||||
@ -711,6 +634,45 @@
|
|||||||
<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="form.price_pattern === 'mixture' ? '止损价格' : '止损价百分比'" prop="stop_loss">
|
||||||
|
<el-input
|
||||||
|
v-model="form.stop_loss"
|
||||||
|
min="0"
|
||||||
|
type="number"
|
||||||
|
:placeholder="form.price_pattern === 'mixture' ? '止损价格' : '止损价百分比'"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="减仓策略">
|
||||||
|
<el-select
|
||||||
|
v-model="form.reduce_strategy_id"
|
||||||
|
style="width: 100%;"
|
||||||
|
placeholder="请选择策略"
|
||||||
|
clearable
|
||||||
|
filterable
|
||||||
|
:remote-method="queryReduceStrategy"
|
||||||
|
:loading="searchLoding"
|
||||||
|
remote
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in reduceStrategyPagition.reduceStrategyList"
|
||||||
|
:key="'reduce_stratefy.' + dict.id"
|
||||||
|
:label="dict.name"
|
||||||
|
:value="dict.id"
|
||||||
|
/>
|
||||||
|
<div class="page">
|
||||||
|
<pagination
|
||||||
|
v-show="reduceStrategyPagition.total > 0"
|
||||||
|
:background="false"
|
||||||
|
:total="reduceStrategyPagition.total"
|
||||||
|
layout="prev, pager, next"
|
||||||
|
:page.sync="reduceStrategyPagition.pageIndex"
|
||||||
|
:limit.sync="reduceStrategyPagition.pageSize"
|
||||||
|
@pagination="queryReduceStrategy"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label="form.price_pattern === 'mixture' ? '主单亏损价格' : '主单亏损百分比'" prop="reduce_price">
|
<el-form-item :label="form.price_pattern === 'mixture' ? '主单亏损价格' : '主单亏损百分比'" prop="reduce_price">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.reduce_price"
|
v-model="form.reduce_price"
|
||||||
@ -1015,114 +977,6 @@
|
|||||||
<el-button @click="modeCancel">取 消</el-button>
|
<el-button @click="modeCancel">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<!-- 加仓 -->
|
|
||||||
<el-dialog title="加仓" :visible.sync="storeOpen" width="700px" :close-on-click-modal="false">
|
|
||||||
<el-form ref="formStore" :model="storeForm" :rules="storeRules" label-width="120px">
|
|
||||||
<el-form-item label="交易所" prop="exchangeType">
|
|
||||||
<el-select
|
|
||||||
v-model="storeForm.exchangeType"
|
|
||||||
style="width: 100%;"
|
|
||||||
placeholder="请选择交易所"
|
|
||||||
clearable
|
|
||||||
filterable
|
|
||||||
size="small"
|
|
||||||
>
|
|
||||||
<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="api用户" prop="api_id">
|
|
||||||
<el-select
|
|
||||||
v-model="storeForm.api_id"
|
|
||||||
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" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="加仓账户" prop="cover_account">
|
|
||||||
<el-radio-group v-model="storeForm.cover_account">
|
|
||||||
<el-radio :label="1">加仓主账号</el-radio>
|
|
||||||
<el-radio :label="2">加仓副账号</el-radio>
|
|
||||||
<el-radio :label="3">都加</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="加仓交易对类型" prop="symbol_type">
|
|
||||||
<el-radio-group v-model="storeForm.symbol_type">
|
|
||||||
<el-radio :label="1">现货</el-radio>
|
|
||||||
<el-radio :label="2">合约</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="加仓交易对" prop="symbols">
|
|
||||||
<el-select
|
|
||||||
v-model="storeForm.symbols"
|
|
||||||
style="width: 100%;"
|
|
||||||
placeholder="请选择加仓交易对"
|
|
||||||
clearable
|
|
||||||
multiple
|
|
||||||
filterable
|
|
||||||
:remote-method="(e) => getSymbol(e, storeForm.symbol_type, storeForm.exchangeType)"
|
|
||||||
:loading="searchLoding"
|
|
||||||
remote
|
|
||||||
size="small"
|
|
||||||
>
|
|
||||||
<el-option v-for="dict in symbol.symbolList" :key="dict.id" :label="dict.symbol" :value="dict.symbol" />
|
|
||||||
<div class="page">
|
|
||||||
<pagination
|
|
||||||
v-show="symbol.total > 0"
|
|
||||||
:background="false"
|
|
||||||
:total="symbol.total"
|
|
||||||
layout="prev, pager, next"
|
|
||||||
:page.sync="symbol.pageIndex"
|
|
||||||
:limit.sync="symbol.pageSize"
|
|
||||||
@pagination="getSymbol($event, storeForm.symbol_type, storeForm.exchangeType)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="加仓主账号类型" prop="cover_account_a_type">
|
|
||||||
<el-radio-group v-model="storeForm.cover_account_a_type">
|
|
||||||
<el-radio label="MARKET">市价</el-radio>
|
|
||||||
<el-radio label="LIMIT">限价</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item
|
|
||||||
v-if="storeForm.cover_account_a_type === 'LIMIT'"
|
|
||||||
label="加仓主账号限价比例"
|
|
||||||
prop="cover_account_a_rate"
|
|
||||||
>
|
|
||||||
<el-input v-model="storeForm.cover_account_a_rate" placeholder="加仓主账号限价比例" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="加仓副账号类型" prop="cover_account_b_type">
|
|
||||||
<el-radio-group v-model="storeForm.cover_account_b_type">
|
|
||||||
<el-radio label="MARKET">市价</el-radio>
|
|
||||||
<el-radio label="LIMIT">限价</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item
|
|
||||||
v-if="storeForm.cover_account_b_type === 'LIMIT'"
|
|
||||||
label="加仓副账号限价比例"
|
|
||||||
prop="cover_account_b_rate"
|
|
||||||
>
|
|
||||||
<el-input v-model="storeForm.cover_account_b_rate" placeholder="加仓副账号限价比例" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="加仓类型" prop="cover_type">
|
|
||||||
<el-radio-group v-model="storeForm.cover_type">
|
|
||||||
<el-radio :label="1">百分比</el-radio>
|
|
||||||
<el-radio :label="2">金额</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item :label="`加仓数值${storeForm.cover_type === 2 ? '(U)' : ''}`" prop="value">
|
|
||||||
<el-input v-model="storeForm.value" :placeholder="`加仓数值${storeForm.cover_type === 2 ? '(U)' : ''}`" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div slot="footer" class="dialog-footer">
|
|
||||||
<el-button type="primary" @click="storeConfirm">确 定</el-button>
|
|
||||||
<el-button @click="storeCancel">取 消</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
<!-- 平仓 -->
|
<!-- 平仓 -->
|
||||||
<el-dialog title="平仓" :visible.sync="positionOpen" width="700px" :close-on-click-modal="false">
|
<el-dialog title="平仓" :visible.sync="positionOpen" width="700px" :close-on-click-modal="false">
|
||||||
<el-form ref="formPosition" :model="positionForm" :rules="positionRules" label-width="120px">
|
<el-form ref="formPosition" :model="positionForm" :rules="positionRules" label-width="120px">
|
||||||
@ -1272,10 +1126,13 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listLineSymbol, getSameSymbol } from '@/api/admin/line-symbol'
|
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, 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'
|
import { getLineApiUserGroupList } from '@/api/admin/line-api-user-group'
|
||||||
|
import { listLineStrategyTemplate } from '@/api/admin/line-strategy-template'
|
||||||
|
import { listLineReduceStrategy } from '@/api/admin/line-reduce-strategy'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'LinePreOrder',
|
name: 'LinePreOrder',
|
||||||
data() {
|
data() {
|
||||||
@ -1296,18 +1153,6 @@ export default {
|
|||||||
{ v: 2, l: '止损' },
|
{ v: 2, l: '止损' },
|
||||||
{ v: 3, l: '平仓' },
|
{ v: 3, l: '平仓' },
|
||||||
{ v: 4, l: '减仓' }
|
{ v: 4, l: '减仓' }
|
||||||
// { v: 1, l: '现货' },
|
|
||||||
// { v: 2, l: '合约' },
|
|
||||||
// { v: 3, l: '合约止盈' },
|
|
||||||
// { v: 4, l: '合约亏损' },
|
|
||||||
// { v: 5, l: '现货止盈' },
|
|
||||||
// { v: 6, l: '现货亏损' },
|
|
||||||
// { v: 7, l: '现货对冲' },
|
|
||||||
// { v: 8, l: '现货加仓' },
|
|
||||||
// { v: 9, l: '现货平仓' },
|
|
||||||
// { v: 10, l: '合约对冲' },
|
|
||||||
// { v: 11, l: '合约加仓' },
|
|
||||||
// { v: 12, l: '合约平仓' }
|
|
||||||
],
|
],
|
||||||
buyer: [
|
buyer: [
|
||||||
{ v: 'BUY', l: '买(多)' },
|
{ v: 'BUY', l: '买(多)' },
|
||||||
@ -1335,20 +1180,6 @@ export default {
|
|||||||
{ v: 7, l: '未知' },
|
{ v: 7, l: '未知' },
|
||||||
{ v: 8, l: '未知' },
|
{ v: 8, l: '未知' },
|
||||||
{ v: 9, l: '已平仓' }
|
{ v: 9, l: '已平仓' }
|
||||||
// { v: 0, l: '待触发' },
|
|
||||||
// { v: 1, l: '已触发' },
|
|
||||||
// { v: 2, l: '下单失败' },
|
|
||||||
// { v: 3, l: '已记录' },
|
|
||||||
// { v: 4, l: '已取消' },
|
|
||||||
// { v: 5, l: '委托中' },
|
|
||||||
// { v: 6, l: '已平仓' },
|
|
||||||
// { v: 7, l: '已补单' },
|
|
||||||
// { v: 8, l: '补单失败' },
|
|
||||||
// { v: 9, l: '现货已成交' },
|
|
||||||
// { v: 10, l: '合约已补单' },
|
|
||||||
// { v: 11, l: '合约补单失败' },
|
|
||||||
// { v: 12, l: '合约已成交' },
|
|
||||||
// { v: 13, l: '已开仓' }
|
|
||||||
],
|
],
|
||||||
statuss: [
|
statuss: [
|
||||||
{ v: 0, l: '待触发' },
|
{ v: 0, l: '待触发' },
|
||||||
@ -1390,6 +1221,14 @@ export default {
|
|||||||
apiIdOptions: [],
|
apiIdOptions: [],
|
||||||
// api用户分组
|
// api用户分组
|
||||||
apiUserGroupList: [],
|
apiUserGroupList: [],
|
||||||
|
strategyTemplateTypeOptions: [{
|
||||||
|
value: 0,
|
||||||
|
label: '无'
|
||||||
|
}, {
|
||||||
|
value: 1,
|
||||||
|
label: '波段涨跌幅'
|
||||||
|
}],
|
||||||
|
strategyTemplateOptions: [],
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
@ -1405,7 +1244,9 @@ export default {
|
|||||||
idOrder: 'desc',
|
idOrder: 'desc',
|
||||||
addPositionStatus: -1,
|
addPositionStatus: -1,
|
||||||
hedgeStatus: -1,
|
hedgeStatus: -1,
|
||||||
status: ''
|
status: '',
|
||||||
|
percentStart: undefined,
|
||||||
|
percentEnd: undefined
|
||||||
},
|
},
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {
|
form: {
|
||||||
@ -1416,6 +1257,7 @@ export default {
|
|||||||
{ 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' }],
|
||||||
|
stop_loss: [{ required: true, message: '请输入止损', trigger: 'blur' }, { validator: this.validateStopLoss, 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' }],
|
||||||
@ -1474,6 +1316,19 @@ export default {
|
|||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 6
|
pageSize: 6
|
||||||
},
|
},
|
||||||
|
// 策略分页数据
|
||||||
|
strategyTemplatePagition: {
|
||||||
|
total: 0,
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10
|
||||||
|
},
|
||||||
|
reduceStrategyPagition: {
|
||||||
|
total: 0,
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
// 减仓策略信息
|
||||||
|
reduceStrategyList: []
|
||||||
|
},
|
||||||
percenter: undefined,
|
percenter: undefined,
|
||||||
// 交易对组
|
// 交易对组
|
||||||
batchOpen: false,
|
batchOpen: false,
|
||||||
@ -1604,12 +1459,6 @@ export default {
|
|||||||
this.getSymbol({})
|
this.getSymbol({})
|
||||||
this.getSymbolGroup(this.form.symbol_type, this.form.exchange_type)
|
this.getSymbolGroup(this.form.symbol_type, this.form.exchange_type)
|
||||||
},
|
},
|
||||||
// 'form.cover_type'(newValue) {
|
|
||||||
// if (newValue === 3) {
|
|
||||||
// this.form.symbol = undefined
|
|
||||||
// this.getSymbol({})
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
'form.price_pattern'(newValue) {
|
'form.price_pattern'(newValue) {
|
||||||
if (newValue === 'aicoin') {
|
if (newValue === 'aicoin') {
|
||||||
this.aicoinPrice = undefined
|
this.aicoinPrice = undefined
|
||||||
@ -1637,6 +1486,7 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.getList()
|
this.getList()
|
||||||
this.getSymbolGroup()
|
this.getSymbolGroup()
|
||||||
|
this.queryReduceStrategy()
|
||||||
// this.getLineApiUserItems()
|
// this.getLineApiUserItems()
|
||||||
// this.getListLineApiUser()
|
// this.getListLineApiUser()
|
||||||
// 获取交易所字典数据
|
// 获取交易所字典数据
|
||||||
@ -1703,6 +1553,13 @@ export default {
|
|||||||
// this.getLineApiUserItems(this.cancelForm.exchangeType)
|
// this.getLineApiUserItems(this.cancelForm.exchangeType)
|
||||||
this.getListLineApiUser(this.cancelForm.exchangeType)
|
this.getListLineApiUser(this.cancelForm.exchangeType)
|
||||||
},
|
},
|
||||||
|
changeStrategyTemplateType(val) {
|
||||||
|
if (val === 1) {
|
||||||
|
this.queryStrategyTemplate()
|
||||||
|
} else {
|
||||||
|
this.form.strategy_template_id = undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
onchangeMode() {
|
onchangeMode() {
|
||||||
this.getListLineApiUser(this.modeForm.exchangeType)
|
this.getListLineApiUser(this.modeForm.exchangeType)
|
||||||
this.getSymbol({}, 2, this.modeForm.exchangeType)
|
this.getSymbol({}, 2, this.modeForm.exchangeType)
|
||||||
@ -1753,6 +1610,28 @@ export default {
|
|||||||
this.searchLoding = false
|
this.searchLoding = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
queryStrategyTemplate() {
|
||||||
|
this.searchLoding = true
|
||||||
|
|
||||||
|
listLineStrategyTemplate({ pageIndex: this.strategyTemplatePagition.pageIndex, pageSize: this.strategyTemplatePagition.pageSize }).then(res => {
|
||||||
|
this.strategyTemplatePagition.total = res.data.count
|
||||||
|
this.strategyTemplateOptions = res.data.list
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.searchLoding = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 查询减仓策略
|
||||||
|
queryReduceStrategy() {
|
||||||
|
this.searchLoding = true
|
||||||
|
listLineReduceStrategy({ pageIndex: this.reduceStrategyPagition.pageIndex, pageSize: this.reduceStrategyPagition.pageSize }).then(res => {
|
||||||
|
this.reduceStrategyPagition.reduceStrategyList = res.data.list
|
||||||
|
this.reduceStrategyPagition.total = res.data.count
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.searchLoding = false
|
||||||
|
})
|
||||||
|
},
|
||||||
// 获取交易对组
|
// 获取交易对组
|
||||||
getSymbolGroup(type = 2, exchangeType) {
|
getSymbolGroup(type = 2, exchangeType) {
|
||||||
listLineSymbolGroup({ pageIndex: 1, pageSize: 999, beginTime: undefined, endTime: undefined, type, exchangeType: exchangeType || this.form.exchange_type }).then(res => {
|
listLineSymbolGroup({ pageIndex: 1, pageSize: 999, beginTime: undefined, endTime: undefined, type, exchangeType: exchangeType || this.form.exchange_type }).then(res => {
|
||||||
@ -1880,57 +1759,6 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onStore() {
|
|
||||||
this.title = ''
|
|
||||||
this.storeForm = {
|
|
||||||
exchangeType: this.exchangeTypes.length ? this.exchangeTypes[0].value : '',
|
|
||||||
api_id: undefined,
|
|
||||||
cover_account: 1,
|
|
||||||
symbol_type: 1,
|
|
||||||
symbols: undefined,
|
|
||||||
cover_account_a_type: 'MARKET',
|
|
||||||
cover_account_b_type: 'MARKET',
|
|
||||||
cover_account_a_rate: undefined,
|
|
||||||
cover_account_b_rate: undefined,
|
|
||||||
cover_type: 1,
|
|
||||||
value: undefined
|
|
||||||
}
|
|
||||||
this.resetForm('formStore')
|
|
||||||
this.getSymbol({}, 1)
|
|
||||||
this.storeOpen = true
|
|
||||||
},
|
|
||||||
storeCancel() {
|
|
||||||
this.storeOpen = false
|
|
||||||
this.storeForm = {
|
|
||||||
exchangeType: this.exchangeTypes.length ? this.exchangeTypes[0].value : '',
|
|
||||||
api_id: undefined,
|
|
||||||
cover_account: 1,
|
|
||||||
symbol_type: 1,
|
|
||||||
symbols: undefined,
|
|
||||||
cover_account_a_type: 'MARKET',
|
|
||||||
cover_account_b_type: 'MARKET',
|
|
||||||
cover_account_a_rate: undefined,
|
|
||||||
cover_account_b_rate: undefined,
|
|
||||||
cover_type: 1,
|
|
||||||
value: undefined
|
|
||||||
}
|
|
||||||
this.resetForm('formStore')
|
|
||||||
},
|
|
||||||
storeConfirm() {
|
|
||||||
this.$refs['formStore'].validate((valid) => {
|
|
||||||
if (valid) {
|
|
||||||
const { symbols, api_id } = this.storeForm
|
|
||||||
manuallyCover({ ...this.storeForm, api_id: Number(api_id), symbols: symbols.toString() }).then(res => {
|
|
||||||
if (res.code === 200) {
|
|
||||||
this.msgSuccess(res.msg)
|
|
||||||
this.storeOpen = false
|
|
||||||
} else {
|
|
||||||
this.msgError(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.open = false
|
this.open = false
|
||||||
@ -2007,6 +1835,9 @@ export default {
|
|||||||
this.form = {
|
this.form = {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
api_id: undefined,
|
api_id: undefined,
|
||||||
|
strategy_template_type: 0,
|
||||||
|
strategy_template_id: undefined,
|
||||||
|
reduce_strategy_id: undefined,
|
||||||
group_id: undefined,
|
group_id: undefined,
|
||||||
quote_symbol: undefined,
|
quote_symbol: undefined,
|
||||||
sign_price: undefined,
|
sign_price: undefined,
|
||||||
@ -2120,6 +1951,16 @@ export default {
|
|||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/** 主单止损价 */
|
||||||
|
validateStopLoss(rule, value, callback) {
|
||||||
|
if (value < 0) {
|
||||||
|
callback(new Error('止损价不能小于0'))
|
||||||
|
} else if (this.form.price_pattern !== 'mixture' && value > 100) {
|
||||||
|
callback(new Error('止损价不能大于100'))
|
||||||
|
} else {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
},
|
||||||
/** 验证第二止盈止损 */
|
/** 验证第二止盈止损 */
|
||||||
validateTptpPriceRatio(rule, value, callback) {
|
validateTptpPriceRatio(rule, value, callback) {
|
||||||
if (!this.form) {
|
if (!this.form) {
|
||||||
@ -2136,7 +1977,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
validateProfit(rule, value, callback) {
|
validateProfit(rule, value, callback) {
|
||||||
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) {
|
||||||
@ -2192,7 +2032,7 @@ export default {
|
|||||||
callback(new Error('必须输入数字'))
|
callback(new Error('必须输入数字'))
|
||||||
} else if (item.takeProfitRatio < 0 || item.stopLossRatio < 0) {
|
} else if (item.takeProfitRatio < 0 || item.stopLossRatio < 0) {
|
||||||
callback(new Error('百分比不能小于 0'))
|
callback(new Error('百分比不能小于 0'))
|
||||||
} else if (item.takeProfitRatio === 0) {
|
} else if (item.addType === 2 && item.addPositionVal < 100 && item.takeProfitRatio === 0) {
|
||||||
callback(new Error('止盈百分比不能为0'))
|
callback(new Error('止盈百分比不能为0'))
|
||||||
} else {
|
} else {
|
||||||
callback() // 校验通过
|
callback() // 校验通过
|
||||||
@ -2497,7 +2337,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
expirateTimeFormat(expirateTime) {
|
expirateTimeFormat(expirateTime) {
|
||||||
// console.log("1111",this.parseTime(expirateTime))
|
|
||||||
// 解析时间并转换为 UTC 时间
|
// 解析时间并转换为 UTC 时间
|
||||||
const targetDate = new Date(expirateTime)
|
const targetDate = new Date(expirateTime)
|
||||||
const currentDate = new Date()
|
const currentDate = new Date()
|
||||||
@ -2507,8 +2346,6 @@ 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('xxxx', diffInYears > 1)
|
|
||||||
if (diffInYears > 1) {
|
if (diffInYears > 1) {
|
||||||
return ''
|
return ''
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
425
src/views/admin/line-reduce-strategy/index.vue
Normal file
425
src/views/admin/line-reduce-strategy/index.vue
Normal file
@ -0,0 +1,425 @@
|
|||||||
|
<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="name"><el-input
|
||||||
|
v-model="queryParams.name"
|
||||||
|
placeholder="请输入策略名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" size="mini" placeholder="请选择订单类型" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="(item2, index2) in statusOptions"
|
||||||
|
:key="'queryStatus.' + index2"
|
||||||
|
:label="item2.label"
|
||||||
|
:value="item2.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</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:lineReduceStrategy: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:lineReduceStrategy: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:lineReduceStrategy: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="lineReduceStrategyList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="策略名称" align="center" prop="name" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="状态" align="center" prop="status" :show-overflow-tooltip="true">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ statusFormat(scope.row.status) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createdAt"
|
||||||
|
width="150"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">{{ parseTime(row.createdAt) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<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:lineReduceStrategy: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:lineReduceStrategy: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="800px">
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="策略名称" prop="name">
|
||||||
|
<el-input v-model="form.name" placeholder="减仓策略名称" show-word-limit maxlength="50" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio v-for="dict in statusOptions" :key="dict.value" :label="dict.value">{{
|
||||||
|
dict.label
|
||||||
|
}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="4"><el-form-item label="减仓配置" /></el-col>
|
||||||
|
<el-col :span="2"><el-button
|
||||||
|
type="primary"
|
||||||
|
size="mini"
|
||||||
|
@click="onAddItem"
|
||||||
|
>新增减仓</el-button></el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row
|
||||||
|
v-for="(item, index) in form.items"
|
||||||
|
:key="'item_' + index"
|
||||||
|
style="margin-top: 10px;"
|
||||||
|
:gutter="20"
|
||||||
|
>
|
||||||
|
<!-- <el-card shadow="hover"> -->
|
||||||
|
<el-col :span="7">
|
||||||
|
<el-form-item
|
||||||
|
label="亏损比例"
|
||||||
|
:prop="'items.' + index + '.lossPercent'"
|
||||||
|
:rules="rules.lossPercent"
|
||||||
|
>
|
||||||
|
<el-input v-model="item.lossPercent" size="mini" placeholder="请输入亏损比例" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="7">
|
||||||
|
<el-form-item
|
||||||
|
label="订单类型"
|
||||||
|
:prop="'items.' + index + '.orderType'"
|
||||||
|
:rules="rules.orderType"
|
||||||
|
>
|
||||||
|
<el-select v-model="item.orderType" size="mini" placeholder="请选择订单类型">
|
||||||
|
<el-option
|
||||||
|
v-for="(item2, index2) in orderTypeOptions"
|
||||||
|
:key="index + '.orderType.' + index2"
|
||||||
|
:label="item2.label"
|
||||||
|
:value="item2.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<!-- <el-form-item> -->
|
||||||
|
<!-- </el-form-item> -->
|
||||||
|
<el-col :span="4" style="height: 36px; line-height: 36px;"><el-button
|
||||||
|
size="mini"
|
||||||
|
type="danger"
|
||||||
|
@click="removeItem(index)"
|
||||||
|
>删除</el-button></el-col>
|
||||||
|
<!-- </el-card> -->
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</el-card>
|
||||||
|
</template>
|
||||||
|
</BasicLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { addLineReduceStrategy, delLineReduceStrategy, getLineReduceStrategy, listLineReduceStrategy, updateLineReduceStrategy } from '@/api/admin/line-reduce-strategy'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'LineReduceStrategy',
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 弹出层标题
|
||||||
|
title: '',
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
isEdit: false,
|
||||||
|
// 类型数据字典
|
||||||
|
typeOptions: [],
|
||||||
|
lineReduceStrategyList: [],
|
||||||
|
orderTypeOptions: [{
|
||||||
|
value: 'LIMIT',
|
||||||
|
label: '限价'
|
||||||
|
}, {
|
||||||
|
value: 'MARKET',
|
||||||
|
label: '市价'
|
||||||
|
}],
|
||||||
|
statusOptions: [{
|
||||||
|
value: 1,
|
||||||
|
label: '启用'
|
||||||
|
}, {
|
||||||
|
value: 2,
|
||||||
|
label: '禁用'
|
||||||
|
}],
|
||||||
|
// 关系表类型
|
||||||
|
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
name: undefined,
|
||||||
|
status: undefined,
|
||||||
|
idOrder: 'desc'
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {
|
||||||
|
},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
name: [{ required: true, message: '减仓策略名称不能为空', trigger: 'blur' }],
|
||||||
|
status: [{ required: true, message: '状态 1-启用 2-禁用不能为空', trigger: 'blur' }],
|
||||||
|
lossPercent: [{ required: true, message: '亏损百分比不能为空', trigger: 'blur' },
|
||||||
|
{ validator: this.validateOrderType, trigger: 'blur' }],
|
||||||
|
orderType: [{ required: true, message: '订单类型不能为空', trigger: 'blur' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 校验节点百分比
|
||||||
|
validateOrderType(rule, value, callback) {
|
||||||
|
const index = rule.fullField.split('.')[1] // 获取索引
|
||||||
|
const item = this.form.items[index]
|
||||||
|
|
||||||
|
if (value === '') {
|
||||||
|
callback(new Error('不能为空'))
|
||||||
|
} else if (isNaN(value)) {
|
||||||
|
callback(new Error('必须输入数字'))
|
||||||
|
} else if (value < 0) {
|
||||||
|
callback(new Error('百分比不能小于 0'))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index > 0 && item.lossPercent <= this.form.items[index - 1].lossPercent) {
|
||||||
|
callback(new Error('亏损百分比不能小于上一节点'))
|
||||||
|
} else {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 查询参数列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true
|
||||||
|
listLineReduceStrategy(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||||
|
this.lineReduceStrategyList = response.data.list
|
||||||
|
this.total = response.data.count
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
statusFormat(status) {
|
||||||
|
const op = this.statusOptions.find(x => x.value === status)
|
||||||
|
|
||||||
|
if (op) {
|
||||||
|
return op.label
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false
|
||||||
|
this.reset()
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
|
||||||
|
id: undefined,
|
||||||
|
name: undefined,
|
||||||
|
status: 1,
|
||||||
|
items: []
|
||||||
|
}
|
||||||
|
this.resetForm('form')
|
||||||
|
},
|
||||||
|
getImgList: function() {
|
||||||
|
this.form[this.fileIndex] = this.$refs['fileChoose'].resultList[0].fullUrl
|
||||||
|
},
|
||||||
|
fileClose: function() {
|
||||||
|
this.fileOpen = false
|
||||||
|
},
|
||||||
|
// 关系
|
||||||
|
// 文件
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageIndex = 1
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dateRange = []
|
||||||
|
this.resetForm('queryForm')
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset()
|
||||||
|
this.open = true
|
||||||
|
this.title = '添加减仓策略'
|
||||||
|
this.isEdit = false
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length !== 1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset()
|
||||||
|
const id =
|
||||||
|
row.id || this.ids
|
||||||
|
getLineReduceStrategy(id).then(response => {
|
||||||
|
this.form = response.data
|
||||||
|
this.open = true
|
||||||
|
this.title = '修改减仓策略'
|
||||||
|
this.isEdit = true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm: function() {
|
||||||
|
this.$refs['form'].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id !== undefined) {
|
||||||
|
updateLineReduceStrategy(this.form).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.msgSuccess(response.msg)
|
||||||
|
this.open = false
|
||||||
|
this.getList()
|
||||||
|
} else {
|
||||||
|
this.msgError(response.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
addLineReduceStrategy(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 delLineReduceStrategy({ 'ids': Ids })
|
||||||
|
}).then((response) => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.msgSuccess(response.msg)
|
||||||
|
this.open = false
|
||||||
|
this.getList()
|
||||||
|
} else {
|
||||||
|
this.msgError(response.msg)
|
||||||
|
}
|
||||||
|
}).catch(function() {
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onAddItem() {
|
||||||
|
this.form.items.push({ lossPercent: undefined, orderType: 'LIMIT' })
|
||||||
|
},
|
||||||
|
removeItem(index) {
|
||||||
|
this.form.items.splice(index, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
414
src/views/admin/line-strategy-template/index.vue
Normal file
414
src/views/admin/line-strategy-template/index.vue
Normal file
@ -0,0 +1,414 @@
|
|||||||
|
<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="direction">
|
||||||
|
<el-select v-model="queryParams.direction" placeholder="请选择涨跌方向" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="item in directionOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="比较类型" prop="compareType">
|
||||||
|
<el-select v-model="queryParams.compareType" placeholder="请选择比较类型" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="item in compareTypeOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.description"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="策略名称" prop="name" />
|
||||||
|
<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:lineStrategyTemplate: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:lineStrategyTemplate: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:lineStrategyTemplate: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="lineStrategyTemplateList"
|
||||||
|
@selection-change="handleSelectionChange"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="策略名称" align="center" prop="name" />
|
||||||
|
<el-table-column label="涨跌方向" align="center" prop="direction" :show-overflow-tooltip="true">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ directionFormat(scope.row.direction) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="涨跌点数" align="center" prop="percentag" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="比较类型" align="center" prop="compareType" :show-overflow-tooltip="true">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ compareTypeFormat(scope.row.compareType) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="时间段开始(分)"
|
||||||
|
align="center"
|
||||||
|
prop="timeSlotStart"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
/>
|
||||||
|
<el-table-column label="时间断截至(分)" align="center" prop="timeSlotEnd" :show-overflow-tooltip="true" />
|
||||||
|
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createdAt"
|
||||||
|
width="150"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">{{ parseTime(row.createdAt) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<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:lineStrategyTemplate: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:lineStrategyTemplate: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="120px">
|
||||||
|
<el-form-item label="策略名称" prop="name">
|
||||||
|
<el-input v-model="form.name" placeholder="策略名称" maxlength="50" show-word-limit />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="涨跌方向" prop="direction">
|
||||||
|
<el-radio-group v-model="form.direction">
|
||||||
|
<el-radio v-for="dict in directionOptions" :key="dict.value" :label="dict.value">{{
|
||||||
|
dict.label
|
||||||
|
}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="涨跌点数" prop="percentag">
|
||||||
|
<el-input v-model="form.percentag" placeholder="涨跌点数" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="比较类型" prop="compareType">
|
||||||
|
<el-select v-model="form.compareType" placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in compareTypeOptions"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="时间段开始(分)" prop="timeSlotStart">
|
||||||
|
<el-input v-model.number="form.timeSlotStart" placeholder="时间段开始(分)" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="时间断截至(分)" prop="timeSlotEnd">
|
||||||
|
<el-input v-model.number="form.timeSlotEnd" placeholder="时间断截至(分)" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</el-card>
|
||||||
|
</template>
|
||||||
|
</BasicLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { addLineStrategyTemplate, delLineStrategyTemplate, getLineStrategyTemplate, listLineStrategyTemplate, updateLineStrategyTemplate } from '@/api/admin/line-strategy-template'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'LineStrategyTemplate',
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 弹出层标题
|
||||||
|
title: '',
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
isEdit: false,
|
||||||
|
// 类型数据字典
|
||||||
|
typeOptions: [],
|
||||||
|
lineStrategyTemplateList: [],
|
||||||
|
|
||||||
|
// 关系表类型
|
||||||
|
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
direction: undefined,
|
||||||
|
percentag: undefined,
|
||||||
|
compareType: undefined,
|
||||||
|
idOrder: 'desc'
|
||||||
|
},
|
||||||
|
directionOptions: [
|
||||||
|
{
|
||||||
|
value: 1,
|
||||||
|
label: '涨'
|
||||||
|
}, {
|
||||||
|
value: 2,
|
||||||
|
label: '跌'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
compareTypeOptions: [{
|
||||||
|
value: 1,
|
||||||
|
label: '>',
|
||||||
|
description: '大于'
|
||||||
|
}, {
|
||||||
|
value: 2,
|
||||||
|
label: '>=',
|
||||||
|
description: '大于等于'
|
||||||
|
}, {
|
||||||
|
value: 3,
|
||||||
|
label: '<',
|
||||||
|
description: '小于'
|
||||||
|
}, {
|
||||||
|
value: 4,
|
||||||
|
label: '<=',
|
||||||
|
description: '小于等于'
|
||||||
|
}, {
|
||||||
|
value: 5,
|
||||||
|
label: '=',
|
||||||
|
description: '等于'
|
||||||
|
}],
|
||||||
|
// 表单参数
|
||||||
|
form: {
|
||||||
|
},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
direction: [{ required: true, message: '涨跌方向不能为空', trigger: 'blur' }],
|
||||||
|
compareType: [{ required: true, message: '比较类型不能为空', trigger: 'blur' }],
|
||||||
|
percentag: [{ required: true, message: '涨跌点数不能为空', trigger: 'blur' }],
|
||||||
|
timeSlotStart: [{ required: true, message: '时间段开始', trigger: 'blur' }],
|
||||||
|
timeSlotEnd: [{ required: true, message: '时间段截至', trigger: 'blur' }],
|
||||||
|
name: [{ required: true, message: '策略名称不能为空', trigger: 'blur' }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
compareTypeFormat(compareType) {
|
||||||
|
const op = this.compareTypeOptions.find(x => x.value === compareType)
|
||||||
|
|
||||||
|
if (op && op.description) {
|
||||||
|
return op.description
|
||||||
|
}
|
||||||
|
},
|
||||||
|
directionFormat(direction) {
|
||||||
|
const op = this.directionOptions.find(x => x.value === direction)
|
||||||
|
|
||||||
|
if (op && op.label) {
|
||||||
|
return op.label
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 查询参数列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true
|
||||||
|
listLineStrategyTemplate(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||||
|
this.lineStrategyTemplateList = response.data.list
|
||||||
|
this.total = response.data.count
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false
|
||||||
|
this.reset()
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
|
||||||
|
id: undefined,
|
||||||
|
direction: 1,
|
||||||
|
percentag: undefined,
|
||||||
|
compareType: undefined,
|
||||||
|
timeSlotStart: undefined,
|
||||||
|
timeSlotEnd: undefined
|
||||||
|
}
|
||||||
|
this.resetForm('form')
|
||||||
|
},
|
||||||
|
getImgList: function() {
|
||||||
|
this.form[this.fileIndex] = this.$refs['fileChoose'].resultList[0].fullUrl
|
||||||
|
},
|
||||||
|
fileClose: function() {
|
||||||
|
this.fileOpen = false
|
||||||
|
},
|
||||||
|
// 关系
|
||||||
|
// 文件
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageIndex = 1
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dateRange = []
|
||||||
|
this.resetForm('queryForm')
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset()
|
||||||
|
this.open = true
|
||||||
|
this.title = '添加波段策略'
|
||||||
|
this.isEdit = false
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length !== 1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset()
|
||||||
|
const id =
|
||||||
|
row.id || this.ids
|
||||||
|
getLineStrategyTemplate(id).then(response => {
|
||||||
|
this.form = response.data
|
||||||
|
this.open = true
|
||||||
|
this.title = '修改波段策略'
|
||||||
|
this.isEdit = true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm: function() {
|
||||||
|
this.$refs['form'].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id !== undefined) {
|
||||||
|
updateLineStrategyTemplate(this.form).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.msgSuccess(response.msg)
|
||||||
|
this.open = false
|
||||||
|
this.getList()
|
||||||
|
} else {
|
||||||
|
this.msgError(response.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
addLineStrategyTemplate(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 delLineStrategyTemplate({ '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>
|
||||||
330
src/views/admin/line-symbol-price/index.vue
Normal file
330
src/views/admin/line-symbol-price/index.vue
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
<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="symbol"><el-input
|
||||||
|
v-model="queryParams.symbol"
|
||||||
|
placeholder="请输入交易对"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="请选择比较类型" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="item in statusOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</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:lineSymbolPrice: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:lineSymbolPrice: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:lineSymbolPrice: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="lineSymbolPriceList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="交易对" align="center" prop="symbol" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="状态" align="center" prop="status" :show-overflow-tooltip="true">
|
||||||
|
<template slot-scope="scope">{{ scope.row.status === 1 ? "已启用" : "禁用" }} </template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createdAt"
|
||||||
|
width="150"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">{{ parseTime(row.createdAt) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<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:lineSymbolPrice: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:lineSymbolPrice: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="symbol">
|
||||||
|
<el-input v-model="form.symbol" placeholder="交易对" />
|
||||||
|
</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="2">禁用</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
<!-- <el-select v-model="form.status" placeholder="请选择">
|
||||||
|
<el-option v-for="dict in statusOptions" :key="dict.value" :label="dict.label"
|
||||||
|
:value="dict.value" />
|
||||||
|
</el-select> -->
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</el-card>
|
||||||
|
</template>
|
||||||
|
</BasicLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { addLineSymbolPrice, delLineSymbolPrice, getLineSymbolPrice, listLineSymbolPrice, updateLineSymbolPrice } from '@/api/admin/line-symbol-price'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'LineSymbolPrice',
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 弹出层标题
|
||||||
|
title: '',
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
isEdit: false,
|
||||||
|
// 类型数据字典
|
||||||
|
typeOptions: [],
|
||||||
|
lineSymbolPriceList: [],
|
||||||
|
statusOptions: [{
|
||||||
|
label: '启用',
|
||||||
|
value: 1
|
||||||
|
}, {
|
||||||
|
label: '禁用',
|
||||||
|
value: 2
|
||||||
|
}],
|
||||||
|
// 关系表类型
|
||||||
|
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
symbol: undefined,
|
||||||
|
status: undefined,
|
||||||
|
idOrder: 'desc'
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {
|
||||||
|
},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
symbol: [{ required: true, message: '交易对不能为空', trigger: 'blur' }],
|
||||||
|
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询参数列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true
|
||||||
|
listLineSymbolPrice(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||||
|
this.lineSymbolPriceList = response.data.list
|
||||||
|
this.total = response.data.count
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false
|
||||||
|
this.reset()
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
|
||||||
|
id: undefined,
|
||||||
|
symbol: undefined,
|
||||||
|
status: 1
|
||||||
|
}
|
||||||
|
this.resetForm('form')
|
||||||
|
},
|
||||||
|
getImgList: function() {
|
||||||
|
this.form[this.fileIndex] = this.$refs['fileChoose'].resultList[0].fullUrl
|
||||||
|
},
|
||||||
|
fileClose: function() {
|
||||||
|
this.fileOpen = false
|
||||||
|
},
|
||||||
|
// 关系
|
||||||
|
// 文件
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageIndex = 1
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dateRange = []
|
||||||
|
this.resetForm('queryForm')
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset()
|
||||||
|
this.open = true
|
||||||
|
this.title = '添加缓存价格交易对'
|
||||||
|
this.isEdit = false
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length !== 1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset()
|
||||||
|
const id =
|
||||||
|
row.id || this.ids
|
||||||
|
getLineSymbolPrice(id).then(response => {
|
||||||
|
this.form = response.data
|
||||||
|
this.open = true
|
||||||
|
this.title = '修改缓存价格交易对'
|
||||||
|
this.isEdit = true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm: function() {
|
||||||
|
this.$refs['form'].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id !== undefined) {
|
||||||
|
updateLineSymbolPrice(this.form).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.msgSuccess(response.msg)
|
||||||
|
this.open = false
|
||||||
|
this.getList()
|
||||||
|
} else {
|
||||||
|
this.msgError(response.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
addLineSymbolPrice(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 delLineSymbolPrice({ '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>
|
||||||
Reference in New Issue
Block a user