Commit 665afd03 authored by chenshouchao's avatar chenshouchao

fix: 删除项目功能打开弹窗时重置表单

parent 91bb6816
...@@ -23,7 +23,7 @@ import InformationDisplay from "@/components/CommonComponents/InformationDisplay ...@@ -23,7 +23,7 @@ import InformationDisplay from "@/components/CommonComponents/InformationDisplay
import classnames from "classnames"; import classnames from "classnames";
import { TextField } from "@mui/material"; import { TextField } from "@mui/material";
import LoadingButton from "@mui/lab/LoadingButton"; import LoadingButton from "@mui/lab/LoadingButton";
import InputAdornment from '@mui/material/InputAdornment'; import InputAdornment from "@mui/material/InputAdornment";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
import Loading from "@/views/Loading"; import Loading from "@/views/Loading";
import MyDialog from "@/components/mui/MyDialog"; import MyDialog from "@/components/mui/MyDialog";
...@@ -59,6 +59,13 @@ const BaseInfo = observer(() => { ...@@ -59,6 +59,13 @@ const BaseInfo = observer(() => {
).name; ).name;
// 弹窗显示控制 // 弹窗显示控制
const [dialogOpen, setDialogOpen] = useState(false); const [dialogOpen, setDialogOpen] = useState(false);
// 打开弹窗时重置表单
useEffect(() => {
if (dialogOpen) {
setDeleteProjectName("");
}
}, [dialogOpen]);
// 是否拥有编辑权限 // 是否拥有编辑权限
const hasEditAuth = useMemo(() => { const hasEditAuth = useMemo(() => {
if (!currentUserName) { if (!currentUserName) {
...@@ -75,7 +82,10 @@ const BaseInfo = observer(() => { ...@@ -75,7 +82,10 @@ const BaseInfo = observer(() => {
}, [currentUserName, projectInfo]); }, [currentUserName, projectInfo]);
const { run, loading } = useMyRequest(getProject, { const { run, loading } = useMyRequest(getProject, {
onSuccess: (result: any) => { onSuccess: (result: any) => {
setProjectInfo({ ...result.data, projectBudget: result.data.projectBudget.toFixed(2) }); setProjectInfo({
...result.data,
projectBudget: result.data.projectBudget.toFixed(2),
});
}, },
}); });
useEffect(() => { useEffect(() => {
...@@ -185,41 +195,41 @@ const BaseInfo = observer(() => { ...@@ -185,41 +195,41 @@ const BaseInfo = observer(() => {
}; };
const budgetChange = (e: any) => { const budgetChange = (e: any) => {
let inputValue = e.target.value.replace('.', '') let inputValue = e.target.value.replace(".", "");
if (inputValue.indexOf('.') !== -1) { if (inputValue.indexOf(".") !== -1) {
setBudgetCheck({ setBudgetCheck({
error: true, error: true,
help: "格式错误,请输入正确的金额,可精确至分(两位小数)", help: "格式错误,请输入正确的金额,可精确至分(两位小数)",
}); });
return return;
} }
if (isNaN(Number(inputValue))) { if (isNaN(Number(inputValue))) {
setBudgetCheck({ setBudgetCheck({
error: true, error: true,
help: "格式错误,请输入正确的金额,可精确至分(两位小数)", help: "格式错误,请输入正确的金额,可精确至分(两位小数)",
}); });
return return;
} else { } else {
setProjectInfo({ setProjectInfo({
...projectInfo, ...projectInfo,
projectBudget: e.target.value projectBudget: e.target.value,
}) });
setBudgetCheck({ setBudgetCheck({
error: false, error: false,
help: "", help: "",
}); });
} }
} };
const budgetBlur = (e: any) => { const budgetBlur = (e: any) => {
setProjectInfo({ setProjectInfo({
...projectInfo, ...projectInfo,
projectBudget: Number(e.target.value).toFixed(2) projectBudget: Number(e.target.value).toFixed(2),
}) });
setBudgetCheck({ setBudgetCheck({
error: false, error: false,
help: "", help: "",
}); });
} };
const { run: updateProjectRun, loading: updateLoading } = useMyRequest( const { run: updateProjectRun, loading: updateLoading } = useMyRequest(
updateProject, updateProject,
...@@ -312,9 +322,9 @@ const BaseInfo = observer(() => { ...@@ -312,9 +322,9 @@ const BaseInfo = observer(() => {
size="small" size="small"
sx={{ sx={{
width: "560px", width: "560px",
'& .MuiOutlinedInput-root': { "& .MuiOutlinedInput-root": {
height: '36px' height: "36px",
} },
}} }}
/> />
{/* <input {/* <input
...@@ -390,12 +400,14 @@ const BaseInfo = observer(() => { ...@@ -390,12 +400,14 @@ const BaseInfo = observer(() => {
size="small" size="small"
sx={{ sx={{
width: "560px", width: "560px",
'& .MuiOutlinedInput-root': { "& .MuiOutlinedInput-root": {
height: '36px' height: "36px",
} },
}} }}
InputProps={{ InputProps={{
startAdornment: <InputAdornment position="start">¥</InputAdornment>, startAdornment: (
<InputAdornment position="start">¥</InputAdornment>
),
}} }}
/> />
</div> </div>
...@@ -426,10 +438,10 @@ const BaseInfo = observer(() => { ...@@ -426,10 +438,10 @@ const BaseInfo = observer(() => {
删除项目将删除其存储的数据和所有相关资源,并且已删除的项目无法恢复!请谨慎操作! 删除项目将删除其存储的数据和所有相关资源,并且已删除的项目无法恢复!请谨慎操作!
</div> </div>
<MyButton <MyButton
text='删除项目' text="删除项目"
variant="contained" variant="contained"
onClick={() => setDialogOpen(true)} onClick={() => setDialogOpen(true)}
color='error' color="error"
// style={{ // style={{
// backgroundColor: "#fff", // backgroundColor: "#fff",
// color: "#FF4E4E", // color: "#FF4E4E",
......
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