import React, { PureComponent } from 'react'; import { FormattedMessage } from 'umi/locale'; import { findDOMNode } from 'react-dom'; import moment from 'moment'; import { connect } from 'dva'; import { List, Card, Row, Col, Radio, Input, Progress, Button, Icon, Dropdown, Menu, Avatar, Modal, Form, DatePicker, Select, } from 'antd'; import { Result } from 'ant-design-pro'; import styles from './style.less'; const FormItem = Form.Item; const RadioButton = Radio.Button; const RadioGroup = Radio.Group; const SelectOption = Select.Option; const { Search, TextArea } = Input; @connect(({ BLOCK_NAME_CAMEL_CASE, loading }) => ({ BLOCK_NAME_CAMEL_CASE, loading: loading.models.BLOCK_NAME_CAMEL_CASE, })) @Form.create() class PAGE_NAME_UPPER_CAMEL_CASE extends PureComponent { state = { visible: false, done: false }; formLayout = { labelCol: { span: 7 }, wrapperCol: { span: 13 }, }; componentDidMount() { const { dispatch } = this.props; dispatch({ type: 'BLOCK_NAME_CAMEL_CASE/fetch', payload: { count: 5, }, }); } showModal = () => { this.setState({ visible: true, current: undefined, }); }; showEditModal = item => { this.setState({ visible: true, current: item, }); }; handleDone = () => { setTimeout(() => this.addBtn.blur(), 0); this.setState({ done: false, visible: false, }); }; handleCancel = () => { setTimeout(() => this.addBtn.blur(), 0); this.setState({ visible: false, }); }; handleSubmit = e => { e.preventDefault(); const { dispatch, form } = this.props; const { current } = this.state; const id = current ? current.id : ''; setTimeout(() => this.addBtn.blur(), 0); form.validateFields((err, fieldsValue) => { if (err) return; this.setState({ done: true, }); dispatch({ type: 'BLOCK_NAME_CAMEL_CASE/submit', payload: { id, ...fieldsValue }, }); }); }; deleteItem = id => { const { dispatch } = this.props; dispatch({ type: 'BLOCK_NAME_CAMEL_CASE/submit', payload: { id }, }); }; render() { const { BLOCK_NAME_CAMEL_CASE: { list }, loading, } = this.props; const { form: { getFieldDecorator }, } = this.props; const { visible, done, current = {} } = this.state; const editAndDelete = (key, currentItem) => { if (key === 'edit') this.showEditModal(currentItem); else if (key === 'delete') { Modal.confirm({ title: '删除任务', content: '确定删除该任务吗?', okText: '确认', cancelText: '取消', onOk: () => this.deleteItem(currentItem.id), }); } }; const modalFooter = done ? { footer: null, onCancel: this.handleDone } : { okText: '保存', onOk: this.handleSubmit, onCancel: this.handleCancel }; const Info = ({ title, value, bordered }) => (
{value}
{bordered && }{owner}
{moment(createdAt).format('YYYY-MM-DD HH:mm')}