Commit 69eb3fb3 authored by wuhao's avatar wuhao 🎯

export

parent c22e9350
Pipeline #3440 passed with stages
in 3 minutes and 29 seconds
import AutoTable from "@/components/AutoTable"; import AutoTable from "@/components/AutoTable";
import DraggableDialog from "@/components/DraggableDialog"; import DraggableDialog from "@/components/DraggableDialog";
import ImportExcel from "@/components/ImportExcel";
import InitForm from "@/components/InitForm"; import InitForm from "@/components/InitForm";
import PremButton from "@/components/PremButton"; import PremButton from "@/components/PremButton";
import SplitDesc from "@/components/SplitDesc"; import SplitDesc from "@/components/SplitDesc";
...@@ -14,7 +13,9 @@ import "./index.less"; ...@@ -14,7 +13,9 @@ import "./index.less";
function Checkhomework() { function Checkhomework() {
const actionRef = useRef(), const actionRef = useRef(),
actionRefs = useRef(); formRef = useRef(),
actionRefs = useRef(),
formRefs = useRef();
const [dialogprops, setdialogprops] = useState({ const [dialogprops, setdialogprops] = useState({
open: false, open: false,
}); });
...@@ -64,7 +65,7 @@ function Checkhomework() { ...@@ -64,7 +65,7 @@ function Checkhomework() {
btn={{ btn={{
size: "small", size: "small",
variant: "text", variant: "text",
color:"inherit", color: "inherit",
onClick: () => { onClick: () => {
setdialogprops({ setdialogprops({
open: true, open: true,
...@@ -90,7 +91,12 @@ function Checkhomework() { ...@@ -90,7 +91,12 @@ function Checkhomework() {
{ title: "实验名称", dataIndex: "experimentName", key: "experimentName" }, { title: "实验名称", dataIndex: "experimentName", key: "experimentName" },
{ title: "分数", dataIndex: "score", key: "score", hideInSearch: true }, { title: "分数", dataIndex: "score", key: "score", hideInSearch: true },
{ title: "权重", dataIndex: "weight", key: "weight", hideInSearch: true }, { title: "权重", dataIndex: "weight", key: "weight", hideInSearch: true },
{ title: "分数(权重)", dataIndex: "scoreWeight", key: "scoreWeight", hideInSearch: true }, {
title: "分数(权重)",
dataIndex: "scoreWeight",
key: "scoreWeight",
hideInSearch: true,
},
{ {
title: "提交时间", title: "提交时间",
dataIndex: "finishTime", dataIndex: "finishTime",
...@@ -148,7 +154,12 @@ function Checkhomework() { ...@@ -148,7 +154,12 @@ function Checkhomework() {
{ title: "实验名称", dataIndex: "experimentName", key: "experimentName" }, { title: "实验名称", dataIndex: "experimentName", key: "experimentName" },
{ title: "分数", dataIndex: "score", key: "score", hideInSearch: true }, { title: "分数", dataIndex: "score", key: "score", hideInSearch: true },
{ title: "权重", dataIndex: "weight", key: "weight", hideInSearch: true }, { title: "权重", dataIndex: "weight", key: "weight", hideInSearch: true },
{ title: "分数(权重)", dataIndex: "scoreWeight", key: "scoreWeight", hideInSearch: true }, {
title: "分数(权重)",
dataIndex: "scoreWeight",
key: "scoreWeight",
hideInSearch: true,
},
{ {
title: "提交时间", title: "提交时间",
dataIndex: "finishTime", dataIndex: "finishTime",
...@@ -183,6 +194,7 @@ function Checkhomework() { ...@@ -183,6 +194,7 @@ function Checkhomework() {
<Box boxShadow={"0 0 18px #f0f0f0"} borderRadius={2}> <Box boxShadow={"0 0 18px #f0f0f0"} borderRadius={2}>
<AutoTable <AutoTable
actionRef={actionRefs} actionRef={actionRefs}
formRef={formRefs}
scroll={{ x: 1366 }} scroll={{ x: 1366 }}
columns={[ columns={[
...columes, ...columes,
...@@ -207,6 +219,7 @@ function Checkhomework() { ...@@ -207,6 +219,7 @@ function Checkhomework() {
<Box boxShadow={"0 0 18px #f0f0f0"} borderRadius={2}> <Box boxShadow={"0 0 18px #f0f0f0"} borderRadius={2}>
<AutoTable <AutoTable
actionRef={actionRef} actionRef={actionRef}
formRef={formRef}
scroll={{ x: 1366 }} scroll={{ x: 1366 }}
columns={[...columns]} columns={[...columns]}
extraparams={{ type: "1" }} extraparams={{ type: "1" }}
...@@ -283,9 +296,9 @@ function Checkhomework() { ...@@ -283,9 +296,9 @@ function Checkhomework() {
}, },
[ [
{ {
title:"实验时长", title: "实验时长",
dataIndex:"useTime", dataIndex: "useTime",
key:"useTime" key: "useTime",
}, },
{ {
title: "批阅状态", title: "批阅状态",
...@@ -345,28 +358,33 @@ function Checkhomework() { ...@@ -345,28 +358,33 @@ function Checkhomework() {
mt={0} mt={0}
> >
<Typography variant="h5">作业批阅</Typography> <Typography variant="h5">作业批阅</Typography>
{active === "1" ? (
<Stack spacing={2} direction="row"> <Stack spacing={2} direction="row">
<ImportExcel></ImportExcel>
<PremButton <PremButton
btn={{ btn={{
variant: "contained", variant: "contained",
onClick: (e) => { onClick: async (e) => {
e.stopPropagation(); e.stopPropagation();
setdialogprops({ if(active === "1"){
open: true, let formval = formRef?.current.getFieldsValue()
defaultFormValue: {}, const params = {
title: "新增学生", ...formval,
}); type:active
}
await doFetch({url:"/studentExperiment/exportByLoginTeacher",params});
}else{
let formval = formRefs?.current.getFieldsValue();
const params = {
...formval,
type:active
}
await doFetch({url:"/studentExperiment/exportByLoginTeacher",params});
}
}, },
}} }}
> >
新增学生 导出
</PremButton> </PremButton>
</Stack> </Stack>
) : (
<Box height={36} />
)}
</Box> </Box>
<Tabs <Tabs
......
import AutoTable from "@/components/AutoTable"; import AutoTable from "@/components/AutoTable";
import ImportExcel from "@/components/ImportExcel"; import PremButton from "@/components/PremButton";
import { doFetch } from "@/utils/doFetch"; import { doFetch } from "@/utils/doFetch";
import { Box, Container, Stack, Typography } from "@mui/material"; import { Box, Container, Stack, Typography } from "@mui/material";
import { useRequest } from "ahooks"; import { useRequest } from "ahooks";
...@@ -11,7 +11,8 @@ import "./index.less"; ...@@ -11,7 +11,8 @@ import "./index.less";
const formatter = (value) => <CountUp end={value} separator="," decimals={2} />; const formatter = (value) => <CountUp end={value} separator="," decimals={2} />;
function Record() { function Record() {
const actionRef = useRef(); const actionRef = useRef(),
formRef = useRef();
const [params, setparams] = useState({}); const [params, setparams] = useState({});
const { runAsync, data, loading } = useRequest( const { runAsync, data, loading } = useRequest(
...@@ -124,20 +125,39 @@ function Record() { ...@@ -124,20 +125,39 @@ function Record() {
</Box> </Box>
</Box> </Box>
<Stack spacing={2} direction="row"> <Stack spacing={2} direction="row">
<ImportExcel></ImportExcel> <PremButton
btn={{
variant: "contained",
onClick: async (e) => {
e.stopPropagation();
let formval = formRef?.current.getFieldsValue();
const param = {
...formval,
...params,
};
await doFetch({
url: "/studentExperiment/scoreReportExport",
params: param,
});
},
}}
>
导出
</PremButton>
</Stack> </Stack>
</Box> </Box>
<Box boxShadow={"0 0 18px #f0f0f0"} borderRadius={2}> <Box boxShadow={"0 0 18px #f0f0f0"} borderRadius={2}>
<AutoTable <AutoTable
actionRef={actionRef} actionRef={actionRef}
formRef={formRef}
scroll={{ x: 1366 }} scroll={{ x: 1366 }}
columns={[...columns]} columns={[...columns]}
dataSource={data?.list ?? []} dataSource={data?.list ?? []}
onValuesChange={(changedValues, values) => { onValuesChange={(changedValues, values) => {
setparams(s=>({ setparams((s) => ({
...values, ...values,
trainId:s.trainId trainId: s.trainId,
})); }));
}} }}
></AutoTable> ></AutoTable>
......
...@@ -3,26 +3,26 @@ ...@@ -3,26 +3,26 @@
* request 网络请求工具 * request 网络请求工具
* 更详细的 api 文档: https://github.com/umijs/umi-request * 更详细的 api 文档: https://github.com/umijs/umi-request
*/ */
import { history } from '@umijs/max'; import { history } from "@umijs/max";
import { message } from 'antd'; import { message } from "antd";
import { extend } from 'umi-request'; import { extend } from "umi-request";
const codeMessage = { const codeMessage = {
200: '服务器成功返回请求的数据。', 200: "服务器成功返回请求的数据。",
201: '新建或修改数据成功。', 201: "新建或修改数据成功。",
202: '一个请求已经进入后台排队(异步任务)。', 202: "一个请求已经进入后台排队(异步任务)。",
204: '删除数据成功。', 204: "删除数据成功。",
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。', 400: "发出的请求有错误,服务器没有进行新建或修改数据的操作。",
401: '用户没有权限(令牌、用户名、密码错误)。', 401: "用户没有权限(令牌、用户名、密码错误)。",
403: '用户得到授权,但是访问是被禁止的。', 403: "用户得到授权,但是访问是被禁止的。",
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。', 404: "发出的请求针对的是不存在的记录,服务器没有进行操作。",
406: '请求的格式不可得。', 406: "请求的格式不可得。",
410: '请求的资源被永久删除,且不会再得到的。', 410: "请求的资源被永久删除,且不会再得到的。",
422: '当创建一个对象时,发生一个验证错误。', 422: "当创建一个对象时,发生一个验证错误。",
500: '服务器发生错误,请检查服务器。', 500: "服务器发生错误,请检查服务器。",
502: '网关错误。', 502: "网关错误。",
503: '服务不可用,服务器暂时过载或维护。', 503: "服务不可用,服务器暂时过载或维护。",
504: '网关超时。', 504: "网关超时。",
}; };
/** /**
* 异常处理程序 * 异常处理程序
...@@ -58,20 +58,20 @@ const request = extend({ ...@@ -58,20 +58,20 @@ const request = extend({
prefix: REACT_APP_URL, //前缀代理 tasks.nangaoyun.com prefix: REACT_APP_URL, //前缀代理 tasks.nangaoyun.com
errorHandler, errorHandler,
// 默认错误处理 // 默认错误处理
credentials: 'include', // 默认请求是否带上cookie credentials: "include", // 默认请求是否带上cookie
}); });
// request拦截器, 改变url 或 options. // request拦截器, 改变url 或 options.
request.interceptors.request.use(async (url, options) => { request.interceptors.request.use(async (url, options) => {
let token = localStorage.getItem('TOKENES'); let token = localStorage.getItem("TOKENES");
if (token) { if (token) {
const headers = const headers =
options.type == 'form' options.type == "form"
? { ? {
token: token, token: token,
} }
: { : {
'Content-Type': 'application/json', "Content-Type": "application/json",
token: token, token: token,
}; };
return { return {
...@@ -83,32 +83,36 @@ request.interceptors.request.use(async (url, options) => { ...@@ -83,32 +83,36 @@ request.interceptors.request.use(async (url, options) => {
// response拦截器, 处理response // response拦截器, 处理response
request.interceptors.response.use(async (response, options) => { request.interceptors.response.use(async (response, options) => {
if (options.url === '/webtool/download') { if (
options.url == "/studentExperiment/exportByLoginTeacher" ||
options?.url == "/studentExperiment/scoreReportExport"
) {
const data = await response.clone().blob(); const data = await response.clone().blob();
let blobUrl = window.URL.createObjectURL(data); let blobUrl = window.URL.createObjectURL(data);
const a = document.createElement('a'); const a = document.createElement("a");
a.style.display = 'none'; a.style.display = "none";
let pathname = '项目_'+ options.params.filename + '_任务列表'; let temp =
a.download = pathname + '.xls'; response.headers.get("Content-Disposition").split(";")[1].split("=")[1] ||
"";
let fileDefaultName = decodeURI(temp);
let pathname = "表格";
a.download = fileDefaultName || pathname + ".xls";
a.href = blobUrl; a.href = blobUrl;
a.click(); a.click();
a.remove(); a.remove();
return; return;
} } else {
const data = await response.clone().json(); const data = await response.clone().json();
// 详情返回的response处理 // 详情返回的response处理
if (data?.code !== "0000") { if (data?.code != "0000") {
if (data?.error || data?.code === -1) {
console.log(location.origin);
// localStorage.removeItem('TOKENES');
//history.replace('/user/login');
} else {
message.destroy(); message.destroy();
message.error(data?.msg); message.warn(data?.msg);
if (data?.code == "0001" && window.location.href.indexOf("login") == -1) {
localStorage.clear();
history.replace("/user/login");
}
} }
} }
return response; return response;
}); });
......
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