/*
 * @Author: Badguy
 * @Date: 2022-05-17 17:04:32
 * @LastEditTime: 2022-05-27 15:04:44
 * @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) {
      switch (column.property) {
        case 'arrivalTime':
        case 'planDepartureTime':
          return timeInZone((cellValue ?? '').replace('T', ' '), this.timeZone)
        case 'actualDepartureTime':
        case 'actualLandingTime':
          return timeInZone((cellValue ?? '').replace('T', ' '), this.timeZone).replace(' ', '\n')
        case 'checkInTime':
        case 'securityTime':
        case 'sortTime':
        case 'loadTime':
        case 'inflTime':
          return cellValue ? `${timeInZone(cellValue.split(',')[0], this.timeZone)}\n${cellValue.split(',')[1]}` : ''
        // return `${cellValue ?? ''}\n${getTimeInZone(row['checkInTime'], this.timeZone)}`
        // case 'DealInfo':
        //   return `${cellValue ?? ''}\n${getTimeInZone(row['DealTime'], this.timeZone)}`
        // case 'sortLocationMark':
        //   return `${cellValue ?? ''}\n${getTimeInZone(row['sortDealTime'], this.timeZone)}`
        // case 'loadLocationMark':
        //   return `${cellValue ?? ''}\n${getTimeInZone(row['loadDealTime'], this.timeZone)}`
        // case 'inflLocationMark':
        //   return `${cellValue ?? ''}\n${getTimeInZone(row['inflLoadDealTime'], this.timeZone)}`
        case 'timeDifference':
          return cellValue <= -120 ? '-2h+' : cellValue >= 120 ? '2h+' : cellValue
        default:
          return cellValue ?? ''
      }
    }
  }
}
