From f7b5fdefdf60484418f394cf0143592412ff092d Mon Sep 17 00:00:00 2001 From: shilin Date: Fri, 14 Feb 2025 10:56:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E8=BE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/line-order-template-logs/index.vue | 11 +- src/views/admin/line-order/index.vue | 137 +++++++-------- src/views/admin/line-pre-order/index.vue | 161 +++++++++--------- 3 files changed, 160 insertions(+), 149 deletions(-) diff --git a/src/views/admin/line-order-template-logs/index.vue b/src/views/admin/line-order-template-logs/index.vue index a081c27..0785008 100644 --- a/src/views/admin/line-order-template-logs/index.vue +++ b/src/views/admin/line-order-template-logs/index.vue @@ -235,10 +235,10 @@ size="small" > @@ -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 = '修改委托下单模板' diff --git a/src/views/admin/line-order/index.vue b/src/views/admin/line-order/index.vue index b19de40..b77be97 100644 --- a/src/views/admin/line-order/index.vue +++ b/src/views/admin/line-order/index.vue @@ -11,10 +11,10 @@ size="small" > @@ -244,7 +244,7 @@ @@ -465,9 +465,9 @@ > @@ -804,9 +804,9 @@ > @@ -917,9 +917,9 @@ > @@ -979,9 +979,9 @@ > @@ -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 }) }, diff --git a/src/views/admin/line-pre-order/index.vue b/src/views/admin/line-pre-order/index.vue index 33e31e8..6c9b6e3 100644 --- a/src/views/admin/line-pre-order/index.vue +++ b/src/views/admin/line-pre-order/index.vue @@ -12,10 +12,10 @@ size="small" > @@ -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 @@ @@ -528,10 +528,10 @@ size="small" > @@ -988,10 +988,10 @@ size="small" > @@ -1119,10 +1119,10 @@ size="small" > @@ -1210,10 +1210,10 @@ size="small" > @@ -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') {