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: "approver", title: "最后审批人" }, 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: {} },
   
  ].map(({ item, attr }) => ({
    attr,
    item: { ...item, hidden: true, fixed: false },
  }));

  const SearchColumns = [
    {
      item: { key: "materialCode", title: "物料编码" },
      attr: {
        is: "el-popover-select-v2",
        referName: "MATERIAL_PARAM",
        valueKey: "code",
        clearable:true,
        dataMapping: { 
          materialName: "name",
        },
      },
    },
    {
      item: { key: "materialName", title: "物料名称" },
      attr: {
        is: "el-popover-select-v2",
        referName: "MATERIAL_PARAM",
        valueKey: "name",
        clearable:true,
        dataMapping: { 
          materialCode: "code",
        },
      },
    },
    {
      item: { key: "status", title: "单据状态" },
      attr: {
        is: "el-select",
        dictName: "documents_status",
        clearable: true,
      },
    },
  
  ].map(({ item, attr }) => ({
    attr,
    item: { ...item, hidden: true, span: item.span || 6 },
  }));

  return { TableColumns, SearchColumns };
}