vue实现周日历 日历按周切换 vue日程管理

在这里插入图片描述
在这里插入图片描述

实现的功能
1、点击今天:回到今日日期并选中今日日期,查当天数据
2、点击左箭头:切换上一周
3、点击右箭头:切换下一周
4、黄圆圈代表有日程提醒,点击选中,下方对应显示当前日程提醒的内容,没有内容则显示暂无数据
5、进入当前页面,默认选中当天日期,查当天数据

vue日程管理按月查询请看上一篇文章

具体代码

template

<div class="schedule-calendar"><div class="calendar-box"><!-- 年月 --><div class="calendar-top"><div class="yearMonth">{{ currentYear }}{{ currentMonth }}</div><div class="today-btn" @click="toToday()">今天</div></div><!-- 星期 --> <div class="weekdays"><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div><!-- 日期 --> <div class="days-item"><div @click="pick(day,index)" v-for="(day, index) in days" :key="index" class="time-normal"><!--今天--> <span v-if="day.getFullYear() == new Date().getFullYear() && day.getMonth() == new Date().getMonth() && day.getDate() == new Date().getDate()" :class="[curShow == true ? 'time-active' : '']">{{ day.getDate() }}</span><span v-else :class="[selectedCur == index ? 'time-active' : '']">{{ day.getDate() }}</span><div v-for="(item, index) in timeData" :key="index"><i class="dots" v-if="item.scheduleAvailable == 1 && item.weeklyDate == formatDate(day.getFullYear(),day.getMonth()+1,day.getDate())"></i></div></div></div><div class="operate-arrow"><i class="el-icon-arrow-left ope-left" @click="weekPre"></i><i class="el-icon-arrow-right ope-right" @click="weekNext"></i></div></div>
</div>

script

data() {return {// 日程timeData:[],//存放表格数据currentYear: "",   // 年份currentMonth: "",  // 月份currentDay: "",    // 日期currentWeek: "",    // 星期days: [],selectedCur:null,//选中的当前日期indextimeNow:"",//今日curShow:true,//今日默认选中效果dateCur:null//选中的当前日期}
},
mounted() {this.initData()this.getCurrentDate() // 获取当前时间this.dateCur = this.timeNowthis.getScheduleData()
},
methods(){//我的日程数据getScheduleData(time) {this.$http({url: this.$http.adornUrl('***/mySchedule'),method: "get",params: {switchDate: time,//默认传空}}).then(res => {console.log("日程:",res)if(res.data && res.data.length){this.timeData = res.data}}).catch(err => {console.log(err)});},// 我的日程-按周 开始toToday(){this.selectedCur = nullthis.curShow = truethis.getCurrentDate() // 获取当前时间this.initData(this.timeNow)this.dateCur = this.timeNowthis.getScheduleData(this.dateCur)},// 日期相关getDate() {const date = new Date();let year = date.getFullYear();let month = date.getMonth() + 1;let day = date.getDate();month = month > 9 ? month : '0' + month;day = day > 9 ? day : '0' + day;return `${year}-${month}-${day}`;},getCurrentDate() {this.timeNow = this.getDate({format: true})console.log("今日:",this.timeNow)},formatDate (year, month, day) {const y = yearlet m = monthif (m < 10) m = `0${m}`let d = dayif (d < 10) d = `0${d}`return `${y}-${m}-${d}`},initData (cur) {let date = ''if (cur) {date = new Date(cur)console.log("qqqq:",date)} else {date = new Date()}this.currentDay = date.getDate()          // 今日日期 几号this.currentYear = date.getFullYear()       // 当前年份this.currentMonth = date.getMonth() + 1    // 当前月份this.currentWeek = date.getDay() // 1...6,0   // 星期几if (this.currentWeek === 0) {this.currentWeek = 7}const str = this.formatDate(this.currentYear, this.currentMonth, this.currentDay) // 今日日期 年-月-日this.days.length = 0// 今天是周日,放在第一行第7个位置,前面6个 这里默认显示一周,如果需要显示一个月,则第二个循环为 i<= 35- this.currentWeek/* eslint-disabled */for (let i = this.currentWeek - 1; i >= 0; i -= 1) {const d = new Date(str)d.setDate(d.getDate() - i)this.days.push(d)}for (let i = 1; i <= 7 - this.currentWeek; i += 1) {const d = new Date(str)d.setDate(d.getDate() + i)this.days.push(d)}},//  上个星期weekPre () {const d = this.days[0]    // 如果当期日期是7号或者小于7号d.setDate(d.getDate() - 7)let preDate = this.formatDate(d.getFullYear(), d.getMonth() + 1, d.getDate())console.log("上一周:",preDate)this.initData(d)this.getScheduleData(preDate)//点击上周时把点击选中清空 this.selectedCur = null},//  下个星期weekNext () {const d = this.days[6]    // 如果当期日期是7号或者小于7号d.setDate(d.getDate() + 7)let nextDate = this.formatDate(d.getFullYear(), d.getMonth() + 1, d.getDate())console.log("下一周:",nextDate)this.initData(d)this.getScheduleData(nextDate)// 点击下周时把点击选中清空 this.selectedCur = null},// 当前选择日期pick (date,index) {console.log(index)this.selectedCur = indexthis.dateCur = this.formatDate(date.getFullYear(), date.getMonth() + 1, date.getDate())if(this.timeNow == this.dateCur){this.curShow = true}else{this.curShow = false}this.getScheduleData(this.dateCur)},// 我的日程-按周 结束
}

样式

/* 日程 */.schedule-calendar{background: #ECF6FF;border-radius: 8px;height: 123px;margin-bottom:10px;}.calendar-box{position: relative;}.schedule-list{/* height: calc(100% - 170px); */overflow: hidden;overflow-y: auto;}.schedule-list::-webkit-scrollbar {width: 5px;}.schedule-list::-webkit-scrollbar-thumb {border-radius: 8px;background-color: #ccc;}.schedule-list::-webkit-scrollbar-track {border-radius: 8px;background-color: #e7e7e7;border: 1px solid #cacaca;}.calendar-top{display: flex;align-items: center;justify-content: space-between;}.yearMonth{font-size: 12px;color: #666666;text-align: left;padding-top: 8px;padding-left: 15px;margin-bottom:10px;}.today-btn{width: 39px;height: 20px;line-height: 20px;border-radius: 60px;background: #FFFFFF;box-sizing: border-box;border: 1px solid #EEEEEE;font-size: 10px;color: #666666;cursor: pointer;margin-right: 5px;}.weekdays{display: flex;align-items: center;justify-content: space-around;margin-bottom:10px;font-size: 14px;color: #666666;}.days-item{height:46px;line-height:46px;text-align: center;display: flex;align-items: center;justify-content: space-around;font-size: 14px;font-weight: bold;color: #3D3D3D;}.time-normal{cursor: pointer;width: 37px;height: 46px;}.time-active{width: 37px;height: 46px;border-radius: 4px;background: linear-gradient(332deg, #2CA7FF -8%, #69BBFF 58%, #90D5FF 112%);cursor: pointer;display: block;}i.dots{width: 6px;height: 6px;border-radius: 6px;background: linear-gradient(180deg, #FFB00E 0%, #FF683F 100%);display: block;margin: 0 auto;margin-top: -13px;}.operate-arrow{}.operate-arrow i {color: #90A7FF;font-weight: bold;cursor: pointer;position: absolute;top:79px;}i.ope-left{left:5px;}i.ope-right{right:5px;}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/1833.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Spring Cloud Zuul面试题

Spring Cloud Zuul面试题 1. Zuul概述1.1 什么是Zuul&#xff1f;1.2 Zuul有哪些核心功能&#xff1f;1.3 Zuul 1和Zuul 2有什么区别&#xff1f;1.4 为什么我们需要使用API网关如Zuul&#xff1f; 2. 路由功能2.1 Zuul是如何实现路由的&#xff1f;1. 集成 Zuul2. 配置路由3. …

C++设计模式|创建型 4.建造者模式

1.什么是建造者模式? 建造者模式&#xff08;也被成为生成器模式&#xff09;&#xff0c;是一种创建型设计模式&#xff0c;软件开发过程中有的时候需要创建很复杂的对象&#xff0c;而建造者模式的主要思想是将对象的构建过程分为多个步骤&#xff0c;并为每个步骤定义一个…

nlp 自然语言处理的dataset数据库积累

下面的这个和 entity recognition有关的。 Weights & Biases

mybatis的一二级缓存

MyBatis 给我们提供了一级缓存和二级缓存机制来提高查询效率和减少数据库交互次数&#xff0c;一级缓存主要用于单次数据库会话内的查询优化&#xff0c;而二级缓存则着眼于整个应用层面的数据复用。 一级缓存&#xff08;Local Cache&#xff09; 特点&#xff1a; 一级缓存是…

Java Collections类、Stream流

Collections类 Java中的Collections类是一个功能丰富的工具类&#xff0c;它提供了一系列静态方法来操作和处理集合。以下是一些主要的功能&#xff1a; 创建集合&#xff1a;可以使用Collections类创建空集合、单元素集合以及不可变集合等。这为集合的初始化提供了便利。排序…

3i平台体验性能加持,13600KF+B760M+撼与科技A770 TITAN装机体验

在2022年&#xff0c;intel重启显卡线&#xff0c;带来了多款性价比十分不错的显卡。而近段时间&#xff0c;又有传言说intel第二代产品e即将面世&#xff0c;甚至已经有数款Battlemage GPU曝光&#xff0c;让不少intel忠实粉丝直呼期待&#xff0c;或许在今年年底&#xff0c;…

mysql面试题八(SQL语句)

目录 1.SQL 基本组成部分 常用操作示例 创建表 插入数据 查询数据 更新数据 删除数据 创建索引 授予用户权限 2.常见的聚合查询 1. 计数&#xff08;COUNT&#xff09; 2. 求和&#xff08;SUM&#xff09; 3. 平均值&#xff08;AVG&#xff09; 4. 最大值&…

卸载jenkins和docker

要卸载Docker中部署的Jenkins以及相关的容器和数据卷&#xff0c;您可以按照以下步骤操作&#xff1a; 卸载Jenkins容器及关联数据卷 停止并删除Jenkins容器&#xff1a; 使用Docker命令找到Jenkins容器的ID&#xff08;如果您还不知道&#xff09;&#xff0c;然后停止并删除…

在stm32中,所需的库函数有那些

使用库函数中封装的函数来访问外设可以使得stm32开发更加方便&#xff0c;省去了查寄存器位操作&#xff0c;只用查库函数就可以了 但是使用库函数时要记住真正的其本质是获取寄存器的地址然后设置其中的位 库函数一般添加到自己创建的Lib文件夹中 库函数实际上分成了两块&…

vue e.target.currentSrc 获取图片图片里包含中文名字出现乱码

<div v-html"info.brief" class"content" click"judgeImg($event)"></div> //判断是否为图片并提取当前图片地址judgeImg(e){ let currentSrc decodeURIComponent(e.target.currentSrc) }, 在 Vue 中&#xff0c;当你从 e…

Opencv | 图像卷积与形态学变换操作

这里写目录标题 一. 滤波 / 卷积操作1. 平滑均值滤波/卷积2. 平滑中值滤波/卷积3. 平滑高斯滤波/卷积3.1 关注区域3.2 分解特性 二. 形态学变换1. 常用核2. cv.erode ( ) 腐蚀操作3. cv.dilate ( ) 膨胀操作4. Open 操作5. Close 操作6. Morphological Gradient 形态梯度操作7.…

设计模式之创建型模式---工厂模式

文章目录 工厂模式概述简单工厂简单工厂的代码实现简单工厂的使用简单工厂应用场景 工厂方法工厂方法模式的代码实现工厂方法的使用工厂方法应用场景 抽象工厂抽象工厂模式代码实现抽象工厂的使用方法抽象工厂模式的应用场景 总结 工厂模式概述 工厂模式从名字就能看出&#x…

查看文件的权限和实际类型

该文件确实存在于指定的位置。可以使用 ls 命令来检查文件是否存在&#xff0c;以及确认文件路径是否正确。 ls -l xxx.xx权限问题: 确保你有权限读取该文件。如果该文件位于受限制的目录中&#xff0c;可能需要使用 sudo 或其他管理员权限来运行命令。 文件格式不正确: 如果…

JS走马灯小功能制作

HTML代码&#xff1a; <div id"contain"><div id"content"> 作文&#xff0c;怎样才能写好&#xff1f;作文&#xff0c;好于勤读&#xff0c;作文&#xff0c;优于真情。作文一词&#xff0c;汇于欲要看究竟&#xff0c;处处细留心。作文于此…

损失函数汇总

kl 在多分类问题中&#xff0c;KL&#xff08;Kullback-Leibler&#xff09;损失通常用于衡量模型预测的概率分布与真实标签的概率分布之间的差异。在多分类任务中&#xff0c;通常使用交叉熵损失&#xff08;Cross Entropy Loss&#xff09;作为主要的损失函数&#xff0c;但…

Threejs绘制传送带

接下来会做一个MES场景下的数字孪生&#xff0c;所以开始做车间相关的模型&#xff0c;不过还是尽量少用建模&#xff0c;纯代码实现&#xff0c;因为一方面可以动态使用&#xff0c;可以调节长度和宽度等&#xff0c; 下面这节就做一个简单的传送带&#xff0c;这是所有车间都…

c++计算DNA探针的熔解温度

DNA探针的熔解温度(Tm)是指DNA双链在解离过程中的温度,可以用来估计DNA探针与靶序列的结合强度。 DNA探针富集实验中使用的盐浓度通常是在高盐条件下进行的,以帮助DNA与探针结合并提高富集效率。一般来说,盐浓度在0.5 M到1 M之间是常见的范围,但具体的盐浓度会根据实验的…

基础SQL DML-插入语句

插入语句前&#xff0c;我们先创建一个表。表的创建在DDL语句里面涉及&#xff0c;可以参考&#xff1a;小赖同学吖-CSDN博客 我们创建一个员工表进行数据的插入操作 插入&#xff08;添加&#xff09;语句的语法 给员工表添加一条记录 给员工表添加多条记录 也可以通过下面的方…

年薪5.8万美元|临床医生赴美国康奈尔大学从事博士后研究

作为临床医学8年制的博士毕业生&#xff0c;A医生希望能到国外从事一段时间的博士后&#xff0c;以强化基础科研训练&#xff0c;弥补职业发展的短板。最终我们为其申请到康奈尔大学Weill Cornell医学院的博士后职位&#xff0c;年薪为5.8万美元。 A医生背景&#xff1a; 申请…

C语言项目实践——贪吃蛇

引言&#xff1a;本篇博客中&#xff0c;我将会使用结构体&#xff0c;链表&#xff0c;WIN32 API等一系列知识完成C语言项目——贪吃蛇的实现。在观看此篇博客之前&#xff0c;请将这些知识所熟悉&#xff0c;不然可能会造成理解困难。 更多有关C语言的知识详解可前往个人主页…