import dayjs from 'dayjs';
function getcolumns(setdrawer) {
    const disabledDate = (current) => {
        // Can not select days before today and today
        return current && current < dayjs().endOf('day');
    };
    const columns = [
        {
            title: '设备编号',
            dataIndex: 'equipmentNo',
            key: 'equipmentNo',
            editable: false,
        },
        {
            title: '设备名称',
            dataIndex: 'equipmentName',
            key: 'equipmentName',
            editable: false,
        },
        {
            title: '工厂名称',
            dataIndex: 'factoryName',
            key: 'factoryId',
            hideInForm: true,
            valueType: 'select',
            fieldProps: {
                placeholder: '请选择',
                showSearch: true,
            },
            options: {
                path: '/auth/sysFactory/getAllFactorySelection',
                params: {},
            },
            editable: false,
        },
        {
            title: '车间名称',
            dataIndex: 'shopName',
            key: 'shopId',
            hideInForm: true,
            valueType: 'select',
            fieldProps: {
                placeholder: '请选择',
                showSearch: true,
            },
            options: {
                path: '/auth/sysShop/getAllShopSelection',
                params: {},
            },
            editable: false,
        },
        {
            title: '下次点检日期',
            dataIndex: 'checkPlanDate',
            formItemProps: {
                rules: [
                    {
                        required: true,
                        message: '此项为必填项',
                    },
                ],
            },
            fieldProps: {
                disabledDate,
            },
            valueType: 'date',
            hideInSearch: true,
        },
    ];
    return [
        {
            tab: '未完成',
            key: 1,
            columns: [
                {
                    title: '点检计划单号',
                    dataIndex: 'checkNo',
                    key: 'checkNo',
                    hideInForm: true,
                    render: (text, row, _, action) => {
                        return (
                            <a
                                onClick={() => {
                                    setdrawer((s) => ({
                                        ...s,
                                        open: true,
                                        val: 'detail',
                                        title: '详细信息',
                                        item: row,
                                    }));
                                }}
                            >
                                {row?.checkNo}
                            </a>
                        );
                    },
                },
                {
                    title: '设备编号',
                    dataIndex: 'equipmentNo',
                    key: 'equipmentNo',
                    hideInForm: true,
                },
                {
                    title: '设备名称',
                    dataIndex: 'equipmentName',
                    key: 'equipmentName',
                    hideInForm: true,
                },
                {
                    title: '工厂名称',
                    dataIndex: 'factoryName',
                    key: 'factoryId',
                    hideInForm: true,
                    valueType: 'select',
                    fieldProps: {
                        placeholder: '请选择',
                        showSearch: true,
                    },
                    options: {
                        path: '/auth/sysFactory/getAllFactorySelection',
                        params: {},
                    },
                },
                {
                    title: '车间名称',
                    dataIndex: 'shopName',
                    key: 'shopId',
                    hideInForm: true,
                    valueType: 'select',
                    fieldProps: {
                        placeholder: '请选择',
                        showSearch: true,
                    },
                    options: {
                        path: '/auth/sysShop/getAllShopSelection',
                        params: {},
                    },
                },
                {
                    title: '点检类型',
                    dataIndex: 'checkTypeName',
                    key: 'checkType',
                    valueType: 'select',
                    options: [
                        {
                            label: '制造点检',
                            value: 1,
                        },
                        {
                            label: '设备点检',
                            value: 2,
                        },
                    ],
                    formItemProps: {
                        rules: [
                            {
                                required: true,
                                message: '此项为必填项',
                            },
                        ],
                    },
                },
                {
                    title: '计划类型',
                    dataIndex: 'checkLoopName',
                    key: 'checkLoop',
                    formItemProps: {
                        rules: [
                            {
                                required: true,
                                message: '此项为必填项',
                            },
                        ],
                    },
                    valueType: 'radio',
                    searchValueType: 'select',
                    options: [
                        {
                            label: '单次',
                            value: 1,
                        },
                        {
                            label: '周期',
                            value: 2,
                        },
                    ],
                },
                {
                    title: '周期(天)',
                    dataIndex: 'checkCycle',
                    key: 'checkCycle',
                    hideInSearch: true,
                    valueType: 'digit',
                    hideInForm: {
                        checkLoop: [1, undefined],
                    },
                    precision: 0,
                },
                {
                    title: '下次点检日期',
                    dataIndex: 'planCheckDate',
                    key: 'planCheckDateList',
                    hideInForm: true,
                    valueType: 'dateRange',
                    render: (text, row, _, action) => {
                        return <span>{row.planCheckDate}</span>;
                    },
                },
                {
                    title: '状态',
                    dataIndex: 'statusName',
                    key: 'status',
                    hideInForm: true,
                    valueType: 'select',
                    fieldProps: {
                        dropdownMatchSelectWidth: 100
                    },
                    options: [
                        {
                            label: '未开始',
                            value: 1,
                        },
                        {
                            label: '执行中',
                            value: 2,
                        },
                    ],
                },
                {
                    title: '选择设备',
                    dataIndex: 'paramList',
                    key: 'paramList',
                    formItemProps: {
                        rules: [
                            {
                                required: true,
                                message: '此项为必填项',
                            },
                        ],
                    },
                    hideInSearch: true,
                    hideInTable: true,
                    valueType: 'formSelectList',
                    colProps: {
                        span: 24,
                    },
                    path: '/asset/equipment/list/user/shop',
                    columns,
                    hideInDescriptions: true,
                    rowName: "equipmentNo"
                },
            ],
            pathconfig: {
                enableadd: true,
                enableedit: false,
                enabledelete: true,
                enabledetail: true,
                add: '/check/umEquipmentCheckPlan/save',
                edit: '',
                list: '/check/umEquipmentCheckPlan/queryNoComplete',
                delete: '/check/umEquipmentCheckPlan/deleteById',
                detail: '/check/umEquipmentCheckPlan/queryDetails',
            },
        },
        {
            tab: '已完成',
            key: 2,
            columns: [
                {
                    title: '点检计划单号',
                    dataIndex: 'checkNo',
                    key: 'checkNo',
                    render: (text, row, _, action) => {
                        return (
                            <a
                                onClick={() => {
                                    setdrawer((s) => ({
                                        ...s,
                                        open: true,
                                        title: '详情',
                                        val: 'detail',
                                        type: 'detail',
                                        title: '详细信息',
                                        item: row,
                                    }));
                                }}
                            >
                                {row?.checkNo}
                            </a>
                        );
                    },
                },
                {
                    title: '设备编号',
                    dataIndex: 'equipmentNo',
                    key: 'equipmentNo',
                },
                {
                    title: '设备名称',
                    dataIndex: 'equipmentName',
                    key: 'equipmentName',
                },
                {
                    title: '工厂名称',
                    dataIndex: 'factoryName',
                    key: 'factoryId',
                    hideInForm: true,
                    valueType: 'select',
                    fieldProps: {
                        placeholder: '请选择',
                        showSearch: true,
                    },
                    options: {
                        path: '/auth/sysFactory/getAllFactorySelection',
                        params: {},
                    },
                },
                {
                    title: '车间名称',
                    dataIndex: 'shopName',
                    key: 'shopId',
                    hideInForm: true,
                    valueType: 'select',
                    fieldProps: {
                        placeholder: '请选择',
                        showSearch: true,
                    },
                    options: {
                        path: '/auth/sysShop/getAllShopSelection',
                        params: {},
                    },
                },
                {
                    title: '点检类型',
                    dataIndex: 'checkTypeName',
                    key: 'checkType',
                    valueType: 'select',
                    options: [
                        {
                            label: '制造点检',
                            value: 1,
                        },
                        {
                            label: '设备点检',
                            value: 2,
                        },
                    ],
                },
                {
                    title: '计划类型',
                    dataIndex: 'checkLoopName',
                    key: 'checkLoop',
                    valueType: 'select',
                    options: [
                        {
                            label: '单次',
                            value: 1,
                        },
                        {
                            label: '周期',
                            value: 2,
                        },
                    ],
                },
                {
                    title: '周期(天)',
                    dataIndex: 'checkCycle',
                    key: 'checkCycle',
                    hideInSearch: true,
                },
                {
                    title: '关单日期',
                    dataIndex: 'endDate',
                    key: 'endDateList',
                    valueType: 'dateRange',
                    render: (text, row, _, action) => {
                        return <span>{row.endDate}</span>;
                    },
                },
                {
                    title: '状态',
                    dataIndex: 'statusName',
                    key: 'statusName',
                    hideInSearch: true,
                },
            ],
            pathconfig: {
                enableadd: false,
                enableedit: false,
                enabledelete: false,
                enabledetail: true,
                add: '',
                edit: '',
                list: '/check/umEquipmentCheckPlan/queryYesComplete',
                delete: '/check/umEquipmentCheckPlan/deleteByI',
                detail: '/check/umEquipmentCheckPlan/queryDetails',
            },
        },
    ];
}
export default getcolumns;