MyApply.jsx 8.78 KB
Newer Older
DarkForst's avatar
DarkForst committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 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 195 196 197 198 199 200 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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
import React, { useRef, useState } from "react"
import { Card, Space, Tag, Input, Form, Select, Button, Tabs, Table, Divider, Popconfirm, Row, Col } from "antd";
import { SettingOutlined, SearchOutlined } from "@ant-design/icons"
import { history, connect, useAccess, Access } from "umi"
import moment from 'moment';

import PopTableCheckbox from '@/components/PopTableCheckbox';
import useFormTable from '@/useHooks/useFormTable'
import { dispatchHandle } from '@/utils/publicHandle'
import TreeSelector from '@/components/TreeSelector'

import style from "./index.less"

const { Option } = Select;
const { TabPane } = Tabs;

const MyApply = (props) => {
    const {
        dispatch,
        loading,
        docimasyType,
        docimasy: {
            myApplyList
        },
        pathKey,//用于配置列的下拉索引
    } = props
    const access = useAccess();
    const popRef = useRef();
    const tabsList = [
        { name: '全部任务', key: '' },
        { name: '待审批', key: 1 },
        { name: '审批通过', key: 2 },
        { name: '已驳回', key: 3 },
        { name: '已撤销', key: 5 },
    ]
    const [form] = Form.useForm();
    const getListItem = (payload = {}) => {
        dispatchHandle(
            dispatch,
            'docimasy/operation_service_m_check_task_iStartedTaskApprovaListPage_post',
            payload
        )
    }
    const { tableProps, search } = useFormTable(getListItem, {
        form
    })
    // tab切换
    const tabChange = (activeKey) => {
        search.submit({
            state: activeKey
        })
    }
    // 撤销
    const revokeAction = (record) => {
        dispatchHandle(
            dispatch,
            'docimasy/operation_service_m_check_task_withdraw_id_delete',
            { id: record.id },
            () => {
                search.refresh()
            }
        )
    }
    const taskColumns = [
        {
            title: '审批类型',
            dataIndex: 'taskAuditTypeName',
        },
        {
            title: '任务编号',
            dataIndex: 'taskNumber',
        },
        // {
        //     title: '任务名称',
        //     dataIndex: 'taskName',
        // },
        {
            title: '检/校类型',
            dataIndex: 'type',
            render: (text, record) => record?.taskBO?.taskTypeName || '--'
        },
        {
            title: '检/校设备',
            dataIndex: 'equipmentName',
            render: (text, record) => record?.taskBO?.deviceName || '--'
        },
        {
            title: '原结束时间',
            dataIndex: 'taskEndTime',
            width: '10%',
            render: (text, record) => <a style={{ color: '#1890ff' }}>{moment(text).format('YYYY/MM/DD HH:mm:ss')}</a>,
        },
        {
            title: '延期至',
            dataIndex: 'delayTime',
            width: '10%',
            render: (text, record) => (
                <>{text ? moment(text).format('YYYY/MM/DD HH:mm:ss') : '--'}</>
            ),
        },
        {
            title: '负责人',
            dataIndex: 'principalName',
            render: (text, record) => record?.taskBO?.principalName || '--'
        },
        // {
        //     title: '任务执行人',
        //     dataIndex: 'taskExecutorNames',
        //     render: (text , record)=>record?.taskBO?.taskExecutorNames || '--'
        // },
        {
            title: '申请状态',
            dataIndex: 'auditState',
            render: (text, record) => ({
                1: <span className='btn_warning'>待审核</span>,
                2: <span className='btn_success'>审核通过</span>,
                3: <span className='btn_disabled'>已驳回</span>,
                4: <span className='btn_warning'>审核中</span>,
                5: <span className='btn_disabled'>已撤销</span>,
            }[record?.state])
        },
        {
            title: '操作',
            dataIndex: 'action',
            fixed: 'right',
            disabled: true,
            render: (text, record) => (
                <div>
                    <Access accessible={access.insideAccess('AYzBOlAkFFO')}>
                        <>
                            <a onClick={() => history.push(`/ops/equipDisposition/docimasy/task/approvaldetail?id=${record.id}&pageType=${'apply'}`)}>查看</a>
                            <Divider type="vertical" />
                        </>
                    </Access>
                    <Access accessible={access.insideAccess('YGQnacoMrcu')}>
                        {
                            record.detailsBO && record.detailsBO.auditState === 1 && (
                                <Popconfirm
                                    title='确认撤销此申请?'
                                    onConfirm={() => revokeAction(record)}
                                >
                                    <a>撤销</a>
                                </Popconfirm>
                            )
                        }
                    </Access>
                </div>

            ),
        },

    ];
    // 配置列
    const [tableColumns, setTableColumns] = useState([
        'taskAuditType',
        "taskNumber",
        // "taskName",
        "type",
        "equipmentName",
        "taskEndTime",
        "delayTime",
        "principalName",
        // "taskExecutorNames",
        'auditState',
        "action"
    ]);
    const popRef2 = useRef();
    const options = popRef2 && (popRef2.current?.handleFormColumns(tableColumns, taskColumns)) || taskColumns;
    return (
        <div className={style.main_task}>
            {/* // 筛选条件 */}
            <div className={style.main_header}>
                <Form form={form} onValuesChange={search.submit} style={{ width: '100%', marginTop: 24 }}>
                    <Row justify="space-between">
                        <Col span={6}>
                            <Form.Item name="taskType" label="任务类型">
                                <Select
                                    allowClear
                                    placeholder="请选择"
                                    showSearch
                                    optionFilterProp="children"
                                >
                                    {
                                        docimasyType && docimasyType?.length > 0 && docimasyType?.map(item => (
                                            <Option key={item?.value} value={item?.value}>{item?.title || ''}</Option>
                                        ))
                                    }
                                </Select>
                            </Form.Item>
                        </Col>
                        <Col span={6}>
                            <Form.Item name="principalId" label="责任人">
                                <TreeSelector isDepart={false} />
                            </Form.Item>
                        </Col>
                        <Col span={6}>
                            <Form.Item name="taskNumberName" label="查询">
                                <Input suffix={<SearchOutlined style={{ color: "rgba(0 , 0 , 0 , 0.25)" }} />} placeholder="请输入任务名称/任务编号" allowClear />
                            </Form.Item>
                        </Col>
                        <Col>
                            <PopTableCheckbox
                                ref={popRef2}
                                options={taskColumns}
                                tableColumns={tableColumns}
                                setTableColumns={setTableColumns}
                                pathKey={pathKey}
                            >
                                <Button
                                    bd="blue"
                                    icon={<SettingOutlined />}
                                >
                                    配置列</Button>
                            </PopTableCheckbox>
                        </Col>
                    </Row>
                </Form>
            </div>
            <Tabs className={style.tables} type="card" onChange={tabChange} style={{ marginBottom: 5 }}>
                {
                    tabsList.map(item => {
                        return <TabPane tab={item.name} key={item.key} />
                    })
                }
            </Tabs>
            <Table
                loading={loading}
                columns={options || taskColumns}
                dataSource={myApplyList.list}
                scroll={{
                    x: 2200
                }}
                pagination={myApplyList.pagination}
                {...tableProps}
            />
        </div>
    )
}

export default connect(({ docimasy, dict, loading }) => ({
    dict,
    docimasy,
    loading: loading.effects['docimasy/operation_service_m_check_task_iStartedTaskApprovaListPage_post']
}))(MyApply)