<template>
    <div>
        <a-select placeholder="请选择" v-model="medicalId" @change="change" style="width: 180px">
            <a-select-option v-for="item in medicalList" :key="item.id" :value="item.id">{{item.medicineName}}</a-select-option>
        </a-select>
    </div>
</template>
<script>
export default {
    data() {
        return {
            medicalId: undefined,
            medicalList: [],
        }
    },
    created() {
        this.getMedicalList();
    },
    methods: {
        getMedicalList() {
            let params = {};
            this.$api.common.fetchAllMedicalName(params).then(({code, data}) => {
                if (code === 'SUCCESS') {
                    this.medicalList = data;
                }
            });
        },

        getIdMedicalList(id) {
            this.medicalId = undefined;
            let params = {
                breedId: id,
            };
            this.$api.stockManage.fetchMedicineByType(params).then(({code, data}) => {
                if (code === 'SUCCESS') {
                    this.medicalList = data;
                }
            })
        },

        change() {
            this.$emit('getMedicalId', this.medicalId);
        },
        clear(){
            this.medicalId=undefined;
        }
    },
}
</script>
