const NUMBER_TYPE = "number";

import { FormatFn } from "@/utils/cardManager/valueFormat.js";

export const getFormat = (columns) => {
  const numberCol = columns.filter((i) => i && i.columnType === NUMBER_TYPE);

  let res = {};

  numberCol.forEach((element) => {
    const { config = {} } = element;
    const { type, data } = config.format || {};

    const key = element.fieldId;

    if (!type) return;
    res[key] = {
      fn: FormatFn(type),
      data,
    };
  });

  return res;
};
// 通过colunmName获取对应的aliasName
export const getLinkFields = (originLink) => {
  return originLink.map((i) => {
    return i.fieldId;
  });
};
