<template>
  <the-common :filter="filter" :param="query" :title-obj="titleObj" type="2"></the-common>
</template>

<script>
import TheCommon from './common/theCommon'
import { getPositionDict } from '@/api/report'
export default {
  name: 'hotel-salary',
  components: { TheCommon },
  data () {
    return {
      titleObj: {
        msg: '酒店薪酬职位分位值',
        key: 'positionName'
      },
      filter: {
        list: [
          {
            type: 'select',
            key: 'type',
            value: 1,
            default: 1,
            label: '划分类型',
            items: [
              { label: '城市划分', value: 1 },
              { label: '城市等级划分', value: 2 },
              { label: '城市群划分', value: 3 }
            ],
            change: this.handleChangeType
          },
          {
            type: 'select',
            key: 'positionName',
            clearable: true,
            value: null,
            default: null,
            label: '职位',
            items: [],
            change: this.handleChangePosition
          }
        ]
      },
      query: {
        type: 1,
        positionName: null
      }
    }
  },
  created () {
    this.getPositionDict()
  },
  methods: {
    handleChangeType (val) {
      this.query.type = val
      this.query.positionName = null
      this.filter.list.find(_e => _e.key === 'positionName').value = null
    },
    handleChangePosition (val) {
      this.query.positionName = val
    },
    async getPositionDict () {
      try {
        const { data } = await getPositionDict()
        this.filter.list.find(_e => _e.key === 'positionName').items = data
      } catch (error) {
        this.$snackbar.error(error)
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
