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

element-plus中el-empty空盒子组件和Collapse 折叠面板组件的使用

一.el-empty空盒子组件的使用

直接复制下面的代码:

<el-empty description="description" />

展示效果:

还可以自定义文字描述:

<el-empty description="暂未选择患者"/>

二.Collapse 折叠面板组件的使用

复制下面的代码:

<template>
  <div>
    <el-button @click="show = !show">Click Me</el-button>

    <div style="margin-top: 20px">
      <el-collapse-transition>
        <div v-show="show" style="height: 400px">
          <div class="transition-box">el-collapse-transition</div>
          <div class="transition-box">el-collapse-transition</div>
        </div>
      </el-collapse-transition>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const show = ref(true)
</script>

<style>
.transition-box {
  margin-bottom: 10px;
  width: 200px;
  height: 100px;
  border-radius: 4px;
  background-color: #409eff;
  text-align: center;
  color: #fff;
  padding: 40px 20px;
  box-sizing: border-box;
  margin-right: 20px;
}
</style>

效果展示:

代码解读:

①自定义变量show

②v-show="show"这个属性,控制着折叠面板的显示。

③添加一个按钮,一点击就修改show的值,从而控制折叠面板是否显示。

三.综合练习

题目要求:

刚打开页面时,我们不显示患者病历表单,而是展示空盒子(表示门诊医生暂未选择看诊的患者)。等到医生选择了某个患者后,才会展示出患者病历表单。

代码大致思路:

①先定义变量isChoose ,控制病历表单是否显示

const isChoose = ref(false);

②定义一个卡片,里面分别存放空盒子组件和折叠面板,然后根据情况展示二者之一即可。

<!-- 卡片(患者病历表单填写) -->
<el-card  style="width:976px;" shadow="hover" >
    <!-- 情况1:一开始显示空盒子 -->
    <el-empty description="暂未选择患者" v-show="!isChoose" />
    <!-- 情况2:选择某个待诊患者后,显示出病例表单 -->
    <el-collapse-transition>
        <div v-show="isChoose"  style="height:600px;width:100%;">
            <el-form :model="medicalRecordDto" label-position="top">
                <!-- 第一行 -->
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="主诉">
                            <el-input type="textarea"  v-model="medicalRecordDto.chiefComplaint" placeholder="请输入主诉" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="现病史">
                            <el-input type="textarea"  v-model="medicalRecordDto.present" placeholder="请输入患者现病史" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <!-- 第二行 -->
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="现病治疗情况">
                            <el-input type="textarea"  v-model="medicalRecordDto.presentTreat" placeholder="请输入现病治疗情况" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="既往史">
                            <el-input type="textarea"  v-model="medicalRecordDto.history" placeholder="请输入既往史" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <!-- 第三行 -->
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="过敏史">
                            <el-input type="textarea"  v-model="medicalRecordDto.allergy" placeholder="请输入过敏史" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="体格检查">
                            <el-input type="textarea"  v-model="medicalRecordDto.physique" placeholder="请输入体格检查" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <!-- 第四行 -->
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="检查建议">
                            <el-input type="textarea"  v-model="medicalRecordDto.proposal" placeholder="请输入检查建议" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="注意事项">
                            <el-input type="textarea"  v-model="medicalRecordDto.care" placeholder="请输入注意事项" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <!-- 第五行 -->
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="检查结果">
                            <el-input type="textarea"  v-model="medicalRecordDto.checkResult" placeholder="请输入检查结果" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="诊断结果">
                            <el-input type="textarea"  v-model="medicalRecordDto.diagnose" placeholder="请输入诊断结果" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <!-- 第六行 -->
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="处理意见">
                            <el-input type="textarea"  v-model="medicalRecordDto.handle" placeholder="请输入处理意见" style="width: 300px;margin-right: 10px" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-button-group style="margin: 50px 25px" type="flex" justify="center">
                            <el-button type="primary" @click="saveRecord" :icon="Refresh" size="large">暂存</el-button>
                            <el-button type="success" @click="commitRecord" :icon="Select" size="large">提交</el-button>
                            <el-button type="warning" @click="resetRecord" :icon="Close" size="large">清屏</el-button>
                        </el-button-group>
                    </el-col>
                </el-row>
            </el-form>
        </div>
    </el-collapse-transition>

</el-card>

③定义一个按钮,来改变isChoose的值,从而实现控制展示空盒子还是折叠面板。 

<el-button type="primary" text @click="isChoose = !isChoose">选择</el-button>

展示效果:

结语

以上就是el-empty空盒子组件和Collapse 折叠面板组件的使用,在项目中需要的话可以这么做。

喜欢本篇文章的话,可以留个免费的关注~

 

相关文章:

  • 第十七章:Future Directions_《C++ Templates》notes
  • java 线程创建Executors 和 ThreadPoolExecutor 和 CompletableFuture 三者 区别
  • 数据库查询练习
  • ASP.NET Web API + VUE3 整合阿里云OSS,后端API生成预签名上传Url,前端VUE进行上传
  • 蓝桥杯第 十一天 国赛 2020 第 2题 扩散
  • CVE-2021-45232未授权接口练习笔记
  • conda环境下解决gitk乱码模糊
  • Postman使用02、断点、fiddler弱网测试
  • Java 基于微信小程序的开放实验室预约管理系统
  • 从单机到集群:Elasticsearch集群搭建指南
  • HTML5 初探:新特性与本地存储的魔法
  • IP-guard与Ping32哪个加密更强?两款加密软件的安全架构解析
  • 专访中兴通讯蒋军:AI数字人驱动企业培训,“内容生产”与“用户体验”双重提升
  • 第十节 MATLAB逻辑运算
  • 深入 SVG:矢量图形、滤镜与动态交互开发指南
  • 【微服务】SpringCloudGateway网关
  • 【开源宝藏】30天学会CSS - DAY8 第八课 跳动的爱心动画
  • 嵌入式八股文学习——基类构造与析构、成员初始化及继承特性详解
  • RAG核心概念
  • 蓝桥杯备考:差分数组+贪心Tallest Cow S
  • 建设通是什么网站/seo优化网站词
  • 绍兴做网站/国家免费技能培训
  • 潍坊网站建设自助建站平台/广东短视频seo搜索哪家好
  • 安徽地方政府网站建设情况/如何做网销
  • 建一个所在区域网站需要多少资金/广告联盟平台挂机赚钱
  • 惠州品牌网站建设价格/长沙seo代理商