import CONFIG from "@/config";

export default function useColumns() {
  const TableColumns = [
    { item: { key: "priceCode", title: "价格编码" }, attr: {} },
    {
      item: { key: "status", title: "状态" },
      attr: { is: "el-dict-tag", dictName: "sys_status" },
    },
    { item: { key: "supplierName", title: "供应商" }, attr: {} },
    { item: { key: "currencyName", title: "币种" }, attr: {} },
    {
      item: { key: "explainStr", title: "价格合理性说明" },
      attr: {},
    },
    { item: { key: "buyerName", title: "采购员" }, attr: {} },
    { item: { key: "puDeptName", title: "采购部门" }, attr: {} },
    {
      item: { key: "file", title: "附件", filter: false },
      attr: { is: "el-file-preview" },
    },
    { item: { key: "createByName", title: "创建人" }, attr: {} },
    {
      item: { key: "isEffective", title: "是否已推价格" },
      attr: { is: "el-dict-tag", dictName: "is_effective" },
    },
    {
      item: { key: "effectiveDate", title: "生效日期" },
      attr: {},
    },
    { item: { key: "source", title: "来源单据号" }, attr: {} },
    {
      item: { key: "sourceType", title: "来源单据类型" },
      attr: {},
    },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      sortabled: true,
      fixedabled: true,
      filterabled: true,
      hiddenabled: true,
    },
  }));
  const SearchColumns = [
    {
      item: { key: "supplierName", title: "供应商" },
      attr: {
        is: "el-popover-select-v2",
        referName: "SUPPLIER_PARAM",
        valueKey: "name",
        dataMapping: { supplier: "id", supplierName: "name" },
      },
    },
    {
      item: { key: "puOrgName", title: "采购组织" },
      attr: {
        is: "el-popover-select-v2",
        referName: "ORG_PARAM",
        valueKey: "name",
        dataMapping: { puOrg: "id", puOrgName: "name" },
      },
    },
    {
      item: { key: "buyerName", title: "采购员" },
      attr: {
        is: "el-popover-select-v2",
        referName: "CONTACTS_PARAM",
        valueKey: "name",
        dataMapping: { buyer: "code", buyerName: "name" },
      },
    },
    {
      item: { key: "currencyName", title: "币种" },
      attr: {
        is: "el-popover-select-v2",
        referName: "CURRENCY_PARAM",
        valueKey: "name",
        dataMapping: { currency: "id", currencyName: "name" },
      },
    },
    {
      item: { key: "puDeptName", title: "采购部门" },
      attr: {
        is: "el-popover-select-v2",
        referName: "DEPT_PARAM",
        valueKey: "name",
        dataMapping: { puDept: "id", puDeptName: "name" },
      },
    },
    {
      item: { key: "isEffective", title: "是否推价" },
      attr: {
        is: "el-select",
        dictName: "is_effective",
        clearable: true,
      },
    },
    {
      item: { key: "status", title: "状态" },
      attr: {
        is: "el-select",
        dictName: "sys_status",
        clearable: true,
      },
    },
  ];

  return { TableColumns, SearchColumns };
}
