<style lang="less">

</style>

<template>
    <Modal v-model="addModal" :loading="loading">
        <p slot="header">
            <Icon type="information-circled"></Icon>
            <span>新增</span>
        </p>
        <div>
            <Form ref="form" :label-width="80">
                <FormItem label="分类">
                    <Input v-model="classify" />
                </FormItem>
            </Form>
        </div>
        <div slot="footer">
            <Button type="primary" @click="submit">确定</Button>
        </div>
    </Modal>
</template>

<script>
export default {
    name: 'add',
    data() {
        return {
            classify: '',
            loading: true,
            addModal: false
        }
    },
    watch: {
        addShow() {
            this.addModal = this.addShow;
        },
        addModal() {
            if (!this.addModal) {
                this.$emit("close");
            }
        }
    },
    props: {
        products: Array,
        addShow: Boolean
    },
    methods: {
        submit() {
            if (!this.classify) {
                this.$emit("close", {classify: classify});
                this.loading = false;
            }
            let classify = this.classify;
            this.axios.post("/product_classify/store", {
                classify: classify
            }).then((res) => {
                this.$emit("close", {classify: classify});
                this.loading = false;
            });
        }
    }
};
</script>
