当前位置: 首页 > news >正文

新增和编辑共用弹窗模板

新增和编辑弹窗模板

<!-- 添加或编辑用例合集 -->
<template><el-dialog:title="`${type == 'add' ? '新建' : type == 'edit' ? '编辑' : ''}`":visible.sync="dialogVisible"width="560px":close-on-click-modal="false":before-close="handleClose"><el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="88px" class="demo-ruleForm"><el-form-item label="名称" prop="name"> <el-input v-model="ruleForm.name" placeholder="请输入" :maxlength="30"></el-input></el-form-item><el-form-item label="描述" prop="desc"><el-input type="textarea" placeholder="请输入" :rows="4" :maxlength="200" v-model="ruleForm.desc"></el-input></el-form-item></el-form><span slot="footer" class="dialog-footer"><el-button size="small" @click="handleClose">取 消</el-button><el-button size="small" type="primary" :loading="loading" @click="submitForm('ruleForm')">确 定</el-button></span></el-dialog>
</template><script>
export default {name: "AddOrEditDialog",props: {rowData: {type: Object},// 弹窗类型type: {type: String,}},data() {return {dialogVisible: true,ruleForm: {name: '',desc: '',},rules: {name: [{ required: true, message: '请输入合集名称', trigger: 'blur' },{ min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur' }],desc: [{ min: 1, max: 200, message: '长度在 1 到 200 个字符', trigger: 'blur' }],},}},computed: {},created() {if(this.type == 'edit') {this.initForm()}},methods: {// 提交表单submitForm(formName) {this.$refs[formName].validate((valid) => {if (valid) {} else {console.log('error submit!!');return false;}});},resetForm(formName) {this.$refs[formName].resetFields();},handleClose() {this.$emit('closeDialog', false)},handleUpdate() {this.$emit('update')},// 初始化表单initForm() {},}
}
</script><style lang="less" scoped></style>

在组件中使用

<AddOrEditDialog
:type="dialogType"
:rowData="rowData"
@closeDialog="handleClose"
@update="handleUpdate"
></AddOrEditDialog>
http://www.lryc.cn/news/621350.html

相关文章:

  • 深度解析 Vue 高阶技巧:提升工程化能力的实用方案
  • 机器人伴侣的智能升级:Deepoc具身智能模型如何重塑成人伴侣体验
  • AI驱动的智能爬虫架构与应用
  • C++中的链式操作原理与应用(三):专注于异步操作延的C++开源库 continuable
  • 开发避坑指南(26):Vue3 input输入框前置后 置元素解决方案
  • uniapp开发动态添加密码验证
  • 【力扣322】零钱兑换
  • C++ 排序指南
  • Kafka下载和安装
  • Ubuntu 22.04 远程桌面设置固定密码的方法
  • HQA-Attack: Toward High Quality Black-Box Hard-Label Adversarial Attack on Text
  • CoreShop商城框架开启多租户(3)
  • PyTorch 2025全解析:从基础到前沿,深度学习框架的技术演进与实战指南
  • ESP32入门开发·通用硬件定时器 (GPTimer)
  • C# 高并发处理方式
  • 算法题Day1
  • torchvision中数据集的使用与DataLoader 小土堆pytorch记录
  • # Vue 列表渲染详解
  • VLMs开发——基于Qwen2.5-VL 实现视觉语言模型在目标检测中的层级结构与实现方法
  • RxJava Android 创建操作符实战:从数据源到Observable
  • 中久数创——笔试题
  • PiscTrace基于YOLO追踪算法的物体速度检测系统详解
  • 2025.8.24复习总结
  • React.memo、useMemo 和 React.PureComponent的区别
  • 基于场景的无人驾驶叉车分类研究:应用场景与技术选型分析
  • springboot myabtis返回list对象集合,对象的一个属性为List对象
  • 飞算 JavaAI 真是 yyds
  • 一周学会Matplotlib3 Python 数据可视化-绘制面积图(Area)
  • [C++] Git 使用教程(从入门到常用操作)
  • TDengine IDMP 基本功能(6. 无问智推)