<template>
    <lj-list-tree-choose-common :allItem="allItem" :rawList="rawList" name-field="mtrltype" button-field="handtype" id-field="mtrltypeid" @item-selected="handleItemSelected" ref="base"/>
</template>
<script>
    import $lj from 'components/lj-public'
    import ljListTreeChoose from 'components/lj-list-tree-choose-common'
    export default{
        name: "l1-mtrltype-choose",
        data() {
            return {
                eventName: "mtrltype-chosen",
                allItem: { mtrltypeid: -1, mtrltype: "全部", handtype: "全部", sonflag: 1, parentid: 0 },
                rawList: []
            }
        },
        created() {
            this.getDataList();
        },
        methods: {
            open() {
                this.$refs.base.init();
                this.$refs.base.open();
            },
            handleItemSelected(item) {
                this.$emit(this.eventName, item);
            },
            getDataList: function () {
                let self = this;
                $lj.postLJRequest(
                    "GetL1Mtrltype", {
                        token: $lj.getStorage("token")
                    },
                    function (ret) {
                        if (ret) {
                            self.rawList = ret.mtrltypeList;
                        }
                    }
                );
            }
        },
        components: {
            "lj-list-tree-choose-common": ljListTreeChoose
        }
    }
</script>