Commit fe719b91 authored by chenshouchao's avatar chenshouchao

Merge branch 'feat-20220620-taskSubmission' into 'release'

Feat 20220620 task submission

See merge request !74
parents c1d4f81a c85ccbe7
import * as React from "react"; import * as React from "react";
import { ReactNode } from "react"; import { ReactNode, useEffect } from "react";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import ButtonComponent from "./Button"; import ButtonComponent from "./Button";
import tipsIcon from "@/assets/project/information-outline.svg"; import tipsIcon from "@/assets/project/information-outline.svg";
...@@ -28,7 +28,7 @@ const MyPopconfirm = (props: IMyPopconfirmProps) => { ...@@ -28,7 +28,7 @@ const MyPopconfirm = (props: IMyPopconfirmProps) => {
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const handleClick = (event: React.MouseEvent<HTMLElement>) => { const handleClick = (event: React.MouseEvent<HTMLElement>) => {
console.log(123); event.nativeEvent.stopImmediatePropagation();
setAnchorEl(anchorEl ? null : event.currentTarget); setAnchorEl(anchorEl ? null : event.currentTarget);
}; };
...@@ -45,6 +45,12 @@ const MyPopconfirm = (props: IMyPopconfirmProps) => { ...@@ -45,6 +45,12 @@ const MyPopconfirm = (props: IMyPopconfirmProps) => {
onConfirm && onConfirm(); onConfirm && onConfirm();
}; };
useEffect(() => {
document.addEventListener("click", (e) => {
setAnchorEl(null);
});
}, []);
return ( return (
<div> <div>
<div aria-describedby={id} onClick={handleClick}> <div aria-describedby={id} onClick={handleClick}>
......
...@@ -97,7 +97,13 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -97,7 +97,13 @@ const ConfigForm = (props: ConfigFormProps) => {
const checkName = (name: string = "") => { const checkName = (name: string = "") => {
const reg = new RegExp(/^[a-zA-Z0-9\u4e00-\u9fa5-_]{3,30}$/); const reg = new RegExp(/^[a-zA-Z0-9\u4e00-\u9fa5-_]{3,30}$/);
if (reg.test(name)) { if (!name) {
setNameHelp({
error: true,
helperText: "任务名称不能为空",
});
return true;
} else if (reg.test(name)) {
setNameHelp({ setNameHelp({
error: false, error: false,
helperText: "", helperText: "",
......
...@@ -91,14 +91,12 @@ const ProjectSubmitWork = () => { ...@@ -91,14 +91,12 @@ const ProjectSubmitWork = () => {
const checkResult = getCheckResult(parameter, value); const checkResult = getCheckResult(parameter, value);
parameter.error = checkResult.error; parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText; parameter.helperText = checkResult.helperText;
} else {
return;
} }
if (getCheckResult(parameter, value).error === true) { if (getCheckResult(parameter, parameter.value).error === true) {
isCheck = false; isCheck = false;
} }
tack.isCheck = isCheck;
}); });
tack.isCheck = isCheck;
} else { } else {
return; return;
} }
......
import { IParameter } from "./interface" import { IParameter } from "./interface";
export const getCheckResult = (parameter: IParameter, value: string): { export const getCheckResult = (
error: boolean, parameter: IParameter,
helperText: string value: string
): {
error: boolean;
helperText: string;
} => { } => {
let error = false let error = false;
let helperText = '' let helperText = "";
// 表单校验 // 表单校验
if (parameter.required) { if (parameter.required) {
if (Array.isArray(value)) { if (Array.isArray(value)) {
if (value.length === 0) { if (value.length === 0) {
error = true error = true;
helperText = '该选项是必填项' helperText = "该选项是必填项";
} }
} else if (value === '' || value === null || value === undefined) { } else if (value === "" || value === null || value === undefined) {
error = true error = true;
helperText = '该选项是必填项' helperText = "该选项是必填项";
} }
} }
if (parameter.validators.length > 0) { if (parameter.validators.length > 0) {
parameter.validators.forEach((validator)=>{ parameter.validators.forEach((validator) => {
const reg = new RegExp(validator.regex) const reg = new RegExp(validator.regex);
if (!reg.test(value)) { if (!reg.test(value)) {
error = true error = true;
helperText = validator.message helperText = validator.message;
} }
}) });
} }
return { return {
error, error,
helperText helperText,
} };
} };
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment