mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2024-11-01 22:20:27 +08:00
56 lines
796 B
Vue
56 lines
796 B
Vue
<template>
|
|
<el-select v-model="newValue" v-bind="props" multiple @change="onChange">
|
|
<el-option
|
|
v-for="(item, index) in list"
|
|
:value="item.id"
|
|
:label="item.name"
|
|
:key="index"
|
|
></el-option>
|
|
</el-select>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: "cl-role-select",
|
|
|
|
props: {
|
|
value: [String, Number, Array],
|
|
props: Object
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
list: [],
|
|
newValue: undefined
|
|
};
|
|
},
|
|
|
|
watch: {
|
|
value: {
|
|
immediate: true,
|
|
handler(val) {
|
|
let arr = [];
|
|
|
|
if (!(val instanceof Array)) {
|
|
arr = [val];
|
|
} else {
|
|
arr = val;
|
|
}
|
|
|
|
this.newValue = arr.filter(Boolean);
|
|
}
|
|
}
|
|
},
|
|
|
|
async created() {
|
|
this.list = await this.$service.system.role.list();
|
|
},
|
|
|
|
methods: {
|
|
onChange(val) {
|
|
this.$emit("input", val);
|
|
}
|
|
}
|
|
};
|
|
</script>
|