From cf41689198d74e30c70538ec626930f0233a40bb Mon Sep 17 00:00:00 2001 From: MengJunYi <1397102156@qq.com> Date: Mon, 17 Aug 2020 14:11:27 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E9=9D=A2=E8=AF=95=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=95=8C=E9=9D=A2=20=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=BA#/time/:guid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +- src/App.js | 5 +- src/components/ChooseTime.js | 302 +++++++++++++++++++++++++++++++++++ src/components/Sheet.js | 42 ----- yarn.lock | 47 +++++- 5 files changed, 353 insertions(+), 47 deletions(-) create mode 100644 src/components/ChooseTime.js diff --git a/package.json b/package.json index 64e60ed..c7da745 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "antd": "^3.26.8", "axios": "^0.19.2", "babel-plugin-import": "^1.13.0", + "co": "4", "customize-cra": "^0.9.1", "enquire-js": "^0.2.1", "http-proxy-middleware": "^0.20.0", @@ -23,7 +24,8 @@ "react-dom": "^16.12.0", "react-router": "^5.2.0", "react-router-dom": "^5.1.2", - "react-scripts": "3.2.0" + "react-scripts": "3.2.0", + "webpack": "4.41.0" }, "scripts": { "start": "react-app-rewired start", diff --git a/src/App.js b/src/App.js index cb0243b..9ca2af8 100644 --- a/src/App.js +++ b/src/App.js @@ -1,11 +1,13 @@ import React, { Component } from "react"; -import { HashRouter, Route, Switch, Link } from "react-router-dom"; +import { HashRouter, Route, Switch} from "react-router-dom"; import { enquireScreen } from "enquire-js"; import Home from "./Home/main"; import Page2 from "./Home/history"; import Entry from "./Entry"; import Login from "./components/Login"; +import ChooseTime from "./components/ChooseTime" + let isMobile; enquireScreen((b) => { isMobile = b; @@ -32,6 +34,7 @@ class App extends Component { + diff --git a/src/components/ChooseTime.js b/src/components/ChooseTime.js new file mode 100644 index 0000000..c81e9bf --- /dev/null +++ b/src/components/ChooseTime.js @@ -0,0 +1,302 @@ +import React from "react"; +import axios from "axios"; +import { Button, Form, Spin, message,Checkbox,Alert,BackTop,Layout,Card } from "antd"; +import "antd/dist/antd.css"; +import { confirmAlert } from "react-confirm-alert"; +import "react-confirm-alert/src/react-confirm-alert.css"; +import qs from "qs"; +import Background from '../background2.jpg'; +import { withRouter } from 'react-router-dom' + + +const Wishes = ["电脑部","电器部","文宣部","人资部","财外部"] +class TimePicker extends React.Component { + constructor(){ + super() + this.state = {confirmed:false} + } + + componentDidMount(){ + this.queryInfo() + this.queryTime() + } + + handleSubmit = (e) => { + e.preventDefault(); + const validateFieldsAndScroll = this.props.form.validateFieldsAndScroll; + confirmAlert({ + title: "提交面试时间", + message: + "点击 Yes 进行提交。", + buttons: [ + { + label: "Yes", + onClick: () => { + validateFieldsAndScroll((err, values) => { + if (err) { + message.error("填写不正确,请按照提示修改"); + } else { + var Times = [] + for(var i in values){ + for(var j = 0;j < values[i].length;j++) + Times = Times.concat(values[i][j]) + } + let addForm = async () => { + let result = await axios("api/posttime", { + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + method: "POST", + data: qs.stringify({ dto:JSON.stringify({Times:Times}),guid:this.props.match.params.guid}), + }); + + if (result.data.status === "success") { + message.success( + "提交成功!期待你的精彩面试表现!" + ); + } else { + message.error("提交失败!可能是网络问题。"); + } + }; + if(Times.length !== 0){ + addForm() + }else{ + message.error("请至少选择一个场次!"); + } + } + }); + }, + }, + { + label: "No", + onClick: () => {}, + }, + ], + }); + }; + queryTime = async () => { + let result = await axios( + 'api/gettime', + { + method: 'GET', + } + ) + if(result.data.status === "success") { + var timetable = [] + for(var time of result.data.data){ + for(var index = 0;index < timetable.length;index++){ + if(timetable[index].day === time.day){ + for(var i = 0 ; i < timetable[index].time.length;i++){ + if(time.beginTime === timetable[index].time[i].label){ + timetable[index].time[i].value.push(time.id) + break + } + } + if(i === timetable[index].time.length){ + timetable[index].time.push({label:time.beginTime,value:[time.id]}) + } + break + } + } + if(index === timetable.length){ + timetable.push({ day:time.day,time:[{label:time.beginTime,value:[time.id]}]}) + } + } + this.setState( + { + option_list: timetable, + option_number: timetable.length + } + ) + }else{ + message.error("获取面试场次失败,请稍后重试") + this.props.history.push('/') + } + } + queryInfo = async () => { + let result = await axios( + 'api/getinfo/'+this.props.match.params.guid, + { + method: 'GET', + } + ) + + if(result.data.status === "success") { + result.data.data.firstWish = Wishes[result.data.data.firstWish-1] + result.data.data.secondWish = Wishes[result.data.data.secondWish-1] + this.setState( + { + info: result.data.data, + } + ) + }else{ + message.error("获取个人信息失败,请稍后重试") + this.props.history.push('/') + } + } + render(){ + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 }, + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 12 }, + }, + }; + + const tailFormItemLayout = { + wrapperCol: { + xs: { + span: 24, + offset: 0, + }, + sm: { + span: 16, + offset: 8, + }, + }, + }; + + const { getFieldDecorator } = this.props.form; + if(this.state.confirmed){ + return( + this.state.option_list ? +
+

+ 请尽量多选 +

+ 0 ? this.state.option_list[0].day:0}> + {getFieldDecorator("time1", { + initialValue: [], + rules: [{ required: false }], + })( 0 ? this.state.option_list[0].time:0} />)} + + + 1 ? this.state.option_list[1].day:0}> + {getFieldDecorator("time2", { + initialValue: [], + rules: [{ required: false }], + })( 1 ? this.state.option_list[1].time:0} />)} + + + 2 ? this.state.option_list[2].day:0}> + {getFieldDecorator("time3", { + initialValue: [], + rules: [{ required: false }], + })( 2 ? this.state.option_list[2].time:0} />)} + + + 3 ? this.state.option_list[3].day:0}> + {getFieldDecorator("time4", { + initialValue: [], + rules: [{ required: false }], + })( 3 ? this.state.option_list[3].time:0} />)} + + + 4 ? this.state.option_list[4].day:0}> + {getFieldDecorator("time5", { + initialValue: [], + rules: [{ required: false }], + })( 4 ?this.state.option_list[4].time:0} />)} + + + 5 ?this.state.option_list[5].day:0}> + {getFieldDecorator("time6", { + initialValue: [], + rules: [{ required: false }], + })( 5 ?this.state.option_list[5].time:0} />)} + + + 6 ? this.state.option_list[6].day:0}> + {getFieldDecorator("time7", { + initialValue: [], + rules: [{ required: false }], + })( 6 ? this.state.option_list[6].time:0} />)} + + + +
: +
+ + + +
+ )}else{ + return(this.state.info? +
+ + +

{this.state.info.name}

+
+ +

{this.state.info.id_student}

+
+ +

{this.state.info.firstWish}

+
+ +

{this.state.info.secondWish}

+
+
+

+ +
+ : +
+ + + +
+ ) + } + } +} +const Chooser = withRouter(Form.create({})(TimePicker)); + +class ChooseTime extends React.Component { + render() { + return ( + +
+

+ 浙江大学学生E志者协会2020年面试时间 +

+ + +

+ 浙江大学学生E志者协会©2020 Created by EVATech +

+ + + ); + } +} +export default ChooseTime \ No newline at end of file diff --git a/src/components/Sheet.js b/src/components/Sheet.js index ec7a7b7..68d3577 100644 --- a/src/components/Sheet.js +++ b/src/components/Sheet.js @@ -295,48 +295,6 @@ class NewForm extends React.Component { ], })()} - - {getFieldDecorator("time1", { - initialValue: 0, - rules: [{ required: true }], - })} - - - {getFieldDecorator("time2", { - initialValue: 0, - rules: [{ required: true }], - })} - - - {getFieldDecorator("time3", { - initialValue: 0, - rules: [{ required: true }], - })} - - - {getFieldDecorator("time4", { - initialValue: 0, - rules: [{ required: true }], - })} - - - {getFieldDecorator("time5", { - initialValue: 0, - rules: [{ required: true }], - })} - - - {getFieldDecorator("time6", { - initialValue: 0, - rules: [{ required: true }], - })} - - - {getFieldDecorator("time7", { - initialValue: 0, - rules: [{ required: true }], - })} -