export function formatDate(value) {
  if (!value) {
    return "-";
  }
  return String(value).slice(0, 10);
}

export function formatDateTime(value) {
  if (!value) {
    return "-";
  }
  return String(value).replace("T", " ").slice(0, 16);
}

export function formatAmount(value) {
  return Number(value || 0).toLocaleString("zh-CN", {
    minimumFractionDigits: 0,
    maximumFractionDigits: 2
  });
}

export function formatQty(value) {
  return Number(value || 0).toLocaleString("zh-CN", {
    minimumFractionDigits: 0,
    maximumFractionDigits: 3
  });
}

export function formatWeight(value) {
  return `${formatQty(value)} kg`;
}

export function emptyToNull(value) {
  return value === "" || value === undefined ? null : value;
}
