import { request } from '@vtx/utils';
import { useRequest } from 'ahooks';
const BaseService = {
    useBaseInfo: (id: string) => {
        const { data: baseInfoRes } = useRequest(
            () =>
                request.post('/cloud/sjzt-reborn/api/v101/dataSet/execute', {
                    data: JSON.stringify({
                        code: 'ZYRY_STAFF_INFO',
                        parameters: {
                            staffId: id,
                        },
                    }),
                }),
            { refreshDeps: [id] },
        );

        const info = baseInfoRes ? baseInfoRes.data[0] : {};
        const baseInfo = [
            {
                label: '编号',
                key: 'code',
                value: info?.code,
            },
            {
                label: '所属单位',
                key: 'deptName',
                value: info?.deptName,
            },
            {
                label: '性别',
                key: 'gender',
                value: info?.gender,
            },
            {
                label: '入职日期',
                key: 'updateTime',
                value: info?.updateTime,
            },
            {
                label: '在职状态',
                key: 'isLeaveName',
                value: info?.isLeaveName,
            },
            {
                label: '所属标段',
                key: 'tenderName',
                value: info?.tenderName,
            },
            {
                label: '行政区划',
                key: 'divisionName',
                value: info?.divisionName,
            },
        ];

        return {
            baseInfo,
            info,
        };
    },
};

export { BaseService };
