import AutoTable from "@/components/AutoTable";
import DraggableDialog from "@/components/DraggableDialog";
import ImportExcel from "@/components/ImportExcel";
import InitForm from "@/components/InitForm";
import PremButton from "@/components/PremButton";
import { doFetch } from "@/utils/doFetch";
import { Box, Container, Stack, Typography } from "@mui/material";
import { useRequest } from "ahooks";
import * as Antd from "antd";
import { useMemo, useRef, useState } from "react";
import "./index.less";
const { message } = Antd;
const { Paragraph } = Antd.Typography;
function Class() {
const actionRef = useRef(),
actionRefs = useRef();
const [dialogprops, setdialogprops] = useState({
open: false,
});
const [active, setactive] = useState("1");
const handleClose = () => {
setdialogprops((s) => ({
...s,
open: false,
}));
};
const { runAsync, loading } = useRequest(doFetch, {
manual: true,
onSuccess: (res, parames) => {
if (res?.code == "0000") {
handleClose();
message.success("操作成功");
if (active === "1") {
actionRef?.current?.reload();
} else {
actionRefs?.current?.reload();
}
}
},
});
const edit = (text, row, _, action) => {
return (
{
setdialogprops({
open: true,
defaultFormValue: { ...row },
title: "编辑",
});
},
}}
>
编辑
);
};
const remove = (text, row, _, action) => {
return (
{
await runAsync({
url: "/model/delete",
params: { id: row.id },
});
},
}}
btn={{
size: "small",
color: "error",
}}
>
删除
);
};
const columns = useMemo(
() => [
{ title: "模型名称", dataIndex: "modelName", key: "modelName" },
{
title: "模型预览的地址",
dataIndex: "url",
key: "url",
search: false,
render: (text, row) => {
return (
{row?.url}
);
},
},
],
[]
);
return (
{
let postdata = { ...val };
switch (dialogprops?.title) {
case "编辑":
postdata = {
...val,
id: dialogprops?.defaultFormValue?.id,
};
break;
default:
break;
}
runAsync({
url: "/model/saveOrUpdate",
params: postdata,
});
}}
>
模型管理
{
e.stopPropagation();
setdialogprops({
open: true,
defaultFormValue: {},
title: "新增模型",
});
},
}}
>
新增模型
[
edit(text, row, _, action),
remove(text, row, _, action),
],
},
]}
path="/model/page"
rerendered={false}
>
);
}
export default Class;