<template>
    <div>
        <el-dialog :class="type==='Delete'? 'response-tip-dialog' :'response-small-dialog'"
                   :close-on-click-modal="false"
                   :show="show"
                   :title="title"
                   :visible.sync="visible"
                   center>
            <div v-if="type==='Edit'">
                <el-input :autosize="{ minRows: 6, maxRows: 10}" type="textarea" v-model="data.content"></el-input>
            </div>
            <div v-else-if="type==='Delete'">
                是否删除此条笔记?
            </div>
            <div v-else-if="type==='Add'">
                <el-input
                        :autosize="{ minRows: 6, maxRows: 10}"
                        placeholder="请输入内容"
                        type="textarea"
                        v-model="addDialogConent">
                </el-input>
            </div>
            <span class="dialog-footer" slot="footer">
                <el-button @click="closeFun">取 消</el-button>
                <el-button :disabled="isDisable" @click="confirmFun" type="primary">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        name:       'biji',
        props: {
            title: {
                type: String,
                default: '提示',
            },
            data: {
                type: Object,
            },
            type: {
                type: String,
                required: true,
            },
            show: {
                type: Boolean,
                default: false
            }
        },
        data() {
            return {
                visible: this.show,
                addDialogConent: '',
                isDisable: false,
                timer:               null,
            };
        },
        watch: {
            show () {
                this.visible = this.show;
            }
        },
        methods:    {
            closeFun(){
                console.log('show'+this.type);
                this.$emit('update:show', false)
            },
            confirmFun(){
                let opt = {
                    conent:this.addDialogConent
                }
                this.isDisable = true
                this.timer = setTimeout(() => {
                    this.isDisable = false
                }, 1000);
                this.$emit('confirmBtn'+this.type, this.data|| opt)
            },
            clearTime(){
                clearTimeout(this.timer)
            },
        },
        created() {
        },
    };
</script>

<style lang="scss">

</style>
