<template>
    <uni-data-picker :localdata="treeList" v-model="labels" :map="{text:'name', value: 'code'}" :disabled="disabled" popup-title="请选择区域" @change="onchange"></uni-data-picker>
</template>

<script>
    import areaService from "@/api/sys/areaService"
    export default {
        props: {
            value: String,
            disabled: {
                type: Boolean,
                default: false
            },
        },
        data() {
            return {
                labels: '',
                treeList: []
            }
        },
        mounted() {
            areaService.treeData().then((data) => {
                this.treeList = data
            }).catch((e) => {
                throw e
            })
        },
        watch: {
            value(newValue) {
                this.labels = newValue; // 在 value 改变时更新 labels
            }
        },
        methods: {
            onchange(e) {
                this.$emit('input', this.labels)
            }
        }
    }
</script>
