import AutoTable from '@/components/AutoTable/mtable';

function getcolumns(setdrawer) {
  const columns = [
    {
      title: '供应商编号',
      dataIndex: 'supplierNo',
      key: 'supplierNo',
      editable: false,
    },
    {
      title: '供应商名称',
      dataIndex: 'supplierName',
      key: 'supplierName',
      editable: false,
    },
    {
      title: '保质期(天)',
      dataIndex: 'qualityGuarantee',
      valueType: 'digit',
      precision: 2,
      fieldProps: {
        precision: 2,
      },
      hideInSearch: true,
    },
    {
      title: '价值',
      dataIndex: 'value',
      valueType: 'money',
      hideInSearch: true,
    },
  ];

  return {
    columns: [
      {
        title: '备件料号',
        dataIndex: 'sparePartNo',
        key: 'sparePartNo',
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
      },
      {
        title: '备件名称',
        dataIndex: 'sparePartName',
        key: 'sparePartName',
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
      },
      {
        title: '备件类型',
        dataIndex: 'sparePartTypeName',
        key: 'sparePartTypeId',
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
        valueType: 'treeSelect',
        options: {
          path: '/sparepart/sparePartType/queryTreeList',
          params: {},
        },
        hideInSearch: true,
      },
      {
        title: '库存上限',
        dataIndex: 'stockUpper',
        key: 'stockUpper',
        valueType: 'digit',
        hideInSearch: true,
      },
      {
        title: '库存下限',
        dataIndex: 'stockLower',
        key: 'stockLower',
        valueType: 'digit',
        hideInSearch: true,
      },
      {
        title: '库存单位',
        dataIndex: 'unit',
        key: 'unit',
        formItemProps: {
          rules: [
            {
              required: true,
              message: '此项为必填项',
            },
          ],
        },
        hideInSearch: true,
      },
      {
        title: '是否寿命件',
        dataIndex: 'isLifeName',
        key: 'isLife',
        valueType: 'select',
        options: [
          {
            label: '是',
            value: 1,
          },
          {
            label: '否',
            value: 2,
          },
        ],
        hideInSearch: true,
        hideInTable: true,
      },
      {
        title: '供应商信息',
        dataIndex: 'relations',
        key: 'relations',
        valueType: 'split',
      },
      {
        title: '供应商',
        dataIndex: 'relationSupplierList',
        key: 'relationSupplierList',
        valueType: 'formSelectList',
        colProps: {
          span: 24,
        },
        columns,
        span: 12,
        path: '/sparepart/sparePartSupplier/queryList',
        params: { status: 1 },
        hideInSearch: true,
        hideInTable: true,
        render: (text, row) => {
          return (
            <AutoTable
              columns={columns?.map((it) => ({
                ...it,
                hideInSearch: true,
              }))}
              dataSource={row?.relationSupplierList}
            />
          );
        },
      },
    ],
    pathconfig: {
      enableadd: true,
      enableedit: true,
      enabledelete: true,
      enabledetail: true,
      add: '/sparepart/sparePart/save',
      edit: '/sparepart/sparePart/save',
      list: '/sparepart/sparePart/queryList',
      delete: '/sparepart/sparePart/deleteById',
      detail: '/sparepart/sparePart/queryDetails',
    },
  };
}
export default getcolumns;
