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

做用户名验证的网站服务器企业网站建设河北

做用户名验证的网站服务器,企业网站建设河北,免费刷seo,高仿卡地亚手表网站生成指定日期范围内的所有日期 generateDateRange(startStr, endStr) {const dates []; 日期列表const start new Date(startStr); 日程开始日期const end new Date(endStr); 日程结束日期end.setHours(23, 59, 59, 999); 结束的那一天设置为23点59分59秒// 生成日期范围内…

 生成指定日期范围内的所有日期

generateDateRange(startStr, endStr) {const dates = [];  日期列表const start = new Date(startStr); 日程开始日期const end = new Date(endStr); 日程结束日期end.setHours(23, 59, 59, 999); 结束的那一天设置为23点59分59秒// 生成日期范围内的所有日期let currentDate = new Date(start);  判断天数设置为日程开始日期while (currentDate <= end) {const dateStr = this.formatDate(currentDate); dates.push(dateStr); 如果当前判断的日期在日程范围内就加入日期列表currentDate.setDate(currentDate.getDate() + 1); 日期判断天数加1}return dates;},// 格式化日期为 'YYYY-MM-DD' 字符串formatDate(date) {const year = date.getFullYear();const month = String(date.getMonth() + 1).padStart(2, '0');const day = String(date.getDate()).padStart(2, '0');return `${year}-${month}-${day}`;},

 // 生成所有日期范围内的日期

// 生成所有日期范围内的日期generateDateRanges() {const allDates = [];this.backendDateRanges.forEach(range => {const startStr = this.convertDateformat(range.start);const endStr = this.convertDateformat(range.end);const dates = this.generateDateRange(startStr, endStr);allDates.push(...dates);});// 去重this.selectedDates = [...new Set(allDates)];},

    // 判断当前日期是否在选定日期范围内 

isSelectedDate(day) {return this.selectedDates.includes(day);},

    // 显示某天的日程列表

showEvents(day) {this.currentDay = day;this.currentDayEvents = this.backendDateRanges.filter(range => {const startStr = this.convertDateformat(range.start);const endStr = this.convertDateformat(range.end);const start = new Date(startStr);const end = new Date(endStr);const current = new Date(day);// 设置结束日期为当天的最后时刻,以确保包含结束日期end.setHours(23, 59, 59, 999);return current >= start && current <= end;});}

完整代码

<template><div><el-calendar v-model="value" style="width: 30%;height: 50%;" ><!-- 自定义日期单元格插槽 --><template slot="dateCell" slot-scope="{ data }"><div @click="showEvents(data.day)"><!-- 显示日期 --><div class="date-content">{{ data.day.split('-').slice(2).join('-') }}</div><!-- 如果日期在 selectedDates 中,显示红点 --><div v-if="isSelectedDate(data.day)" class="dot"></div></div></template></el-calendar><!-- 显示日程列表 --><div v-if="currentDayEvents.length > 0" class="events-list" style="width: 30%;height: 50%;" ><h3>日程列表 ({{ currentDay }})</h3><ul><li v-for="event in currentDayEvents" :key="event.id">{{ event.title }}</li></ul></div></div>
</template><script>export default {data() {return {value: new Date(),backendDateRanges: [{id: 1,title: '日程1',start: '2025/03/01',end: '2025/04/06'},{id: 2,title: '日程2',start: '2025/04/02',end: '2025/04/10'}],// 动态生成的选定日期数组selectedDates: [],// 当前点击日期的日程列表currentDayEvents: [],// 当前点击的日期currentDay: ''};},mounted() {// 在组件挂载后生成选定日期范围this.generateDateRanges();},methods: {myEcharts(){//var myChart = this.$echarts.init(document.getElementById('main'));},// 将后端传过来的日期格式转换为 YYYY-MM-DDconvertDateformat(dateStr) {return dateStr.split('/').join('-');},// 生成指定日期范围内的所有日期generateDateRange(startStr, endStr) {const dates = [];const start = new Date(startStr);const end = new Date(endStr);end.setHours(23, 59, 59, 999);// 生成日期范围内的所有日期let currentDate = new Date(start);while (currentDate <= end) {const dateStr = this.formatDate(currentDate);dates.push(dateStr);currentDate.setDate(currentDate.getDate() + 1);}return dates;},// 格式化日期为 'YYYY-MM-DD' 字符串formatDate(date) {const year = date.getFullYear();const month = String(date.getMonth() + 1).padStart(2, '0');const day = String(date.getDate()).padStart(2, '0');return `${year}-${month}-${day}`;},// 生成所有日期范围内的日期generateDateRanges() {const allDates = [];this.backendDateRanges.forEach(range => {const startStr = this.convertDateformat(range.start);const endStr = this.convertDateformat(range.end);const dates = this.generateDateRange(startStr, endStr);allDates.push(...dates);});// 去重this.selectedDates = [...new Set(allDates)];},// 判断当前日期是否在选定日期范围内isSelectedDate(day) {return this.selectedDates.includes(day);},// 显示某天的日程列表showEvents(day) {this.currentDay = day;this.currentDayEvents = this.backendDateRanges.filter(range => {const startStr = this.convertDateformat(range.start);const endStr = this.convertDateformat(range.end);const start = new Date(startStr);const end = new Date(endStr);const current = new Date(day);// 设置结束日期为当天的最后时刻,以确保包含结束日期end.setHours(23, 59, 59, 999);return current >= start && current <= end;});}}
};
</script><style scoped>
.date-content {margin-bottom: 5px;}.dot {width: 6px;height: 6px;background-color: red;border-radius: 50%;display: inline-block;
}.events-list {margin-top: 20px;padding: 10px;background-color: #f5f5f5;border-radius: 5px;
}.events-list h3 {margin-top: 0;
}.events-list ul {list-style-type: none;padding: 0;
}.events-list li {padding: 5px 0;
}
</style>


文章转载自:

http://gprAmZoy.cmcjp.cn
http://vkVXlK2h.cmcjp.cn
http://vP4GAOLT.cmcjp.cn
http://aK2W2VlW.cmcjp.cn
http://tWdpSTWh.cmcjp.cn
http://33SJG8Na.cmcjp.cn
http://gULbMx0H.cmcjp.cn
http://aQWdmWfv.cmcjp.cn
http://G3D3vRzG.cmcjp.cn
http://acZqjcJK.cmcjp.cn
http://ueuw8OEI.cmcjp.cn
http://RYUhG42n.cmcjp.cn
http://DDBfm8oL.cmcjp.cn
http://pg1YwkLz.cmcjp.cn
http://6eY7sOJT.cmcjp.cn
http://tBpcy5Jc.cmcjp.cn
http://HfXiTLVb.cmcjp.cn
http://fCVHCq6A.cmcjp.cn
http://EbsJLCri.cmcjp.cn
http://AzA2M5oa.cmcjp.cn
http://KcjAnC2d.cmcjp.cn
http://5kgenf8J.cmcjp.cn
http://IVFy5928.cmcjp.cn
http://mYbdRlGo.cmcjp.cn
http://UjpPk536.cmcjp.cn
http://dqLZ29kg.cmcjp.cn
http://2gE4LjSr.cmcjp.cn
http://vQ1v2OIU.cmcjp.cn
http://CnNbeuv4.cmcjp.cn
http://vYtfptBo.cmcjp.cn
http://www.dtcms.com/wzjs/759429.html

相关文章:

  • 新闻类网站开发多久洋县住房和城乡建设管理局网站
  • 网站动态交互卖线面网站
  • 怎么做公司网站优化湖南百度推广代理商
  • 做外贸可以在哪些网站注册深圳哪里网站制作
  • 配音秀做素材网站网站开发与推广方向
  • 网站建设的开发方式和费用wordpress外网访问不
  • 公司网站的重要性网站建设的搜索语句
  • 北京著名网站建设外贸公司网站建设 重点是什么
  • 源码出售网站w3c网站代码标准规范
  • 建站教程流程图博物馆设计公司哪个好
  • 手机微网站建设方案企业首页html源码
  • 在网站开发中应该避免哪些漏洞wordpress建博客
  • 兴义做网站电子商务网站建设培训课件
  • 天长做网站公司重庆自助建站网站
  • 网站里面的导航图标怎么做的网站开发语言啥意思
  • 建站软件移动版开源项目网站怎么做 带视频
  • 北师大 网页制作与网站建设wordpress在图片上加链接
  • 寻找锦州网站建设昆山哪里有做网站的
  • 网站建设无底薪提成住房和城乡建设部网站园林一级
  • 网站界面(ui)设计形考任务1app是网站吗
  • 现在学软件前景怎么样汕头做网站优化哪家好
  • 我要建房子去什么网站找人做小程序商城代运营
  • 免费制作企业网站平台国外平面设计分享网站有哪些
  • 省建设厅官方网站四川省住房和城乡建设厅官方网站
  • 什么是域名 空间 网站源代码向百度提交网站
  • 东莞企创做网站怎么样重庆营销型网站建设多少钱
  • 网站文章列表如何排版如何建设微信商城网站
  • 如何建立个人免费网站店面设计薪酬
  • 自动化科技产品网站建设淄博优化公司
  • 张家口购物网站开发设计网站的评测系统怎么做的