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

VUE获取当前日期的周日和周六

<template><div><div  @click="handleLast()">上一周</div><div  @click="handleNext()">下一周</div><el-calendarref="monChild"v-model="value":first-day-of-week="7":range="[starttime, endtime]"style="height: 82px;"><!-- 这里使用的是 2.5 slot 语法,对于新项目请使用 2.6 slot 语法--><!-- slot="dateCell" --><!-- slot-scope="{date, data}"> --><template #dateCell="{ data }"><div:class="data.isSelected ? 'is-selected' : ''"@click="handleClick(data)"><div style="line-height: 18px">{{ parseTime(data.day, "{d}") }}</div><!-- 圆点显示 --><div class="g-flexcenter"><div v-if="dateList.findIndex((res) => res.scheduleTime === data.day) !==-1" :class="data.isSelected? 'g-color-blue': 'g-color-blue'">·</div></div></div></template></el-calendar></div>
</template><script>import dayjs from "dayjs";export default {name: "",data() {return {value: new Date(), //选中的日期 默认当天starttime: "",endtime: "",timeLength: "", //时长};},created() {this.weekCheckingIn();},methods: {/**获取近一周的日期  开始周起始日,结束周结束日*/weekCheckingIn() {let now = new Date(this.value);let nowTime = now.getTime();let day = now.getDay() || 7; // 不加 || 7.周末会变成下周一let oneDayTime = 24 * 60 * 60 * 1000;let SundayTime = nowTime - day * oneDayTime; //显示周日let SaturdayTime = nowTime + (7 - day - 1) * oneDayTime; //显示周六this.starttime = dayjs(SundayTime).format("YYYY-MM-DD");this.endtime = dayjs(SaturdayTime).format("YYYY-MM-DD");},/**上一周 */handleLast() {const last = new Date(this.value);last.setDate(last.getDate() - 7); //日期相加减this.value = last;this.weekCheckingIn();},/**下一周 */handleNext() {const next = new Date(this.value);next.setDate(next.getDate() + 7);this.value = next;this.weekCheckingIn();},/**选中的日期 */handleClick(data) {this.value = data.day;//调详情列表},//给list添加一个字段timeLength// this.$set(item,'timeLength',(new Date(endTime) - new Date(startTime)) / (1000 * 60 * 60))},
};
</script><style lang="scss" scoped>::v-deep .el-calendar__header {display: none;font-size: 12px;padding: 10px 0px;.el-button--mini {padding: 2px 5px;border-radius: 3px;}
}
::v-deep .el-calendar__body {padding: 0;.el-calendar-table thead th {font-size: 12px;font-weight: 400;color: #8f959e;padding: 12px 0 8px !important;}
}::v-deep .el-calendar-table .el-calendar-day {height: auto;padding: 5px;}
::v-deep .el-calendar-table td.is-selected .el-calendar-day {height: 27px !important;width: 27px !important;background: none !important;background-color: #ebeefc !important;font-size: 14px !important;font-weight: bold !important;color: #ffffff !important;background: #3370ff !important;
}
::v-deep .el-calendar-table tr td {border: 0px;text-align: center;font-weight: bold !important;
}
::v-deep .el-calendar-table td.is-selected {display: flex;justify-content: center;background: #fff;.el-calendar-day {width: 34px;height: 31px;background: url("~@/assets/images/workbench/icon_date.png") no-repeat;background-size: 100% 100%;border-radius: 50%;// font-family: PingFang SC;font-weight: bold;color: #409eff;}
}
::v-deep .el-calendar-table td :hover {background: none;color: #409eff;
}
::v-deep .el-calendar-table td.is-selected :hover {border-radius: 50%;
}</style>

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

相关文章:

  • K8S篇之k8s containerd模式fail to pull image certificate signed by unknown authority
  • 算法进阶指南图论 最优贸易
  • 【Android】Debug时禁用主线程ANR限制
  • P6入门:项目初始化1-项目详情介绍
  • 进行 “最佳价格查询器” 的开发
  • Brain Teaser概率类 - 三局两胜制
  • 在现实生活中传感器GV-H130/GV-21的使用
  • 海康Visionmaster-全局脚本:通过通讯触发快速匹配 模块换型的方法
  • 什么是闭包
  • sql6(Leetcode1387使用唯一标识码替换员工ID)
  • qt-C++笔记之Qt中的时间与定时器
  • 【C++】复杂的多继承及其缺陷(菱形继承)
  • esp32-rust-no_std-examples-blinky
  • GitHub上的开源工业软件
  • Centos7安装配置中文输入法
  • 【OJ比赛日历】快周末了,不来一场比赛吗? #11.11-11.17 #12场
  • 提取当前文件夹下多文件夹中的数据
  • 深度学习(生成式模型)——Classifier Free Guidance Diffusion
  • C语言 每日一题 11.9 day15
  • STM32F103C8T6第三天:pwm、sg90、超声波、距离感应按键开盖震动开盖蜂鸣器
  • 栈的顺序存储实现(C语言)(数据结构与算法)
  • 设计模式 -- 观察者模式
  • Go RabbitMQ简介 使用
  • 【面经】Spring框架中用了哪些设计模式
  • SpringBoot自动配置的原理篇,剖析自动配置原理;实现自定义启动类!附有代码及截图详细讲解
  • 苹果Ios系统app应用程序开发者如何获取IPA文件签名证书时需要注意什么?
  • 算法通关村第七关-黄金挑战二叉树迭代遍历
  • 2023-11-Rust
  • iOS代码混淆----自动
  • 对Mysql和应用微服务做TPS压力测试