<template> <el-dialog :title="title" :visible.sync="dialogFormVisible" width="600px" append-to-body> <el-form ref="dataForm" :model="form" :size="size" label-position="right" label-width="120px"> <el-row type="flex" justify="center"> <el-col :span="16"> <el-form-item label="请选择有效期限" prop="txt"> <el-date-picker v-model="form.txt" type="datetime" placeholder="选择时间" clearable/> </el-form-item> <div style="text-align: center"> 提示:不选表示永久有效 </div> </el-col> </el-row> </el-form> <div slot="footer" class="dialog-footer"> <el-button v-if="showSuccess" type="primary" @click="success">{{ successBtn }}</el-button> <el-button v-if="showRefuse" type="warning" @click="refuse">{{ refuseBtn }}</el-button> <el-button v-if="showCancel" @click="cancel">取消</el-button> </div> </el-dialog> </template> <script> export default { name: 'SetTimeDialog', props: { title: { type: String, default: '' }, // 标题 placeholder: { type: String, default: '' }, // 占位符 reExp: { type: String, default: '' }, // 正则校验 errorMessage: { type: String, default: '请选择有效时间' }, showSuccess: { type: Boolean, default: true }, // 显示成功按钮 showRefuse: { type: Boolean, default: false }, // 显示拒绝按钮 showCancel: { type: Boolean, default: true }, // 显示取消按钮 successBtn: { type: String, default: '确定' }, // 成功按钮 refuseBtn: { type: String, default: '驳回' } // 驳回按钮 }, data() { return { dialogFormVisible: false, // 对话框是否显示 btnLoading: false, // 保存按钮的加载中状态 size: 'small', form: { txt: '' }, // 表单 } }, methods: { initDialog() { this.dialogFormVisible = true this.resetForm() }, // 重置表单 resetForm() { this.form.txt = '' this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) }, // 保存数据 success: function() { this.dialogFormVisible = false this.$emit('report', 'success', this.form.txt) }, refuse: function() { this.dialogFormVisible = false this.$emit('report', 'refuse', this.form.txt) }, cancel: function() { this.dialogFormVisible = false } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .el-dialog{ width:700px } .dialog-footer{ margin-top:-20px; } </style>