bug fix && add third wish && add warning when choosing time
continuous-integration/drone/push Build is passing Details

master
MengJunYi 2020-08-23 17:31:23 +08:00
parent 30009110e8
commit 100a156c4c
3 changed files with 156 additions and 34 deletions

View File

@ -1,16 +1,6 @@
import React from "react"; import React from "react";
import axios from "axios"; import axios from "axios";
import { import {Button,Form,Spin,message,Checkbox,Alert,BackTop,Layout,Card,List,notification} from "antd";
Button,
Form,
Spin,
message,
Checkbox,
Alert,
BackTop,
Layout,
Card,
} from "antd";
import "antd/dist/antd.css"; import "antd/dist/antd.css";
import { confirmAlert } from "react-confirm-alert"; import { confirmAlert } from "react-confirm-alert";
import "react-confirm-alert/src/react-confirm-alert.css"; import "react-confirm-alert/src/react-confirm-alert.css";
@ -35,7 +25,7 @@ class TimePicker extends React.Component {
const validateFieldsAndScroll = this.props.form.validateFieldsAndScroll; const validateFieldsAndScroll = this.props.form.validateFieldsAndScroll;
confirmAlert({ confirmAlert({
title: "提交面试时间", title: "提交面试时间",
message: "点击 Yes 进行提交。", message: "请核实无误后谨慎提交。",
buttons: [ buttons: [
{ {
label: "Yes", label: "Yes",
@ -133,9 +123,13 @@ class TimePicker extends React.Component {
if (result.data.status === "success") { if (result.data.status === "success") {
result.data.data.firstWish = Wishes[result.data.data.firstWish - 1]; result.data.data.firstWish = Wishes[result.data.data.firstWish - 1];
result.data.data.secondWish = Wishes[result.data.data.secondWish - 1]; result.data.data.secondWish = Wishes[result.data.data.secondWish - 1];
result.data.data.thirdWish = Wishes[result.data.data.thirdWish - 1];
this.setState({ this.setState({
info: result.data.data, info: result.data.data,
}); });
if(this.state.info.times.length !== 0){
message.warning("你已选择过面试时间!重复提交面试时间可能导致场次排错,请谨慎重复提交!",0)
}
} else { } else {
message.error("获取个人信息失败,请稍后重试"); message.error("获取个人信息失败,请稍后重试");
this.props.history.push("/"); this.props.history.push("/");
@ -305,7 +299,7 @@ class TimePicker extends React.Component {
/> />
)} )}
</Form.Item> </Form.Item>
<br></br>
<Button <Button
icon="copy" icon="copy"
style={{ display: "block", margin: "0 auto" }} style={{ display: "block", margin: "0 auto" }}
@ -327,8 +321,32 @@ class TimePicker extends React.Component {
</Spin> </Spin>
</div> </div>
); );
} else { } else if(this.state.info){
return this.state.info ? ( return( this.state.info.times.length !== 0 ?
<Alert
message="你已经选择过面试时间!"
description={
<div >
<p>重复提交面试时间可能导致场次排错请谨慎重复提交点击右上角关闭警告以继续</p>
<List
size="small"
header={<div>已选择的时间</div>}
bordered
dataSource={this.state.info.times}
renderItem={item => <List.Item>{item}</List.Item>}
/>
</div>
}
type="warning"
showIcon
closable
style={{ height: "700px", textAlign: "center"}}
afterClose = {()=>{
const info = Object.assign({},this.state.info,{times: []});
this.setState({info:info})
}
}
/>:
<div> <div>
<Card title="个人信息"> <Card title="个人信息">
<Card type="inner" title="姓名"> <Card type="inner" title="姓名">
@ -343,8 +361,11 @@ class TimePicker extends React.Component {
<Card type="inner" title="第二志愿"> <Card type="inner" title="第二志愿">
<h3>{this.state.info.secondWish}</h3> <h3>{this.state.info.secondWish}</h3>
</Card> </Card>
<Card type="inner" title="第三志愿">
<h3>{this.state.info.thirdWish}</h3>
</Card> </Card>
<p></p> </Card>
<br></br>
<Button <Button
style={{ display: "block", margin: "0 auto" }} style={{ display: "block", margin: "0 auto" }}
type="primary" type="primary"
@ -358,7 +379,8 @@ class TimePicker extends React.Component {
确认个人信息 确认个人信息
</Button> </Button>
</div> </div>
) : ( )}else{
return(
<div> <div>
<Spin size="large" tip="Loading..."> <Spin size="large" tip="Loading...">
<Alert <Alert

View File

@ -13,6 +13,7 @@ class NewForm extends React.Component {
} }
loadLocalStorage = () => { loadLocalStorage = () => {
const values = JSON.parse(localStorage.getItem("formCache") || "{}"); const values = JSON.parse(localStorage.getItem("formCache") || "{}");
this.props.setID(values.id_student)
this.props.form.setFieldsValue(values); this.props.form.setFieldsValue(values);
}; };
saveLocalStorage = () => { saveLocalStorage = () => {
@ -88,6 +89,24 @@ class NewForm extends React.Component {
}); });
}; };
validator = (rule, value, callback) => {
try{
const form = this.props.form
var firstWish = value
var secondWish = form.getFieldValue('secondWish')
var thirdWish = form.getFieldValue('thirdWish')
if(firstWish === undefined ||secondWish === undefined ||thirdWish === undefined){
throw("请完整填写三个志愿")
}
if(firstWish === secondWish||firstWish === thirdWish ||secondWish === thirdWish){
throw("三个志愿不能重复")
}
}catch(err){
callback(err)
}
callback()
}
render() { render() {
const formItemLayout = { const formItemLayout = {
labelCol: { labelCol: {
@ -217,13 +236,16 @@ class NewForm extends React.Component {
})(<Input />)} })(<Input />)}
</Form.Item> </Form.Item>
<Form.Item label="第一志愿(志愿请不要重复选择)"> <Form.Item label="第一志愿(三个志愿请不要重复选择)">
{getFieldDecorator("firstWish", { {getFieldDecorator("firstWish", {
rules: [ rules: [
{ {
required: true, required: true,
message: "请选择第一志愿", message: "请选择第一志愿",
}, },
{
validator: this.validator
}
], ],
})( })(
<Radio.Group name="firstWish" size="medium"> <Radio.Group name="firstWish" size="medium">
@ -236,16 +258,47 @@ class NewForm extends React.Component {
)} )}
</Form.Item> </Form.Item>
<Form.Item label="第二志愿(志愿请不要重复选择)"> <Form.Item label="第二志愿(三个志愿请不要重复选择)">
{getFieldDecorator("secondWish", { {getFieldDecorator("secondWish", {
rules: [ rules: [
{ {
required: true, required: true,
message: "请选择第二志愿", message: "请选择第二志愿"
}, },
{ 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>
<Radio.Button value={4}>人资部</Radio.Button>
<Radio.Button value={5}>财外部</Radio.Button>
</Radio.Group>
)}
</Form.Item>
<Form.Item label="第三志愿(三个志愿请不要重复选择)">
{getFieldDecorator("thirdWish", {
rules: [
{
required: true,
message: "请选择第三志愿",
},
{ validator: (rule, value, callback) => {
this.props.form.validateFields(['firstWish'], { force: true })
callback()
}
}
],
})(
<Radio.Group name="thirdWish" size="medium"
>
<Radio.Button value={1}>电脑部</Radio.Button> <Radio.Button value={1}>电脑部</Radio.Button>
<Radio.Button value={2}>电器部</Radio.Button> <Radio.Button value={2}>电器部</Radio.Button>
<Radio.Button value={3}>文宣部</Radio.Button> <Radio.Button value={3}>文宣部</Radio.Button>
@ -293,6 +346,16 @@ class NewForm extends React.Component {
})(<Input.TextArea autosize={{ minRows: 2, maxRows: 8 }} />)} })(<Input.TextArea autosize={{ minRows: 2, maxRows: 8 }} />)}
</Form.Item> </Form.Item>
<Form.Item label="简述你选择第三志愿的原因">
{getFieldDecorator("thirdReason", {
rules: [
{
required: true,
message: "请填入你选择志愿的原因",
},
],
})(<Input.TextArea autosize={{ minRows: 2, maxRows: 8 }} />)}
</Form.Item>
<Form.Item label="简单介绍一下你的特长"> <Form.Item label="简单介绍一下你的特长">
{getFieldDecorator("question1", { {getFieldDecorator("question1", {
rules: [ rules: [

View File

@ -3461,6 +3461,13 @@ decode-uri-component@^0.2.0:
resolved "https://registry.npm.taobao.org/decode-uri-component/download/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" resolved "https://registry.npm.taobao.org/decode-uri-component/download/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=
deep-eql@~3.0.1:
version "3.0.1"
resolved "https://registry.npm.taobao.org/deep-eql/download/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df"
integrity sha1-38lARACtHI/gI+faHfHBR8S0RN8=
dependencies:
type-detect "^4.0.0"
deep-equal@^1.0.1: deep-equal@^1.0.1:
version "1.1.1" version "1.1.1"
resolved "https://registry.npm.taobao.org/deep-equal/download/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a" resolved "https://registry.npm.taobao.org/deep-equal/download/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a"
@ -9241,6 +9248,18 @@ rc-trigger@^3.0.0:
rc-animate "^3.0.0-rc.1" rc-animate "^3.0.0-rc.1"
rc-util "^4.15.7" rc-util "^4.15.7"
rc-tween-one@^1.2.5:
version "1.8.1"
resolved "https://registry.npm.taobao.org/rc-tween-one/download/rc-tween-one-1.8.1.tgz#5b3b464b9bf2c369efc16c816cccf57bc16ae253"
integrity sha1-WztGS5vyw2nvwWyBbMz1e8Fq4lM=
dependencies:
babel-runtime "6.x"
deep-eql "~3.0.1"
prop-types "^15.6.1"
raf "~3.4.0"
style-utils "~0.1.13"
tween-functions "~1.2.0"
rc-tween-one@^2.2.0, rc-tween-one@^2.4.0, rc-tween-one@^2.5.0, rc-tween-one@^2.6.8: rc-tween-one@^2.2.0, rc-tween-one@^2.4.0, rc-tween-one@^2.5.0, rc-tween-one@^2.6.8:
version "2.6.8" version "2.6.8"
resolved "https://registry.npm.taobao.org/rc-tween-one/download/rc-tween-one-2.6.8.tgz#75edf141af491a28b18812dc419efa6b0238e2a7" resolved "https://registry.npm.taobao.org/rc-tween-one/download/rc-tween-one-2.6.8.tgz#75edf141af491a28b18812dc419efa6b0238e2a7"
@ -9481,6 +9500,14 @@ react-slick@~0.25.2:
lodash.debounce "^4.0.8" lodash.debounce "^4.0.8"
resize-observer-polyfill "^1.5.0" resize-observer-polyfill "^1.5.0"
react-sublime-video@^0.2.5:
version "0.2.5"
resolved "https://registry.npm.taobao.org/react-sublime-video/download/react-sublime-video-0.2.5.tgz#c967b8e9a374b36d6a5d1b63b93fa6ec02e54842"
integrity sha1-yWe46aN0s21qXRtjuT+m7ALlSEI=
dependencies:
prop-types "^15.5.10"
rc-tween-one "^1.2.5"
react@^16.12.0: react@^16.12.0:
version "16.12.0" version "16.12.0"
resolved "https://registry.npm.taobao.org/react/download/react-16.12.0.tgz#0c0a9c6a142429e3614834d5a778e18aa78a0b83" resolved "https://registry.npm.taobao.org/react/download/react-16.12.0.tgz#0c0a9c6a142429e3614834d5a778e18aa78a0b83"
@ -10679,6 +10706,11 @@ style-loader@1.0.0:
loader-utils "^1.2.3" loader-utils "^1.2.3"
schema-utils "^2.0.1" schema-utils "^2.0.1"
style-utils@~0.1.13:
version "0.1.24"
resolved "https://registry.npm.taobao.org/style-utils/download/style-utils-0.1.24.tgz#fc0675d79a0b201bf86fc5d5a1dd202f838de544"
integrity sha1-/AZ115oLIBv4b8XVod0gL4ON5UQ=
style-utils@~0.2.0: style-utils@~0.2.0:
version "0.2.0" version "0.2.0"
resolved "https://registry.npm.taobao.org/style-utils/download/style-utils-0.2.0.tgz#3d8614931b8ff6e1eea0545f1dbfaf271bb1aa7e" resolved "https://registry.npm.taobao.org/style-utils/download/style-utils-0.2.0.tgz#3d8614931b8ff6e1eea0545f1dbfaf271bb1aa7e"
@ -11009,6 +11041,11 @@ type-check@~0.3.2:
dependencies: dependencies:
prelude-ls "~1.1.2" prelude-ls "~1.1.2"
type-detect@^4.0.0:
version "4.0.8"
resolved "https://registry.npm.taobao.org/type-detect/download/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
integrity sha1-dkb7XxiHHPu3dJ5pvTmmOI63RQw=
type-fest@^0.8.1: type-fest@^0.8.1:
version "0.8.1" version "0.8.1"
resolved "https://registry.npm.taobao.org/type-fest/download/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" resolved "https://registry.npm.taobao.org/type-fest/download/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"