<template>
    <lj-list-tree-choose-common :allItem="allItem" :rawList="rawList" name-field="Cusareaname" button-field="areaname" id-field="CusareaID" @item-selected="handleItemSelected" ref="base"/>
</template>
<script>
    import LjListTreeChooseCommon from "components/lj-list-tree-choose-common";
    export default{
        name: "q5-area-choose",
        components: {LjListTreeChooseCommon},
        data() {
            return {
                eventName: "area-chosen",
                allItem: { CusareaID: -1, Cusareaname: "全部", areaname: "全部", sonflag: 0, parentid: 0 },
                rawList: []
            }
        },
        created() {
            this.getDataList();
        },
        methods: {
            open() {
                this.$refs.base.init();
                this.$refs.base.open();
            },
            handleItemSelected(item) {
                this.$emit(this.eventName, item);
            },
            getDataList() {
                let self = this;
                $lj.postLJRequest(
                    "GetL1Cusarea", {
                        token: $lj.getStorage("token")
                    },
                    function(ret) {
                        if (ret) {
                            self.rawList = ret.areaList;
                        }
                    }
                );
            }
        }
    }
</script>