<template>
    <div class="form-group">
        <div>
            <select class="form-control"
                    v-model="selectedValue">
                <option v-for="keyValue in keyValues"
                        :value="keyValue.keyStr"
                        :key="keyValue.keyStr">{{keyValue.value}}</option>
            </select>
        </div>
    </div>
</template>

<script>
module.exports = {
    props: ["keyValues", "enumValue"],

    data: function () {
        return {
            selectedValue: (this.enumValue == undefined ? '' : this.enumValue),
        }
    },

    watch: {
        selectedValue: function (curVal, oldVal) {
            console.log("Enum Selected Value changed：" + curVal);
            if (curVal != oldVal) {
                this.$emit("valueChanged", curVal);
            }
        },

        enumValue: function (val) {
            this.selectedValue = val;
        }
    }
}

</script>

<style scoped>
.required-mark {
    color: red;
    margin-right: 10px;
}
</style>