| | |
| | | import React, { useEffect, useState } from 'react'; |
| | | import { |
| | | ProForm, |
| | | ProFormDigit, |
| | | ProFormText, |
| | | ProFormSelect, |
| | | ProFormDateTimePicker |
| | | } from '@ant-design/pro-components'; |
| | | import { Form, Modal } from 'antd'; |
| | | import { useIntl, FormattedMessage } from '@umijs/max'; |
| | | import moment from 'moment'; |
| | | import Http from '@/utils/http'; |
| | | |
| | | const Edit = (props) => { |
| | | const [form] = Form.useForm(); |
| | | const { } = props; |
| | | const intl = useIntl(); |
| | | |
| | | useEffect(() => { |
| | | form.resetFields(); |
| | | form.setFieldsValue({ |
| | | ...props.values |
| | | }) |
| | | }, [form, props]) |
| | | |
| | | const handleCancel = () => { |
| | | props.onCancel(); |
| | | }; |
| | | |
| | | const handleOk = () => { |
| | | form.submit(); |
| | | } |
| | | |
| | | const handleFinish = async (values) => { |
| | | props.onSubmit({ ...values }); |
| | | } |
| | | |
| | | return ( |
| | | <> |
| | | <Modal |
| | | title="Edit" |
| | | width={640} |
| | | forceRender |
| | | destroyOnClose |
| | | open={props.open} |
| | | onCancel={handleCancel} |
| | | onOk={handleOk} |
| | | > |
| | | <ProForm |
| | | form={form} |
| | | submitter={false} |
| | | onFinish={handleFinish} |
| | | layout="horizontal" |
| | | grid={true} |
| | | > |
| | | <ProFormDigit |
| | | name="id" |
| | | disabled |
| | | hidden={true} |
| | | /> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="name" |
| | | label="角色名称" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | rules={[{ required: true, message: "请输入角色名称!" }]} |
| | | /> |
| | | <ProFormText |
| | | name="code" |
| | | label="角色标识" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | placeholder="请输入" |
| | | rules={[{ required: true, message: "请输入角色标识!" }]} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormSelect |
| | | name="status" |
| | | label="状态" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | options={[ |
| | | { label: '正常', value: 1 }, |
| | | { label: '禁用', value: 0 }, |
| | | ]} |
| | | rules={[{ required: true, message: "请选择状态!" }]} |
| | | /> |
| | | <ProFormDateTimePicker |
| | | name="updateTime" |
| | | label="修改时间" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | transform={(value) => { |
| | | return moment(value).toISOString(); |
| | | }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProFormSelect |
| | | name="hostId" |
| | | label="搜索查询" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | showSearch |
| | | debounceTime={300} // 防抖 |
| | | request={async ({ keyWords }) => { |
| | | const resp = await Http.doPost('api/host/page', { ...keyWords }); |
| | | console.log(resp); |
| | | // return [ |
| | | // { |
| | | // value: keyWords, |
| | | // label: '目标_target', |
| | | // }, |
| | | // { value: '520000201604258831', label: 'Patricia Lopez' }, |
| | | // { value: '520000198509222123', label: 'Jose Martinez' }, |
| | | // { value: '210000200811194757', label: 'Elizabeth Thomas' }, |
| | | // { value: '530000198808222758', label: 'Scott Anderson' }, |
| | | // { value: '500000198703236285', label: 'George Jackson' }, |
| | | // { value: '610000199906148074', label: 'Linda Hernandez' }, |
| | | // { value: '150000197210168659', label: 'Sandra Hall' }, |
| | | // { label: '目标_target' }, |
| | | // ] |
| | | }} |
| | | placeholder="Please select a country" |
| | | /> |
| | | </ProForm> |
| | | </Modal> |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react';
|
| | | import {
|
| | | ProForm,
|
| | | ProFormDigit,
|
| | | ProFormText,
|
| | | ProFormSelect,
|
| | | ProFormDateTimePicker
|
| | | } from '@ant-design/pro-components';
|
| | | import { FormattedMessage, useIntl } from '@umijs/max';
|
| | | import { Form, Modal } from 'antd';
|
| | | import moment from 'moment';
|
| | | import Http from '@/utils/http';
|
| | |
|
| | | const Edit = (props) => {
|
| | | const intl = useIntl();
|
| | | const [form] = Form.useForm();
|
| | | const { } = props;
|
| | |
|
| | | useEffect(() => {
|
| | | form.resetFields();
|
| | | form.setFieldsValue({
|
| | | ...props.values
|
| | | })
|
| | | }, [form, props])
|
| | |
|
| | | const handleCancel = () => {
|
| | | props.onCancel();
|
| | | };
|
| | |
|
| | | const handleOk = () => {
|
| | | form.submit();
|
| | | }
|
| | |
|
| | | const handleFinish = async (values) => {
|
| | | props.onSubmit({ ...values });
|
| | | }
|
| | |
|
| | | return (
|
| | | <>
|
| | | <Modal
|
| | | title={
|
| | | Object.keys(props.values).length > 0
|
| | | ? intl.formatMessage({ id: 'page.edit', defaultMessage: '编辑' })
|
| | | : intl.formatMessage({ id: 'page.add', defaultMessage: '添加' })
|
| | | }
|
| | | width={640}
|
| | | forceRender
|
| | | destroyOnClose
|
| | | open={props.open}
|
| | | onCancel={handleCancel}
|
| | | onOk={handleOk}
|
| | | >
|
| | | <ProForm
|
| | | form={form}
|
| | | submitter={false}
|
| | | onFinish={handleFinish}
|
| | | layout="horizontal"
|
| | | grid={true}
|
| | | >
|
| | | <ProFormDigit
|
| | | name="id"
|
| | | disabled
|
| | | hidden={true}
|
| | | />
|
| | | <ProForm.Group>
|
| | | <ProFormText
|
| | | name="name"
|
| | | label="角色名称"
|
| | | colProps={{ md: 12, xl: 12 }}
|
| | | rules={[{ required: true, message: "请输入角色名称!" }]}
|
| | | />
|
| | | <ProFormText
|
| | | name="code"
|
| | | label="角色标识"
|
| | | colProps={{ md: 12, xl: 12 }}
|
| | | rules={[{ required: true, message: "请输入角色标识!" }]}
|
| | | />
|
| | | </ProForm.Group>
|
| | | <ProForm.Group>
|
| | | <ProFormSelect
|
| | | name="status"
|
| | | label="状态"
|
| | | colProps={{ md: 12, xl: 12 }}
|
| | | options={[
|
| | | { label: '正常', value: 1 },
|
| | | { label: '禁用', value: 0 },
|
| | | ]}
|
| | | rules={[{ required: true, message: "请选择状态!" }]}
|
| | | />
|
| | | <ProFormText
|
| | | name="memo"
|
| | | label="备注"
|
| | | colProps={{ md: 12, xl: 12 }}
|
| | | />
|
| | | </ProForm.Group>
|
| | | </ProForm>
|
| | | </Modal>
|
| | | </>
|
| | | )
|
| | | }
|
| | |
|
| | | export default Edit; |