<template>
  <zpa-form ref="Form">
    <zpa-form-group>
      <zpa-select
        v-model="id"
        label="可选岗位"
        :labelWidth="120"
        :query="getUserstations"
      />
    </zpa-form-group>
  </zpa-form>
</template>
<script>
import {
  queryPositions,
  getPosition,
  setPosition,
} from '@centit/api-auth'

export default {
  name: 'UserRank',

  data () {
    return {
      id: '',
    }
  },

  computed: {

  },

  methods: {
    async getUserstations () {
      const res = await queryPositions()

      return res.map(m => {
        return {
          value: m.userUnitId,
          text: m.valueField,
        }
      })
    },

    async afterOpen () {
      const currentuser = await getPosition()
      this.id = currentuser.userUnitId
    },

    submit () {
      return setPosition(this.id)
    },
  },
}
</script>
