export default function useColumns() {
  const SearchColumns = [
    {
      item: { key: "materialClassifyOne", title: "物料一级大类编码" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
    {
      item: { key: "materialClassifyOneName", title: "物料一级大类名称" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
    {
      item: { key: "materialClassifyTwo", title: "物料二级大类编码" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
    {
      item: { key: "materialClassifyTwoName", title: "物料二级大类名称" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
    {
      item: { key: "materialClassifyThree", title: "物料三级大类编码" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
    {
      item: { key: "materialClassifyThreeName", title: "物料三级大类名称" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
    {
      item: { key: "materialClassify", title: "物料四级大类编码" },
      attr: {
        // is: "el-popover-multiple-tree-select",
        is: "el-popover-tree-select",
        referName: "MATERIALCLASSIFY_PARAM",
        valueKey: "code",
        clearable: true,
        // 末级
        onlyFinal: true,
        readonly: true,
        defaultProps: {
          label: function (data, node) {
            return data.code + " " + data.name;
          },
          children: "children",
        },
      },
    },
    {
      item: { key: "materialClassifyFourName", title: "物料四级大类名称" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
    {
      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-input",
        clearable: true,
      },
    },
    {
      item: { key: "orderPersonalName", title: "订单员" },
      attr: {
        is: "el-popover-select-v2",
        referName: "CONTACTS_PARAM",
        valueKey: "name",
        dataMapping: {
          orderPersonal: "code"
        }
      },
    },
    {
      item: { key: "buyerName", title: "采购员" },
      attr: {
        is: "el-popover-select-v2",
        referName: "CONTACTS_PARAM",
        valueKey: "name",
        dataMapping: {
          buyer: 'code',
        },
      },
    },
    {
      item: { key: "manufacturer", title: "生产厂家" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
    {
      item: { key: "remark", title: "备注" },
      attr: {
        is: "el-input",
        clearable: true,
      },
    },
  ];

  const TableColumns = [
    {
      item: { key: "materialClassify", title: "物料分类编码", width: 120, },
      attr: {}
    },
    {
      item: { key: "materialClassifyOneName", title: "一级分类名称", width: 120, },
      attr: {}
    },
    {
      item: { key: "materialClassifyTwoName", title: "二级分类名称", width: 120, },
      attr: {}
    },
    {
      item: { key: "materialClassifyThreeName", title: "三级分类名称", width: 120, },
      attr: {}
    },
    {
      item: { key: "materialClassifyFourName", title: "四级分类名称", },
      attr: {}
    },
    {
      item: { key: "materialCode", title: "物料编码", },
      attr: {}
    },
    {
      item: { key: "materialName", title: "物料名称", },
      attr: {}
    },
    {
      item: { key: "manufacturer", title: "生产厂商", },
      attr: {}
    },
    {
      item: { key: "orgName", title: "所属组织", },
      attr: {}
    },
    {
      item: { key: "orderPersonalName", title: "订单员", width: 120, },
      attr: {}
    },
    {
      item: { key: "buyerName", title: "采购员", width: 120, },
      attr: {}
    },
    {
      item: { key: "orderDeptName", title: "订单部门", },
      attr: {}
    },
    {
      item: { key: "puDeptName", title: "部门", },
      attr: {}
    },
    {
      item: { key: "createByName", title: "创建人", width: 120, },
      attr: {}
    },
    {
      item: { key: "createTime", title: "创建时间", },
      attr: {}
    },
    {
      item: { key: "updateByName", title: "修改人", width: 120, },
      attr: {}
    },
    {
      item: { key: "updateTime", title: "修改时间", },
      attr: {}
    },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      width: item.width || 150,
      sortabled: true,
      fixedabled: true,
      filterabled: true,
      hiddenabled: true,
    },
  }));

  return { SearchColumns, TableColumns };
}