This commit is contained in:
shilin
2025-02-14 10:56:16 +08:00
parent 082ab5794d
commit f7b5fdefdf
3 changed files with 160 additions and 149 deletions

View File

@ -235,10 +235,10 @@
size="small"
>
<el-option
v-for="dict in userIdOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
v-for="dict in lineUsers"
:key="dict.id"
:label="dict.apiName"
:value="String(dict.id)"
/>
</el-select>
</el-col>
@ -613,7 +613,7 @@ export default {
},
created() {
this.getList()
this.getLineApiUserItems()
// this.getLineApiUserItems()
this.getSymbolGroup()
// 获取交易所字典数据
this.getDicts('exchange_type').then(response => {
@ -823,6 +823,7 @@ export default {
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.onchangePattern(false)
this.getListLineApiUser()
this.form.type === 2 && this.getSymbolGroup(this.inForm.symbol_type)
this.open = true
this.title = '修改委托下单模板'

View File

@ -11,10 +11,10 @@
size="small"
>
<el-option
v-for="dict in apiIdOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
v-for="dict in lineUsersAll"
:key="dict.id"
:label="dict.apiName"
:value="dict.id"
/>
</el-select>
</el-form-item>
@ -244,7 +244,7 @@
</el-table-column>
<el-table-column
label="api用户名"
align="left"
align="center"
prop="api_name"
:show-overflow-tooltip="true"
/>
@ -465,9 +465,9 @@
>
<el-option
v-for="dict in apiIdOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
:key="dict.id"
:label="dict.apiName"
:value="dict.id"
/>
</el-select>
</el-col>
@ -804,9 +804,9 @@
>
<el-option
v-for="dict in apiIdOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
:key="dict.id"
:label="dict.apiName"
:value="dict.id"
/>
</el-select>
</el-form-item>
@ -917,9 +917,9 @@
>
<el-option
v-for="dict in apiIdOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
:key="dict.id"
:label="dict.apiName"
:value="dict.id"
/>
</el-select>
</el-form-item>
@ -979,9 +979,9 @@
>
<el-option
v-for="dict in apiIdOptions"
:key="dict.key"
:label="dict.value"
:value="Number(dict.key)"
:key="dict.id"
:label="dict.apiName"
:value="Number(dict.id)"
/>
</el-select>
</el-form-item>
@ -1047,15 +1047,13 @@ export default {
{ v: 9, l: '已平仓' }
],
statuss: [
{ v: '0', l: '待触发' },
{ v: '1', l: '已触发' },
{ v: '2', l: '下单失败' },
{ v: '4', l: '已取消' },
{ v: '5', l: '委托中' },
{ v: '6', l: '已平仓' },
{ v: '9', l: '现货已成交' },
{ v: '12', l: '合约已成交' },
{ v: '13', l: '已开仓' }
{ v: 0, l: '待触发' },
{ v: 1, l: '已触发' },
{ v: 2, l: '下单失败' },
{ v: 4, l: '已取消' },
{ v: 5, l: '委托中' },
{ v: 6, l: '已成交' },
{ v: 9, l: '已平仓' }
],
// 遮罩层
loading: true,
@ -1128,6 +1126,7 @@ export default {
modeTitle: '',
modeOpen: false
},
lineUsersAll: [],
lineUsers: [],
lineTotal: 0,
storeOpen: false,
@ -1207,9 +1206,10 @@ export default {
},
created() {
this.getList()
this.getLineApiUserItems()
// this.getLineApiUserItems()
this.getSymbolGroup()
this.getListLineApiUser()
listLineApiUser({ pageIndex: 1, pageSize: 999, exchangeType: '' }).then(response => { this.lineUsersAll = response?.data?.list || [] })
},
methods: {
onSelectAll() {
@ -1227,8 +1227,8 @@ export default {
this.modeForm.api_user_ids = this.lineUsers.map(item => item.id)
},
// 获取杠杆api用户
getListLineApiUser() {
listLineApiUser({ pageIndex: 1, pageSize: 999 }).then(response => {
getListLineApiUser(exchangeType) {
listLineApiUser({ pageIndex: 1, pageSize: 999, exchangeType: exchangeType || this.form.exchange_type }).then(response => {
this.lineUsers = response.data.list
this.lineTotal = response.data.count
})
@ -1270,41 +1270,44 @@ export default {
}
},
onExpand(row, expanded) {
// const { symbol, id } = row
const { symbol, id, mainId } = row
// // 查询后更新数据
// if (Object.keys(row).length > 0) {
// for (const x in this.cacheRefresh) {
// // 当前的刷新
// if (`${row.symbol}${row.id}` === x) {
// const curr = this.cacheRefresh[`${symbol}${id}`]
// curr.expandCount++
// // 如果是展开状态且展开次数大于1且上一次的状态为折叠则请求api数据不需要更新子菜单
// if (expanded && curr.expandCount > 1 && !curr.prevStatus) {
// getChildOrder({ id }).then(res => {
// curr.resolve(res.data)
// }).finally(() => {})
// }
// curr.expandCount = 1
// curr.prevStatus = expanded
// } else {
// if (this.cacheRefresh[x].prevStatus) {
// const flag = this.linePreOrderList.findIndex(item => `${item.symbol}${item.id}` === x)
// this.cacheRefresh[x].expandCount = 0
// this.cacheRefresh[x].prevStatus = false
// this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], false)
// }
// }
// }
// }
// 查询后更新数据
if (Object.keys(row).length > 0) {
for (const x in this.cacheRefresh) {
// 当前的刷新
if (`${symbol}${id}` === x) {
const curr = this.cacheRefresh[`${symbol}${id}`]
curr.expandCount++
// 如果是展开状态且展开次数大于1且上一次的状态为折叠则请求api数据不需要更新子菜单
if (expanded && curr.expandCount > 1 && !curr.prevStatus) {
getChildOrder({ id }).then(res => {
curr.resolve(res.data)
}).finally(() => {})
}
curr.expandCount = 1
curr.prevStatus = expanded
} else {
if (this.cacheRefresh[x].prevStatus && mainId !== this.cacheRefresh[x].mainId) {
const flag = this.linePreOrderList.findIndex(item => `${item.symbol}${item.id}` === x)
if (flag >= 0) {
this.cacheRefresh[x].expandCount = 0
this.cacheRefresh[x].prevStatus = false
this.$refs.table && this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], false)
}
}
}
}
}
},
// 获取子数据
onLoadChild(tree, treeNode, resolve) {
const { id } = tree
// this.currentExpandId = tree.id
// this.cacheRefresh[`${symbol}${id}`] = {}
// this.cacheRefresh[`${symbol}${id}`].resolve = resolve
// this.cacheRefresh[`${symbol}${id}`].expandCount = 0
const { symbol, id } = tree
this.currentExpandId = tree.id
this.cacheRefresh[`${symbol}${id}`] = {}
this.cacheRefresh[`${symbol}${id}`].mainId = id
this.cacheRefresh[`${symbol}${id}`].resolve = resolve
this.cacheRefresh[`${symbol}${id}`].expandCount = 0
getChildOrder({ id }).then(res => {
const r = res.data.map((item) => ({ ...item, hasChildren: item.child_num > 0 }))
resolve(r)
@ -1317,13 +1320,13 @@ export default {
this.linePreOrderList = response.data.list.map(item => ({ ...item, hasChildren: true }))
this.total = response.data.count
// 查询后更新数据
// for (const x in this.cacheRefresh) {
// const flag = this.linePreOrderList.findIndex(item => `${item.symbol}${item.id}` === x)
// if (flag !== -1 && this.cacheRefresh[x].prevStatus) {
// this.$refs.table && this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], false)
// this.$refs.table && this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], true)
// }
// }
for (const x in this.cacheRefresh) {
const flag = this.linePreOrderList.findIndex(item => `${item.symbol}${item.id}` === x)
if (flag !== -1 && this.cacheRefresh[x].prevStatus) {
this.$refs.table && this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], false)
this.$refs.table && this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], true)
}
}
this.loading = false
})
},

View File

@ -12,10 +12,10 @@
size="small"
>
<el-option
v-for="dict in apiIdOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
v-for="dict in lineUsersAll"
:key="dict.id"
:label="dict.apiName"
:value="dict.id"
/>
</el-select>
</el-form-item>
@ -225,7 +225,7 @@
row-key="id"
lazy
:load="onLoadChild"
:tree-props="{children: 'children', hasChildren: 'hasChildren' }"
:tree-props="{children: 'children', hasChildren: 'hasChildren', checkStrictly: true }"
height="560"
@selection-change="handleSelectionChange"
@expand-change="onExpand"
@ -247,7 +247,7 @@
</el-table-column>
<el-table-column
label="api用户名"
align="left"
align="center"
prop="api_name"
:show-overflow-tooltip="true"
/>
@ -528,10 +528,10 @@
size="small"
>
<el-option
v-for="dict in apiIdOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
v-for="dict in lineUsers"
:key="dict.id"
:label="dict.apiName"
:value="dict.id"
/>
</el-select>
</el-col>
@ -988,10 +988,10 @@
size="small"
>
<el-option
v-for="dict in apiIdOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
v-for="dict in lineUsers"
:key="dict.id"
:label="dict.apiName"
:value="dict.id"
/>
</el-select>
</el-form-item>
@ -1119,10 +1119,10 @@
size="small"
>
<el-option
v-for="dict in apiIdOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
v-for="dict in lineUsers"
:key="dict.id"
:label="dict.apiName"
:value="dict.id"
/>
</el-select>
</el-form-item>
@ -1210,10 +1210,10 @@
size="small"
>
<el-option
v-for="dict in apiIdOptions"
:key="dict.key"
:label="dict.value"
:value="Number(dict.key)"
v-for="dict in lineUsers"
:key="dict.id"
:label="dict.apiName"
:value="Number(dict.id)"
/>
</el-select>
</el-form-item>
@ -1305,15 +1305,13 @@ export default {
// { v: 13, l: '已开仓' }
],
statuss: [
{ v: '0', l: '待触发' },
{ v: '1', l: '已触发' },
{ v: '2', l: '下单失败' },
{ v: '4', l: '已取消' },
{ v: '5', l: '委托中' },
{ v: '6', l: '已平仓' },
{ v: '9', l: '现货已成交' },
{ v: '12', l: '合约已成交' },
{ v: '13', l: '已开仓' }
{ v: 0, l: '待触发' },
{ v: 1, l: '已触发' },
{ v: 2, l: '下单失败' },
{ v: 4, l: '已取消' },
{ v: 5, l: '委托中' },
{ v: 6, l: '已成交' },
{ v: 9, l: '已平仓' }
],
options: [
{ label: '买入点1', value: 'buyPoint1' },
@ -1396,6 +1394,7 @@ export default {
modeTitle: '',
modeOpen: false
},
lineUsersAll: [],
lineUsers: [],
lineTotal: 0,
storeOpen: false,
@ -1492,13 +1491,14 @@ export default {
},
created() {
this.getList()
this.getLineApiUserItems()
this.getSymbolGroup()
this.getListLineApiUser()
// this.getLineApiUserItems()
// this.getListLineApiUser()
// 获取交易所字典数据
this.getDicts('exchange_type').then(response => {
this.exchangeTypes = response.data
})
listLineApiUser({ pageIndex: 1, pageSize: 999, exchangeType: '' }).then(response => { this.lineUsersAll = response?.data?.list || [] })
},
methods: {
onchangeSymbol() {
@ -1535,13 +1535,15 @@ export default {
return this.selectDictLabel(this.exchangeTypes || [], row.exchangeType)
},
onChangePosition() {
this.getLineApiUserItems(this.positionForm.exchange_type)
// this.getLineApiUserItems(this.positionForm.exchange_type)
this.getListLineApiUser(this.positionForm.exchange_type)
this.$set(this.positionForm, 'symbol', undefined)
this.getSymbol({}, this.positionForm.close_type, this.positionForm.exchange_type)
},
onChangeCancel() {
this.cancelForm.api_id = undefined
this.getLineApiUserItems(this.cancelForm.exchangeType)
// this.getLineApiUserItems(this.cancelForm.exchangeType)
this.getListLineApiUser(this.cancelForm.exchangeType)
},
onchangeMode() {
this.getListLineApiUser(this.modeForm.exchangeType)
@ -1612,42 +1614,44 @@ export default {
}
},
onExpand(row, expanded) {
// const { symbol, id } = row
// // 查询后更新数据
// if (Object.keys(row).length > 0) {
// for (const x in this.cacheRefresh) {
// // 当前的刷新
// if (`${row.symbol}${row.id}` === x) {
// const curr = this.cacheRefresh[`${symbol}${id}`]
// curr.expandCount++
// // 如果是展开状态且展开次数大于1且上一次的状态为折叠则请求api数据不需要更新子菜单
// if (expanded && curr.expandCount > 1 && !curr.prevStatus) {
// getChildOrder({ id }).then(res => {
// const r = res.data.map((item) => ({...item,hasChildren: item.child_num>0}))
// curr.resolve(r)
// }).finally(() => {})
// }
// curr.expandCount = 1
// curr.prevStatus = expanded
// } else {
// if (this.cacheRefresh[x].prevStatus) {
// const flag = this.linePreOrderList.findIndex(item => `${item.symbol}${item.id}` === x)
// this.cacheRefresh[x].expandCount = 0
// this.cacheRefresh[x].prevStatus = false
// this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], false)
// }
// }
// }
// }
const { symbol, id, mainId } = row
// 查询后更新数据
if (Object.keys(row).length > 0) {
for (const x in this.cacheRefresh) {
// 当前的刷新
if (`${symbol}${id}` === x) {
const curr = this.cacheRefresh[`${symbol}${id}`]
curr.expandCount++
// 如果是展开状态且展开次数大于1且上一次的状态为折叠则请求api数据不需要更新子菜单
if (expanded && curr.expandCount > 1 && !curr.prevStatus) {
getChildOrder({ id }).then(res => {
const r = res.data.map((item) => ({ ...item, hasChildren: item.child_num > 0 }))
curr.resolve(r)
}).finally(() => {})
}
curr.expandCount = 1
curr.prevStatus = expanded
} else {
if (this.cacheRefresh[x].prevStatus && mainId !== this.cacheRefresh[x].mainId) {
const flag = this.linePreOrderList.findIndex(item => `${item.symbol}${item.id}` === x)
if (flag >= 0) {
this.cacheRefresh[x].expandCount = 0
this.cacheRefresh[x].prevStatus = false
this.$refs.table && this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], false)
}
}
}
}
}
},
// 获取子数据
onLoadChild(tree, treeNode, resolve) {
const { id } = tree
// this.currentExpandId = tree.id
// this.cacheRefresh[`${symbol}${id}`] = {}
// this.cacheRefresh[`${symbol}${id}`].resolve = resolve
// this.cacheRefresh[`${symbol}${id}`].expandCount = 0
const { symbol, id } = tree
this.currentExpandId = id
this.cacheRefresh[`${symbol}${id}`] = {}
this.cacheRefresh[`${symbol}${id}`].mainId = id
this.cacheRefresh[`${symbol}${id}`].resolve = resolve
this.cacheRefresh[`${symbol}${id}`].expandCount = 0
getChildOrder({ id }).then(res => {
const r = res.data.map((item) => ({ ...item, hasChildren: item.child_num > 0 }))
resolve(r)
@ -1660,13 +1664,13 @@ export default {
this.linePreOrderList = response.data.list.map(item => ({ ...item, hasChildren: true }))
this.total = response.data.count
// 查询后更新数据
// for (const x in this.cacheRefresh) {
// const flag = this.linePreOrderList.findIndex(item => `${item.symbol}${item.id}` === x)
// if (flag !== -1 && this.cacheRefresh[x].prevStatus) {
// this.$refs.table && this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], false)
// this.$refs.table && this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], true)
// }
// }
for (const x in this.cacheRefresh) {
const flag = this.linePreOrderList.findIndex(item => `${item.symbol}${item.id}` === x)
if (flag !== -1 && this.cacheRefresh[x].prevStatus) {
this.$refs.table && this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], false)
this.$refs.table && this.$refs.table.toggleRowExpansion(this.linePreOrderList[flag], true)
}
}
this.loading = false
})
},
@ -1681,7 +1685,8 @@ export default {
close_type: 1
}
this.getSymbol({}, 1)
this.getLineApiUserItems(this.positionForm.exchange_type)
// this.getLineApiUserItems(this.positionForm.exchange_type)
this.getListLineApiUser(this.positionForm.exchange_type)
this.positionOpen = true
},
positionCancel() {
@ -1919,6 +1924,7 @@ export default {
handleAdd(title) {
this.title = title || '添加委托管理'
this.reset()
this.getListLineApiUser()
this.open = true
this.isEdit = false
},
@ -1991,7 +1997,8 @@ export default {
this.$refs.formCancel?.resetFields()
this.cancelForm.exchangeType = this.exchangeTypes.length ? this.exchangeTypes[0].value : ''
// 获取用户
this.getLineApiUserItems(this.cancelForm.exchangeType)
// this.getLineApiUserItems(this.cancelForm.exchangeType)
this.getListLineApiUser(this.cancelForm.exchangeType)
},
handleCancel(row) {
if (typeof row === 'string') {