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