|
|
@@ -1,12 +1,220 @@
|
|
|
-import React from "react";
|
|
|
+import React, {
|
|
|
+ useCallback,
|
|
|
+ useEffect,
|
|
|
+ useMemo,
|
|
|
+ useRef,
|
|
|
+ useState,
|
|
|
+} from "react";
|
|
|
import styles from "./index.module.scss";
|
|
|
- function B1Submit() {
|
|
|
-
|
|
|
+import { Button, Input, Select, Table, Tooltip } from "antd";
|
|
|
+import { useDispatch, useSelector } from "react-redux";
|
|
|
+import {
|
|
|
+ B1StatusObj,
|
|
|
+ B1TypeObj,
|
|
|
+ B1options1,
|
|
|
+ B1options2,
|
|
|
+ B1selectType,
|
|
|
+} from "./data";
|
|
|
+import { B1_APIgetList } from "@/store/action/B1Submit";
|
|
|
+import { RootState } from "@/store";
|
|
|
+import { B1tableType } from "@/types";
|
|
|
+import { QuestionCircleOutlined } from "@ant-design/icons";
|
|
|
+import B1Info from "./B1Info";
|
|
|
+
|
|
|
+function B1Submit() {
|
|
|
+ const dispatch = useDispatch();
|
|
|
+
|
|
|
+ // 筛选和分页
|
|
|
+ const [tableSelect, setTableSelect] = useState<B1selectType>({
|
|
|
+ searchKey: "",
|
|
|
+ status: "",
|
|
|
+ type: "",
|
|
|
+ pageSize: 10,
|
|
|
+ pageNum: 1,
|
|
|
+ });
|
|
|
+
|
|
|
+ // 输入框的改变
|
|
|
+ const txtTimeRef = useRef(-1);
|
|
|
+ const txtChangeFu = useCallback(
|
|
|
+ (txt: string, key: "searchKey") => {
|
|
|
+ clearTimeout(txtTimeRef.current);
|
|
|
+ txtTimeRef.current = window.setTimeout(() => {
|
|
|
+ setTableSelect({ ...tableSelect, [key]: txt, pageNum: 1 });
|
|
|
+ }, 500);
|
|
|
+ },
|
|
|
+ [tableSelect]
|
|
|
+ );
|
|
|
+
|
|
|
+ // 发送接口的函数
|
|
|
+ const getListFu = useCallback(() => {
|
|
|
+ dispatch(B1_APIgetList(tableSelect));
|
|
|
+ }, [dispatch, tableSelect]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ getListFu();
|
|
|
+ }, [getListFu]);
|
|
|
+
|
|
|
+ // 点击重置
|
|
|
+ const [inputKey, setInputKey] = useState(1);
|
|
|
+ const resetSelectFu = useCallback(() => {
|
|
|
+ // 把2个输入框和时间选择器清空
|
|
|
+ setInputKey(Date.now());
|
|
|
+ setTableSelect({
|
|
|
+ searchKey: "",
|
|
|
+ status: "",
|
|
|
+ type: "",
|
|
|
+ pageSize: 10,
|
|
|
+ pageNum: 1,
|
|
|
+ });
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ const B1TableList = useSelector(
|
|
|
+ (state: RootState) => state.B1Submit.tableInfo
|
|
|
+ );
|
|
|
+
|
|
|
+ // 页码变化
|
|
|
+ const paginationChange = useCallback(
|
|
|
+ () => (pageNum: number, pageSize: number) => {
|
|
|
+ setTableSelect({ ...tableSelect, pageNum, pageSize });
|
|
|
+ },
|
|
|
+ [tableSelect]
|
|
|
+ );
|
|
|
+
|
|
|
+ const columns = useMemo(() => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ title: "申请类型",
|
|
|
+ render: (item: B1tableType) => Reflect.get(B1TypeObj, item.type),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "申请编号",
|
|
|
+ dataIndex: "num",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "创建时间",
|
|
|
+ dataIndex: "createTime",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "发起人员",
|
|
|
+ dataIndex: "creatorName",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "审批状态",
|
|
|
+ render: (item: B1tableType) => (
|
|
|
+ <>
|
|
|
+ {Reflect.get(B1StatusObj, item.status)}
|
|
|
+ <span className="globalTit" hidden={!item.auditDesc}>
|
|
|
+ <Tooltip title={item.auditDesc}>
|
|
|
+
|
|
|
+ <QuestionCircleOutlined rev={undefined} />
|
|
|
+ </Tooltip>
|
|
|
+ </span>
|
|
|
+ </>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "审批时间",
|
|
|
+ render: (item: B1tableType) => item.auditTime || "(空)",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "审批人员",
|
|
|
+ render: (item: B1tableType) => item.auditUser || "(空)",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "操作",
|
|
|
+ render: (item: B1tableType) => (
|
|
|
+ <Button size="small" type="text" onClick={() => setLookInfo(item)}>
|
|
|
+ 查看
|
|
|
+ </Button>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ // 点击查看打开的页面
|
|
|
+ const [lookInfo, setLookInfo] = useState({} as B1tableType);
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles.B1Submit}>
|
|
|
- <div className="pageTitle">我提交的</div>
|
|
|
+ <div className="pageTitle">
|
|
|
+ 我提交的
|
|
|
+ {lookInfo.id
|
|
|
+ ? `/查看 - ${Reflect.get(B1TypeObj, lookInfo.type)}`
|
|
|
+ : null}
|
|
|
+ </div>
|
|
|
+ {/* 顶部筛选 */}
|
|
|
+ <div className="B1top">
|
|
|
+ {/* 左侧输入框 */}
|
|
|
+ <div className="B1top1">
|
|
|
+ <div className="B1topRow">
|
|
|
+ <span>搜索项:</span>
|
|
|
+ <Input
|
|
|
+ key={inputKey}
|
|
|
+ maxLength={10}
|
|
|
+ style={{ width: 248 }}
|
|
|
+ placeholder="请输入申请编号,最多10字"
|
|
|
+ allowClear
|
|
|
+ onChange={(e) => txtChangeFu(e.target.value, "searchKey")}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="B1topRow">
|
|
|
+ <span>申请类型:</span>
|
|
|
+ <Select
|
|
|
+ style={{ width: 150 }}
|
|
|
+ value={tableSelect.type}
|
|
|
+ onChange={(e) =>
|
|
|
+ setTableSelect({ ...tableSelect, type: e, pageNum: 1 })
|
|
|
+ }
|
|
|
+ options={B1options2}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="B1topRow">
|
|
|
+ <span>审批状态:</span>
|
|
|
+ <Select
|
|
|
+ style={{ width: 150 }}
|
|
|
+ value={tableSelect.status}
|
|
|
+ onChange={(e) =>
|
|
|
+ setTableSelect({ ...tableSelect, status: e, pageNum: 1 })
|
|
|
+ }
|
|
|
+ options={B1options1}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ {/* 右侧按钮 */}
|
|
|
+ <div className="B1top2">
|
|
|
+ <Button onClick={resetSelectFu}>重置</Button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/* 表格主体 */}
|
|
|
+ <div className="tableMain">
|
|
|
+ <Table
|
|
|
+ scroll={{ y: 625 }}
|
|
|
+ dataSource={B1TableList.list}
|
|
|
+ columns={columns}
|
|
|
+ rowKey="id"
|
|
|
+ pagination={{
|
|
|
+ showQuickJumper: true,
|
|
|
+ position: ["bottomCenter"],
|
|
|
+ showSizeChanger: true,
|
|
|
+ current: tableSelect.pageNum,
|
|
|
+ pageSize: tableSelect.pageSize,
|
|
|
+ total: B1TableList.total,
|
|
|
+ onChange: paginationChange(),
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ {lookInfo.id ? (
|
|
|
+ <B1Info
|
|
|
+ pageKey="我提交的"
|
|
|
+ closeFu={() => setLookInfo({} as B1tableType)}
|
|
|
+ info={lookInfo}
|
|
|
+ />
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
- )
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
const MemoB1Submit = React.memo(B1Submit);
|