/*
 * @Author: Badguy
 * @Date: 2022-05-17 17:04:32
 * @LastEditTime: 2022-05-17 18:38:03
 * @LastEditors: your name
 * @Description: 时区相关
 * have a nice day!
 */
import { timeInZone } from '@/utils/table'
import { mapGetters } from 'vuex'

export default {
  computed: {
    ...mapGetters(['timeZone'])
  },
  methods: {
    // 表格数据格式化
    tableFormat(row, column, cellValue) {
      if (cellValue || cellValue === 0) {
        switch (column.property) {
          // case 'FlightDate':
          //   return cellValue.split('-').slice(1).join('-')
          case 'PlanLandingTime':
          case 'PlanDepartureTime':
            return timeInZone(cellValue, this.timeZone)
          case 'ActualDepartureTime':
          case 'ActualLandingTime':
            return timeInZone(cellValue.replace('T', ' '), this.timeZone).replace(' ', '\n')
          case 'checkIn':
          case 'security':
          case 'sorting':
          case 'loading':
          case 'installed':
            return cellValue.split('\n')[0] + '\n' + timeInZone(cellValue.split('\n')[1].replace('T', ' '), this.timeZone)
          case 'timeDifference':
            return cellValue <= -120 ? '-2h+' : cellValue >= 120 ? '2h+' : cellValue
          default:
            return cellValue
        }
      } else {
        return ''
      }
    }
  }
}
