index.tsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import classNames from "classnames";
  2. import { useCallback, useEffect, useMemo, useState } from "react";
  3. import { Button, Form, Input, Select, Table } from "antd";
  4. import { useNavigate } from "react-router-dom";
  5. import { PageContainer } from "@/components";
  6. import {
  7. ASSESSMENT_TYPE_OPTIONS,
  8. PUBLISH_STATUS_MAP,
  9. PUBLISH_STATUS_OPTIONS,
  10. } from "../../../constants";
  11. import style from "../Form/index.module.scss";
  12. import { debounce } from "lodash";
  13. import { getManageEvaluationListApi } from "@/api";
  14. import { IManageFormItem, IManageFormListParams } from "@/types";
  15. const DEFAULT_PARAMS: IManageFormListParams = {
  16. deptStatus: undefined,
  17. searchKey: "",
  18. status: undefined,
  19. type: undefined,
  20. pageNum: 1,
  21. pageSize: 20,
  22. };
  23. const ManagementEvaluationPage = () => {
  24. const navigate = useNavigate();
  25. const [list, setList] = useState<IManageFormItem[]>([]);
  26. const [loading, setLoading] = useState(false);
  27. const [params, setParams] = useState({
  28. ...DEFAULT_PARAMS,
  29. });
  30. const [total, setTotal] = useState(0);
  31. const getList = useCallback(async () => {
  32. setLoading(true);
  33. try {
  34. const data = await getManageEvaluationListApi(params);
  35. setList(data.data);
  36. setTotal(data.total);
  37. } finally {
  38. setLoading(false);
  39. }
  40. }, [params]);
  41. const paginationChange = useCallback(
  42. () => (pageNum: number, pageSize: number) => {
  43. setParams({ ...params, pageNum, pageSize });
  44. },
  45. [params]
  46. );
  47. const debounceSearch = useMemo(
  48. () =>
  49. debounce((changedVal: unknown, vals: any) => {
  50. setParams({ ...params, ...vals });
  51. }, 500),
  52. [params]
  53. );
  54. useEffect(() => {
  55. getList();
  56. }, []);
  57. return (
  58. <PageContainer title="考核评定">
  59. <div className={style.filter}>
  60. <Form
  61. layout="inline"
  62. className="inline-form"
  63. onValuesChange={debounceSearch}
  64. >
  65. <Form.Item label="搜索" name="searchKey">
  66. <Input placeholder="请输入考核名称" className="w160" />
  67. </Form.Item>
  68. <Form.Item label="考核类别">
  69. <div className="w160">
  70. <Form.Item noStyle name="type">
  71. <Select
  72. allowClear
  73. placeholder="请选择"
  74. options={ASSESSMENT_TYPE_OPTIONS}
  75. />
  76. </Form.Item>
  77. </div>
  78. </Form.Item>
  79. <Form.Item label="发布状态">
  80. <div className="w160">
  81. <Form.Item noStyle name="status">
  82. <Select
  83. allowClear
  84. placeholder="请选择"
  85. options={PUBLISH_STATUS_OPTIONS}
  86. />
  87. </Form.Item>
  88. </div>
  89. </Form.Item>
  90. <Form.Item>
  91. <Button type="primary" onClick={getList}>
  92. 查询
  93. </Button>
  94. </Form.Item>
  95. </Form>
  96. </div>
  97. <div className={style.table}>
  98. <Table
  99. className={classNames("cus-table large")}
  100. dataSource={list}
  101. rowKey="id"
  102. scroll={{ x: "max-content" }}
  103. columns={[
  104. {
  105. title: "名称",
  106. dataIndex: "name",
  107. align: "center",
  108. minWidth: 100,
  109. },
  110. {
  111. title: "类别",
  112. align: "center",
  113. minWidth: 100,
  114. render: (item: IManageFormItem) => {
  115. return ASSESSMENT_TYPE_OPTIONS.find(
  116. (i) => i.value === item.type
  117. )?.label;
  118. },
  119. },
  120. {
  121. title: "说明",
  122. dataIndex: "remark",
  123. align: "center",
  124. minWidth: 100,
  125. },
  126. {
  127. title: "考核周期",
  128. align: "center",
  129. minWidth: 100,
  130. render: (item: IManageFormItem) =>
  131. `${item.dateStart}-${item.dateEnd}`,
  132. },
  133. {
  134. title: "发布状态",
  135. key: "c",
  136. align: "center",
  137. minWidth: 100,
  138. render: (item: IManageFormItem) => (
  139. <p
  140. style={{
  141. color: PUBLISH_STATUS_MAP[item.publishStatus].color,
  142. }}
  143. >
  144. {PUBLISH_STATUS_MAP[item.publishStatus].label}
  145. </p>
  146. ),
  147. },
  148. {
  149. title: "操作",
  150. key: "h",
  151. align: "center",
  152. fixed: "right",
  153. render: (item: IManageFormItem) => {
  154. return (
  155. <Button
  156. type="link"
  157. onClick={() =>
  158. navigate(`/management/evaluation/detail/${item.id}`)
  159. }
  160. >
  161. 查看
  162. </Button>
  163. );
  164. },
  165. },
  166. ]}
  167. pagination={{
  168. showQuickJumper: true,
  169. position: ["bottomCenter"],
  170. showSizeChanger: true,
  171. current: params.pageNum,
  172. pageSize: params.pageSize,
  173. total,
  174. onChange: paginationChange(),
  175. }}
  176. />
  177. </div>
  178. </PageContainer>
  179. );
  180. };
  181. export default ManagementEvaluationPage;