import CONFIG from "@/config";

export default function useColumns() {
  const TableColumns = [
    { item: { key: "priceCode", title: "价格编码", width: 150 }, attr: {} },
    {
      item: { key: "status", title: "状态", width: 100 },
      attr: { is: "el-dict-tag", dictName: "sys_status", width: 100 },
    },
    { item: { key: "supplierName", title: "供应商", width: 150 }, attr: {} },
    { item: { key: "currencyName", title: "币种", width: 100 }, attr: {} },
    {
      item: { key: "explainStr", title: "价格合理性说明", width: 100 },
      attr: {},
    },
    { item: { key: "buyerName", title: "采购员", width: 100 }, attr: {} },
    { item: { key: "puDeptName", title: "采购部门", width: 100 }, attr: {} },
    {
      item: { key: "file", title: "附件", filter: false, width: 100 },
      attr: { is: "el-file-preview" },
    },
    { item: { key: "createByName", title: "创建人", width: 100 }, attr: {} },
    { item: { key: "approveUser", title: "当前审批人", width: 100 }, attr: {} },
    {
      item: { key: "isEffective", title: "是否已推价格", width: 100 },
      attr: { is: "el-dict-tag", dictName: "is_effective" },
    },
    {
      item: { key: "approveTime", title: "单据申请日期", width: 100 },
      attr: {},
    },
    {
      item: { key: "sourceType", title: "来源单据类型", width: 100 },
      attr: { is: "el-dict-tag", dictName: "price_source" },
    },
    // 加个字典获取收回模板id
    {
      item: { key: "", title: "", width: 0 },
      attr: { dictName: "oa_templete_id" },
    },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      sortabled: true,
      fixedabled: true,
      filterabled: true,
      hiddenabled: true,
    },
  }));
  const SearchColumns = [
    {
      item: {
        key: "priceCode",
        title: "价格编码",
      },
      attr: {
        clearable: true,
        is: "el-input",
      },
    },
    {
      item: { key: "supplierName", title: "供应商" },
      attr: {
        is: "el-popover-select-v2",
        referName: "SUPPLIER_PARAM",
        valueKey: "name",
        dataMapping: {
          supplier: "id",
          supplierCode: "code",
          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: "buyerList",
        title: "采购员",
      },
      attr: {
        clearable: true,
        is: "el-popover-multiple-select-v2",
        referName: "CONTACTS_PARAM",
        valueKey: "code",
      },
    },
    {
      item: { key: "materialCodeList", title: "物料编码" },
      attr: {
        clearable: true,
        is: "el-popover-multiple-select-v2",
        valueKey: "code",
        referName: "MATERIAL_PARAM",
      },
    },
    {
      item: { key: "materialCodes", title: "物料编码" },
      attr: {
        clearable: true,
        is: "el-input",
        placeholder: '多物料编码使用 , 隔开',
      },
    },
    {
      item: { width: 100, key: "manufacturerName", title: "生产厂家" },
      attr: {
        is: "el-popover-select-v2",
        clearable: true,
        referName: "MANUFACTURER_PARAM",
        valueKey: "name",
        dataMapping: {
          manufacturer: "id",
          manufacturerName: "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,
      },
    },
    {
      item: { key: "explainStr", title: "内审备注" },
      attr: {
        clearable: true,
        is: "el-input",
      },
    },
    {
      item: { width: 100, key: "billDates", title: "单据日期", span: 8 },
      attr: {
        clearable: true,
        is: "el-date-picker",
        type: "datetimerange",
        rangeSeparator: "至",
        startPlaceholder: "开始日期",
        endPlaceholder: "结束日期",
        valueFormat: "yyyy-MM-dd HH:mm:ss",
      },
    },
  ];

  return { TableColumns, SearchColumns };
}
