dev_forum
杨树林 5 years ago
parent ac2065b518
commit 01f19b9bcf

@ -1,176 +1,177 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { Modal, Button, Input, Form, } from "antd"; import { Modal, Button, Input, Form, } from "antd";
import axios from 'axios' import axios from 'axios'
import ModalWrapper from "../../courses/common/ModalWrapper" import ModalWrapper from "../../courses/common/ModalWrapper"
import { City } from 'educoder' import { City } from 'educoder'
import '../account/common.css' import '../account/common.css'
const { TextArea } = Input; const { TextArea } = Input;
const Search = Input.Search const Search = Input.Search
class ApplyForAddOrgModal extends Component{ class ApplyForAddOrgModal extends Component{
constructor(props){ constructor(props){
super(props); super(props);
this.state={ this.state={
} }
} }
componentDidUpdate=(prevState)=>{ componentDidUpdate=(prevState)=>{
if(this.props.schoolName && prevState.schoolName != this.props.schoolName){ if(this.props.schoolName && prevState.schoolName != this.props.schoolName){
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
schoolName:this.props.schoolName schoolName:this.props.schoolName
}) })
} }
} }
componentDidMount=()=>{ componentDidMount=()=>{
if(this.props.schoolName){ if(this.props.schoolName){
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
schoolName:this.props.schoolName schoolName:this.props.schoolName
}) })
} }
} }
setVisible = (visible) => { setVisible = (visible) => {
this.refs.modalWrapper.setVisible(visible) this.refs.modalWrapper.setVisible(visible)
} }
onSendOk = () => { onSendOk = () => {
this.props.form.validateFieldsAndScroll((err, values) => { this.props.form.validateFieldsAndScroll((err, values) => {
console.log(values); console.log(values);
if(!err){ if(!err){
let url=`/add_school_applies.json`; let url=`/add_school_applies.json`;
axios.post(url,{ axios.post(url,{
name:values.schoolName, name:values.schoolName,
province:values.city && values.city[0], province:values.city && values.city[0],
city:values.city && values.city[1], city:values.city && values.city[1],
address:values.address, address:values.address,
remarks:values.remarks remarks:values.remarks
}).then((result)=>{ }).then((result)=>{
if(result){ if(result){
this.props.showNotification("新增学校/单位成功!"); this.props.showNotification("新增学校/单位成功!");
this.props.addOrgSuccess(values.schoolName) this.setVisible(false);
this.setVisible(false); this.props.addOrgSuccess(values.schoolName)
}
}).catch((error)=>{ }
console.log(error); }).catch((error)=>{
}) console.log(error);
} })
}) }
} })
}
onOk = () => {
this.onSendOk() onOk = () => {
} this.onSendOk()
}
render(){
const { course_lists, checkBoxValues, searchValue, loading, hasMore } = this.state render(){
const { moduleName } = this.props const { course_lists, checkBoxValues, searchValue, loading, hasMore } = this.state
const { getFieldDecorator } = this.props.form; const { moduleName } = this.props
return( const { getFieldDecorator } = this.props.form;
<ModalWrapper return(
ref="modalWrapper" <ModalWrapper
title={`申请添加单位名称`} ref="modalWrapper"
{...this.props } title={`申请添加单位名称`}
onOk={this.onOk} {...this.props }
okText="保存" onOk={this.onOk}
className="applyForModal" okText="保存"
> className="applyForModal"
<style>{` >
.applyForModal .ant-form-item-label { <style>{`
width: 100px; .applyForModal .ant-form-item-label {
padding-right: 10px; width: 100px;
} padding-right: 10px;
.applyForModal .ant-form-item-label label { }
color: #979797 .applyForModal .ant-form-item-label label {
} color: #979797
.applyForModal .formItemInline .ant-form-item-control-wrapper{ }
width: 390px; .applyForModal .formItemInline .ant-form-item-control-wrapper{
} width: 390px;
.applyForModal .formItemInline .ant-form-item-control .ant-cascader-picker,.applyForModal .formItemInline .ant-cascader-picker-large .ant-input{ }
width: 100%; .applyForModal .formItemInline .ant-form-item-control .ant-cascader-picker,.applyForModal .formItemInline .ant-cascader-picker-large .ant-input{
height:32px!important; width: 100%;
} height:32px!important;
.applyForModal .formItemInline .ant-input-lg{ }
font-size:14px!important; .applyForModal .formItemInline .ant-input-lg{
} font-size:14px!important;
.explain .ant-form-explain{ }
top:36px; .explain .ant-form-explain{
} top:36px;
}
.addOrg ul.ant-cascader-menu {
width: 196px; .addOrg ul.ant-cascader-menu {
} width: 196px;
`}</style> }
<Form onSubmit={this.onOk}> `}</style>
<Form.Item <Form onSubmit={this.onOk}>
label="单位全称:" <Form.Item
className="mt15 formItemInline explain" label="单位全称:"
> className="mt15 formItemInline explain"
{getFieldDecorator('schoolName', { >
rules: [{ {getFieldDecorator('schoolName', {
// initialValue: this.state.cityDefaultValue, rules: [{
required: true, // initialValue: this.state.cityDefaultValue,
message: '请输入学校或工作单位', required: true,
}], message: '请输入学校或工作单位',
})( }],
<Input placeholder="学校或工作单位" className="validateInput"></Input> })(
)} <Input placeholder="学校或工作单位" className="validateInput"></Input>
<div className="df mt18"> )}
<li style={{lineHeight:"22px"}}>示例</li> <div className="df mt18">
<ul style={{lineHeight:"22px"}}> <li style={{lineHeight:"22px"}}>示例</li>
<li> <ul style={{lineHeight:"22px"}}>
<i className="iconfont icon-chenggong color-green-light font-14 ml2 mr5 fl"></i> <li>
<span> 国防科学技术大学</span> <i className="iconfont icon-chenggong color-green-light font-14 ml2 mr5 fl"></i>
</li> <span> 国防科学技术大学</span>
<li> </li>
<i className="iconfont icon-htmal5icon19 font-18 fl mr4" style={{color:"#FF9348"}}></i> <li>
<span> 国防科学技术大学开福校区</span> <i className="iconfont icon-htmal5icon19 font-18 fl mr4" style={{color:"#FF9348"}}></i>
</li> <span> 国防科学技术大学开福校区</span>
</ul> </li>
</div> </ul>
</Form.Item> </div>
</Form.Item>
<Form.Item
label="地区:" <Form.Item
className="mt15 formItemInline hideRequireTag" label="地区:"
> className="mt15 formItemInline hideRequireTag"
{getFieldDecorator('city', { >
rules: [], {getFieldDecorator('city', {
})( rules: [],
<City matchInputWidth={true} popupClassName={"addOrg"}></City> })(
)} <City matchInputWidth={true} popupClassName={"addOrg"}></City>
</Form.Item> )}
</Form.Item>
<Form.Item
label="详细地址:" <Form.Item
className="mt15 formItemInline hideRequireTag" label="详细地址:"
> className="mt15 formItemInline hideRequireTag"
{getFieldDecorator('address', { >
rules: [], {getFieldDecorator('address', {
})( rules: [],
<Input placeholder="请填写完整的地址信息" className="validateInput"></Input> })(
)} <Input placeholder="请填写完整的地址信息" className="validateInput"></Input>
</Form.Item> )}
</Form.Item>
<Form.Item
label="说明:" <Form.Item
className="mt15 formItemInline hideRequireTag" label="说明:"
> className="mt15 formItemInline hideRequireTag"
{getFieldDecorator('remarks', { >
})( {getFieldDecorator('remarks', {
<TextArea placeholder="再次说明特别情况(选填)" className="validateInput"></TextArea> })(
)} <TextArea placeholder="再次说明特别情况(选填)" className="validateInput"></TextArea>
</Form.Item> )}
</Form.Item>
</Form>
</Form>
</ModalWrapper>
) </ModalWrapper>
} )
} }
const WrappedApplyForAddOrgModal = Form.create({ name: 'ApplyForAddOrgModal' })(ApplyForAddOrgModal); }
const WrappedApplyForAddOrgModal = Form.create({ name: 'ApplyForAddOrgModal' })(ApplyForAddOrgModal);
export default WrappedApplyForAddOrgModal;
export default WrappedApplyForAddOrgModal;

Loading…
Cancel
Save