index.jsx 23.9 KB
Newer Older
wuhao's avatar
wuhao committed
1 2 3
import AutoTable from "@/components/AutoTable";
import DraggableDialog from "@/components/DraggableDialog";
import InitForm from "@/components/InitForm";
wuhao's avatar
wuhao committed
4
import PointViewer from "@/components/PointViewer";
wuhao's avatar
wuhao committed
5 6 7 8 9 10
import PremButton from "@/components/PremButton";
import SplitDesc from "@/components/SplitDesc";
import { doFetch } from "@/utils/doFetch";
import { ProDescriptions } from "@ant-design/pro-components";
import { Box, Container, Stack, Typography } from "@mui/material";
import { useRequest } from "ahooks";
wuhao's avatar
wuhao committed
11
import { Divider, Drawer, message, Table, Tabs, Tag, Tooltip } from "antd";
wuhao's avatar
wuhao committed
12 13
import { useMemo, useRef, useState } from "react";
import "./index.less";
wuhao's avatar
wuhao committed
14 15 16
function removeFirstAndLastChar(str) {
  return str.substring(1, str.length - 1);
}
wuhao's avatar
wuhao committed
17 18
function Checkhomework() {
  const actionRef = useRef(),
wuhao's avatar
wuhao committed
19 20
    formRef = useRef(),
    actionRefs = useRef(),
wuhao's avatar
wuhao committed
21 22
    formRefs = useRef(),
    formRefc = useRef();
wuhao's avatar
wuhao committed
23 24 25 26
  const [dialogprops, setdialogprops] = useState({
    open: false,
  });
  const [active, setactive] = useState("2");
wuhao's avatar
wuhao committed
27
  const [params, setparams] = useState();
wuhao's avatar
wuhao committed
28 29 30 31 32 33 34 35 36 37 38

  const handleClose = () => {
    setdialogprops((s) => ({
      ...s,
      open: false,
    }));
  };

  const { runAsync, loading } = useRequest(doFetch, {
    manual: true,
    onSuccess: (res, parames) => {
wuhao's avatar
wuhao committed
39
      if (parames?.url === "/studentExperiment/giveScore") return;
wuhao's avatar
wuhao committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
      if (res?.code == "0000") {
        message.success("操作成功");
        if (active === "1") {
          actionRef?.current?.reload();
        } else {
          actionRefs?.current?.reload();
        }
      }
    },
  });

  const audit = (text, row, _, action) => {
    return row.reviewType == 1 ? (
      <PremButton
        btn={{
          size: "small",
          variant: "text",
wuhao's avatar
wuhao committed
57 58
          onClick: async () => {
            let res = await doFetch({
wuhao's avatar
wuhao committed
59
              url: "/studentExperiment/queryResultForPc",
wuhao's avatar
wuhao committed
60 61 62 63
              params: {
                id: row.id,
              },
            });
wuhao's avatar
wuhao committed
64 65 66 67
            setdialogprops({
              open: true,
              defaultFormValue: { ...row },
              title: "批阅",
wuhao's avatar
wuhao committed
68
              tabdata: res?.data?.data,
wuhao's avatar
wuhao committed
69 70 71 72 73 74 75 76 77 78 79
            });
          },
        }}
      >
        批阅
      </PremButton>
    ) : (
      <PremButton
        btn={{
          size: "small",
          variant: "text",
wuhao's avatar
wuhao committed
80
          color: "inherit",
wuhao's avatar
wuhao committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
          onClick: () => {
            setdialogprops({
              open: true,
              defaultFormValue: { ...row },
              title: "详情",
              maxWidth: "md",
              footer: false,
            });
          },
        }}
      >
        详情
      </PremButton>
    );
  };

wuhao's avatar
wuhao committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
  const remove = (text, row, _) => {
    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
123 124 125 126 127 128 129 130 131
  const columns = useMemo(
    () => [
      { 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: "score", key: "score", hideInSearch: true },
      { title: "权重", dataIndex: "weight", key: "weight", hideInSearch: true },
wuhao's avatar
wuhao committed
132 133 134 135 136 137
      {
        title: "分数(权重)",
        dataIndex: "scoreWeight",
        key: "scoreWeight",
        hideInSearch: true,
      },
wuhao's avatar
wuhao committed
138 139 140 141 142 143 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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
      {
        title: "提交时间",
        dataIndex: "finishTime",
        key: "finishTimeRange",
        valueType: "dateTimeRange",
      },
      {
        title: "批阅时间",
        dataIndex: "reviewTime",
        key: "reviewTimeRange",
        valueType: "dateTimeRange",
      },
      {
        title: "批阅状态",
        dataIndex: "reviewTypeName",
        key: "reviewType",
        valueType: "select",
        mode: "radio",
        options: [
          { label: "待批阅", value: "1" },
          { label: "已批阅", value: "2" },
        ],
      },
    ],
    []
  );

  const detailcolumns = [
    { 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: "score", key: "score", hideInSearch: true },
    { title: "权重", dataIndex: "weight", key: "weight", hideInSearch: true },
    { title: "分数", dataIndex: "scoreWeight", key: "scoreWeight" },
    {
      title: "提交时间",
      dataIndex: "finishTime",
      key: "finishTimeRange",
    },
    {
      title: "批阅时间",
      dataIndex: "reviewTime",
      key: "reviewTimeRange",
    },
  ];

  const columes = useMemo(() => {
    return [
      { 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: "score", key: "score", hideInSearch: true },
      { title: "权重", dataIndex: "weight", key: "weight", hideInSearch: true },
wuhao's avatar
wuhao committed
195 196 197 198 199 200
      {
        title: "分数(权重)",
        dataIndex: "scoreWeight",
        key: "scoreWeight",
        hideInSearch: true,
      },
wuhao's avatar
wuhao committed
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
      {
        title: "提交时间",
        dataIndex: "finishTime",
        key: "finishTimeRange",
        valueType: "dateTimeRange",
      },
      {
        title: "批阅时间",
        dataIndex: "reviewTime",
        key: "reviewTimeRange",
        valueType: "dateTimeRange",
      },
      {
        title: "批阅状态",
        dataIndex: "reviewTypeName",
        key: "reviewType",
        valueType: "select",
        mode: "radio",
        options: [
          { label: "待批阅", value: "1" },
          { label: "已批阅", value: "2" },
        ],
      },
    ];
  }, []);

wuhao's avatar
wuhao committed
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
  const [datas, setdatas] = useState({
    tabs: [],
  });

  let blid = useRequest(
    async () => {
      let res = await doFetch({
        url: "/studentExperiment/queryAllByLoginTeacher",
        params: {},
      });
      return res?.data?.dataList;
    },
    {
      refreshDeps: [],
      onSuccess: (data, params) => {
wuhao's avatar
wuhao committed
242 243 244
        if (data?.code !== "0000") {
          return;
        }
wuhao's avatar
wuhao committed
245 246 247 248 249 250 251 252 253
        setdatas((s) => ({
          ...s,
          tabs: data?.map((it) => ({
            ...it,
            label: it?.studentName,
            key: it?.id,
          })),
        }));
        if (dialogprops?.open) {
wuhao's avatar
wuhao committed
254 255
          setdialogprops((s) => ({
            ...s,
wuhao's avatar
wuhao committed
256 257 258
            open: true,
            defaultFormValue: { ...data[0] },
            title: "批阅",
wuhao's avatar
wuhao committed
259
          }));
wuhao's avatar
wuhao committed
260 261 262 263 264 265 266
        }

        formRefc?.current?.resetFields();
      },
    }
  );

wuhao's avatar
wuhao committed
267 268 269 270 271 272 273
  //全部数量
  let totaldata = useRequest(async () => {
    let res = await doFetch({
      url: "/studentExperiment/queryCountByLoginTeacher",
      params: {},
    });
    return res?.data?.data;
wuhao's avatar
wuhao committed
274
  });
wuhao's avatar
wuhao committed
275 276 277 278 279

  const items = useMemo(() => {
    return [
      {
        key: "2",
wuhao's avatar
wuhao committed
280
        label: `已提交 ${params?.already ?? totaldata?.data?.submitNum ?? 0}`,
wuhao's avatar
wuhao committed
281 282 283 284 285 286 287 288 289 290 291 292 293 294
        children: (
          <Box boxShadow={"0 0 18px #f0f0f0"} borderRadius={2}>
            <AutoTable
              actionRef={actionRefs}
              formRef={formRefs}
              scroll={{ x: 1366 }}
              columns={[
                ...columes,
                {
                  title: "操作",
                  valueType: "option",
                  width: 136,
                  render: (text, row, _, action) => [
                    audit(text, row, _, action),
wuhao's avatar
wuhao committed
295
                    remove(text, row, _, action),
wuhao's avatar
wuhao committed
296 297 298 299 300 301
                  ],
                },
              ]}
              path="/studentExperiment/queryPageByLoginTeacher"
              rerendered={false}
              extraparams={{ type: "2" }}
wuhao's avatar
wuhao committed
302 303 304 305 306 307
              setparams={(val) => {
                setparams((s) => ({
                  ...s,
                  already: val,
                }));
              }}
wuhao's avatar
wuhao committed
308 309 310 311 312 313
            ></AutoTable>
          </Box>
        ),
      },
      {
        key: "1",
wuhao's avatar
wuhao committed
314 315 316
        label: `待提交 ${
          params?.unalready ?? totaldata?.data?.notSubmitNum ?? 0
        }`,
wuhao's avatar
wuhao committed
317 318 319 320 321 322 323 324 325 326
        children: (
          <Box boxShadow={"0 0 18px #f0f0f0"} borderRadius={2}>
            <AutoTable
              actionRef={actionRef}
              formRef={formRef}
              scroll={{ x: 1366 }}
              columns={[...columns]}
              extraparams={{ type: "1" }}
              path="/studentExperiment/queryPageByLoginTeacher"
              rerendered={false}
wuhao's avatar
wuhao committed
327 328 329 330 331 332
              setparams={(val) => {
                setparams((s) => ({
                  ...s,
                  unalready: val,
                }));
              }}
wuhao's avatar
wuhao committed
333 334 335 336 337 338
            ></AutoTable>
          </Box>
        ),
      },
    ];
  }, [totaldata]);
wuhao's avatar
wuhao committed
339

wuhao's avatar
wuhao committed
340 341 342 343 344 345 346 347 348 349
  const [drawer, setDrawer] = useState({
    open: false,
    onClose: () => {
      setDrawer((s) => ({
        ...s,
        open: false,
      }));
    },
  });

wuhao's avatar
wuhao committed
350 351 352
  return (
    <Container maxWidth={false}>
      <DraggableDialog
wuhao's avatar
wuhao committed
353 354 355 356
        handleClose={() => {
          handleClose();
          actionRef?.current?.reload();
        }}
wuhao's avatar
wuhao committed
357
        loading={loading}
wuhao's avatar
wuhao committed
358
        formRef={formRefc}
wuhao's avatar
wuhao committed
359
        dialogprops={dialogprops}
wuhao's avatar
wuhao committed
360
        maxWidth={dialogprops?.maxWidth ?? "md"}
wuhao's avatar
wuhao committed
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
        formdom={
          dialogprops?.title === "批阅" && (
            <InitForm
              fields={[
                {
                  title: "批阅信息",
                  dataIndex: "sort",
                  key: "sort",
                  valueType: "split",
                },
                {
                  title: "打分",
                  dataIndex: "score",
                  key: "score",
                  colProps: { span: 24 },
                  valueType: "digit",
                },
wuhao's avatar
wuhao committed
378 379 380 381 382 383 384 385 386
                {
                  title: "评语",
                  dataIndex: "comment",
                  key: "comment",
                  valueType: "textarea",
                  colProps: {
                    span: 24,
                  },
                },
wuhao's avatar
wuhao committed
387 388
              ]}
              defaultFormValue={{ examineResult: "1" }}
wuhao's avatar
wuhao committed
389
              onFinish={async (val, extra) => {
wuhao's avatar
wuhao committed
390 391 392 393
                let postdata = {
                  ...val,
                  id: dialogprops?.defaultFormValue?.id,
                };
wuhao's avatar
wuhao committed
394
                await runAsync({
wuhao's avatar
wuhao committed
395 396 397
                  url: "/studentExperiment/giveScore",
                  params: postdata,
                });
wuhao's avatar
wuhao committed
398
                await blid?.runAsync();
wuhao's avatar
wuhao committed
399 400 401 402 403 404
              }}
            ></InitForm>
          )
        }
      >
        {dialogprops?.title === "批阅" ? (
wuhao's avatar
wuhao committed
405 406 407 408
          <>
            <Tabs
              items={datas?.tabs}
              activeKey={dialogprops?.defaultFormValue?.id}
wuhao's avatar
wuhao committed
409
              onChange={async (key) => {
wuhao's avatar
wuhao committed
410
                let currow = datas?.tabs?.filter((it) => it?.id == key)[0];
wuhao's avatar
wuhao committed
411
                let res = await doFetch({
wuhao's avatar
wuhao committed
412
                  url: "/studentExperiment/queryResultForPc",
wuhao's avatar
wuhao committed
413 414 415 416
                  params: {
                    id: currow.id,
                  },
                });
wuhao's avatar
wuhao committed
417 418 419 420
                setdialogprops({
                  open: true,
                  defaultFormValue: { ...currow },
                  title: "批阅",
wuhao's avatar
wuhao committed
421
                  tabdata: res?.data?.data,
wuhao's avatar
wuhao committed
422 423 424 425 426 427 428 429 430 431
                });
              }}
            ></Tabs>
            <Divider style={{ marginTop: 0 }}></Divider>
            <ProDescriptions
              columns={detailcolumns}
              column={2}
              style={{ marginBottom: 12 }}
              dataSource={dialogprops?.defaultFormValue}
            ></ProDescriptions>
wuhao's avatar
wuhao committed
432

wuhao's avatar
wuhao committed
433 434 435 436 437
            <Divider></Divider>

            <b style={{ fontSize: 14, paddingBottom: 10, display: "block" }}>
              实验素养
            </b>
wuhao's avatar
wuhao committed
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
            <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>

wuhao's avatar
wuhao committed
473 474
            <Divider></Divider>

wuhao's avatar
wuhao committed
475 476 477
            <div style={{ position: "relative", minHeight: 360 }}>
              <Drawer
                {...drawer}
wuhao's avatar
wuhao committed
478
                width={"100%"} //fixer
wuhao's avatar
wuhao committed
479 480
                title={false}
                closable={false}
wuhao's avatar
wuhao committed
481
                destroyOnClose
wuhao's avatar
wuhao committed
482 483 484
              >
                <PointViewer
                  position={drawer?.position}
wuhao's avatar
wuhao committed
485
                  CurGongjianData={dialogprops?.tabdata?.CurGongjianData}
wuhao's avatar
wuhao committed
486 487 488
                  CoordinatePoint={dialogprops?.tabdata?.CoordinatePoint}
                  CurGongjianPoint={dialogprops?.tabdata?.CurGongjianPoint}
                ></PointViewer>
wuhao's avatar
wuhao committed
489 490 491 492 493 494 495 496 497 498 499 500 501 502
              </Drawer>
              <b style={{ fontSize: 14, paddingBottom: 10, display: "block" }}>
                实验报告
              </b>
              <Table
                size="small"
                pagination={{
                  pageSize: 6,
                }}
                columns={[
                  {
                    title: "名称",
                    dataIndex: "Name",
                    key: "Name",
wuhao's avatar
wuhao committed
503
                  },
wuhao's avatar
wuhao committed
504 505 506 507 508 509 510
                  {
                    title: "测量值",
                    dataIndex: "actualValue",
                    key: "actualValue",
                    render: (text, row) => {
                      return row?.actualValue?.toFixed(4) ?? "";
                    },
wuhao's avatar
wuhao committed
511
                  },
wuhao's avatar
wuhao committed
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
                  {
                    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
wuhao's avatar
wuhao committed
534 535 536 537 538 539 540 541 542 543
                    ? Object.values(dialogprops?.tabdata?.PeculiarityInfosDict)
                        ?.map((it, i) => {
                          return it?.map((item, index) => {
                            return {
                              ...item,
                              id: i + "," + index,
                            };
                          });
                        })
                        ?.flat()
wuhao's avatar
wuhao committed
544 545 546
                    : []
                }
                expandable={{
wuhao's avatar
wuhao committed
547
                  expandedRowRender: ({ ElementInfoList, PointList }) => {
wuhao's avatar
wuhao committed
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
                    return (
                      <div style={{ display: "flex", gap: 6 }}>
                        {ElementInfoList?.map((it) => {
                          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,
                                      }));
wuhao's avatar
wuhao committed
584
                                    }}
wuhao's avatar
wuhao committed
585 586 587 588 589 590 591 592 593
                                    style={{ cursor: "pointer" }}
                                  >
                                    {its.Name}
                                  </Tag>
                                </Tooltip>
                              ))}
                            </div>
                          );
                        })}
wuhao's avatar
wuhao committed
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632

                        <div
                          style={{
                            padding: 12,
                            backgroundColor: "#f0f0f0",
                            display: "inline-block",
                            borderRadius: 4,
                            marginBottom: 6,
                          }}
                        >
                          <span style={{ paddingRight: 12 }}>点集合</span>
                          {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>
wuhao's avatar
wuhao committed
633 634 635 636 637 638
                      </div>
                    );
                  },
                }}
              ></Table>
            </div>
wuhao's avatar
wuhao committed
639
          </>
wuhao's avatar
wuhao committed
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
        ) : dialogprops?.title === "详情" ? (
          <Stack
            direction={"column"}
            alignItems={"center"}
            justifyContent={"center"}
            gap={1}
          >
            <SplitDesc
              columns={[
                detailcolumns,
                {
                  title: "批阅信息",
                  dataIndex: "sort",
                  key: "sort",
                  valueType: "split",
                },
                [
                  {
wuhao's avatar
wuhao committed
658
                    title: "实验时长",
wuhao's avatar
wuhao committed
659 660
                    dataIndex: "testTime",
                    key: "testTime",
wuhao's avatar
wuhao committed
661
                    render: (text, record) => {
wuhao's avatar
wuhao committed
662
                      return record.testTime + '分';
wuhao's avatar
wuhao committed
663
                    },
wuhao's avatar
wuhao committed
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
                  },
                  {
                    title: "批阅状态",
                    dataIndex: "reviewTypeName",
                    key: "reviewTypeName",
                  },
                  {
                    title: "批阅时间",
                    dataIndex: "reviewTime",
                    key: "reviewTime",
                  },
                  {
                    title: "批阅人",
                    dataIndex: "reviewUserName",
                    key: "reviewUserName",
                  },
                  {
                    title: "分数",
                    dataIndex: "score",
                    key: "score",
wuhao's avatar
wuhao committed
684
                    span: 2,
wuhao's avatar
wuhao committed
685 686 687 688 689
                  },
                  {
                    title: "评语",
                    dataIndex: "comment",
                    key: "comment",
wuhao's avatar
wuhao committed
690
                    span: 3,
wuhao's avatar
wuhao committed
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
                  },
                ],
              ]}
              dataSource={dialogprops?.defaultFormValue}
            ></SplitDesc>
          </Stack>
        ) : (
          <InitForm
            fields={columns}
            defaultFormValue={dialogprops?.defaultFormValue}
            onFinish={(val, extra) => {
              let postdata = { ...val, type: "3" };
              switch (dialogprops?.title) {
                case "编辑":
                  postdata = {
                    ...val,
                    id: dialogprops?.defaultFormValue?.id,
                  };
                  break;
                default:
                  break;
              }
              runAsync({
                url: "/user/saveOrUpdate",
                params: postdata,
              });
            }}
          ></InitForm>
        )}
      </DraggableDialog>

      <Box
        display={"flex"}
        justifyContent={"space-between"}
        alignItems={"center"}
        sx={{ mb: 1 }}
        mt={0}
      >
        <Typography variant="h5">作业批阅</Typography>
wuhao's avatar
wuhao committed
730 731 732 733 734 735
        <Stack spacing={2} direction="row">
          <PremButton
            btn={{
              variant: "contained",
              onClick: async (e) => {
                e.stopPropagation();
wuhao's avatar
wuhao committed
736 737
                if (active === "1") {
                  let formval = formRef?.current.getFieldsValue();
wuhao's avatar
wuhao committed
738 739
                  const params = {
                    ...formval,
wuhao's avatar
wuhao committed
740 741 742 743 744 745 746
                    type: active,
                  };
                  await doFetch({
                    url: "/studentExperiment/exportByLoginTeacher",
                    params,
                  });
                } else {
wuhao's avatar
wuhao committed
747 748 749
                  let formval = formRefs?.current.getFieldsValue();
                  const params = {
                    ...formval,
wuhao's avatar
wuhao committed
750 751 752 753 754 755
                    type: active,
                  };
                  await doFetch({
                    url: "/studentExperiment/exportByLoginTeacher",
                    params,
                  });
wuhao's avatar
wuhao committed
756 757 758 759 760 761 762
                }
              },
            }}
          >
            导出
          </PremButton>
        </Stack>
wuhao's avatar
wuhao committed
763 764 765 766
      </Box>

      <Tabs
        activeKey={active}
wuhao's avatar
wuhao committed
767 768 769
        onChange={(value) => {
          setactive(value);
        }}
wuhao's avatar
wuhao committed
770 771 772 773 774 775 776 777 778
        items={items}
        tabPosition="top"
        animated={true}
      />
    </Container>
  );
}

export default Checkhomework;