Blame view

src/pages/backlog/TaskTime/index.tsx 4.73 KB
3786031a   赵凤   待办时效配置
1
  import React, { useState} from "react";
d2a4028d   赵凤   待办时效配置
2
  import { PageHeaderWrapper } from "@ant-design/pro-layout";
4dd26c2d   赵凤   add待办时效考核
3
  import { Card, Table, Popconfirm, message, Button, Input, Popover, Select } from "antd";
fae1c4f3   赵凤   待办时效列表添加气泡提示
4
  import { PlusOutlined, ExclamationCircleFilled } from "@ant-design/icons";
d2a4028d   赵凤   待办时效配置
5
  import usePagination from "@/hooks/usePagination";
4dd26c2d   赵凤   add待办时效考核
6
  import { ListVO, getTimeListApi, taskDeleteApi, ItemListVO } from "./api";
3786031a   赵凤   待办时效配置
7
  import {TimeUnits } from "./entity";
d2a4028d   赵凤   待办时效配置
8
9
  import { debounce } from "lodash";
  import CreateModal from "./components/CreateModal";
4dd26c2d   赵凤   add待办时效考核
10
11
  
  import { systemListApi } from "@/pages/admin/Privilege/api";
d2a4028d   赵凤   待办时效配置
12
13
14
15
16
  
  const Column = Table.Column;
  const Search = Input.Search;
  
  export default function TaskConfig() {
4dd26c2d   赵凤   add待办时效考核
17
    const { list, loading, paginationConfig, setParams, setLoading } = usePagination<ListVO>(getTimeListApi, {}, {});
a78bcc4d   赵凤   修复待办名称展示
18
    const [item, setItem] =useState({});
4dd26c2d   赵凤   add待办时效考核
19
    const { list: syslist } = usePagination(systemListApi, { current: 1, pageSize: 100 });
3786031a   赵凤   待办时效配置
20
    const [modalData, setModalData] = useState<{ visible: boolean; row: ItemListVO }>({ visible: false, row: {} });
d2a4028d   赵凤   待办时效配置
21
  
4dd26c2d   赵凤   add待办时效考核
22
23
24
25
26
27
28
29
30
31
    function triggerModal(row: ItemListVO = {}) {
      setModalData({ visible: !modalData.visible, row });
    }
    const _onChange = debounce((val: string) => {
      setParams({ keywords: val.trim(), current: 1 }, true);
    }, 500);
    //根据系统名称搜索
    const _onChangeSys = debounce((e: any) => {
      setParams({ sysId: e, current: 1 }, true);
    }, 500);
d2a4028d   赵凤   待办时效配置
32
33
34
35
36
37
38
39
    // 删除待办
    const handleDelete = (record: any) => {
      taskDeleteApi(record.id)
        .then((res) => {
          message.success("删除成功!");
          setLoading(true);
        })
        .catch((e) => {
d2a4028d   赵凤   待办时效配置
40
41
42
43
          message.error(e.message);
        });
    };
  
d2a4028d   赵凤   待办时效配置
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    return (
      <PageHeaderWrapper title="待办时效">
        <Card>
          <div
            style={{
              display: "flex",
              flexDirection: "row",
              justifyContent: "space-between",
              alignItems: "center",
              marginBottom: 20,
            }}
          >
            <div style={{ display: "flex" }}>
              <Search allowClear placeholder="搜索待办名" onChange={(e) => _onChange(e.target.value)} style={{ maxWidth: 260, marginRight: 15 }} />
4dd26c2d   赵凤   add待办时效考核
58
59
60
61
62
63
64
65
  
              <Select allowClear placeholder="搜索系统名称" style={{ width: 260, marginRight: 5 }} onChange={(e: any) => _onChangeSys(e)}>
                {syslist.map((item) => (
                  <Select.Option value={item.id!} key={item.id}>
                    {item.sysName}
                  </Select.Option>
                ))}
              </Select>
d2a4028d   赵凤   待办时效配置
66
            </div>
4dd26c2d   赵凤   add待办时效考核
67
  
d2a4028d   赵凤   待办时效配置
68
69
70
71
            <Button type="primary" icon={<PlusOutlined />} onClick={() => triggerModal()}>
              新增
            </Button>
          </div>
4dd26c2d   赵凤   add待办时效考核
72
          <Table loading={loading} dataSource={list} pagination={paginationConfig} rowKey={(record: ListVO) => String(record.id || record.configId)}>
d2a4028d   赵凤   待办时效配置
73
74
75
76
77
78
79
80
81
82
83
            <Column title="待办名称" dataIndex="configName" align="center" />
            <Column
              title="待办时效"
              dataIndex="periodValue"
              align="center"
              render={(text, record: ListVO) => {
                const tempTimeData = record.periodUnit ? `${text}${TimeUnits[record.periodUnit]}` : "--";
                return text ? tempTimeData : "--";
              }}
            />
            <Column
fae1c4f3   赵凤   待办时效列表添加气泡提示
84
85
86
87
88
89
90
91
92
93
94
              title={
                <Popover
                  placement="topLeft"
                  content={
                    <>
                      <p> 待办截止时间=待办时效时间+待办延时时间</p>
                      <p>如未配置待办延时时间,则表示待办无结束时间</p>
                    </>
                  }
                >
                  <span>
fae1c4f3   赵凤   待办时效列表添加气泡提示
95
96
97
98
99
                    待办延时时间&nbsp;&nbsp;
                    <ExclamationCircleFilled style={{ color: "#40a9ff" }} />
                  </span>
                </Popover>
              }
d2a4028d   赵凤   待办时效配置
100
101
102
103
              dataIndex="extendValue"
              align="center"
              render={(text, record: ListVO) => {
                const endTimeData = record.extendUnit ? `${text}${TimeUnits[record.extendUnit]}` : "--";
8eeded53   赵凤   延时为0展示出来
104
                return text !== null ? endTimeData : "--";
d2a4028d   赵凤   待办时效配置
105
106
              }}
            />
d2a4028d   赵凤   待办时效配置
107
108
109
110
111
            <Column
              title="操作"
              align="center"
              render={(val, row: ListVO) => (
                <>
a78bcc4d   赵凤   修复待办名称展示
112
                  <Button type="link" onClick={() => { triggerModal(row); setItem(row); }}>
d2a4028d   赵凤   待办时效配置
113
114
115
116
117
118
119
120
121
                    编辑
                  </Button>
                  <Popconfirm placement="top" title="确认删除?" onConfirm={() => handleDelete(row)}>
                    <Button type="link">删除</Button>
                  </Popconfirm>
                </>
              )}
            />
          </Table>
a78bcc4d   赵凤   修复待办名称展示
122
          <CreateModal visible={modalData.visible} onCancel={() => { triggerModal(); setItem({}); }} onRefreshing={() => setLoading(true)} item={item} />
d2a4028d   赵凤   待办时效配置
123
124
125
126
        </Card>
      </PageHeaderWrapper>
    );
  }