import { Tooltip, Image, Tag } from 'antd';
import { doFetch } from '@/utils/doFetch';
const statusColors = {
    1: '#7ac143',
    2: '#00bce4',
    3: '#6a737b',
    4: '#fa4659'
};
function getcolumns(setdrawer, activeKey) {
    return activeKey == 'item-1' ? {
        columns: [
            {
                title: '设备信息',
                valueType: 'split'
            },
            {
                title: '设备编号',
                dataIndex: 'equipmentNo',
                key: 'equipmentNo',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
                colProps: { span: 8 },
            },
            {
                title: '设备名称',
                dataIndex: 'equipmentName',
                key: 'equipmentName',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
                colProps: { span: 8 },
                render: (_, row) => {
                    return (
                        <Tooltip title={row.equipmentName}>
                            <a
                                className="table-cell"
                                onClick={() => {
                                    setdrawer && setdrawer((s) => ({
                                        ...s,
                                        open: true,
                                        item: row,
                                        val: 'only',
                                        title: '设备详情'
                                    }));
                                }}
                            >
                                {row.equipmentName}
                            </a>
                        </Tooltip>
                    );
                }
            },
            {
                title: '资产编号',
                dataIndex: 'assetNumber',
                key: 'assetNumber',
                colProps: { span: 8 },
                hideInTable: true,
                hideInSearch: true
            },
            {
                title: '关联设备',
                dataIndex: 'ledgerEquipment',
                key: 'ledgerEquipment',
                hideInForm: true,
                colProps: { span: 8 }
            },
            {
                title: '设备品牌',
                dataIndex: 'brand',
                key: 'brand',
                colProps: { span: 8 }
            },
            {
                title: '设备型号',
                dataIndex: 'equipmentModelName',
                key: 'equipmentModelId',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
                valueType: 'select',
                options: { path: '/asset/equipmentModel/query/selection', params: {} },
                colProps: { span: 8 },
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
            },
            {
                title: '开始租赁时间',
                dataIndex: 'startLeaseTime',
                key: 'startLeaseTimeList',
                valueType: 'dateRange',
                hideInDescriptions: true,
            },
            {
                title: '结束租赁时间',
                dataIndex: 'endLeaseTime',
                key: 'endLeaseTimeList',
                valueType: 'dateRange',
                hideInDescriptions: true,
            },
            {
                title: '设备类型',
                dataIndex: 'equipmentTypeName',
                key: 'equipmentType',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
                hideInSearch: true,
                valueType: 'select',
                options: [
                    { label: '设备', value: 1 },
                    { label: '智能单元', value: 2 },
                ],
                colProps: { span: 8 },
                hideInTable: true
            },
            {
                title: '经营状态',
                dataIndex: 'statusName',
                key: 'status',
                hideInForm: true,
                valueType: 'select',
                options: [
                    { label: '报废', value: '0' },
                    { label: '预占', value: '1' },
                    { label: '租赁', value: '2' },
                    { label: '销售', value: '3' },
                    { label: '闲置', value: '4' },
                    { label: '待复检', value: '5' },
                    { label: '未绑定', value: '6' },
                    { label: '绑定', value: '7' },
                ],
                hideInSearch: true,
                hideInForm: true,
                hideInTable: true
            },
            {
                title: '采集状态',
                dataIndex: 'collectStatusName',
                key: 'collectStatus',
                hideInForm: true,
                valueType: 'select',
                options: [
                    { label: '工作', value: 1 },
                    { label: '待机', value: 2 },
                    { label: '关机', value: 3 },
                    { label: '报警', value: 4 }
                ],
                fixed: 'right',
                render: (_, row) => {
                    return <span style={{ color: statusColors[row.collectStatus] }}>{row.collectStatusName}</span>
                }
            },
            {
                title: '所属信息',
                valueType: 'split'
            },
            {
                title: '公司名称',
                dataIndex: 'companyName',
                key: 'organizationId',
                hideInSearch: true,
                hideInTable: true,
                valueType: 'select',
                options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
                colProps: { span: 8 },
                span: 1
            },
            {
                title: '部门名称',
                dataIndex: 'departmentName',
                key: 'departmentId',
                formItemProps: { rules: [{ required: false, message: '此项为必填项' }] },
                hideInSearch: true,
                hideInTable: true,
                valueType: 'treeSelect',
                options: { path: '/auth/sysDepartment/query/children/tree', linkParams: { organizationId: 'parentId' } },
                colProps: { span: 8 }
            },
            {
                title: '工厂名称',
                dataIndex: 'factoryName',
                key: 'factoryId',
                valueType: 'select',
                options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
                hideInForm: true,
                hideInSearch: true,
                hideInTable: true,
                colProps: { span: 8 },
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
            },
            {
                title: '车间名称',
                dataIndex: 'shopName',
                key: 'shopId',
                hideInSearch: true,
                hideInTable: true,
                valueType: 'select',
                options: { path: '/auth/sysShop/getShopSelectionByFactory', linkParams: { factoryId: '' } },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
                colProps: { span: 8 },
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
            },
            {
                title: '工段名称',
                dataIndex: 'sectionName',
                key: 'sectionId',
                hideInSearch: true,
                hideInTable: true,
                valueType: 'select',
                options: {
                    path: '/auth/sysSection/getAllSectionSelectionByShop',
                    linkParams: { shopId: '' },
                },
                colProps: { span: 8 }
            },
            {
                title: '产线名称',
                dataIndex: 'productionLineName',
                key: 'productionLineId',
                valueType: 'select',
                hideInSearch: true,
                hideInTable: true,
                options: {
                    path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
                    linkParams: { shopId: '' },
                },
                colProps: { span: 8 }
            },
            {
                title: '关联客户',
                dataIndex: 'ledgerCustomer',
                key: 'ledgerCustomer',
                hideInSearch: true,
                hideInTable: true,
                hideInForm: true,
                span: 3
            },
            {
                title: '其他信息',
                valueType: 'split'
            },
            {
                title: '供应商',
                dataIndex: 'supplierName',
                key: 'supplierId',
                valueType: 'select',
                options: { path: '/lease/umEquipmentSupplier/getSelection', params: {} },
                colProps: { span: 8 },
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
                span: 1
            },
            {
                title: '保管单位',
                dataIndex: 'custodyUnit',
                key: 'custodyUnit',
                colProps: { span: 8 },
                hideInTable: true,
                hideInSearch: true
            },
            {
                title: '产权单位',
                dataIndex: 'propertyUnit',
                key: 'propertyUnit',
                colProps: { span: 8 },
                hideInTable: true,
                hideInSearch: true
            },
            {
                title: '租赁合同单号',
                dataIndex: 'contractNo',
                key: 'contractNo',
                colProps: { span: 8 },
                hideInDescriptions: true,
            },
            {
                title: '图片',
                dataIndex: 'imageUrl',
                key: 'imageUrl',
                hideInSearch: true,
                hideInForm: true,
                render: (_, row) => {
                    return row?.imageUrl ? <Image style={{ width: 40, height: 40, objectFit: 'contain', objectPosition: 'center' }} src={row?.imageUrl} /> : '-'
                }
            },
            {
                title: '二维码',
                dataIndex: 'qrCodeUrl',
                key: 'qrCodeUrl',
                hideInSearch: true,
                hideInForm: true,
                render: (_, row) => {
                    return row?.qrCodeUrl ? <Image style={{ width: 40, height: 40, objectFit: 'contain', objectPosition: 'center' }} src={row?.qrCodeUrl} /> : '-'
                }
            }
        ],
        pathconfig: {
            add: '',
            edit: '',
            list: '',
            delete: '',
        },
    } : {
        columns: [
            {
                title: '设备编号',
                dataIndex: 'equipmentNo',
                key: 'equipmentNo',

                width: 120,
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
            },
            {
                title: '设备名称',
                dataIndex: 'equipmentName',

                width: 220,
                key: 'equipmentName',
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
            },
            {
                title: '位置号',
                width: 120,

                dataIndex: 'positionNo',
                search: false,
                hideInTable: true,
                key: 'positionNo',
            },
            {
                width: 120,
                title: '设备类型',
                dataIndex: 'equipmentTypeName',
                key: 'equipmentTypeId',
                valueType: 'treeSelect',
                options: { path: '/asset/equipmentType/queryTreeList', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
            },
            {
                title: '设备型号',
                dataIndex: 'equipmentModelName',
                width: 120,

                key: 'equipmentModelId',
                valueType: 'select',
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
                options: { path: '/asset/equipmentModel/query/selection', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
            },
            {
                title: '公司名称',

                dataIndex: 'organizationName',
                width: 120,
                key: 'organizationId',
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
                valueType: 'select',
                options: { path: '/auth/sysDepartment/query/organization/selectbox', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
            },
            {
                title: '部门名称',
                width: 120,
                valueType: 'treeSelect',
                dataIndex: 'departmentName',
                key: 'departmentId',
                options: {
                    path: '/auth/sysDepartment/query/children/tree',
                    linkParams: {
                        organizationId: 'parentId',
                    },
                },
            },
            {
                title: '工厂名称',
                dataIndex: 'factoryName',
                key: 'factoryId',
                width: 120,
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
                valueType: 'select',
                options: { path: '/auth/sysFactory/getAllFactorySelection', params: {} },
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
            },
            {
                title: '车间名称',
                dataIndex: 'shopName',

                width: 120,
                valueType: 'select',
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
                options: {
                    path: '/auth/sysShop/getShopSelectionByFactory',
                    linkParams: {
                        factoryId: '',
                    },
                },
                key: 'shopId',
                search: false,
                formItemProps: { rules: [{ required: true, message: '此项为必填项' }] },
            },
            {
                title: '车间名称',
                dataIndex: 'shopName',
                width: 120,
                valueType: 'select',
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
                options: {
                    path: '/auth/sysShop/getAllShopSelection',
                    params: {},
                },
                key: 'shopId',
                hideInForm: true,
                hideInTable: true,
            },
            {
                title: '工段名称',
                width: 120,
                dataIndex: 'sectionName',

                key: 'sectionId',
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
                valueType: 'select',
                options: {
                    path: '/auth/sysSection/getAllSectionSelectionByShop',
                    linkParams: {
                        shopId: '',
                    },
                },
                search: false,
            },
            {
                title: '工段名称',
                width: 120,
                dataIndex: 'sectionName',
                key: 'sectionId',
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
                valueType: 'select',
                options: {
                    path: '/auth/sysSection/getAllSectionSelection',
                    params: {},
                },
                hideInForm: true,
                hideInTable: true,
            },
            {
                title: '产线名称',
                width: 120,
                dataIndex: 'productLineName',
                valueType: 'select',
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
                key: 'productLineId',

                options: {
                    path: '/auth/sysProductionLine/getAllProductLineSelectionByShop',
                    linkParams: {
                        shopId: '',
                    },
                },
                search: false,
            },
            {
                title: '产线名称',
                width: 120,
                dataIndex: 'productLineName',
                valueType: 'select',
                fieldProps: {
                    placeholder: '请选择',
                    showSearch: true,
                },
                key: 'productLineId',
                options: {
                    path: '/auth/sysProductionLine/getAllProductLineSelection',
                    params: {},
                },
                hideInForm: true,
                hideInTable: true,
            },
            {
                title: '供应商',
                width: 120,
                valueType: 'select',
                dataIndex: 'supplierName',

                hideInTable: true,
                search: false,
                key: 'supplierId',
                options: {
                    path: '/asset/equipmentSupplier/query/selection',
                    params: {},
                },
            },
            {
                title: '设备原值(万元)',
                valueType: 'digit',
                search: false,
                hideInTable: true,

                dataIndex: 'equipmentWorth',
                key: 'equipmentWorth',
            },
            {
                title: '安装投产日期',
                hideInTable: true,
                search: false,

                dataIndex: 'productDate',
                key: 'productDate',
                valueType: 'date',
            },
            {
                title: '图片',
                width: 120,
                dataIndex: 'pictureUrl',
                search: false,
                search: false,
                key: 'picList',

                valueType: 'uploadImage',
                fieldProps: {
                    limit: 1,
                },
                formItemProps: {
                    rules: [
                        {
                            required: false,
                            message: '此项为必填项',
                        },
                    ],
                },
                render: (_, row) => {
                    return row?.pictureUrl ? <Image style={{ width: 40, height: 40, objectFit: 'contain', objectPosition: 'center' }} src={row?.pictureUrl} /> : '-'
                }
            },
            {
                title: '二维码',
                width: 120,

                search: false,

                dataIndex: 'qrCodeUrl',
                key: 'qrCodeUrl',
                valueType: 'uploadImage',
                search: false,
                hideInForm: true,
                render: (text, row) => {
                    if (row?.qrCodeUrl == null) {
                        return (
                            <div
                                style={{
                                    height: 50,
                                    display: 'flex',
                                    justifyContent: 'center',
                                    alignItems: 'center',
                                }}
                            >
                                <span>暂无图片</span>
                            </div>
                        );
                    } else {
                        return <Image width={50} src={row.qrCodeUrl} />;
                    }
                },
            },
            {
                title: '状态名称',

                search: false,
                hideInTable: true,
                dataIndex: 'statusName',
                key: 'statusName',
                hideInForm: true,
            },
            {
                title: '设备状态',
                dataIndex: 'status',
                width: 120,

                hideInForm: true,
                fixed: 'right',
                valueType: 'select',
                options: [
                    {
                        label: '在用',
                        value: 1,
                    },
                    {
                        label: '借用中',
                        value: 2,
                    },
                    {
                        label: '报废',
                        value: 3,
                    },
                ],
                key: 'status',
                render: (text, row) => {
                    switch (row.status) {
                        case 1:
                            return <Tag color="success">在用</Tag>;
                        case 3:
                            return <Tag>报废</Tag>;
                        case 2:
                            return <Tag color="volcano">借用中</Tag>;
                        default:
                            break;
                    }
                },
            },
        ]
    };
}
export default getcolumns;