<template>
  <el-dialog
    append-to-body
    title="选择售票员"
    :visible.sync="visible"
    width="400px"
    @close="handleClose">
    <el-form
      :model="form"
      ref="form"
      label-width="80px"
      style="padding:20px">
      <el-form-item
        verify
        label="售票员"
        prop="cancel_manager">
        <el-select
          value-key="id"
          v-model="form.cancel_manager">
          <el-option
            v-for="item in salesList"
            :key="item.id"
            :value="item"

            :label="item.nickName"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>

    <span slot="footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button
        type="primary"
        @click="submit">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  computed: {
    salesList () {
      return this.$store.state.user.salesList
    }
  },
  data () {
    return {
      visible: false,
      form: {
        cancel_manager: ''
      }
    }
  },
  methods: {
    show (id) {
      this.visible = true
      this.$nextTick(() => {
        this.form.cancel_manager = this.salesList.find(i => i.id === id)
      })
    },
    handleClose () {
      this.visible = false
    },
    submit () {
      this.$emit('change', this.form.cancel_manager)
      this.handleClose()
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-dialog .el-form-item {
  display: inline-block;
}
::v-deep .el-form-item__content{
    width: 200px;
}
</style>
