import React, { PureComponent, Fragment } from 'react'; import { connect } from 'dva'; import moment from 'moment'; import { Row, Col, Card, Form, Input, Select, Icon, Button, Dropdown, Menu, InputNumber, DatePicker, Modal, message, Badge, Divider, Steps, Radio, } from 'antd'; import StandardTable from '@/components/StandardTable'; import PageHeaderLayout from '@/layouts/PageHeaderLayout'; import styles from './TableList.less'; const FormItem = Form.Item; const { Step } = Steps; const { TextArea } = Input; const { Option } = Select; const RadioGroup = Radio.Group; const getValue = obj => Object.keys(obj) .map(key => obj[key]) .join(','); const statusMap = ['default', 'processing', 'success', 'error']; const status = ['关闭', '运行中', '已上线', '异常']; const CreateForm = Form.create()(props => { const { modalVisible, form, handleAdd, handleModalVisible } = props; const okHandle = () => { form.validateFields((err, fieldsValue) => { if (err) return; form.resetFields(); handleAdd(fieldsValue); }); }; return ( handleModalVisible()} > {form.getFieldDecorator('desc', { rules: [{ required: true, message: '请输入至少五个字符的规则描述!', min: 5 }], })()} ); }); @Form.create() class UpdateForm extends PureComponent { columns = [ { title: '规则名称', dataIndex: 'name', }, { title: '描述', dataIndex: 'desc', }, { title: '服务调用次数', dataIndex: 'callNo', sorter: true, align: 'right', render: val => `${val} 万`, // mark to display a total number needTotal: true, }, { title: '状态', dataIndex: 'status', filters: [ { text: status[0], value: 0, }, { text: status[1], value: 1, }, { text: status[2], value: 2, }, { text: status[3], value: 3, }, ], render(val) { return ; }, }, { title: '上次调度时间', dataIndex: 'updatedAt', sorter: true, render: val => {moment(val).format('YYYY-MM-DD HH:mm:ss')}, }, { title: '操作', render: (text, record) => ( this.handleUpdateModalVisible(true, record)}>配置 订阅警报 ), }, ]; constructor(props) { super(props); this.state = { formVals: { name: props.values.name, desc: props.values.desc, key: props.values.key, target: '0', template: '0', type: '1', time: '', frequency: 'month', }, currentStep: 0, }; this.formLayout = { labelCol: { span: 7 }, wrapperCol: { span: 13 }, }; } handleNext = currentStep => { const { form, handleUpdate } = this.props; const { formVals: oldValue } = this.state; form.validateFields((err, fieldsValue) => { if (err) return; const formVals = { ...oldValue, ...fieldsValue }; this.setState( { formVals, }, () => { if (currentStep < 2) { this.forward(); } else { handleUpdate(formVals); } } ); }); }; backward = () => { const { currentStep } = this.state; this.setState({ currentStep: currentStep - 1, }); }; forward = () => { const { currentStep } = this.state; this.setState({ currentStep: currentStep + 1, }); }; renderContent = (currentStep, formVals) => { const { form } = this.props; if (currentStep === 1) { return [ {form.getFieldDecorator('target', { initialValue: formVals.target, })( )} , {form.getFieldDecorator('template', { initialValue: formVals.template, })( )} , {form.getFieldDecorator('type', { initialValue: formVals.type, })( )} , ]; } if (currentStep === 2) { return [ {form.getFieldDecorator('time', { rules: [{ required: true, message: '请选择开始时间!' }], })( )} , {form.getFieldDecorator('frequency', { initialValue: formVals.frequency, })( )} , ]; } return [ {form.getFieldDecorator('name', { rules: [{ required: true, message: '请输入规则名称!' }], initialValue: formVals.name, })()} , {form.getFieldDecorator('desc', { rules: [{ required: true, message: '请输入至少五个字符的规则描述!', min: 5 }], initialValue: formVals.desc, })(