增加初稿问题
continuous-integration/drone/push Build is passing Details

master
cxz66666 2020-09-09 00:24:19 +08:00
parent 0dd32e2964
commit 6fb7a51311
1 changed files with 104 additions and 56 deletions

View File

@ -10,11 +10,15 @@ import successInform from "./Message";
class NewForm extends React.Component {
constructor() {
super();
this.state = { WishValid:false,firstWish:undefined,secondWish:undefined };
this.state = {
WishValid: false,
firstWish: undefined,
secondWish: undefined,
};
}
componentDidMount() {
this.loadLocalStorage();
this.props.form.validateFields(['firstWish'], { force: true });
this.props.form.validateFields(["firstWish"], { force: true });
}
loadLocalStorage = () => {
const values = JSON.parse(localStorage.getItem("formCache") || "{}");
@ -41,7 +45,7 @@ class NewForm extends React.Component {
label: "Yes",
onClick: () => {
validateFieldsAndScroll((err, values) => {
if(err) {
if (err) {
message.error("填写不正确,请按照提示修改");
} else {
// console.log(values);
@ -94,33 +98,58 @@ class NewForm extends React.Component {
});
};
validator = (rule, value, callback) => {
this.setState({WishValid:true})
const form = this.props.form
var firstWish = value
var secondWish = form.getFieldValue('secondWish')
var thirdWish = form.getFieldValue('thirdWish')
this.setState({firstWish:firstWish,secondWish:secondWish})
try{
if(firstWish === undefined ||secondWish === undefined ||thirdWish === undefined){
throw("请完整填写三个志愿")
validator = (rule, value, callback) => {
this.setState({ WishValid: true });
const form = this.props.form;
var firstWish = value;
var secondWish = form.getFieldValue("secondWish");
var thirdWish = form.getFieldValue("thirdWish");
this.setState({ firstWish: firstWish, secondWish: secondWish });
try {
if (
firstWish === undefined ||
secondWish === undefined ||
thirdWish === undefined
) {
throw "请完整填写三个志愿";
}
if(firstWish === secondWish||firstWish === thirdWish ||secondWish === thirdWish){
throw("三个志愿不能重复")
if (
firstWish === secondWish ||
firstWish === thirdWish ||
secondWish === thirdWish
) {
throw "三个志愿不能重复";
}
}catch(err){
this.setState({WishValid:false})
callback(err)
} catch (err) {
this.setState({ WishValid: false });
callback(err);
}
callback()
}
callback();
};
render() {
const questions = [[],
["1","2"],
["3","4"],
["5","6"],
["7","8"],
["9","10"]]
const questions = [
[],
[
"电脑部:说说你跟电脑有关的印象深刻的事情(或者你对电脑最感兴趣的地方,可以是某个组成部分)",
"电脑部:来电脑部之后想学些什么?有什么想学的也可以说呀",
],
[
"电器部:你有没有自己拆装简单电器的经历,有的话请简述",
"电器部:你希望自己在电器部成为一个怎样的人?定位在劳动者,领导者还是创新者?请简述",
],
[
"文宣部描述一下你构想的以xx为主题的海报or摄影作品xx可以是你想到的任何事物",
"文宣部:你觉得我们是干什么的(正经脸)",
],
[
"人资部:请举一个你想出的创新点子(实现过或现实中有一定的可操作性),最好是关于组织某次活动(活动包括但不限于宣传活动,内建活动,特殊的生日祝福等等)",
"人资部:你觉得你身上最符合人资部的特点是什么?",
],
[
"财外部:在社团全员大会/部门内建/部门事务这三种情况打破了你原来的学习安排的情况下,你如何去平衡社团与学习生活?",
"财外部:说说令你印象最深刻的理财经历,可以是任何和理财有关的哦",
],
];
const tailFormItemLayout = {
wrapperCol: {
@ -150,7 +179,10 @@ class NewForm extends React.Component {
})(<Input />)}
</Form.Item>
<Form.Item label="学号(请先填写此项再上传照片)" onChange={this.onStuIdChange}>
<Form.Item
label="学号(请先填写此项再上传照片)"
onChange={this.onStuIdChange}
>
{getFieldDecorator("id_student", {
rules: [
{
@ -258,8 +290,8 @@ class NewForm extends React.Component {
message: "请选择第一志愿",
},
{
validator: this.validator
}
validator: this.validator,
},
],
})(
<Radio.Group name="firstWish" size="medium">
@ -277,17 +309,19 @@ class NewForm extends React.Component {
rules: [
{
required: true,
message: "请选择第二志愿"
message: "请选择第二志愿",
},
{
validator: (rule, value, callback) => {
this.props.form.validateFields(["firstWish"], {
force: true,
});
callback();
},
},
{ validator: (rule, value, callback) => {
this.props.form.validateFields(['firstWish'], { force: true });
callback()
}
}
],
})(
<Radio.Group name="secondWish" size="medium"
>
<Radio.Group name="secondWish" size="medium">
<Radio.Button value={1}>电脑部</Radio.Button>
<Radio.Button value={2}>电器部</Radio.Button>
<Radio.Button value={3}>文宣部</Radio.Button>
@ -304,15 +338,17 @@ class NewForm extends React.Component {
required: true,
message: "请选择第三志愿",
},
{ validator: (rule, value, callback) => {
this.props.form.validateFields(['firstWish'], { force: true })
callback()
}
}
{
validator: (rule, value, callback) => {
this.props.form.validateFields(["firstWish"], {
force: true,
});
callback();
},
},
],
})(
<Radio.Group name="thirdWish" size="medium"
>
<Radio.Group name="thirdWish" size="medium">
<Radio.Button value={1}>电脑部</Radio.Button>
<Radio.Button value={2}>电器部</Radio.Button>
<Radio.Button value={3}>文宣部</Radio.Button>
@ -322,9 +358,15 @@ class NewForm extends React.Component {
)}
</Form.Item>
<Form.Item label="是否服从调剂" onChange = {() => {
if(this.props.form.getFieldValue("adjustment") === true)
message.warning("往届两技术部报名人数较多,选择调剂表示存在您被分配到第二、三志愿的可能,请审慎选择。")}}>
<Form.Item
label="是否服从调剂"
onChange={() => {
if (this.props.form.getFieldValue("adjustment") === true)
message.warning(
"往届两技术部报名人数较多,选择调剂表示存在您被分配到第二、三志愿的可能,请审慎选择。"
);
}}
>
{getFieldDecorator("adjustment", {
rules: [
{
@ -333,15 +375,17 @@ class NewForm extends React.Component {
},
],
})(
<Radio.Group >
<Radio.Group>
<Radio value={true}></Radio>
<Radio value={false}></Radio>
</Radio.Group>
)}
</Form.Item>
<Form.Item label={this.state.firstWish?questions[this.state.firstWish][0]:""}
style={this.state.WishValid?{}:{display:"none"}}>
<Form.Item
label={this.state.firstWish ? questions[this.state.firstWish][0] : ""}
style={this.state.WishValid ? {} : { display: "none" }}
>
{getFieldDecorator("firstReason", {
rules: [
{
@ -352,8 +396,10 @@ class NewForm extends React.Component {
})(<Input.TextArea autosize={{ minRows: 2, maxRows: 8 }} />)}
</Form.Item>
<Form.Item label={this.state.firstWish?questions[this.state.firstWish][1]:""}
style={this.state.WishValid?{}:{display:"none"}}>
<Form.Item
label={this.state.firstWish ? questions[this.state.firstWish][1] : ""}
style={this.state.WishValid ? {} : { display: "none" }}
>
{getFieldDecorator("secondReason", {
rules: [
{
@ -364,9 +410,12 @@ class NewForm extends React.Component {
})(<Input.TextArea autosize={{ minRows: 2, maxRows: 8 }} />)}
</Form.Item>
<Form.Item label={this.state.secondWish?questions[this.state.secondWish][0]:""}
style={this.state.WishValid?{}:{display:"none"}}>
<Form.Item
label={
this.state.secondWish ? questions[this.state.secondWish][0] : ""
}
style={this.state.WishValid ? {} : { display: "none" }}
>
{getFieldDecorator("thirdReason", {
rules: [
{
@ -377,7 +426,6 @@ class NewForm extends React.Component {
})(<Input.TextArea autosize={{ minRows: 2, maxRows: 8 }} />)}
</Form.Item>
<Form.Item label="你希望未来能在E志者协会得到什么又能为E志付出什么">
{getFieldDecorator("question2", {
rules: [