|
@@ -63,6 +63,8 @@ function MyLPPageContent() {
|
|
|
const [page, setPage] = useState(1)
|
|
const [page, setPage] = useState(1)
|
|
|
const [pageSize] = useState(50)
|
|
const [pageSize] = useState(50)
|
|
|
const [poolMap, setPoolMap] = useState<Record<string, LPInfo>>({})
|
|
const [poolMap, setPoolMap] = useState<Record<string, LPInfo>>({})
|
|
|
|
|
+ const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([])
|
|
|
|
|
+ const [batchClosing, setBatchClosing] = useState(false)
|
|
|
|
|
|
|
|
const fetchLPDetail = async (positions: RecordInfo[]) => {
|
|
const fetchLPDetail = async (positions: RecordInfo[]) => {
|
|
|
message.loading(`正在查询当前页面仓位详细信息,请稍等...`)
|
|
message.loading(`正在查询当前页面仓位详细信息,请稍等...`)
|
|
@@ -473,6 +475,43 @@ function MyLPPageContent() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ async function handleBatchClosePosition() {
|
|
|
|
|
+ if (selectedRowKeys.length === 0) {
|
|
|
|
|
+ message.info('请先选择要关闭的仓位')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ setBatchClosing(true)
|
|
|
|
|
+ message.loading({
|
|
|
|
|
+ key: 'batchClosePosition',
|
|
|
|
|
+ content: `正在批量关闭仓位... (0/${selectedRowKeys.length})`,
|
|
|
|
|
+ duration: 0,
|
|
|
|
|
+ })
|
|
|
|
|
+ try {
|
|
|
|
|
+ const selectedPositions = lpList.filter((item) =>
|
|
|
|
|
+ selectedRowKeys.includes(item.nftMintAddress)
|
|
|
|
|
+ )
|
|
|
|
|
+ for (let i = 0; i < selectedPositions.length; i++) {
|
|
|
|
|
+ const position = selectedPositions[i]
|
|
|
|
|
+ await handleClosePosition(position)
|
|
|
|
|
+ message.loading({
|
|
|
|
|
+ key: 'batchClosePosition',
|
|
|
|
|
+ content: `正在批量关闭仓位... (${i + 1}/${selectedRowKeys.length})`,
|
|
|
|
|
+ duration: 0,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ message.success(
|
|
|
|
|
+ `批量关闭仓位成功,关闭了 ${selectedRowKeys.length} 个仓位`
|
|
|
|
|
+ )
|
|
|
|
|
+ setSelectedRowKeys([])
|
|
|
|
|
+ } catch (err: unknown) {
|
|
|
|
|
+ console.error('Error batch closing positions:', err)
|
|
|
|
|
+ message.error(err instanceof Error ? err.message : '批量关闭仓位失败')
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ message.destroy('batchClosePosition')
|
|
|
|
|
+ setBatchClosing(false)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
const userAddress = localStorage.getItem('userAddress')
|
|
const userAddress = localStorage.getItem('userAddress')
|
|
|
if (userAddress) {
|
|
if (userAddress) {
|
|
@@ -503,6 +542,16 @@ function MyLPPageContent() {
|
|
|
>
|
|
>
|
|
|
一键关闭无上级仓位
|
|
一键关闭无上级仓位
|
|
|
</Button>
|
|
</Button>
|
|
|
|
|
+ {selectedRowKeys.length > 0 && (
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ danger
|
|
|
|
|
+ onClick={handleBatchClosePosition}
|
|
|
|
|
+ loading={batchClosing}
|
|
|
|
|
+ >
|
|
|
|
|
+ 批量快速关仓 ({selectedRowKeys.length})
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ )}
|
|
|
</div>
|
|
</div>
|
|
|
) : (
|
|
) : (
|
|
|
<Button type="primary" onClick={handleAddAddress}>
|
|
<Button type="primary" onClick={handleAddAddress}>
|
|
@@ -520,6 +569,12 @@ function MyLPPageContent() {
|
|
|
rowClassName={(record: RecordInfo) => {
|
|
rowClassName={(record: RecordInfo) => {
|
|
|
return record?.hasDetail ? '' : 'bg-green-100'
|
|
return record?.hasDetail ? '' : 'bg-green-100'
|
|
|
}}
|
|
}}
|
|
|
|
|
+ rowSelection={{
|
|
|
|
|
+ selectedRowKeys,
|
|
|
|
|
+ onChange: (newSelectedRowKeys) => {
|
|
|
|
|
+ setSelectedRowKeys(newSelectedRowKeys)
|
|
|
|
|
+ },
|
|
|
|
|
+ }}
|
|
|
pagination={{
|
|
pagination={{
|
|
|
pageSize: pageSize,
|
|
pageSize: pageSize,
|
|
|
showSizeChanger: true,
|
|
showSizeChanger: true,
|