UNPKG

app-base-web

Version:
146 lines (144 loc) 4.72 kB
import React, { Suspense, lazy } from 'react'; import { Switch, Table, Form, Modal, Row, Col, Button, Input, message } from 'antd'; import CheckGroup from "../../../library/check-group" import api from "../../../library/util-axios" import Dic from "../../../library/dic" // 用户管理-用户/专家 const title = "用户/专家"; const url = "User/"; export default class FormEdit extends React.Component { constructor(props) { super(props); this.state = { ...props.values }; } onSave = (values) => { let me = this; values.id = this.state.id; api.post(url + "save", values).then(function (rs) { if (rs.success) { message.info(rs.msg); me.props.onSave(values); } else { message.error(rs.msg); } }); } render() { console.log('this.state',this.state) return ( <Form onFinish={this.onSave} labelCol={{ span: 6 }} wrapperCol={{ span: 18 }} className="form-edit" > <div className="form-title"> <i> {title} - {this.state.id ? "编辑" : "录入"}</i> {this.state.id ? <span><Button className="btn-return" onClick={this.props.onEditReturn}><i className="iconfont icon-return"></i>返回</Button></span> : ""} </div> <div className="form-content" style={{ height: this.props.height }}> <Row> <Col xs={12}> <Form.Item name="name" label="用户名称" initialValue={this.state.name}> <Input /> </Form.Item> </Col> </Row> <Row> <Col xs={12}> <Form.Item name="isExpert" label="是否为专家" valuePropName="checked" initialValue={Boolean(this.state.isExpert)}> <Switch /> </Form.Item> </Col> <Col xs={12}> <Form.Item name="type" label="专家类型" initialValue={this.state.type}> <CheckGroup options={[{ id: "机械", name: "机械" }, { id: "电学", name: "电学" }, { id: "化学", name: "化学" }, { id: "其他", name: "其他" }]} /> </Form.Item> </Col> </Row> <Row> <Col xs={12}> <Form.Item name="sex" label="性别" initialValue={String(this.state.sex)}> <Dic params={{ app: "system", type: "性别" }} /> </Form.Item> </Col> <Col xs={12}> <Form.Item name="position" label="职务" initialValue={this.state.position}> <Input /> </Form.Item> </Col> </Row> <Row> <Col xs={12}> <Form.Item name="phone" label="手机" initialValue={this.state.phone}> <Input /> </Form.Item> </Col> </Row> <Row> <Col xs={12}> <Form.Item name="email" label="邮箱" initialValue={this.state.email}> <Input /> </Form.Item> </Col> </Row> <Row> <Col xs={12}> <Form.Item name="companyName" label="公司名称" initialValue={this.state.companyName}> <Input /> </Form.Item> </Col> </Row> <Row> <Col xs={24}> <Form.Item labelCol={{ span: 3 }} wrapperCol={{ span: 21 }} name="intro" label="简介" initialValue={this.state.intro}> <Input.TextArea /> </Form.Item> </Col> </Row> <Row> <Col xs={24}> <Form.Item labelCol={{ span: 3 }} wrapperCol={{ span: 21 }} name="introDetail" label="详细介绍" initialValue={this.state.introDetail}> <Input.TextArea /> </Form.Item> </Col> </Row> </div> <div className="form-toolbar"> <Button className="btn-cancel" onClick={this.props.onCancel}><i className="iconfont icon-cancel"></i>取消</Button> <Button className="btn-submit" htmlType="submit"><i className="iconfont icon-submit"></i>提交</Button> </div> </Form> ); } }