<!--
 * @Description: 删除框封装
 * @Author: xiaofengzhou
 * @Email: 2946471396@qq.com
 * @Date: 2022-08-16 09:12:46
 * @LastEditTime: 2022-08-22 15:55:41
 * @LastEditors: xiaofengzhou
-->
<template>
    <div class=''>

        <a-modal :maskClosable="false" centered v-model:visible="visible" @ok="handleOk" okText="确认" cancelText="取消"
            style="text-align:center">
            <span class="iconfont icon-Shapex" style="color:red"> 确认删除?</span>
            <a-form-model :model="formData" :rules="rules" ref="deleteForm" style="margin-top: 20px;">
                <a-form-model-item prop="reason" v-bind="{}">
                    <a-textarea type="textarea" v-model="formData.reason" placeholder="请输入删除原因" />
                </a-form-model-item>
            </a-form-model>
        </a-modal>
    </div>
</template>

<script>
export default {
    props: {
        delete: {
            type: Function
        }
    },
    components: {},
    data() {
        return {
            formData: {
                reason: "",

            },
            visible: false,
            rules: {
                reason: [
                    {
                        required: true,
                        message: "删除原因不能为空",
                        trigger: "blur",
                    },
                    {
                        max: 255,
                        message: "删除原因最大长度不能大于255",
                        trigger: "blur",
                    },
                ],
            }
        };
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合
    methods: {
        init(){
            this.formData.reason=''
        },
        handleOk() {
            this.$refs.deleteForm.validate((valid) => {
                if (valid) {
                    this.delete()

                }
            })
        }

    },
    //生命周期 - 创建完成（可以访问当前this实例）
    created() {

    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {

    },
    beforeCreate() { }, //生命周期 - 创建之前
    beforeMount() { }, //生命周期 - 挂载之前
    beforeUpdate() { }, //生命周期 - 更新之前
    updated() { }, //生命周期 - 更新之后
    beforeDestroy() { }, //生命周期 - 销毁之前
    destroyed() { }, //生命周期 - 销毁完成
    activated() { }, //如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style scoped>
</style>