import store from '@/store'

class StoreUtil {
  /**
   * 设置地图实例
   * @param data
   */
  public setMapInstance(data: any) {
    store.commit('setMapInstance', data)
  }

  /**
   * 设置地图封装方法
   * @param data
   */
  public setMapFun(data: any) {
    store.commit('setMapFun', data)
  }

  /**
   * 获取地图封装方法
   */
  public getMapFun() {
    return store.state.mapFun
  }

  /**
   * 获取地图实例
   */
  public getMapInstance() {
    return store.state.mapInstance
  }

  /**
   * 设置目录
   * @param data
   */
  public setDictionary(data: any) {
    store.state.dictionary = data
  }

  /**
   * 设置船舶信息
   * @param data
   */
  public setShipData(data: any) {
    store.state.ship = data
  }

  /**
   * 设置船舶信息
   * @param data
   */
  public setShipFleet(data: any) {
    store.state.shipFleet = data
  }

  /**
   * 获取国籍字典
   */
  public getCountry() {
    const data: any = store.state.dictionary
    if (data) {
      return data.shipCountry
    } else {
      return null
    }
  }

  /**
   * 获取船舶类型字典
   */
  public getShipType() {
    const data: any = store.state.dictionary
    if (data) {
      return data.shipType
    } else {
      return null
    }
  }

  /**
   * 获取船舶状态字典
   */
  public getShipStatus() {
    const data: any = store.state.dictionary
    if (data) {
      return data.shipStatus
    } else {
      return null
    }
  }

  /**
   * 获取船舶状态字典
   */
  public getShipFleet() {
    const data: any = store.state.shipFleet
    if (data) {
      return data
    } else {
      return null
    }
  }
}

export default new StoreUtil()
