import React from 'react';
import PropTypes from 'prop-types';
import BaseContent from './base';
import BottleOperateLog from './bottleOperateLog';
import SecurityCheckRecord from './securityCheckRecord';
import VmGasModal from '../vm-gas-modal';
import useModal from '../vm-hooks/useModal';
import { getUrlParam } from '@vtx/utils';
import './style';
const TABS_BASE = 'gas-staff-base';
const TABS_BOTTLEOPERATELOG1 = 'gas-staff-bottle-operate-log1';
const TABS_BottleOperateLog2 = 'gas-staff-bottle-operate-log2';
const TABS_SECURITYCHECKRECORD = 'gas-staff-security-check-record';
const Modal = ({ id, ...resetProps }) => {
    const tabs = [
        {
            value: '人员信息',
            content: <BaseContent id={id} />,
            key: TABS_BASE,
        },
        {
            value: '气瓶收送记录',
            content: <BottleOperateLog id={id} operateTypes="OPERATE_4,OPERATE_5" />,
            key: TABS_BOTTLEOPERATELOG1,
        },
        {
            value: '气瓶装检记录',
            content: <BottleOperateLog id={id} operateTypes="OPERATE_1,OPERATE_2,OPERATE_3" />,
            key: TABS_BottleOperateLog2,
        },
        {
            value: '入户安检记录',
            content: <SecurityCheckRecord id={id} />,
            key: TABS_SECURITYCHECKRECORD,
        },
    ];
    if (getUrlParam().carqFlag == 'true') {
        tabs.splice(1, 2);
    }
    return <VmGasModal tabs={tabs} title="从业人员信息" {...resetProps} />;
};

const VtxGasStaffModal = props => {
    const { label, id } = props;
    const { showModal, ...modalProps } = useModal();

    return (
        <>
            {label ? (
                <a type="link" onClick={showModal}>
                    {label}
                </a>
            ) : (
                <span>-</span>
            )}
            <Modal id={id} {...modalProps} />
        </>
    );
};

Modal.propTypes = {
    id: PropTypes.string.isRequired,
};

VtxGasStaffModal.propTypes = {
    id: PropTypes.string.isRequired,
    label: PropTypes.string.isRequired,
};

VtxGasStaffModal.Modal = Modal;

export default VtxGasStaffModal;
