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

vue使用elementui组件的的对话框;使用ref

 1.第一步,先在父组件中引用,设置ref的值

<el-dialog :visible.sync="dialogEditVisible"append-to-body width="1000px" title="编辑":close-on-click-modal="false"><dialog-edit v-if="dialogEditVisible" ref="dialogEdit":visible.sync="dialogEditVisible" />
</el-dialog>

 2.引入和注册组件:

import DialogEdit from './edit'
export default {components: { Pagination,DialogAdd,DialogEdit,DialogView},

3.需要再data中设置对话框默认不打开:

 dialogEditVisible: false,

4.在父组件中mothod中实现调用对话框的方法:

handleEdit(scope) {this.dialogEditVisible = truethis.$nextTick(() => {//this.$refs.dialogEditthis.$refs.dialogEdit.getDetailed()})},

5.创建一个vue组件,名字为edit.vue,并且在method中添加getDetailed()   ,这个方法:

getDetailed() {
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      getInfo({ code: this.proid }).then(response => {
        this.form = response.data.mdProjectInfo,
        loading.close()
      }).catch(function() {
        loading.close()
      })
    },

<template><div style="width:100%;height:auto; margin:0 auto;"><el-form :model="form" label-width="100px" label-position="left"><el-row :gutter="20"><el-col :span="16"><el-form-item><!-- <div slot="label">项目名称<font color="red">*</font></div>           <el-select v-model="form.dirId" clearable style="width:100%;" @change="selectGoodsByGroupId($event)"><el-option v-for="item in symbols" :key="item.id" :label="item.name" :value="item.id" /></el-select> --></el-form-item></el-col><el-col :span="8"><el-form-item><div slot="label">问题标题<font color="red">*</font></div><el-input v-model="form.name" placeholder="问题标题" /></el-form-item></el-col></el-row><el-row :gutter="20"><el-col :span="8"><el-form-item><div slot="label">问题类型<font color="red">*</font></div><el-input v-model="form.staffId" placeholder="问题类型" /></el-form-item></el-col>  <el-col :span="8"><el-form-item><div slot="label">优先级<font color="red">*</font></div><el-input v-model="form.staffId" placeholder="优先级" /></el-form-item></el-col><el-col :span="8"><el-form-item><div slot="label">问题状态<font color="red">*</font></div><el-input v-model="form.staffId" placeholder="问题状态" /></el-form-item></el-col></el-row><el-form-item label="内容"><el-input v-model="form.content" type="textarea" :autosize="{ minRows: 3, maxRows: 6}" /></el-form-item><el-form-item label="备注"><el-input v-model="form.message" type="textarea" :autosize="{ minRows: 3, maxRows: 6}" /></el-form-item></el-form><div style="text-align:center;"><el-button type="primary" @click="save()">保存</el-button><el-button type="danger" @click="closePage">取消</el-button></div></div>
</template>
<script>import { saveData,getInfo,edit} from '@/api/records'import { getAllList } from '@/api/maApplicationInfo'
import { Message } from 'element-ui'export default {inject: ['getList'],props: { // 第二种方式proid: {type: String,required: true}},data() {return {form: {},types: [],symbols: []}},created() {     this.getproject()},methods: {getDetailed() {const loading = this.$loading({lock: true,text: 'Loading',spinner: 'el-icon-loading',background: 'rgba(0, 0, 0, 0.7)'})getInfo({ code: this.proid }).then(response => {this.form = response.data.mdProjectInfo,loading.close()}).catch(function() {loading.close()})},getproject(){getAllList().then(response=> {this.symbols = response.data})},selectGoodsByGroupId(val) { // 根据设备组id获取相应的商品if (val != null && val !== '' && val !== undefined) {for (var i = 0; i < this.symbols.length; i++) {if (this.symbols[i].id === val) {this.form.userId = this.symbols[i].customerMid}}}},save(){this.form.startTime = this.form.itemTime[0]this.form.endTime = this.form.itemTime[1]const loading = this.$loading({lock: true,text: 'Loading',spinner: 'el-icon-loading',background: 'rgba(0, 0, 0, 0.7)'})edit(this.form).then(response => {Message({message: '编辑成功',type: 'success',duration: 5 * 1000})this.$emit('update:visible', false)loading.close()this.getList()}).catch(response => {loading.close()this.getList()})},closePage() {this.$emit('update:visible', false)}}
}
</script>

http://www.lryc.cn/news/330065.html

相关文章:

  • 第十四届蓝桥杯(八题C++ 题目+代码+注解)
  • HTTP协议格式详解之报头(HTTP header)、请求正文(body)
  • [yolox]ubuntu上部署yolox的ncnn模型
  • YOLOv9改进策略 :IoU优化 | 提出一种新的Shape IoU,更加关注边界框本身的形状和尺度,对小目标检测也很友好
  • 如何使用KST指标进行多头交易,Anzo Capital一个条件设置
  • 【QT进阶】第十三章QT动画类的使用QAbstractAnimation
  • 【机器学习】揭秘无监督学习:机器如何自我学习发现数据奥秘
  • 鸿蒙(HarmonyOS)ArkTs语言基础教程(大纲)
  • 掌握未来商机:如何利用会话式AI赢在起跑线
  • 软考高级架构师:数据传输控制方式:程序控制方式、程序中断方式、DMA方式、通道方式、IO处理机
  • 大模型之路2:继续趟一条小路
  • 打造安全医疗网络:三网整体规划与云数据中心构建策略
  • imu测试--UDP、PTP
  • 软考 系统架构设计师系列知识点之云原生架构设计理论与实践(13)
  • 2024多功能知识付费源码下载
  • 计算机网络——33多点访问协议
  • 基于神经网络的人脸识别系统的设计与实现
  • 远控桌面多任务并发文件保密传输
  • 探索 ZKFair 的Dargon Slayer蓝图,解锁新阶段的潜力
  • open Gauss 数据库-04 openGauss数据库日志管理指导手册
  • Redis性能瓶颈与安全隐患排查验证纪实
  • 【C/C++】C语言实现顺序表
  • 零基础快速上手:搭建类ChatGPT对话机器人的完整指南
  • Java中的取余与取模运算:概念、区别与实例详解
  • Excel制作甘特图
  • Dapr(一) 基于云原生了解Dapr
  • RESTful的优点
  • 网络检测与监控
  • 基于架构的软件开发方法_1.概述和相关概念及术语
  • 读所罗门的密码笔记07_共生思想(中)