修改添加地址为弹窗形式
This commit is contained in:
parent
97f8961e0b
commit
10614bdb9b
|
|
@ -1,47 +1,36 @@
|
|||
import React, { useState } from 'react';
|
||||
// 选择作品弹窗
|
||||
import React, { useRef } from 'react';
|
||||
import { createForm } from '@formily/core';
|
||||
import { createSchemaField } from '@formily/react';
|
||||
import Modal, { ModalProps } from '@/components/Modal';
|
||||
import { message } from 'antd';
|
||||
|
||||
import { Form, FormItem, Input, Submit } from '@formily/antd';
|
||||
import { AddAddress } from '@/services/eth';
|
||||
import { initWeb3, walletSign } from '../../../../utils/web3';
|
||||
import { values } from 'lodash';
|
||||
import { Form, FormItem, Input } from '@formily/antd';
|
||||
|
||||
interface AddAddressModalPropsType extends ModalProps {
|
||||
onOk: (val: any) => void;
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
const SchemaField = createSchemaField({
|
||||
components: {
|
||||
FormItem,
|
||||
Input,
|
||||
Submit,
|
||||
},
|
||||
});
|
||||
|
||||
const form = createForm({});
|
||||
|
||||
const AddAddressModal = (onOk, { ...rest }: AddAddressModalPropsType) => {
|
||||
const AddAddressModal = ({ onOk, onCancel, ...rest }: AddAddressModalPropsType) => {
|
||||
const handleOk = () => {
|
||||
const val = form.getState();
|
||||
console.log('val = ', val);
|
||||
onOk && onOk(val);
|
||||
// try {
|
||||
// await initWeb3();
|
||||
// const signInfo = await walletSign();
|
||||
// val.key = signInfo.raw;
|
||||
// val.sign = signInfo.sign;
|
||||
// val.coinType = 'eth';
|
||||
// val.num = parseInt(val.num);
|
||||
// const params = { ...val };
|
||||
// await AddAddress(params);
|
||||
// message.success('操作成功');
|
||||
// } catch (e) {}
|
||||
const formState = form.getFormState();
|
||||
onOk(formState.values);
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
onCancel();
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal title="添加地址" onOk={handleOk} width={800} {...rest}>
|
||||
<Modal title="选择作品" onOk={handleOk} onCancel={handleCancel} width={800} {...rest}>
|
||||
<Form form={form} labelCol={4} wrapperCol={18}>
|
||||
<SchemaField>
|
||||
<SchemaField.String
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
import React, { useRef, useState } from 'react';
|
||||
import Table, { ProColumns, ActionType } from '@/components/Table';
|
||||
import { history } from 'umi';
|
||||
import RoutePath from '@/routes/routePath';
|
||||
import { queryAddressList } from '@/services/eth';
|
||||
import { fetchTableData } from '@/utils/table';
|
||||
import CoinType from '@/constants/enum/coinType';
|
||||
// import WorkSelectModal from '@/widget/Work/WorkSelectModal';
|
||||
// import AddAddressModal from '../Edit/AddAddressModal';
|
||||
import AddAddressModal from '../Edit/AddAddressModal';
|
||||
import { AddAddress } from '@/services/eth';
|
||||
import { initWeb3, walletSign } from '../../../../utils/web3';
|
||||
import { message } from 'antd';
|
||||
|
||||
const AddressList = () => {
|
||||
// const [isModalVisible, setIsModalVisible] = useState(false);
|
||||
const [isModalVisible, setIsModalVisible] = useState(false);
|
||||
const tableRef = useRef<ActionType>();
|
||||
const columns: ProColumns<any>[] = [
|
||||
{
|
||||
|
|
@ -46,8 +46,8 @@ const AddressList = () => {
|
|||
{
|
||||
type: 'add',
|
||||
onConfirm: () => {
|
||||
history.push(RoutePath.ETH_ADDRESS.EDIT);
|
||||
// setIsModalVisible(true);
|
||||
// history.push(RoutePath.ETH_ADDRESS.EDIT);
|
||||
setIsModalVisible(true);
|
||||
},
|
||||
},
|
||||
]}
|
||||
|
|
@ -56,19 +56,26 @@ const AddressList = () => {
|
|||
return fetchTableData(queryAddressList, params);
|
||||
}}
|
||||
/>
|
||||
{/* <WorkSelectModal
|
||||
<AddAddressModal
|
||||
visible={isModalVisible}
|
||||
value={[]}
|
||||
onOk={function (val: any): void {
|
||||
onCancel={function () {
|
||||
setIsModalVisible(false);
|
||||
}}
|
||||
/> */}
|
||||
{/* <AddAddressModal
|
||||
visible={isModalVisible}
|
||||
onOk={function (val: any): void {
|
||||
onOk={async function (val: any): Promise<void> {
|
||||
try {
|
||||
await initWeb3();
|
||||
const signInfo = await walletSign();
|
||||
val.key = signInfo.raw;
|
||||
val.sign = signInfo.sign;
|
||||
val.coinType = CoinType.ETH;
|
||||
val.num = parseInt(val.num);
|
||||
const params = { ...val };
|
||||
await AddAddress(params);
|
||||
message.success('操作成功');
|
||||
} catch (e) {}
|
||||
setIsModalVisible(false);
|
||||
}}
|
||||
/> */}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue