调整改版后调分弹框

issues25489
杨树林 6 years ago
parent 9e98330dbb
commit be3b094e2f

@ -32,7 +32,7 @@ module.exports = {
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s
// devtool: "cheap-module-eval-source-map", // devtool: "cheap-module-eval-source-map",
// 开启调试 // 开启调试
// devtool: "source-map", // 开启调试 devtool: "source-map", // 开启调试
// These are the "entry points" to our application. // These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle. // This means they will be the "root" imports that are included in JS bundle.
// The first two entry points enable "hot" CSS and auto-refreshes for JS. // The first two entry points enable "hot" CSS and auto-refreshes for JS.

@ -1,5 +1,5 @@
import React,{ Component } from "react"; import React,{ Component } from "react";
import {Modal, Checkbox, Upload, Button, Icon, message, Input, Form} from "antd"; import {Modal, Checkbox, Upload, Button, Icon, message, Input, Form, InputNumber} from "antd";
import { WordNumberTextarea } from 'educoder'; import { WordNumberTextarea } from 'educoder';
import './Newshixunmodel.css' import './Newshixunmodel.css'
@ -17,6 +17,7 @@ class ModulationModal extends Component{
Saves=()=>{ Saves=()=>{
console.log("Saves=()");
let {textareaval,Inputsval}=this.state; let {textareaval,Inputsval}=this.state;
// if(textareaval===""||textareaval===undefined){ // if(textareaval===""||textareaval===undefined){
// this.setState({ // this.setState({
@ -44,6 +45,7 @@ class ModulationModal extends Component{
Inputsvaltype: false, Inputsvaltype: false,
Inputsvaltest: "", Inputsvaltest: "",
}) })
console.log(Inputsval);
this.props.Saves(textareaval,Inputsval) this.props.Saves(textareaval,Inputsval)
} }
@ -55,31 +57,45 @@ class ModulationModal extends Component{
} }
setInputs=(e)=>{ setInputs=(e)=>{
debugger console.log("setInputs");
var value=parseInt(e.target.value) let value = undefined;
try {
value = parseFloat(e);
} catch (e) {
this.setState({
borredszf: "ml10 color-grey-9 bor-reds ",
Inputsval: 0,
Inputsvaltype: true,
Inputsvaltest: "请输入分数",
})
return;
}
if(isNaN(value)){ if (value === undefined || value === null || value === "") {
value = 0;
this.setState({ this.setState({
Inputsval: value, borredszf: "ml10 color-grey-9 bor-reds ",
Inputsval: 0,
Inputsvaltype: true, Inputsvaltype: true,
Inputsvaltest: "请输入分数", Inputsvaltest: "请输入分数",
}) })
}else{ return
if(value<0||value>100){ }
value = 0; var re = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 //判断正整数 /^[1-9]+[0-9]*]*$/
this.setState({ var nubmer = value;
Inputsval: value, if (!re.test(nubmer)) {
Inputsvaltype: true, this.setState({
Inputsvaltest: "请输入0-100的分数", borredszf: "ml10 color-grey-9 bor-reds ",
}) Inputsval: value,
Inputsvaltype: true,
} Inputsvaltest: "请输入0-100的分数",
} })
this.setState({ return;
}
console.log(value);
this.setState({
Inputsval: value, Inputsval: value,
Inputsvaltype: false, Inputsvaltype: false,
}) })
} }
render(){ render(){
let {textareaval, Inputsval, textareavaltype, Inputsvaltype, Inputsvaltest} = this.state; let {textareaval, Inputsval, textareavaltype, Inputsvaltype, Inputsvaltest} = this.state;
@ -123,16 +139,26 @@ class ModulationModal extends Component{
lineHeight: " 40px", lineHeight: " 40px",
color: " #f5222d", color: " #f5222d",
}}>*</span></span> }}>*</span></span>
<Input <style>
className={Inputsvaltype === true ? "borerinput" : ""} {
style={{ `
width: "120px", .myinputnumbers .ant-input-number-input{
height: "40px", line-height: 40px;
}} height: 40px;
placeholder="请填写分数" }
value={Inputsval} `
onInput={this.setInputs} }
/> </style>
<InputNumber min={0}
className={Inputsvaltype === true ? "borerinput myinputnumbers" : "myinputnumbers"}
style={{
width: "120px",
height: "40px",
}}
step={0.1}
onChange={this.setInputs}
value={Inputsval === undefined || Inputsval === null ? 0 : Inputsval}/>
<span <span
style={{ style={{
textAlign: "center", textAlign: "center",

Loading…
Cancel
Save