export default function useColumns() {

  const TableColumns = [
    { item: { key: "orgName", title: "所属组织" }, attr: {} },
    { item: { key: "code", title: "单据编码" }, attr: {} },
    {
      item: { key: "applicationTime", title: "申请时间" },
      attr: { },
    },
    { item: { key: "status", title: "单据状态",width:120, }, 
      attr: {
        
        is: "el-dict-tag",
        dictName: "documents_status", // 字典名
      } 
    },
    // { item: { key: "materialCode", title: "物料编码" }, attr: {} },
    // {
    //   item: { key: "materialName", title: "物料名称" },
    //   attr: {},
    // },
    { item: { key: "approverName", title: "最后审批人",width:150, }, attr: {} },
    { item: { key: "approvalTime", title: "最后审核时间" }, attr: {} },
    { item: { key: "createByName", title: "创建人" ,width:150, }, attr: {} },
    { item: { key: "createTime", title: "创建时间" }, attr: {} },
    {
      item: { key: "updateByName", title: "最后修改人" ,width:150, },
      attr: {  },
    },
    { item: { key: "updateTime", title: "最后修改时间" }, attr: {} },
    
    { 
      item:{ key: "approveUser", title: "当前审批人" ,},
      attr:{
      },
    },
   
  ].map(({ item, attr }) => ({
    attr,
    item: { 
      ...item, 
      sortabled: true,
      fixedabled: true,
      filterabled: true,
      hiddenabled: true, 
    },
  }));

  const SearchColumns = [
    {
      item: { key: "materialCode", title: "物料编码" },
      attr: {
        is: "el-popover-select-v2",
        referName: "MATERIAL_PARAM",
        valueKey: "code",
        clearable:true,
        dataMapping: { 
          materialName: "name",
        },
      },
    },
    {
      item:{
        key: "manufacturerIdName",
        title: "生产厂家/代理人",  
      },
      attr:{
        clearable:true,
        is: "el-popover-select-v2",
        valueKey: "name",
        referName: "MANUFACTURER_PARAM",
        dataMapping: {
          manufacturerId: "id",
        },
      },
    },
    {
      item:{
        // key: "approverName",
        key: "createByName",
        title: "申请人",
      },
      attr: {
        clearable:true,
        is: "el-popover-select-v2",
        referName: "CONTACTS_PARAM",
        valueKey: "name",
        dataMapping: {
          // approver: "code",
          createBy: "code",
        },
      },
    },
    {
      item:{
        key: "applyTimeArray",
        title: "申请日期",
       // span:12,
      },
      attr: {
        clearable:true,
        is: "el-date-picker",
        type:"daterange",
        rangeSeparator:"-",
        startPlaceholder:"开始日期",
        endPlaceholder:"结束日期",
        valueFormat:"yyyy-MM-dd",
      },
    },
    {
      item: {
        key: "code",
        title: "单据编码",
      },
      attr: {
        clearable: true,
        is: "el-input",
      },
    },
    {
      item: { key: "status", title: "单据状态" },
      attr: {
        is: "el-select",
        dictName: "documents_status",
        clearable: true,
      },
    },
    {
      item: {
        key: "materialClassifyIds",
        title: "物料分类",
      },
      attr: {
        is: "el-popover-multiple-tree-select",
        // is: "el-popover-tree-select",
        referName: "MATERIALCLASSIFY_PARAM",
        valueKey: "id",
        clearable:true,
      },
    },
    {
      item:{
        key: "updateTimeArray",
        title: "修改日期",
       // span:12,
      },
      attr: {
        clearable:true,
        is: "el-date-picker",
        type:"daterange",
        rangeSeparator:"-",
        startPlaceholder:"开始日期",
        endPlaceholder:"结束日期",
        valueFormat:"yyyy-MM-dd",
      },
    },

    // {
    //   item: { key: "materialName", title: "物料名称" },
    //   attr: {
    //     is: "el-popover-select-v2",
    //     referName: "MATERIAL_PARAM",
    //     valueKey: "name",
    //     clearable:true,
    //     dataMapping: { 
    //       materialCode: "code",
    //     },
    //   },
    // },
  
  ].map(({ item, attr }) => ({
    attr,
    item: { ...item, hidden: true, span: item.span || 6 },
  }));

  return { TableColumns, SearchColumns };
}