| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <template>
- <div class="week-days-content">
- <span class="day-item" v-for="(item, index) in weekdays" @click="itemClick(item,index)">
- <span :class="['weekday-name',active == index ?'today-active':'']">{{item.weekdayName}}</span>
- <span :class="['day-date',active == index ?'date-active':'']">{{item.day}}</span>
- <span class="day-has-suit"></span>
- </span>
- </div>
- </template>
- <script>
- import * as dateUtils from '../utils/dateUtils'
- export default {
- name: 'WeekDays',
- data() {
- return {
- active: -1
- }
- },
- computed:{
- weekdays:function() {
- let arr = dateUtils.getWeekDays(this.start,this.end)
- let findIndex = arr.findIndex(t=>t.isActive)
- if(findIndex > -1){
- arr[findIndex].isActive = false
- }
- this.active = findIndex
- return arr
- }
- },
- mounted () {
- },
- props:{
- 'start': {
- type: Date,
- default: new Date()
- },
- 'end': {
- type: Date,
- default: new Date()
- }
- },
- methods:{
- itemClick(item,index) {
- this.weekdays.forEach(t=>t.isActive = false)
- this.active = index
- this.$emit('on-item-click',item)
- }
- }
- }
- </script>
- <style scoped>
- .week-days-content {
- width: 100%;
- display: flex;
- }
- .day-item{
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- flex: 1;
- }
- .day-item span {
- width: 100%;
- text-align: center;
- }
- .weekday-name {
- flex: 1;
- font-size: 0.5em;
- color: rgba(0,0,0,0.54);
- margin-bottom: 10px;
- }
- .day-has-suit{
- display: block;
- width: 6px !important;
- height: 6px !important;
- background-color: #31CA8A;
- border-radius: 100px;
- margin-top: 10px;
- }
- .today-active{
- color: black;
- font-weight: 600;
- }
- .date-active{
- border-radius: 100px;
- background-color: #7D72F2;
- color: white;
- }
- .day-date{
- font-size: 1em;
- display: block;
- width: 5vw !important;
- height: 5vw;
- line-height: 5vw;
- border-radius: 100px;
- }
- </style>
|