export default function useColumns() {
  const SearchColumns = [
    {
      item: { key: "source", title: "来源单据" },
      attr: {
        is: "el-input",
      }
    },
    {
      item: { key: "customerName", title: "客户" },
      attr: {
        is: "el-popover-select-v2",
        referName: "CUSTOMER_PARAM",
        valueKey: "name",
        dataMapping: {
          customer: 'id',
        }
      }
    },
    {
      item: { key: "materialName", title: "物料" },
      attr: {
        is: "el-popover-select-v2",
        referName: "MATERIAL_PARAM",
        valueKey: "name",
        dataMapping: {
          material: 'id',
        }
      }
    },
  ];

  const TableColumns = [
    {
      item: { key: "source", title: "来源单据" },
      attr: {}
    },
    {
      item: { key: "puCode", title: "集采编号" },
      attr: {}
    },
    {
      item: { key: "customerName", title: "客户" },
      attr: {}
    },
    {
      item: { key: "materialCode", title: "物料编码", width: 150, },
      attr: {}
    },
    {
      item: { key: "materialName", title: "物料" },
      attr: {}
    },
    {
      item: { key: "qty", title: "可用量", width: 120, },
      attr: {}
    },
    {
      item: { key: "usedQty", title: "已用量", width: 120, },
      attr: {}
    },
    {
      item: { key: "reservedQty", title: "预留数量", width: 120, },
      attr: {}
    },
    {
      item: { key: "createTime", title: "创建时间" },
      attr: {}
    },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      sortabled: true,
      fixedabled: true,
      filterabled: true,
      hiddenabled: true,
    },
  }));

  const FormColumns = [
    {
      item: { key: "source", title: "单据来源" },
      attr: {
        is: "el-input",
        disabled: true,
      }
    },
    {
      item: { key: "puCode", title: "集采编号" },
      attr: {
        is: "el-input",
        disabled: true,
      }
    },
    {
      item: { key: "createTime", title: "创建时间" },
      attr: {
        is: "el-input",
        disabled: true,
      }
    },
    {
      item: { key: "customerName", title: "客户" },
      attr: {
        is: "el-input",
        disabled: true,
      }
    },
    {
      item: { key: "materialCode", title: "物料编码" },
      attr: {
        is: "el-input",
        disabled: true,
      }
    },
    {
      item: { key: "materialName", title: "物料" },
      attr: {
        is: "el-input",
        disabled: true,
      }
    },
    {
      item: { key: "usedQty", title: "已用量" },
      attr: {
        is: "el-input",
        disabled: true,
      }
    },
    {
      item: { key: "reservedQty", title: "预留数量" },
      attr: {
        is: "el-input",
        disabled: true,
      }
    },
    {
      item: { key: "qty", title: "可用量" },
      attr: {
        is: "el-input-number",
        min: 0,
        controlsPosition: "right",
      }
    },
  ]

  return { SearchColumns, TableColumns, FormColumns }
}