diff --git a/src/App.css b/src/App.css
deleted file mode 100644
index 03f42e5..0000000
--- a/src/App.css
+++ /dev/null
@@ -1,5 +0,0 @@
-.App {
- text-align: center;
- background-image: url(https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg);
- background-size: 100%;
-}
diff --git a/src/App.js b/src/App.js
index f7de1a5..2c0ccc4 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,11 +1,9 @@
-import "./App.css";
import React, { Component } from "react";
import axios from "axios";
import config from "./config.json";
-import Inputsmall from "./Test";
-import {Result } from "antd";
+import { Result } from "antd";
import EVAfooter from "./EVAfooter";
-import From from "./From";
+import EVAForm from "./EVAForm";
class App extends Component {
constructor(props) {
super(props);
@@ -14,20 +12,18 @@ class App extends Component {
devurl: config.devurl,
formname: "EVA",
error: false,
- info:{}
+ info: "",
};
}
- componentDidMount() {
- this.setState({ router: window.location.pathname });
+ getforminfo() {
axios
.get(`${this.state.devurl}/api/forminfo/${this.state.router}/`)
.then((res) => {
if (res.data.code === 200) {
this.setState({ formname: res.data.data.formname });
- this.setState({info:res.data.data.info})
- console.log(this.state.info);
+ this.setState({ info: res.data.data.info });
+ // console.log(this.state.info);
document.title = this.state.formname;
- this.render();
} else {
throw "network error when getting forminfo";
}
@@ -37,6 +33,10 @@ class App extends Component {
this.setState({ error: true });
});
}
+ componentDidMount() {
+ this.setState({ router: window.location.pathname });
+ this.getforminfo();
+ }
render() {
return (
<>
@@ -49,14 +49,15 @@ class App extends Component {
/>
) : (
<>
-
-
My React App!
-
Welcome :)
-
{this.state.router}
-
-
-
-
+
+
+
My React App!
+
Welcome :)
+
{this.state.router}
+
+
+
+
>
)}
>
diff --git a/src/EVAForm.js b/src/EVAForm.js
new file mode 100644
index 0000000..e194e5c
--- /dev/null
+++ b/src/EVAForm.js
@@ -0,0 +1,150 @@
+import React, { useState } from "react";
+import { Form, Input, Radio, Button } from "antd";
+import axios from "axios";
+import config from "./config.json";
+const { TextArea } = Input;
+function EVAForm(props) {
+ const [info] = useState(props.info);
+ const [form] = Form.useForm();
+ let router = window.location.pathname;
+ const onFinish = (values) => {
+ console.log("Success:", values);
+ axios.post(`${config.devurl}/api/formsubmit/${router}`, values).then((res) => {
+ if (res.data.code === 200) {
+ console.log("success");
+ } else {
+ throw "network error when submitting form";
+ }
+ })
+ .catch((err) => {
+ console.log(err);
+ })
+ };
+ const onFinishFailed = (errorInfo) => {
+ console.log("Failed:", errorInfo);
+ };
+ const onSaveStorage = () => {
+ console.log(form.getFieldValue());
+ //save value to localstorage
+ localStorage.setItem("form", JSON.stringify(form.getFieldValue()));
+ };
+ const onLoadStorage = () => {
+ //load value from localstorage
+ form.setFieldsValue(JSON.parse(localStorage.getItem("form")));
+ }
+
+
+ return (
+
+
+
+
+
+
+ );
+}
+
+export default EVAForm;
diff --git a/src/From.js b/src/From.js
deleted file mode 100644
index b1cc27d..0000000
--- a/src/From.js
+++ /dev/null
@@ -1,19 +0,0 @@
-import React from "react";
-class From extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- info: {}
- }
- }
- componentDidMount() {
- console.log(this.props.info);
- this.setState({ info: this.props.info })
- }
- render() {
- return (
- <>>
- );
- }
-}
-export default From;
\ No newline at end of file
diff --git a/src/Inputsmall.js b/src/Inputsmall.js
new file mode 100644
index 0000000..37dd07b
--- /dev/null
+++ b/src/Inputsmall.js
@@ -0,0 +1,25 @@
+import { Input } from "antd";
+import React, { Component } from "react";
+class Inputsmall extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ describe: "#",
+ placeholder: "请输入你的名字",
+ };
+ }
+ render() {
+ return (
+
+ {this.state.describe}
+
+
+
+
+ );
+ }
+}
+export default Inputsmall;
diff --git a/src/Test.js b/src/Test.js
index ddd96da..d94316c 100644
--- a/src/Test.js
+++ b/src/Test.js
@@ -1,22 +1,29 @@
-import { Input} from "antd";
+import { Radio } from "antd";
import React, { Component } from "react";
-class Inputsmall extends Component {
+class Radiomiddle extends Component {
constructor(props) {
super(props);
this.state = {
- describe: "#",
- placeholder: "请输入你的名字",
+ describe: "你的名字是?",
+ choice: ["option1", "option2", "option3"],
+ value: 0,
};
}
render() {
return (
- 你的名字是?
+ {this.state.describe}
-
+
+ {
+ this.state.choice.map((item, index) => {
+ return {item}
+ })
+ }
+
);
}
}
-export default Inputsmall;
+export default Radiomiddle;
diff --git a/src/index.css b/src/index.css
index ec2585e..fb10fa6 100644
--- a/src/index.css
+++ b/src/index.css
@@ -11,3 +11,8 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
+
+#root{
+ background-image: url(https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg);
+ background-size: 100%;
+}
\ No newline at end of file