diff --git a/src/api/admin/line-api-user-group.js b/src/api/admin/line-api-user-group.js
new file mode 100644
index 0000000..4586fae
--- /dev/null
+++ b/src/api/admin/line-api-user-group.js
@@ -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
+ })
+}
diff --git a/src/views/admin/line-api-user-group/index.vue b/src/views/admin/line-api-user-group/index.vue
new file mode 100644
index 0000000..398eb0b
--- /dev/null
+++ b/src/views/admin/line-api-user-group/index.vue
@@ -0,0 +1,367 @@
+
+
+
+
+
+
+
+
+
+ 搜索
+ 重置
+
+
+
+
+
+ 新增
+
+
+
+ 修改
+
+
+
+ 删除
+
+
+
+
+
+
+
+
+
+ {{ exchangeTypeFormat(row) }}
+
+
+
+
+
+
+
+ 修改
+
+
+
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 开启
+ 关闭
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/admin/line-api-user/index.vue b/src/views/admin/line-api-user/index.vue
index 1284ea5..e164377 100644
--- a/src/views/admin/line-api-user/index.vue
+++ b/src/views/admin/line-api-user/index.vue
@@ -97,14 +97,14 @@
>
{{ ['现货','合约','现货合约'][row.affiliation-1] }}
-->
-
{{ ['否','是'][row.adminShow] }}
-
+ -->
-
{{ groupIdFormat(scope.row) }}
- -->
+ {
this.exchangeTypes = response.data
@@ -414,11 +415,11 @@ export default {
this.userIdOptions = this.setItems(res, 'id', 'username')
})
},
- getLineApiGroupItems() {
- this.getItems(listLineApiGroup, undefined).then(res => {
- this.groupIdOptions = this.setItems(res, 'id', 'groupName')
- })
- },
+ // getLineApiGroupItems() {
+ // this.getItems(listLineApiGroup, undefined).then(res => {
+ // this.groupIdOptions = this.setItems(res, 'id', 'groupName')
+ // })
+ // },
// 文件
/** 搜索按钮操作 */
handleQuery() {
diff --git a/src/views/admin/line-order-template-logs/index.vue b/src/views/admin/line-order-template-logs/index.vue
index a27125c..019cfb4 100644
--- a/src/views/admin/line-order-template-logs/index.vue
+++ b/src/views/admin/line-order-template-logs/index.vue
@@ -48,17 +48,11 @@
>新增
-->
-
- 修改
+
合约
+
+
+
+ 单个
+ 分组
+
+
-
+
+
+
+
+
+
+
计算
-
-
+
+
+ {{ comTakePrice }}
+
@@ -418,8 +439,14 @@
直接执行
-
-
+
+
+ {{ comReducePrice }}
+
@@ -636,6 +663,8 @@ import { addLineOrderTemplateLogs, delLineOrderTemplateLogs, getLineOrderTemplat
import { listLineSymbolGroup } from '@/api/admin/line-symbol-group'
import { getMainUser, listLineApiUser } from '@/api/admin/line-api-user'
import { calculate, aicoinSymbol, quickAddPreOrder } from '@/api/admin/line-pre-order'
+import { getLineApiUserGroupList } from '@/api/admin/line-api-user-group'
+
export default {
name: 'LineOrderTemplateLogs',
components: {
@@ -675,6 +704,7 @@ export default {
// 关系表类型
userIdOptions: [],
+ apiUserGroupList: [],
// 查询参数
queryParams: {
@@ -706,10 +736,10 @@ export default {
price: [{ required: true, message: '请输入下单百分比不能为空', trigger: 'blur' },
{ validator: this.validatePercentage, trigger: 'blur' }
],
- profit: [{ required: true, message: '请输入止盈百分比', trigger: 'blur' },
+ profit: [{ required: true, message: '请输入', trigger: 'blur' },
{ validator: this.validateProfit, trigger: 'blur' }],
reduce_price: [
- { required: true, message: '主单亏损减仓百分比不能为空', trigger: 'blur' },
+ { required: true, message: '主单亏损不能为空', trigger: 'blur' },
{ validator: this.validateReducePrice, trigger: 'blur' }],
reduce_num: [
{ required: true, message: '主单减仓数量百分比不能为空', trigger: 'blur' },
@@ -754,7 +784,9 @@ export default {
],
tpTpPriceRatio: [{ 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: {},
searchLoding: false,
@@ -779,10 +811,45 @@ export default {
const s = this.comSymbols.find(item => item.symbol === symbol)
if (s) {
const res = ((price - s.lastPrice) / s.lastPrice) * 100
- return `${res}%`
+ return `${res.toFixed(2)}%`
}
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
}
},
@@ -812,7 +879,7 @@ export default {
},
validateReducePrice(rule, value, callback) {
if (value === 0 || value === undefined || value === null || value === '') {
- callback(new Error('亏损百分比必须大于0'))
+ callback(new Error('必须大于0'))
} else {
callback()
}
@@ -866,9 +933,9 @@ export default {
},
validateProfit(rule, value, callback) {
if (this.inForm.profit === '' || this.inForm.profit === undefined || this.inForm.profit === null) {
- callback(new Error('止盈百分比不能为空'))
+ callback(new Error('不能为空'))
} else if (this.inForm.profit <= 0) {
- callback(new Error('止盈百分比不能小于0'))
+ callback(new Error('不能小于0'))
} else {
callback()
}
@@ -990,7 +1057,7 @@ export default {
this.inForm.ext.splice(index, 1)
return false
}
- console.log('ext', this.inForm.ext)
+
this.inForm.ext.push({
// 类型 订单类型 加仓类型 加仓数值 价格百分比 止盈百分比 止损百分比
addType: type === 0 ? 1 : 2,
@@ -1032,11 +1099,17 @@ export default {
},
// 获取杠杆api用户
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.lineTotal = response.data.count
})
},
+ // 获取api用户分组
+ getApiUserGroupList(exchangeType) {
+ getLineApiUserGroupList({ exchangeType: exchangeType || this.inForm.exchange_type }).then(response => {
+ this.apiUserGroupList = response.data
+ })
+ },
// 交易对列表
getSymbol(e, type, exchangeType) {
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() {
this.open = false
@@ -1182,11 +1276,19 @@ export default {
this.ext = []
const id =
row.id || this.ids
+
getLineOrderTemplateLogs(id).then(response => {
this.form = response.data
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.getSymbol(undefined, x.symbol_type, x.exchange_type)
+ this.inForm = {
+ ...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.getListLineApiUser()
this.form.type === 2 && this.getSymbolGroup(this.inForm.symbol_type)
@@ -1210,6 +1312,10 @@ export default {
if (formValid.every(valid => valid)) {
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({
...this.inForm,
reduce_price: this.inForm.reduce_price || 0,
@@ -1293,9 +1399,17 @@ export default {
return quickAddPreOrder({ ids: Ids.toString() })
}).then((response) => {
if (response.code === 200) {
+ if (response.data !== '') {
+ this.$notify({
+ title: '部分失败',
+ message: response.data,
+ type: 'warning'
+ })
+ } else {
+ this.msgSuccess(response.msg)
+ }
this.ids = []
this.$refs.table?.clearSelection()
- this.msgSuccess(response.msg)
} else {
this.msgError(response.msg)
}
diff --git a/src/views/admin/line-pre-order/index.vue b/src/views/admin/line-pre-order/index.vue
index 3811743..995360c 100644
--- a/src/views/admin/line-pre-order/index.vue
+++ b/src/views/admin/line-pre-order/index.vue
@@ -110,15 +110,15 @@
>加仓
-->
-
+
设置杠杆
-
+
设置保证金模式
-
+
取消委托
@@ -144,7 +144,7 @@
>删除
-->
-
+
一键清除数据
-
+
合约对现货
-->
-
+
+
+ 单个
+ 分组
+
+
+
+
+
+
+
+