import Vue, { PropType } from "vue"
import StaffService from '@/service/StaffService/index' 
import { eLevel } from "@/types/level"
import { mapActions, mapMutations, mapState } from 'vuex'

const staff = new StaffService()

export default Vue.extend({
  data() {
    return {
    }
  },
  methods: {
    ...mapMutations('platformUserManagement', {
      platformSave: 'save',
    }),
    ...mapActions('platformUserManagement', {
      platformQuery: 'queryUser',
    }),
    // getLevel(s: string) {
    //   switch(s) {
    //     case '1':
    //       return eLevel.firstLevel_branch
    //     case '2':
    //       return eLevel.secondary_branch
    //     case '3':
    //       return eLevel.firstLevel_sub_branch
    //     default:
    //       return eLevel.secondary_sub_branch
    //   }
    // },
    getLists(params: any) {
      // const keys = JSON.parse(this.$route.query.rankVal as string)
      // const level = keys.length + ''
      // const _level = this.getLevel(level)

      this.platformSave({
        ...params
      })
      this.platformQuery()
    }
  },
  created() {
    const keys = JSON.parse(this.$route.query.rankVal as string)
    const level = this.$route.query.level
    const params = {
      firstBranch: +keys[0] || undefined,
      firstSubBranch: +keys[2] || undefined,
      secondBranch: +keys[1] || undefined,
      secondSubBranch: +keys[3] || undefined,
      level
    }
    this.getLists(params)
  }
})