el-calendar制作OA打卡日历

1.vue+elementui需求如图所示:
在这里插入图片描述
2.废话不多说,直接贴代码:

<el-calendar v-model="value">
        <div slot="dateCell" slot-scope="{ data }" class="calendarItem">
          <p :class="data.isSelected ? 'is-selected' : ''">
            {{ data.day.split("-").slice(2).join("-") }}
            <!-- {{ data.isSelected ? "✔️" : "" }} -->
          </p>
          <div v-for="item in calendarData" :key="item.id">
            <!-- <div v-if="(item.months).indexOf(data.day.split('-').slice(1).join('-')) != -1"> -->
              <div v-if="(item.days).indexOf(data.day.split('-').slice(2).join('-')) != -1">
                <div :class="item.status == '0'? 'green' : 'yellow'"></div>
                <el-row class="calendarContent">
                  <el-col :span="12">
                    <p>{{item.morning}}</p>
                    <p>{{item.afternoon}}</p>
                  </el-col>
                  <el-col :span="12">
                    {{item.workHours}}
                  </el-col>
                </el-row>
              </div>
            <!-- </div> -->
          </div>
        </div>
      </el-calendar>

  data() {
    return {
      calendarData: [
        {id:0,status: '1', months: ['05'],days: ['02'],afternoon: '下班打卡: 19:45',morning: '上班打卡: 8:45', workHours: '工作10小时'},
        {id:1,status: '0', months: ['05'],days: ['03'],afternoon: '下班打卡: 19:45',morning: '上班打卡: 8:45', workHours: '工作10小时'},
        {id:2,status: '1', months: ['05'],days: ['06'],afternoon: '下班打卡: 19:45',morning: '上班打卡: 8:45', workHours: '工作10小时'},
        {id:3,status: '1', months: ['05'],days: ['09'],afternoon: '下班打卡: 19:45',morning: '上班打卡: 8:45', workHours: '工作10小时'}, 
        {id:4,status: '0', months: ['05'],days: ['15'],afternoon: '下班打卡: 19:45',morning: '上班打卡: 8:45', workHours: '工作10小时'},
        {id:5,status: '0', months: ['05'],days: ['16'],afternoon: '下班打卡: 19:45',morning: '上班打卡: 8:45', workHours: '工作10小时'},
        {id:26,status: '1', months: ['05'],days: ['17'],afternoon: '下班打卡: 19:45',morning: '上班打卡: 8:45', workHours: '工作10小时'},
        {id:7,status: '1', months: ['05'],days: ['18'],afternoon: '下班打卡: 19:45',morning: '上班打卡: 8:45', workHours: '工作10小时'}   
      ],
      value: new Date()
    };
  },
.el-calendar /deep/ .el-calendar__header {
  display: none !important;
}
.el-calendar /deep/ .el-calendar-table thead th {
  height: 70px;
}
.el-calendar /deep/ .el-calendar-table .el-calendar-day {
  height: 100px;
}
.calendarItem{
  position: relative;
}
.green{
  width: 60px;
  height: 20px;
  position: absolute;
  right: 0;
  top: 0;
  border-radius: 2px;
  background-color: rgb(53, 155, 53);
}
.yellow{
  width: 60px;
  height: 20px;
  position: absolute;
  right: 0;
  top: 0;
  border-radius: 2px;
  background-color: rgb(241, 209, 67);
}
.calendarContent{
  height: 60px;
}
.calendarContent .el-col{
  height: 60px;
  line-height: 25px;
  font-size: 14px;
}
.calendarContent .el-col p{
  margin: 0 0 10px 0
}
.calendarContent .el-col:nth-child(2){
  line-height: 60px;
  text-align: right;
}
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值