From 6fb7a513117d4bebad8ccab238ebcbddc3b210d3 Mon Sep 17 00:00:00 2001 From: cxz66666 <1092889706@qq.com> Date: Wed, 9 Sep 2020 00:24:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=9D=E7=A8=BF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Sheet.js | 160 ++++++++++++++++++++++++++-------------- 1 file changed, 104 insertions(+), 56 deletions(-) diff --git a/src/components/Sheet.js b/src/components/Sheet.js index a5a7fcb..c91eb75 100644 --- a/src/components/Sheet.js +++ b/src/components/Sheet.js @@ -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 { })()} - + {getFieldDecorator("id_student", { rules: [ { @@ -258,8 +290,8 @@ class NewForm extends React.Component { message: "请选择第一志愿", }, { - validator: this.validator - } + validator: this.validator, + }, ], })( @@ -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() - } - } ], })( - + 电脑部 电器部 文宣部 @@ -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(); + }, + }, ], })( - + 电脑部 电器部 文宣部 @@ -322,9 +358,15 @@ class NewForm extends React.Component { )} - { - if(this.props.form.getFieldValue("adjustment") === true) - message.warning("往届两技术部报名人数较多,选择调剂表示存在您被分配到第二、三志愿的可能,请审慎选择。")}}> + { + if (this.props.form.getFieldValue("adjustment") === true) + message.warning( + "往届两技术部报名人数较多,选择调剂表示存在您被分配到第二、三志愿的可能,请审慎选择。" + ); + }} + > {getFieldDecorator("adjustment", { rules: [ { @@ -333,15 +375,17 @@ class NewForm extends React.Component { }, ], })( - + )} - + {getFieldDecorator("firstReason", { rules: [ { @@ -352,8 +396,10 @@ class NewForm extends React.Component { })()} - + {getFieldDecorator("secondReason", { rules: [ { @@ -364,9 +410,12 @@ class NewForm extends React.Component { })()} - - + {getFieldDecorator("thirdReason", { rules: [ { @@ -376,7 +425,6 @@ class NewForm extends React.Component { ], })()} - {getFieldDecorator("question2", {