<!-- 字典 -->
<template>
    <u-picker
        ref="pickerRef"
        :keyName="'dictLabel'"
        :show="isShow"
        :columns="[columns]"
        @confirm="confirm"
        @cancel="close"></u-picker>
</template>

<script>
/* https://uviewui.com/components/picker.html */
import { getDicts } from "@/api/dict/data";
export default {
    props: {
        dictType: { //字典类型
            type: String,
            default: ''
        },
    },

    data() {
        return {
            columns: [],
            isShow: false,
        }
    },
    mounted() {
        this.init()
    },
    methods: {
        // 获取字典数据
        init() {
            getDicts(this.dictType).then((res) => {
                this.columns = res.data
            })
        },
        show() {
            this.isShow = true;
        },

        close() {
            this.isShow = false
        },

        confirm(e) {
            console.log('确定', e)
            const { value } = e
            this.$emit('confirm', value[0])
            this.close()
        },


    }
}
</script>

<style lang="scss" scoped></style>
