首页 > 其他 > 详细

element 新增和修改复用一个弹框

时间:2020-12-10 13:35:32      阅读:159      评论:0      收藏:0      [点我收藏+]
技术分享图片

 

 技术分享图片

 

 技术分享图片

 

 

<template>
<el-card>
    <el-row>
        <el-button type="success" @click="add">新增</el-button>
        <el-button type="info" @click="edit">修改</el-button>
    </el-row>

        <!-- 添加安全漏洞信息弹窗 -->
    <el-dialog :title="addTitle" :visible.sync="addMessageVisiable" @close="sericutyFormClosed">
        <el-form :model="sericutyForm" ref="sericutyRef" :rules="rules">
            <el-form-item label="安全漏洞主题" prop="title">
                <el-input  autocomplete="off" v-model="sericutyForm.title"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="addMessageVisiable = false">取 消</el-button>
            <el-button type="primary" @click="addMessageSure">保存</el-button>
        </div>
    </el-dialog>
    </el-card>
</template>

<script>
export default {
    data(){
        return{  
            addTitle:"添加安全漏洞信息",
            addMessageVisiable:false,
            sericutyForm:{
                title:‘‘
            },
            rules: {
                title: [{ required: true, message: "请输入安全漏洞主题!", trigger: "blur" }],
            },
        }
    },
    methods:{
        // 新增
        add(){
            this.addMessageVisiable=true,
            this.addTitle="新增"
        },
        edit(){
            this.addMessageVisiable=true,
            this.addTitle="修改"
        },
        // 保存
        addMessageSure(){
            this.$refs.sericutyRef.validate(valid=>{
                if(valid){
                    // 新增
                    if(this.addTitle="新增"){
                        // 掉接口
                    }else{
                        this.addTitle="修改"
                        // 数据回显
                    }

                }else{
                    this.$message.error("请按要求填写")
                }
            })
        },
        // 重置
        sericutyFormClosed(){
            for(let key in this.sericutyForm){
                this.$set(this.sericutyForm,key,"")
            }
        }
    }
}
</script>
<style lang="scss">
    .el-dialog{
        width:30%
    }
</style>

element 新增和修改复用一个弹框

原文:https://www.cnblogs.com/guohanting/p/14113440.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!