123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- import classNames from "classnames";
- import { useCallback, useEffect, useMemo, useState } from "react";
- import { Button, Form, Input, Select, Table } from "antd";
- import { useNavigate } from "react-router-dom";
- import { PageContainer } from "@/components";
- import {
- ASSESSMENT_TYPE_OPTIONS,
- PUBLISH_STATUS_MAP,
- PUBLISH_STATUS_OPTIONS,
- } from "../../../constants";
- import style from "../Form/index.module.scss";
- import { debounce } from "lodash";
- import { getManageEvaluationListApi } from "@/api";
- import { IManageFormItem, IManageFormListParams } from "@/types";
- const DEFAULT_PARAMS: IManageFormListParams = {
- deptStatus: undefined,
- searchKey: "",
- status: undefined,
- type: undefined,
- pageNum: 1,
- pageSize: 20,
- };
- const ManagementEvaluationPage = () => {
- const navigate = useNavigate();
- const [list, setList] = useState<IManageFormItem[]>([]);
- const [loading, setLoading] = useState(false);
- const [params, setParams] = useState({
- ...DEFAULT_PARAMS,
- });
- const [total, setTotal] = useState(0);
- const getList = useCallback(async () => {
- setLoading(true);
- try {
- const data = await getManageEvaluationListApi(params);
- setList(data.data);
- setTotal(data.total);
- } finally {
- setLoading(false);
- }
- }, [params]);
- const paginationChange = useCallback(
- () => (pageNum: number, pageSize: number) => {
- setParams({ ...params, pageNum, pageSize });
- },
- [params]
- );
- const debounceSearch = useMemo(
- () =>
- debounce((changedVal: unknown, vals: any) => {
- setParams({ ...params, ...vals });
- }, 500),
- [params]
- );
- useEffect(() => {
- getList();
- }, []);
- return (
- <PageContainer title="考核评定">
- <div className={style.filter}>
- <Form
- layout="inline"
- className="inline-form"
- onValuesChange={debounceSearch}
- >
- <Form.Item label="搜索" name="searchKey">
- <Input placeholder="请输入考核名称" className="w160" />
- </Form.Item>
- <Form.Item label="考核类别">
- <div className="w160">
- <Form.Item noStyle name="type">
- <Select
- allowClear
- placeholder="请选择"
- options={ASSESSMENT_TYPE_OPTIONS}
- />
- </Form.Item>
- </div>
- </Form.Item>
- <Form.Item label="发布状态">
- <div className="w160">
- <Form.Item noStyle name="status">
- <Select
- allowClear
- placeholder="请选择"
- options={PUBLISH_STATUS_OPTIONS}
- />
- </Form.Item>
- </div>
- </Form.Item>
- <Form.Item>
- <Button type="primary" onClick={getList}>
- 查询
- </Button>
- </Form.Item>
- </Form>
- </div>
- <div className={style.table}>
- <Table
- className={classNames("cus-table large")}
- dataSource={list}
- rowKey="id"
- scroll={{ x: "max-content" }}
- columns={[
- {
- title: "名称",
- dataIndex: "name",
- align: "center",
- minWidth: 100,
- },
- {
- title: "类别",
- align: "center",
- minWidth: 100,
- render: (item: IManageFormItem) => {
- return ASSESSMENT_TYPE_OPTIONS.find(
- (i) => i.value === item.type
- )?.label;
- },
- },
- {
- title: "说明",
- dataIndex: "remark",
- align: "center",
- minWidth: 100,
- },
- {
- title: "考核周期",
- align: "center",
- minWidth: 100,
- render: (item: IManageFormItem) =>
- `${item.dateStart}-${item.dateEnd}`,
- },
- {
- title: "发布状态",
- key: "c",
- align: "center",
- minWidth: 100,
- render: (item: IManageFormItem) => (
- <p
- style={{
- color: PUBLISH_STATUS_MAP[item.publishStatus].color,
- }}
- >
- {PUBLISH_STATUS_MAP[item.publishStatus].label}
- </p>
- ),
- },
- {
- title: "操作",
- key: "h",
- align: "center",
- fixed: "right",
- render: (item: IManageFormItem) => {
- return (
- <Button
- type="link"
- onClick={() =>
- navigate(`/management/evaluation/detail/${item.id}`)
- }
- >
- 查看
- </Button>
- );
- },
- },
- ]}
- pagination={{
- showQuickJumper: true,
- position: ["bottomCenter"],
- showSizeChanger: true,
- current: params.pageNum,
- pageSize: params.pageSize,
- total,
- onChange: paginationChange(),
- }}
- />
- </div>
- </PageContainer>
- );
- };
- export default ManagementEvaluationPage;
|