WaitInventory.jsx 10.1 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 245 246 247 248 249 250 251 252 253 254 255 256
import React, { useState, useRef,useEffect } from 'react';
import { Tabs, Form, Col, Row, Select, Input, Button, Divider ,Popconfirm,Table,Badge} from 'antd';
import { SettingOutlined } from '@ant-design/icons';
import { history } from 'umi';
import PopTableCheckbox from '@/components/PopTableCheckbox';
import useFormTable from '@/useHooks/useFormTable';
import utilsStyles from '@/utils/utils.less';
import classNames from 'classnames';
import style from "../index.less";
import { dispatchHandle } from '@/utils/publicHandle';
import moment from 'moment';
import { connect } from 'umi';

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

const WaitInventory = (props) => {
    const [form] = Form.useForm();
    const [tableColumns, setTableColumns] = useState([
        'deviceInventoryOrder',
        'taskName', 
        'taskEndDateTime', 
        'firstInventoryUserName', 
        'repeatInventoryUserName', 
        'shouldInventoryAmount', 
        'actualInventoryAmount', 
        'orderStatus', 
        'operate']);
    const popTableCheckboxRef = useRef();
    const tabKeys = [
        {
            name: '全部',
            key: null
        },
        {
            name: '待审核',
            key: 4
        },
        {
            name:'审批通过',
            key: 2
        },
        {
            name: '审核不通过',
            key: 3
        }
    ];
    const {
        dispatch,
        opsEquip: { inventoryList },
        setting: { users },
        loadingQuery
    } = props;
  

    const usersList = users.list;

    const [activeKeys, setActiveKeys] = useState('');
    // 审核状态 (1待审核 2 审核通过  3 审核不通过 )
    const allTabsChange = (activeKey) => {
        setActiveKeys(activeKey);
        let searchData = search.searchData;
        console.log(`searchData is:`, searchData);
        search.submit({ ...searchData, auditState: Number(activeKey) })
    };

    useEffect((payload = {}) => {
        dispatchHandle(dispatch, 'setting/account_service_user_page_post', payload)
    }, []);

        //更新审批的数量tag
    useEffect(() => {
        activeKeys === 1 && dispatchHandle(
                  dispatch,
                    'opsEquip/setModelsState',
                    {
                        equipInventoryAuditCount: inventoryList?.pagination?.total || 0
                    }
                )
    }, [activeKeys, inventoryList]);

    const getListItems = (payload = {}) => {
        dispatchHandle(
            dispatch,
            'opsEquip/operation_service_device_inventory_order_myAudit_post',
            payload,
        );
    }
    const tableDelete = (id) => {
        dispatchHandle(dispatch, 'opsEquip/operation_service_device_inventory_order_cancel_get', {id}, () => {
            search.refresh();
        });
    }
    //领导公共审核撤销
    const revertRecordBack = reviewRecordId => {
          dispatchHandle(dispatch, 'universal/common_service_m_audit_nodeRevoke_auditId_delete', {auditId:reviewRecordId}, () => {
            search.refresh();
        });
    }
    const { tableProps, search } = useFormTable(getListItems, {
        form,
    });

    const options = [

        {
            title: '盘点单号', dataIndex: 'deviceInventoryOrder',
        },
        {
            title: '任务名称', dataIndex: 'taskName', 
        },
        {
            title: '起止时间', dataIndex: 'taskEndDateTime',
            render: (val,record) => {
                return `${record.taskStartDateTime && moment(record.taskStartDateTime).format(`YYYY/MM/DD`)}-${ record.taskEndDateTime && moment(record.taskEndDateTime).format(`YYYY/MM/DD`)}` || '暂无'
            }
        },
        {
            title: '初盘人', dataIndex: 'firstInventoryUserName'
        },
        { title: '复盘人', dataIndex: 'repeatInventoryUserName'},
        { title: '应盘数', dataIndex: 'shouldInventoryAmount' },
        { title: '实盘数', dataIndex: 'actualInventoryAmount' },
        {
            //工单状态 1:待审批 5:已完成 10:已驳回 15:已撤销 20:未开始 25:进行中 30:已超时 35:已关闭
            title: '盘点状态', dataIndex: 'orderStatus',
            render: (val) => {
                return (
                    <>
                        {(val === 1 && (
                            <span className={classNames(utilsStyles.comTag)} type="warn" style={{ paddingRight: '20px', paddingLeft: '20px' }}>
                                待审批
                            </span>
                        )) || (val === 5 && (
                                <span className={classNames(utilsStyles.comTag)} type="success">
                                    已完成
                                </span>
                            )) || (val === 10 && (
                                <span className={classNames(utilsStyles.comTag)} type="warn">
                                    已驳回
                                </span>
                            )) ||  (val === 15 && (
                                <span className={classNames(utilsStyles.comTag)} type="warn">
                                    已撤销
                                </span>
                            )) ||
                            (val === 20 && (
                                <span className={classNames(utilsStyles.comTag)} type="success">
                                    未开始
                                </span>
                            )) ||
                            (val === 25 && (
                                <span className={classNames(utilsStyles.comTag)} type="warn" style={{ paddingRight: '20px', paddingLeft: '20px' }}>
                                    进行中
                                </span>
                            )) || (val === 30 && (
                                <span className={classNames(utilsStyles.comTag)} type="warn" style={{ paddingRight: '20px', paddingLeft: '20px' }}>
                                    已超时
                                </span>
                            )) ||  (val === 35 && (
                                <span className={classNames(utilsStyles.comTag)} type="warn" style={{ paddingRight: '20px', paddingLeft: '20px' }}>
                                    已关闭
                                </span>
                            )) || <span className={classNames(utilsStyles.comTag)} type="blue" style={{ paddingRight: '20px', paddingLeft: '20px' }}>
                                    暂无状态
                           </span>
                        }
                    </>
                );
            },
        },

        {
            title: '操作', dataIndex: 'operate', disabled: true,
            render: (val,record) => (
                <>
                    {/* 
                    工单状态 4,待审核 2 通过 3,不通过
                    */}
                    {
                        Number(record.personalAuditState) === 4 && <a onClick={()=>history.push(`/ops/equipDisposition/equipInventory/audit/${record?.id}`)}>审批</a> || <a onClick={()=>history.push(`/ops/equipDisposition/equipInventory/auditView/${record?.id}`)}>查看</a>
                    }
                </>
            ),
        },

    ];
    const columns = popTableCheckboxRef && (popTableCheckboxRef.current?.handleFormColumns(tableColumns, options)) || options;
    const formItemLayout = {
        labelCol: { span: 6 },
        wrapperCol: { span: 18 }
    };
    const formItemLayout2 = {
        labelCol: { span: 6 },
        wrapperCol: { span: 18 }
    };

    return (
        <div>
            <Form form={form} style={{ marginTop: '15px' }} onValuesChange={search.submit}>
                <Row>
                 <Col span={6}>
                        <Form.Item name='deviceInventoryOrder' label='盘点单号' {...formItemLayout}>
                            <Input placeholder='请填写' allowClear style={{width:'100%'}} />
                        </Form.Item>
                    </Col>
                    <Col span={6}>
                        <Form.Item name='taskName' label='任务名称' {...formItemLayout}>
                            <Input placeholder='请填写' allowClear style={{width:'100%'}} />
                        </Form.Item>
                    </Col>
                    <Col span={6}>
                        <Form.Item name='search' label='查询' {...formItemLayout2}>
                            <Search placeholder='请输入' style={{width:'100%'}} />
                        </Form.Item>
                    </Col>
                    <Col span={6}>
                        <Form.Item label='' style={{ textAlign: 'end' }}>
                            <PopTableCheckbox ref={popTableCheckboxRef} options={options} tableColumns={tableColumns} setTableColumns={setTableColumns} >
                                <Button bd="blue" icon={<SettingOutlined />} style={{ marginTop: 2 }} >配置列</Button>
                            </PopTableCheckbox>
                        </Form.Item>
                    </Col>
                </Row>
            </Form>
            <div>
                <Divider style={{ marginTop: '0' }} />
                <Tabs type="card" onChange={allTabsChange}>
                     {
                        tabKeys.map(i => (
                            <TabPane tab={i.name} key={i.key} />
                        ))
                    }
                </Tabs>
                 <Table
                    columns={columns}
                    dataSource={inventoryList.list}
                    rowKey={record => record.id}
                    className='custom-table-setting'
                    {...tableProps}
                    style={{ marginTop: 15 }}
                    loading = { loadingQuery }
                />
            </div>
            {/* 待审批条数 */}
            <Badge className={style.count}>{ inventoryList?.pagination?.total || 0 }</Badge>
        </div>
    )
}

export default connect(({ opsEquip, setting,loading }) => ({
    opsEquip,setting,
    loading,
    loadingQuery:loading.effects['opsEquip/operation_service_device_inventory_order_myAudit_post']
}))(WaitInventory);