index.jsx 3.22 KB
Newer Older
maojiafeng's avatar
maojiafeng committed
1
import AutoTable from "@/components/AutoTable";
wuhao's avatar
wuhao committed
2
import PremButton from "@/components/PremButton";
maojiafeng's avatar
maojiafeng committed
3
import { Box, Container, Stack, Typography } from "@mui/material";
wuhao's avatar
wuhao committed
4
import { useParams } from "@umijs/max";
maojiafeng's avatar
maojiafeng committed
5
import { useMemo, useRef } from "react";
wuhao's avatar
wuhao committed
6 7
import { useRequest } from "ahooks";
import { doFetch } from "@/utils/doFetch";
maojiafeng's avatar
maojiafeng committed
8 9 10 11 12 13
import "./index.less";

function Record() {
  const actionRef = useRef();
  const params = useParams();

wuhao's avatar
wuhao committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
  const { runAsync, loading } = useRequest(doFetch, {
    manual: true,
    onSuccess: (res) => {
      if (res?.code == "0000") {
        message.success("操作成功");
      }
    },
  });



  const rollback = (text, row, action) => {
    return (
      <PremButton
        pop={{
          disabled: row?.reviewType !== 1,
          title: "是否退回该实训?",
          okText: "确认",
          cancelText: "取消",
          onConfirm: async () => {
            await runAsync({
              url: "/studentExperiment/remake",
              params: { id: row?.id },
            });
          },
        }}
        btn={{
          disabled: row?.reviewType !== 1,
          size: "small",
          color: "error",
        }}
      >
        撤回
      </PremButton>
    );
  };

maojiafeng's avatar
maojiafeng committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
  const columns = useMemo(() => {
    let res = [
      { title: "课程名称", dataIndex: "courseName", key: "courseName" },
      { title: "实训名称", dataIndex: "trainName", key: "trainName" },
      { title: "实验名称", dataIndex: "experimentName", key: "experimentName" },
      {
        title: "分数",
        dataIndex: "scoreWeight",
        key: "scoreWeight",
        hideInSearch: true,
      },
      {
        title: "提交时间",
        dataIndex: "finishTime",
        key: "finishTimeRange",
        valueType: "dateTimeRange",
      },
      {
        title: "批阅时间",
        dataIndex: "reviewTime",
        key: "reviewTimeRange",
        valueType: "dateTimeRange",
      },
      {
        title: "批阅状态",
        dataIndex: "reviewTypeName",
        key: "reviewType",
        valueType: "select",
        options: [
          { label: "待批阅", value: "1" },
          { label: "已批阅", value: "2" },
        ],
      },
wuhao's avatar
wuhao committed
84 85 86 87 88 89 90 91
      {
        title: "操作",
        valueType: "option",
        width: 88,
        render: (text, row, _, action) => [
          rollback(text, row, _, action),
        ],
      },
maojiafeng's avatar
maojiafeng committed
92 93 94 95 96 97
    ];
    return res;
  }, []);

  return (
    <Container maxWidth={false}>
wuhao's avatar
wuhao committed
98 99 100 101 102 103
      <Stack
        direction={"row"}
        justifyContent={"space-between"}
        alignItems={"center"}
        mb={2}
      >
maojiafeng's avatar
maojiafeng committed
104
        <Typography variant="h5">成绩单</Typography>
wuhao's avatar
wuhao committed
105 106 107 108 109 110 111 112 113 114 115
        <PremButton
          btn={{
            variant: "outlined",
            onClick: (e) => {
              e.stopPropagation();
              history.back();
            },
          }}
        >
          返回
        </PremButton>
maojiafeng's avatar
maojiafeng committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
      </Stack>

      <Box boxShadow={"0 0 18px #f0f0f0"} borderRadius={2}>
        <AutoTable
          actionRef={actionRef}
          scroll={{ x: 1366 }}
          columns={[...columns]}
          path={"/studentTrain/experimentPage"}
          extraparams={{
            id: params?.id,
          }}
        ></AutoTable>
      </Box>
    </Container>
  );
}

export default Record;