userSelect.vue 654 Bytes
Newer Older
huhaiqing's avatar
huhaiqing committed
1
<template>
huhaiqing's avatar
huhaiqing committed
2
  <el-select filterable :value="value === 0 ? undefined : value" @change="change" v-bind="$attrs" clearable>
huhaiqing's avatar
huhaiqing committed
3
    <el-option v-for="user in getUser" :key="user.id" :value="user.id" :label="user.nickname"></el-option>
huhaiqing's avatar
huhaiqing committed
4 5 6 7 8 9 10 11 12
  </el-select>
</template>

<script>
/**
 * 用户
 */
export default {
  name: "userSelect",
huhaiqing's avatar
huhaiqing committed
13
  inheritAttrs: false,
huhaiqing's avatar
huhaiqing committed
14
  props: {
huhaiqing's avatar
huhaiqing committed
15
    value: Number | Array,
huhaiqing's avatar
huhaiqing committed
16
    allUsers: Array,
huhaiqing's avatar
huhaiqing committed
17 18 19 20 21 22
  },
  model: {
    prop: "value",
    event: "change",
  },
  data() {
huhaiqing's avatar
huhaiqing committed
23
    return {};
huhaiqing's avatar
huhaiqing committed
24 25 26
  },
  computed: {
    getUser() {
huhaiqing's avatar
huhaiqing committed
27
      return this.allUsers;
huhaiqing's avatar
huhaiqing committed
28 29 30 31 32 33 34 35 36
    },
  },
  methods: {
    change(val) {
      this.$emit("change", val);
    },
  },
};
</script>