import { dayjs } from 'element-plus'
import type { IDictType } from './person-regitster'

export function jointDate(start: string, end?: string) {
  if (start === '') {
    return ''
  }
  if (end === '') {
    return dayjs(start).format('YYYY-MM-DD')
  }
  else {
    return `${dayjs(start).format('YYYY-MM-DD')} 至 ${dayjs(end).format('YYYY-MM-DD')}`
  }
}

export function getDictTextByValue(dictList: Array<IDictType>, value: string) {
  const target = dictList.filter(item => item.value === value)
  if (target.length > 0) {
    return target.at(0)?.name
  }
  else {
    return ''
  }
}
