|
|
@ -1,16 +1,19 @@ |
|
|
|
import React, { useEffect, useRef, useState } from "react"; |
|
|
|
import api from "@/api"; |
|
|
|
import MyTable from "@/components/MyTable"; |
|
|
|
import { DeleteFilled, EditOutlined, RightCircleFilled } from "@ant-design/icons"; |
|
|
|
import { DeleteFilled, EditOutlined, RightCircleFilled, SolutionOutlined } from "@ant-design/icons"; |
|
|
|
import { Button, Form, Input, Modal, Popconfirm, Radio, Select, Switch, notification } from "antd"; |
|
|
|
import { getOriginUrl } from "@/utils/axios"; |
|
|
|
import { getBaseUrl, getOriginUrl } from "@/utils/axios"; |
|
|
|
|
|
|
|
const ProxyList = () => { |
|
|
|
const [modal, setModal] = useState(false); |
|
|
|
const [modalFollow, setModalFollow] = useState(false); |
|
|
|
const [visible, setVisible] = useState(false); |
|
|
|
const [path, setPath] = useState('wallet'); |
|
|
|
const currentAccount = useRef({} as any); |
|
|
|
const [form] = Form.useForm(); |
|
|
|
const [formAccount] = Form.useForm(); |
|
|
|
const [formFollow] = Form.useForm(); |
|
|
|
const tableRef = useRef(null); |
|
|
|
|
|
|
|
const options = [ |
|
|
@ -26,17 +29,14 @@ const ProxyList = () => { |
|
|
|
]; |
|
|
|
|
|
|
|
const getToken = async (item) => { |
|
|
|
const url = getOriginUrl(); |
|
|
|
const targetWindow = window.open(url, '_blank'); |
|
|
|
|
|
|
|
const res: any = await api.get_userToken({ id: item.id }); |
|
|
|
if (res.code === 0) { |
|
|
|
for (let i = 0; i < 5; i++) { |
|
|
|
setTimeout(() => { |
|
|
|
targetWindow.postMessage({ token: res.data.token }, url); |
|
|
|
}, i * 1000); |
|
|
|
} |
|
|
|
} |
|
|
|
const _token = res.data.token |
|
|
|
window.localStorage.setItem('Tarder_Token', _token) |
|
|
|
setTimeout(() => { |
|
|
|
const url = getOriginUrl() |
|
|
|
window.open(url, '_blank'); |
|
|
|
}, 1000) |
|
|
|
}; |
|
|
|
|
|
|
|
const deleteAccount = async (item) => { |
|
|
@ -69,7 +69,7 @@ const ProxyList = () => { |
|
|
|
wallet: { |
|
|
|
onFinish: (values) => onFinish(values, api.set_userWalletBalance, '修改成功'), |
|
|
|
items: [ |
|
|
|
{ label: "当前余额", name: "balance", initialValue: currentAccount.current.balance, disabled: true }, |
|
|
|
{ label: "当前余额", component: <Input value={currentAccount.current.balance || ''} disabled /> }, |
|
|
|
{ label: "加减金额", name: "balance", rules: [{ required: true, message: '请输入加减金额' }] }, |
|
|
|
{ label: "邮箱通知", name: "email_flag", initialValue: true, valuePropName: "checked", component: <Switch /> } |
|
|
|
] |
|
|
@ -119,7 +119,7 @@ const ProxyList = () => { |
|
|
|
const onFinishAddAccount = async (values) => { |
|
|
|
const res: any = await api.add_account({ ...values }); |
|
|
|
if (res.code === 0) { |
|
|
|
form.resetFields(); |
|
|
|
formAccount.resetFields(); |
|
|
|
setVisible(false); |
|
|
|
tableRef.current.update(); |
|
|
|
notification.success({ |
|
|
@ -131,6 +131,21 @@ const ProxyList = () => { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const onFinishFollow = async (values) => { |
|
|
|
setModalFollow(false) |
|
|
|
const res: any = await api.copy_tradeapi({ |
|
|
|
...values, |
|
|
|
id: currentAccount.current.id |
|
|
|
}) |
|
|
|
if (res.code === 0) { |
|
|
|
formFollow.resetFields() |
|
|
|
notification.success({ |
|
|
|
message: '跟单设置成功' |
|
|
|
}) |
|
|
|
tableRef.current.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const columns = [ |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
@ -144,6 +159,10 @@ const ProxyList = () => { |
|
|
|
<RightCircleFilled style={{ margin: '0 10px' }} onClick={() => { |
|
|
|
getToken(row); |
|
|
|
}} /> |
|
|
|
<SolutionOutlined onClick={() => { |
|
|
|
currentAccount.current = row |
|
|
|
setModalFollow(true) |
|
|
|
}} /> |
|
|
|
{/* <Popconfirm title={`确定删除 "${row.name}" 吗?`} onConfirm={() => deleteAccount(row)}> |
|
|
|
<DeleteFilled /> |
|
|
|
</Popconfirm> */} |
|
|
@ -208,7 +227,7 @@ const ProxyList = () => { |
|
|
|
bodyStyle={{ padding: "20px" }} |
|
|
|
footer={() => null} |
|
|
|
> |
|
|
|
<Form form={form} onFinish={onFinishAddAccount}> |
|
|
|
<Form form={formAccount} onFinish={onFinishAddAccount}> |
|
|
|
<Form.Item label="名字" name="name" rules={[{ required: true, message: '请输入用户名称' }]}> |
|
|
|
<Input placeholder="请输入用户名称" /> |
|
|
|
</Form.Item> |
|
|
@ -227,6 +246,25 @@ const ProxyList = () => { |
|
|
|
</div> |
|
|
|
</Form> |
|
|
|
</Modal> |
|
|
|
|
|
|
|
<Modal |
|
|
|
visible={modalFollow} |
|
|
|
onCancel={() => setModalFollow(false)} |
|
|
|
width="50%" |
|
|
|
title={`跟单设置: ${currentAccount.current.name}`} |
|
|
|
bodyStyle={{ padding: "20px" }} |
|
|
|
footer={() => null} |
|
|
|
> |
|
|
|
<Form form={formFollow} onFinish={onFinishFollow}> |
|
|
|
<Form.Item label="跟单账号" name="follower" rules={[{ required: true, message: '请输入跟单账号' }]}> |
|
|
|
<Input placeholder="请输入跟单账号" /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item label="操作"> |
|
|
|
<Button onClick={() => setModalFollow(false)}>取消</Button> |
|
|
|
<Button type="primary" htmlType="submit" style={{ marginLeft: 20 }}>确认</Button> |
|
|
|
</Form.Item> |
|
|
|
</Form> |
|
|
|
</Modal> |
|
|
|
</div> |
|
|
|
); |
|
|
|
}; |
|
|
|