index.vue 812 Bytes
Newer Older
陈浩玮's avatar
陈浩玮 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<template>
    <a-select
        :value="value"
        style="width: 100%"
        :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
        placeholder="Please select"
        allow-clear
        :options="data"
        v-on="$listeners"
        v-bind="$attrs"
    />
</template>

<script>
import { formatObj } from '@/utils';

export default {
    model: {
        prop: 'value',
        event: 'change',
    },
    props: {
        value: [String, Number, Array],
        request: Function,
    },
    data() {
        return {
            data: [],
        };
    },
    async mounted() {
        if (this.request) {
            const newArr = await this.request();
            this.data = await formatObj(newArr, { value: 'jobId', label: 'jobName', key: 'jobId' });
        }
    },
};
</script>