import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { PageContainer } from '@ant-design/pro-components';
import { Button, Space } from 'antd';
import { getList } from './action';
import { dateFormatter, getStorage } from '@component/utils';
import { useRoutes } from '@component/utils';
import { useRef } from 'react';
import { getAqServiceStandard } from 'actions/service.action';
import { CustomProTable } from '@component/ui';
const STATUS = {
    1: '待执行',
    2: '已签到',
    3: '编辑报告中',
    4: '机构初审',
    5: '保险审核',
    6: '审核不通过',
    7: '已完成',
    8: '已取消',
};
export default function ({ poltform }) {
    const { historyPush } = useRoutes();
    const formRef = useRef();
    const isInsure = poltform == 'insure';
    const columns = [
        {
            title: '服务编号',
            dataIndex: 'serviceNumber',
            ellipsis: true,
            formItemProps: { label: '关键字', name: 'keyword' },
            fieldProps: { placeholder: '编号/名称' },
        },
        {
            title: '服务名称',
            dataIndex: 'serviceName',
            ellipsis: true,
            search: false,
        },
        {
            title: '被服务对象',
            dataIndex: 'customerName',
            ellipsis: true,
            search: false,
        },
        {
            title: '标准分类',
            dataIndex: 'aqServiceName',
            valueType: 'select',
            fieldProps: { placeholder: '' },
            formItemProps: {
                name: 'aqServiceId',
            },
            request: getAqServiceStandard,
        },
        {
            title: '归属机构',
            dataIndex: 'insuranceName',
            hideInTable: !isInsure,
            search: false,
        },
        {
            title: '服务机构',
            hideInTable: !isInsure,
            dataIndex: 'executedOrganName',
            search: false,
        },
        {
            title: '服务人员',
            dataIndex: 'userName',
            search: false,
        },
        {
            title: '创建时间',
            dataIndex: 'createdAt',
            renderText: dateFormatter,
            search: false,
        },
        {
            title: '操作',
            valueType: 'option',
            key: 'option',
            width: 140,
            fixed: 'right',
            render: (_, record) => {
                return (_jsxs(Space, { children: [_jsx(Button, Object.assign({ type: "link", style: { padding: 0 }, disabled: !(['3', '11'].includes(String(record === null || record === void 0 ? void 0 : record.status)) && getStorage('userId') == (record === null || record === void 0 ? void 0 : record.createUserId)), onClick: () => {
                                ['3', '11'].includes(String(record === null || record === void 0 ? void 0 : record.status)) && getStorage('userId') == (record === null || record === void 0 ? void 0 : record.createUserId) &&
                                    historyPush('edit', {
                                        serviceId: record.serviceId,
                                    });
                            } }, { children: "\u7F16\u8F91" })), _jsx(Button, Object.assign({ type: "link", style: { padding: 0 }, onClick: () => historyPush('detail', {
                                serviceId: record.serviceId,
                            }) }, { children: "\u8BE6\u60C5" }))] }));
            },
        },
    ];
    return (_jsx(PageContainer, Object.assign({ header: {
            title: null,
        } }, { children: _jsx(CustomProTable, { toolbar: {
                title: _jsx("span", { children: "\u67E5\u8BE2\u7ED3\u679C" }),
                multipleLine: true,
                actions: [
                    _jsx(Button, Object.assign({ type: "link", onClick: () => historyPush('add') }, { children: "\u6DFB\u52A0\u8865\u5F55" })),
                ],
            }, formRef: formRef, request: (params) => {
                return getList(params);
            }, rowKey: "serviceId", params: {
                roleId: getStorage('roleId'),
                executedOrganId: getStorage('organId'),
                organId: getStorage('organId'),
            }, columns: columns }) })));
}