index.jsx 11.6 KB
Newer Older
wuhao's avatar
wuhao committed
1
import AutoTable from "@/components/AutoTable";
wuhao's avatar
wuhao committed
2
import DraggableDialog from "@/components/DraggableDialog";
wuhao's avatar
wuhao committed
3
import PointViewer from "@/components/PointViewer";
wuhao's avatar
wuhao committed
4 5 6
import PremButton from "@/components/PremButton";
import { doFetch } from "@/utils/doFetch";
import { ProDescriptions } from "@ant-design/pro-components";
wuhao's avatar
wuhao committed
7
import { Box, Container, Stack, Typography } from "@mui/material";
wuhao's avatar
wuhao committed
8 9
import { useRequest } from "ahooks";
import { Divider, Drawer, message, Table, Tag, Tooltip } from "antd";
wuhao's avatar
wuhao committed
10 11 12
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import { useMemo, useRef, useState } from "react";
wuhao's avatar
wuhao committed
13

wuhao's avatar
wuhao committed
14 15
import "./index.less";

wuhao's avatar
wuhao committed
16 17
dayjs.extend(duration);

wuhao's avatar
wuhao committed
18 19
function Record() {
  const actionRef = useRef();
wuhao's avatar
wuhao committed
20 21 22 23 24 25 26 27 28
  const [dialogprops, setdialogprops] = useState({
    open: false,
  });
  const handleClose = () => {
    setdialogprops((s) => ({
      ...s,
      open: false,
    }));
  };
wuhao's avatar
wuhao committed
29

wuhao's avatar
wuhao committed
30
  const detailcolumns = [
wuhao's avatar
wuhao committed
31 32 33 34 35 36 37 38 39 40 41 42 43
    {
      title: "分数",
      dataIndex: "score",
      key: "score",
      hideInSearch: true,
      span: 2,
    },
    {
      title: "评语",
      dataIndex: "comment",
      key: "comment",
      span: 2,
    },
wuhao's avatar
wuhao committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    { title: "学生姓名", dataIndex: "studentName", key: "studentName" },
    { title: "学生账号", dataIndex: "studentAccount", key: "studentAccount" },
    { title: "课程名称", dataIndex: "courseName", key: "courseName" },
    { title: "实训名称", dataIndex: "trainName", key: "trainName" },
    { title: "实验名称", dataIndex: "experimentName", key: "experimentName" },
    {
      title: "实验时长(分钟)",
      dataIndex: "testTime",
      key: "testTime",
    },
    { title: "权重", dataIndex: "weight", key: "weight", hideInSearch: true },
    { title: "分数", dataIndex: "scoreWeight", key: "scoreWeight" },
    {
      title: "提交时间",
      dataIndex: "finishTime",
      key: "finishTimeRange",
    },
    {
      title: "批阅人",
      dataIndex: "reviewUserName",
      key: "reviewUserName",
    },
    {
      title: "批阅时间",
      dataIndex: "reviewTime",
      key: "reviewTime",
    },
  ];

wuhao's avatar
wuhao committed
73 74 75 76 77 78 79 80 81
  const { runAsync, loading } = useRequest(doFetch, {
    manual: true,
    onSuccess: (res) => {
      if (res?.code == "0000") {
        message.success("操作成功");
      }
    },
  });

wuhao's avatar
wuhao committed
82 83 84 85 86 87 88 89 90 91 92 93 94
  const detail = (text, row, _, action) => {
    return (
      <PremButton
        btn={{
          size: "small",
          variant: "text",
          color: "inherit",
          onClick: async () => {
            let res = await doFetch({
              url: "/studentExperiment/detail",
              params: { id: row?.id },
            });

wuhao's avatar
wuhao committed
95 96 97 98 99 100 101
            let result = await doFetch({
              url: "/studentExperiment/queryResultForPc",
              params: {
                id: row.id,
              },
            });

wuhao's avatar
wuhao committed
102 103 104 105 106 107
            setdialogprops({
              open: true,
              defaultFormValue: { ...res?.data?.data },
              title: "详情",
              maxWidth: "md",
              footer: false,
wuhao's avatar
wuhao committed
108
              tabdata: result?.data?.data,
wuhao's avatar
wuhao committed
109 110 111 112 113 114 115 116
            });
          },
        }}
      >
        详情
      </PremButton>
    );
  };
wuhao's avatar
wuhao committed
117

wuhao's avatar
wuhao committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
  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>
    );
  };

wuhao's avatar
wuhao committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
  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
177 178 179
      {
        title: "操作",
        valueType: "option",
wuhao's avatar
wuhao committed
180 181 182 183 184
        width: 128,
        render: (text, row, _, action) => [
          detail(text, row, _, action),
          rollback(text, row, _, action),
        ],
wuhao's avatar
wuhao committed
185
      },
wuhao's avatar
wuhao committed
186 187 188 189
    ];
    return res;
  }, []);

wuhao's avatar
wuhao committed
190 191 192 193 194 195 196 197 198 199
  const [drawer, setDrawer] = useState({
    open: false,
    onClose: () => {
      setDrawer((s) => ({
        ...s,
        open: false,
      }));
    },
  });

wuhao's avatar
wuhao committed
200 201
  return (
    <Container maxWidth={false}>
wuhao's avatar
wuhao committed
202 203 204 205 206 207
      <DraggableDialog
        handleClose={handleClose}
        dialogprops={dialogprops}
        maxWidth={dialogprops?.maxWidth ?? "sm"}
        footer={false}
      >
wuhao's avatar
wuhao committed
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
        <div>
          <ProDescriptions
            columns={detailcolumns}
            column={2}
            style={{ marginBottom: 12 }}
            dataSource={dialogprops?.defaultFormValue}
          ></ProDescriptions>
          <Divider></Divider>
          <b style={{ fontSize: 14, paddingBottom: 10, display: "block" }}>
            实验素养
          </b>
          <Table
            size="small"
            pagination={{
              pageSize: 6,
            }}
            columns={[
              {
                title: "操作名称",
                dataIndex: "config",
                key: "config",
                render: (text, row) => {
                  return row?.config?.name;
                },
              },
              {
                title: "是否操作",
                dataIndex: "isComplete",
                key: "isComplete",
                width: 200,
                render: (text, row) => {
                  return row?.isComplete ? (
                    "完成"
                  ) : (
                    <span style={{ color: "red" }}>未完成</span>
                  );
                },
              },
            ]}
            dataSource={
              dialogprops?.tabdata?.recordDataDic
                ? Object.values(dialogprops?.tabdata?.recordDataDic)
                : []
            }
          ></Table>
          <Divider></Divider>
          <div style={{ position: "relative", minHeight: 360 }}>
            <Drawer
              {...drawer}
              getContainer={false}
              title={false}
              closable={false}
              destroyOnClose
            >
              <PointViewer
                position={drawer?.position}
                CoordinatePoint={dialogprops?.tabdata?.CoordinatePoint}
                CurGongjianPoint={dialogprops?.tabdata?.CurGongjianPoint}
              ></PointViewer>
            </Drawer>
            <b style={{ fontSize: 14, paddingBottom: 10, display: "block" }}>
              实验报告
            </b>
            <Table
              size="small"
              pagination={{
                pageSize: 6,
              }}
              columns={[
                {
                  title: "名称",
                  dataIndex: "Name",
                  key: "Name",
                },
                {
                  title: "测量值",
                  dataIndex: "actualValue",
                  key: "actualValue",
                  render: (text, row) => {
                    return row?.actualValue?.toFixed(4) ?? "";
                  },
                },
                {
                  title: "名义值",
                  dataIndex: "normal",
                  key: "normal",
                  render: (text, row) => {
                    return row?.normal?.toFixed(4) ?? "";
                  },
                },
                {
                  title: "上公差",
                  dataIndex: "Upper",
                  key: "Upper",
                },
                {
                  title: "下公差",
                  dataIndex: "Down",
                  key: "Down",
                },
              ]}
              rowKey={"id"}
              dataSource={
                dialogprops?.tabdata?.PeculiarityInfosDict
                  ? Object.values(
                      dialogprops?.tabdata?.PeculiarityInfosDict
                    )?.map((it, i) =>
                      it?.[0]
                        ? {
                            ...it?.[0],
                            id: i + 1,
                          }
                        : {}
                    )
                  : []
              }
              expandable={{
                expandedRowRender: ({ ElementInfoList }) => {
                  return (
                    <div style={{ display: "flex", gap: 6 }}>
                      {ElementInfoList?.map((it) => {
                        function removeFirstAndLastChar(str) {
                          return str.substring(1, str.length - 1);
                        }
                        return (
                          <div
                            style={{
                              padding: 12,
                              backgroundColor: "#f0f0f0",
                              display: "inline-block",
                              borderRadius: 4,
                              marginBottom: 6,
                            }}
                          >
                            <span style={{ paddingRight: 12 }}>{it?.Name}</span>
                            {it?.PointList?.map((its) => (
                              <Tooltip
                                key={its?.id}
                                title={
                                  <div
                                    dangerouslySetInnerHTML={{
                                      __html: removeFirstAndLastChar(
                                        JSON.stringify(its.Position)
                                      ).replace(/,/g, "<br/>"),
                                    }}
                                  ></div>
                                }
                              >
                                <Tag
                                  onClick={() => {
                                    setDrawer((s) => ({
                                      ...s,
                                      position: its.Position,
                                      open: true,
                                    }));
                                  }}
                                  style={{ cursor: "pointer" }}
                                >
                                  {its.Name}
                                </Tag>
                              </Tooltip>
                            ))}
                          </div>
                        );
                      })}
                    </div>
                  );
                },
              }}
            ></Table>
          </div>
        </div>
wuhao's avatar
wuhao committed
380 381
      </DraggableDialog>

wuhao's avatar
wuhao committed
382
      <Stack direction={"row"} mb={2}>
wuhao's avatar
wuhao committed
383
        <Typography variant="h5">我的成绩</Typography>
wuhao's avatar
wuhao committed
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
      </Stack>

      <Box boxShadow={"0 0 18px #f0f0f0"} borderRadius={2}>
        <AutoTable
          actionRef={actionRef}
          scroll={{ x: 1366 }}
          columns={[...columns]}
          path={"/studentExperiment/queryPageByLoginStudent"}
        ></AutoTable>
      </Box>
    </Container>
  );
}

export default Record;