export default {
  state: {
    // 企业车位
    companyCarportList: [],
    // 个人车位
    personalCarportList: [],
    // 我的常用车辆
    myCarList: []
  },
  mutations: {
    addCompanyCarport(state, companyCarport) {
      state.companyCarportList.push(companyCarport);
    },
    addPersonalCarport(state, personalCarport) {
      state.personalCarportList.push(personalCarport);
    },
    addMyCar(state, carObj) {
      state.myCarList.push(carObj);
    },
    deleteMyCar(state, carNumber) {
      state.myCarList.find((item, index) => {
        if (item.number === carNumber) {
          state.myCarList.splice(index, 1)
          return true;
        }
        return false;
      })
    }
  },
  actions: {
    addMyCar({ commit }, carObj) {
      commit('addMyCar', carObj);
    },
    deleteMyCar({ commit }, carNumber) {
      commit('deleteMyCar', carNumber);
    }
  }
}
