Commit 665afd03 authored by chenshouchao's avatar chenshouchao

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

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