export default function useColumns() {

  const TableColumns = [
    {
      item: { key: "code", title: "需求单号", width: 150 },
      attr: {}
    },
    {
      item: { key: "demandDate", title: "需求日期", width: 150 },
      attr: {}
    },
    {
      item: { key: "createTime", title: "制单日期", width: 150 },
      attr: {}
    },
    {
      item: { key: "planType", title: "需求计划", width: 150 },
      attr: { is: "el-dict-tag", dictName: "sys_plan_type" }
    },
    {
      item: { key: "approverFinishTime", title: "审批结束日期", width: 150 },
      attr: {}
    },
    {
      item: { key: "status", title: "单据状态", width: 150 },
      attr: { is: "el-dict-tag", dictName: "sys_status" }
    },
    {
      item: { key: "billType", title: "业务类型", width: 150 },
      attr: { is: "el-dict-tag", dictName: "sys_business" }
    },
    {
      item: { key: "demandPersonalName", title: "需求人员", width: 150 },
      attr: {}
    },
    {
      item: { key: "customerName", title: "需求客户", width: 150 },
      attr: {}
    },
    {
      item: { key: "demandDeptName", title: "需求部门", width: 150 },
      attr: {}
    },
    {
      item: { key: "source", title: "单据来源", width: 150 },
      attr: { is: "el-dict-tag", dictName: "sys_bill_source" }
    },
    {
      item: { key: "approveUser", title: "当前审批人", width: 150 },
      attr: {}
    },
    {
      item: { key: "remark", title: "备注", width: 150 },
      attr: {}
    },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      width: item.width || 160,
      sortabled: true,
      fixedabled: true,
      filterabled: true,
      hiddenabled: true,
    },
  }));


  const SearchColumns = [
    {
      item: { key: "code", title: "需求单号" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
    {
      item: { key: "customerName", title: "需求客户" },
      attr: {
        is: "el-popover-select-v2",
        referName: "CUSTOMER_PARAM",
        valueKey: "name",
        dataMapping: {
          customer: "id",
          customerName: "name"
        },
      },
    },
    {
      item: { key: "isCustomerSpecified", title: "是否客户指定" },
      attr: {
        is: "el-select",
        dictName: "sys_yes_no",
        clearable: true,
      },
    },
    {
      item: { key: "demandPersonalName", title: "需求人员" },
      attr: {
        is: "el-popover-select-v2",
        referName: "CONTACTS_PARAM",
        valueKey: "name",
        dataMapping: {
          demandPersonal: "code",
          demandPersonalName: "name"
        },
      },
    },
    {
      item: { key: "source", title: "单据来源" },
      attr: {
        is: "el-select",
        dictName: "sys_bill_source",
        clearable: true,
      },
    },
    {
      item: { key: "billType", title: "业务类型" },
      attr: {
        is: "el-select",
        dictName: "sys_business",
        clearable: true,
      },
    },
    {
      item: { key: "demandDeptName", title: "需求部门" },
      attr: {
        is: "el-popover-select-v2",
        referName: "DEPT_PARAM",
        valueKey: "name",
        dataMapping: {
          demandDept: "id",
          demandDeptName: "name"
        },
      },
    },
    {
      item: { width: 100, key: "demandDate", title: "需求日期", },
      attr: {
        clearable: true,
        is: "el-date-picker",
        type: "date",
        valueFormat: "yyyy-MM-dd",
      },
    },
    {
      item: { key: "materialCode", title: "物料编码" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
    {
      item: { key: "status", title: "单据状态" },
      attr: {
        is: "el-select",
        dictName: "sys_status",
        clearable: true,
      },
    },
    {
      item: { key: "planType", title: "需求计划" },
      attr: {
        is: "el-select",
        dictName: "sys_plan_type",
        clearable: true,
      },
    },
    {
      item: { width: 100, key: "createTimeString", title: "制单日期", },
      attr: {
        clearable: true,
        is: "el-date-picker",
        type: "date",
        valueFormat: "yyyy-MM-dd",
      },
    },
    {
      item: { key: "additionalSupplierName", title: "补单供应商" },
      attr: {
        is: "el-popover-select-v2",
        referName: "SUPPLIER_PARAM",
        valueKey: "name",
        dataMapping: {
          additionalSupplier: "id",
          additionalSupplierName: "name"
        },
      },
    },
  ];



  return { TableColumns, SearchColumns }
}