制作周变化日程组件

news2024/10/7 18:30:42

要实现的样子

 实现的功能:

上面年月左右切换至改变月份,改变后显示月份的1号在的一周从周天开始

下面周历左右切换周,当存在1号的时候月份变为1号的月份和年份。

点击日程时间下面的日程变化(日程上的点代表有日程信息)

 这里用到了获取// 指定日期的一周的所有日期的数组 js中获取指定日期的一周的开始和结束日期,以及一周的所有日期的数组_js获取一周内的日期_slom_fxt的博客-CSDN博客

代码如下:

<template>
    <div class="rcZj">
        <div class="head">
            <div>
                <div class="left">
                    <div :class="[tab4Index == index ? 'active' : '']" v-for="(item, index) in tab4" :key="index"
                        @click="getTab4(index)">
                        {{ item }}
                    </div>
                </div>
                <div class="right">
                    <div v-html="'更多 >'">

                    </div>
                </div>
            </div>
        </div>
        <div class="timeBox">
            <div class="ny">
                <div class="pre"
                    :style="{ 'opacity': dateList.yVale == 1 ? '0.6' : '1', 'cursor': dateList.yVale == 1 ? 'not-allowed' : 'pointer' }"
                    @click="nyPre(0)" v-html="'<'"></div>
                <div class="dateBox">
                    <el-dropdown trigger="click" @command="getNian">
                        <span class="el-dropdown-link">
                            {{ dateList.nVale }}年<i class="el-icon-caret-bottom"></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item :command="item.value" v-for="(item, index) in dateList.n" :key="index">{{
                                item.value }}</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                    <el-dropdown trigger="click" @command="getYue">
                        <span class="el-dropdown-link">
                            {{ dateList.yVale }}月<i class="el-icon-caret-bottom"></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item :command="item" v-for="(item, index) in dateList.y" :key="index">{{ item
                            }}</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
                <div class="pre"
                    :style="{ 'opacity': dateList.yVale == 12 ? '0.6' : '1', 'cursor': dateList.yVale == 12 ? 'not-allowed' : 'pointer' }"
                    @click="nyPre(1)" v-html="'>'"></div>
            </div>
            <div>
                <div class="rl">
                    <div>
                        <div>日</div>
                        <div>一</div>
                        <div>二</div>
                        <div>三</div>
                        <div>四</div>
                        <div>五</div>
                        <div>六</div>
                    </div>
                    <div>
                        <div :class="[el.time == activeRc ? 'active' : '']" v-for="(el, index) in riDate" :key="index"
                            @click="clickRc(el)">
                            <span>{{ el.time.split('/')[2] }}</span>
                            <div class="dian">
                                <div v-show="el.isRc"></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="pre-left" @click="rcLeft()"></div>
                <div class="pre-right" @click="rcRight()"></div>
            </div>
        </div>
        <div class="rcBox">
            <div>
                <div class="title">
                    今日日程
                </div>
                <div class="table">
                    <div>
                        <div>
                            <img src="../assets/rc.png" alt="">江西省区域金融改革优秀项目展
                        </div>
                        <div>09:00-10:00</div>
                    </div>
                    <div>
                        <div>
                            <img src="../assets/rc.png" alt="">参加数字化转型项目会议
                        </div>
                        <div>09:00-10:00</div>
                    </div>
                </div>
            </div>
            <div>
                <div class="title">
                    明日日程
                </div>
                <div class="table">
                    <div>
                        <div>
                            <img src="../assets/rc.png" alt="">人力资源部第二季工作汇总
                        </div>
                        <div>09:00-10:00</div>
                    </div>
                    <div>
                        <div>
                            <img src="../assets/rc.png" alt="">人力资源部第二季工作汇总
                        </div>
                        <div>09:00-10:00</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name:'rcZj',
    components: {

    },
    data: () => ({
         //日程的tab
         tab4: ["个人日程", "领导日程", "部门日程"],
        tab4Index: 0,
        //日程的年月下拉
        dateList: {
            n: [
                {
                    name: "2018年",
                    value: 2018
                },
                {
                    name: "2019年",
                    value: 2019
                },
                {
                    name: "2020年",
                    value: 2020
                },
                {
                    name: "2021年",
                    value: 2021
                },
                {
                    name: "2022年",
                    value: 2022
                },
                {
                    name: "2023年",
                    value: 2023
                }
            ],
            nVale: new Date().getFullYear(),
            y: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
            yVale: new Date().getMonth() + 1
        },
        //选中的日程
        activeRc: `${new Date().getFullYear()}/${new Date().getMonth() + 1}/${new Date().getDate()}`,
        //一周日历从周天开始到下周六
        riDate: [],
    }),
    computed: {},
    watch: {},
    created() { },
    mounted() {
        //初始化
        this.getrlDate('','','',true)
    },
    methods: {
        //日程的切换
        getTab4(index) {
            this.tab4Index = index
        },
        //日程年份的下拉选项
        getNian(item){
            this.dateList.nVale=item
            this.$nextTick(()=>{
              this.getrlDate2()
            })
        },
         //日程月份的下拉选项
         getYue(item){
            this.dateList.yVale=item
            this.$nextTick(()=>{
              this.getrlDate2()
            })
        },
        //获取周日历从周日开始
        getrlDate(year,month,day,flag,type){
            //有日程的标识
            let dianArr=[true,true,true,false,false,true,true]
            let riDate=[]
            let arr1=[]
            //初始化
            if(flag){
                //现获取正常的从周一到周天
                arr1 =new Date().getWeekTime()
                arr1.pop();
                arr1.unshift(new Date(this.dateList.nVale,this.dateList.yVale-1,Number(arr1[0].split('/')[2])-1).getWeekTime()[6]) 
                arr1.map((el)=>{
                    riDate.push({
                        time:el,
                    })
                })
            }else{
                arr1 =new Date(year,month-1,day).getWeekTime()
                arr1.pop();
                arr1.unshift(new Date(year,Number(arr1[0].split('/')[1])-1,Number(arr1[0].split('/')[2])-1).getWeekTime()[6]) 
                arr1.map((el)=>{
                    riDate.push({
                        time:el,
                    })
                })
                let a= arr1.filter((el)=>{
                    return el.split('/')[2] ==1
                })
                if(a.length>0){
                    this.dateList.nVale=a[0].split('/')[0]
                    this.dateList.yVale=a[0].split('/')[1]
                }else{
                    this.dateList.nVale=arr1[0].split('/')[0]
                    this.dateList.yVale=arr1[0].split('/')[1]
                }
            }
            dianArr.map((el,index)=>{
                riDate[index].isRc=el
            })
            this.riDate=riDate
        },
        //获取每年一月一的第一周的日期
        getrlDate2(){
            //有日程的标识
            let dianArr=[true,true,true,false,false,true,true]
            //获取月第一周的时间
            let arr =new Date( this.dateList.nVale,Number(this.dateList.yVale)-1,1).getWeekTime()
            let timeArr=[]
            let riDate=[]
            //判断1号是周天吗
            if(arr[arr.length-1].split('/')[2]==1){

                timeArr= new Date(this.dateList.nVale,Number(this.dateList.yVale)-1,2).getWeekTime()
                timeArr.pop()
                timeArr.unshift(arr[arr.length-1])
                timeArr.map((el)=>{
                    riDate.push({
                        time:el,
                    })
                })
            }else{
                timeArr=arr
                timeArr.pop()
                timeArr.unshift(new Date(this.dateList.nVale,Number(timeArr[0].split('/')[1])-1,Number(timeArr[0].split('/')[2])-1).getWeekTime()[6])
                timeArr.map((el)=>{
                    riDate.push({
                        time:el,
                    })
                })
            }
            dianArr.map((el,index)=>{
                riDate[index].isRc=el
            })
            this.riDate=riDate
        },
        //年月的左右切换月份
        nyPre(type){
            if(type!=1 && this.dateList.yVale!=1){
                this.dateList.yVale=Number(this.dateList.yVale)-1
                this.getrlDate2()
            }
            if(type==1 && this.dateList.yVale!=12){
                this.dateList.yVale=Number(this.dateList.yVale)+1
                this.getrlDate2()
            }
        },
        //日程的日历下方的左边
        rcLeft(){
            this.getrlDate(Number(this.riDate[0].time.split('/')[0]),Number(this.riDate[0].time.split('/')[1]),Number(this.riDate[0].time.split('/')[2])-1,false,0)
        },
        //日程的日历下方的右边
        rcRight(){
            this.getrlDate(Number(this.riDate[this.riDate.length-1].time.split('/')[0]),Number(this.riDate[this.riDate.length-1].time.split('/')[1]),Number(this.riDate[this.riDate.length-1].time.split('/')[2])+2,false,1)
        },
        //点击选择日程
        clickRc(el){
            this.activeRc=el.time
        },
    },
    destroyed() { },
}
</script>
<style>
.el-dropdown-menu{
    /* width: 80px; */
    height: 100px;
    overflow-y: auto;
    overflow-x: hidden;
}
.el-dropdown-menu .el-dropdown-menu__item{
    list-style: none;
    line-height: 36px;
    padding: 0;
    margin: 0;
    font-size: 14px;
    padding: 0 20px;
    color: #606266;
    cursor: pointer;
    outline: 0;
    text-align: center;
}
</style>
<style lang="scss" >
.head {
    height: 56px;
    width: 100%;
    border-bottom: 1px solid rgba(221, 226, 231, 1);

    &>div {
        width: 97%;
        height: 100%;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: space-between;

        .left {
            height: 100%;
            font-family: 'pf';
            font-size: 18px;
            color: #333333;
            font-weight: 400;
            display: flex;
            align-items: center;

            &>div {
                height: 100%;
                display: flex;
                align-items: center;
                ;
                justify-content: center;
                cursor: pointer;
            }

            &>div:not(:first-child) {
                margin-left: 50px;
            }

            .active {
                color: #0070FF;
                font-weight: 600;
                position: relative;
            }

            .active::before {
                content: '';
                display: inline-block;
                width: 72px;
                height: 3px;
                background: #0070FF;
                position: absolute;
                bottom: 0;
            }
        }

        .right {
            font-family: 'pf';
            font-size: 16px;
            color: #999999;
            text-align: right;
            font-weight: 400;
            cursor: pointer;
        }
    }
}

.rcZj {
    width: 100%;
    height: 100%;
    background: #FFFFFF;
    box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.14);
    border-radius: 8px;

    .head {
        &>div {
            width: 92%;
        }
    }

    .timeBox {
        width: 92%;
        height: 35%;
        margin: 0 auto;
        margin-bottom: 24px;
        display: flex;
        flex-direction: column;
        align-items: center;

        .ny {
            display: flex;
            align-items: center;
            margin-top: 24px;
            margin-bottom: 18px;

            .pre {
                width: 18px;
                height: 18px;
                background: #4F8BE2;
                border-radius: 2.25px;
                color: #fff;
                font-size: 14px;
                display: flex;
                align-items: center;
                justify-content: center;
                cursor: pointer;
            }

            .dateBox {
                margin: 0 15px;

                &>div:nth-child(2) {
                    margin-left: 10px;
                }

                >>>.el-dropdown {
                    font-family: 'pfm';
                    font-size: 16px;
                    color: #4F8BE2;
                    letter-spacing: 0;
                    font-weight: 500;
                    cursor: pointer;

                    .el-icon-caret-bottom {
                        margin-left: 4px;
                        color: #c6c6c6;
                    }
                }
            }
        }

        &>div:nth-child(2) {
            width: 100%;
            height: 100%;
            background: rgba(236, 245, 254, 0.53);
            border-radius: 4px;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;

            .rl {
                width: 90%;
                margin: 0 auto;

                &>div {

                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    font-family: 'pf';
                    font-size: 14px;
                    color: #9EA0A2;
                    text-align: center;
                    line-height: 20px;
                    font-weight: 400;

                    &>div {
                        width: 52px;
                    }
                }

                &>div:nth-child(2) {
                    font-family: 'pfm';
                    font-size: 16px;
                    color: #303031;
                    text-align: center;
                    line-height: 20px;
                    font-weight: 500;
                    margin-top: 13px;

                    &>div {
                        width: 52px;
                        height: 44px;
                        // background: #0070FF;
                        border-radius: 10px;
                        display: flex;
                        flex-direction: column;
                        align-items: center;
                        justify-content: center;
                        cursor: pointer;

                        .dian {
                            width: 6px;
                            height: 6px;
                            margin-top: 3px;

                            &>div {
                                width: 6px;
                                height: 6px;
                                background: #0070FF;
                                border-radius: 50%;
                            }
                        }
                    }

                    .active {
                        background: #0070FF;
                        color: #fff;

                        .dian {
                            &>div {
                                background: #ffffff;
                            }
                        }
                    }
                }
            }

            .pre-left {
                position: absolute;
                width: 19px;
                height: 42px;
                background: url(../assets/left.png) no-repeat;
                background-size: 100% 100%;
                left: 0;
                top: 50%;
                transform: translate(0, -50%);
                cursor: pointer;
            }

            .pre-right {
                position: absolute;
                width: 19px;
                height: 42px;
                background: url(../assets/right.png) no-repeat;
                background-size: 100% 100%;
                right: 0;
                top: 50%;
                transform: translate(0, -50%);
                cursor: pointer;
            }
        }
    }

    .rcBox {
        width: 92%;
        margin: 0 auto;
        height: 50%;
        overflow-y: auto;

        &>div {
            .title {
                font-family: 'pfm';
                font-size: 16px;
                color: #4D4636;
                font-weight: 600;
                margin-bottom: 16px;
            }

            .table {
                &>div {
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    margin-bottom: 24px;

                    &>div:nth-child(1) {
                        display: flex;
                        align-items: center;
                        font-family: 'pf';
                        font-size: 16px;
                        color: #333333;
                        line-height: 20px;
                        font-weight: 400;

                        img {
                            width: 28px;
                            height: 28px;
                            margin-right: 16px;
                        }
                    }

                    &>div:nth-child(2) {
                        font-family: 'pf';
                        font-size: 16px;
                        color: #626466;
                        line-height: 16px;
                        font-weight: 400;
                        margin-right: 4px;
                    }
                }
            }
        }
    }

    /*设置滚动条的样式*/
    .rcBox::-webkit-scrollbar {
        /*滚动条整体样式*/
        width: 5px;
        /*高宽分别对应横竖滚动条的尺寸*/
    }

    .rcBox::-webkit-scrollbar-thumb {
        /*滚动条里面小方块*/
        border-radius: 10px;
        background-color: #7dafe4;
    }

    .rcBox::-webkit-scrollbar-track {
        /*滚动条里面轨道*/
        box-shadow: inset 0 0 5px rgba(29, 94, 164, 0.4);
        /* background: #ededed; */
        border-radius: 10px;

    }
}
</style>

 

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

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

相关文章

【白话机器学习系列】白话梯度下降

白话梯度下降 梯度下降是机器学习中最常见的优化算法之一。理解它的基本实现是理解所有基于它构建的高级优化算法的基础。 文章目录 优化算法一维梯度下降均方误差梯度下降什么是均方误差单权重双权重三权重三个以上权重 矩阵求导结论 优化算法 在机器学习中&#xff0c;优化是…

三维模型OBJ格式轻量化处理技术方法浅析

三维模型OBJ格式轻量化处理技术方法浅析 维模型的OBJ格式轻量化处理技术方法旨在减小模型文件大小、提高加载性能和优化渲染效果。本文将对三维模型OBJ格式轻量化处理技术方法进行浅析&#xff0c;并探讨其在数据压缩、几何简化和纹理优化等方面的应用。 首先&#xff0c;数据…

R语言统计学DOE实验设计:用平衡不完全区组设计(BIBD)分析纸飞机飞行时间实验数据...

全文链接&#xff1a;http://tecdat.cn/?p31010 平衡不完全区组设计&#xff08;BIBD&#xff09;是一个很好的研究实验设计&#xff0c;可以从统计的角度看各种所需的特征&#xff08;点击文末“阅读原文”获取完整代码数据&#xff09;。 最近我们被客户要求撰写关于BIBD的研…

【Linux从入门到精通】通信 | 共享内存(System V)

本篇文章接着上篇文章通信 | 管道通信&#xff08;匿名管道 & 命名管道&#xff09;进行讲解。本篇文章的中点内容是共享内存。 文章目录 一、初识与创建共享内存 1、1 什么是共享内存 1、2 共享内存函数 1、2、1 创建共享内存 shmget 1、2、2 ftok 生成 key 1、2、3 获取共…

nvm 在 Windows 上的使用

NVM&#xff08;Node Version Manager&#xff09;是一个用于管理和切换多个 Node.js 版本的工具。它允许你在同一台机器上同时安装和使用不同版本的 Node.js&#xff0c;而无需手动安装和卸载。 之前都是只安装一个版本的 node.js&#xff0c;该更新时更新&#xff0c;使得以前…

RK3568-GPIO控制

RK3568-GPIO控制 1. Sysfs接口 实现逻辑 芯片的GPIO由芯片的GPIO控制器来管理&#xff0c;GPIO控制器封装在芯片内部&#xff0c;控制器的驱动芯片厂家已经写好了。RK3568有五组GPIO控制器&#xff0c;每组管理32个引脚&#xff0c;对应/dev下的gpiochip0~4的设备节点。 Lin…

【Redis专题】RedisCluster集群运维与核心原理剖析

目录 课程内容一、Redis集群架构模型二、Redis集群架构搭建&#xff08;单机搭建&#xff09;2.1 在服务器下新建各个节点的配置存放目录2.2 修改配置&#xff08;以redis-8001.conf为例&#xff09; 三、Java代码实战四、Redis集群原理分析4.1 槽位定位算法4.2 跳转重定位4.3 …

【Linux】网络编程网络基础(C++)

目录 一、计算机网络背景 二、认识 "协议" 三、网络协议初识 【3.1】协议分层 【3.2】OSI七层模型 【3.3】TCP/IP五层(或四层)模型 四、网络传输基本流程 【4.1】网络传输流程图 【4.2】数据包封装和分用 五、网络中的地址管理 一、计算机网络背景 【独立…

用Python实现一个可定制风格的绘图系统

文章目录 调用绘图风格控件代码组织源代码base.pyaframe.pyalist.pyds.py Python绘图系统&#xff1a; &#x1f4c8;从0开始的3D绘图系统&#x1f4c9;一套3D坐标&#xff0c;多个函数&#x1f4ca;散点图、极坐标和子图自定义控件&#xff1a;&#x1f4c9;绘图风格&#x1…

【精华】AIGC专栏-Text/Img/Video/audio

&#xff08;一&#xff09;LLM专栏 大模型相关技术原理以及实战经验&#xff1a;liguodongiot/llm-action 1 ColossalAI &#xff08;1&#xff09;参考资料&#xff1a;700 亿参数 LLaMA2 训练加速 195%&#xff0c;基础大模型最佳实践再升级 &#xff08;2&#xff09;开…

Linux常用命令——convertquota命令

在线Linux命令查询工具 convertquota 把老的配额文件转换为新的格式 补充说明 convertquota命令用于将老的磁盘额数据文件&#xff08;“quota.user”和“quota.group”&#xff09;转换为新格式的文件&#xff08;“quota.user”和“quota.group”&#xff09;。 语法 c…

Day59|leetcode 503.下一个更大元素II、42. 接雨水

leetcode 503.下一个更大元素II 题目链接&#xff1a;503. 下一个更大元素 II - 力扣&#xff08;LeetCode&#xff09; 视频链接&#xff1a;单调栈&#xff0c;成环了可怎么办&#xff1f;LeetCode&#xff1a;503.下一个更大元素II_哔哩哔哩_bilibili 题目概述 给定一个循环…

接口使用的最佳时机

1. 引言 接口在系统设计中&#xff0c;以及代码重构优化中&#xff0c;是一个不可或缺的工具&#xff0c;能够帮助我们写出可扩展&#xff0c;可维护性更强的程序。 在本文&#xff0c;我们将介绍什么是接口&#xff0c;在此基础上&#xff0c;通过一个例子来介绍接口的优点。…

【2023高教社杯】A题 定日镜场的优化设计 问题分析及数学模型

【2023高教社杯】A题 定日镜场的优化设计 问题分析及数学模型 1 题目 构建以新能源为主体的新型电力系统&#xff0c;是我国实现“碳达峰”“碳中和”目标的一项重要措施。塔式太阳能光热发电是一种低碳环保的新型清洁能源技术[1]。 定日镜是塔式太阳能光热发电站&#xff08;…

微电网的概念

微电网分布式控制理论与方法  顾伟等 微电网的概念和作用 微电网是由多种分布式电源、储能、负载以及相关监控保护装置构成的能够实现自我控制和管理的自治型电力系统&#xff0c;既可以与电网并网进行&#xff0c;也可以以孤岛运行。 分布式发电是指将容量在兆瓦以内的可再…

Elsevier出版社 | 优质好刊合集

【SciencePub学术】 爱思唯尔(Elsevier)是一家全球专业从事科学与医学的信息分析公司作为出版公司&#xff0c;成立于1880年&#xff0c;其产品包括《柳叶刀》、《四面体》和《细胞》等学术期刊&#xff0c;ScienceDirect电子期刊集&#xff0c; “趋势”(Trends)系列和“新见…

uniapp项目运行Missing script: “dev“, To see a list of scripts, run:

webstorm 打开项目根目录不对&#xff0c;打开到了项目上一级。 另外一个原因是&#xff0c;当前项目是Hbuilder 可视化界面创建的&#xff0c;不能在terminal直接脚本指令启动。 可以webstorm 安装支持uniapp项目插件&#xff0c;然后创建一个运行器&#xff0c;运行h5。 安…

vue 验证码 图片点击

实现登陆验证 图片依次点击功能 demo &#xff0c;上图可以根据demo修改&#xff0c;直接拿用 <template><div><div class"big-box" id"BigBox" :style"background-image:url( imgCodeUrl )"><div class"click-box…

C#,《小白学程序》第十八课:随机数(Random)第五,方差及标准方差(标准差)的计算方法与代码

1 文本格式 /// <summary> /// 《小白学程序》第十八课&#xff1a;随机数&#xff08;Random&#xff09;第五&#xff0c;方差及标准方差&#xff08;标准差&#xff09;的计算方法与代码 /// 方差 SUM(&#xff08;Xi - X)^2 ) / n i0...n-1 X Average of X[i] ///…

APP备案流程详细解读

背景介绍 2023年8月4日&#xff0c;工信部发布《工业和信息化部关于开展移动互联网应用程序备案工作的通知》。 在中华人民共和国境内从事互联网信息服务的APP主办者&#xff0c;应当依照《中华人民共和国反电信网络诈骗法》《互联网信息服务管理办法》&#xff08;国务院令第…