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

View File

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

View File

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