TimeDate.vue
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!-- 日期时间 - 选择器 -->
<template>
<div class="time-selector">
<el-button icon="el-icon-d-arrow-left" type="text" :disabled="currentWeek === 1" @click="handleWeek(false)"></el-button>
<div class="date-picker">
<div
class="wrapper"
v-for="(item, index) in dateList.slice(currentWeek * 7 - 7, currentWeek * 7)"
:key="index"
>
<span>
<p
v-for="(info, infoIndex) in appointData[index].infoList"
:key="infoIndex"
>
<el-popover
placement="bottom-start"
title=""
width="200"
open-delay="600"
trigger="hover"
:disabled="info.status !== 1"
>
<div>
<p>1、客户姓名,时间,项目</p>
<p>2、客户姓名,时间,项目</p>
<p>余位数:8</p>
</div>
<el-button
class="col-width hour-block"
slot="reference"
:disabled="((item.date == new Date().toLocaleDateString()) && (+hoursList[infoIndex].hour.split(':')[0] <= new Date().getHours())) || (info.status === 2)"
@click="handleAppoint(item, infoIndex)"
>{{appointStatusList[info.status]}}</el-button>
</el-popover>
</p>
</span>
<el-button
type="text"
:class="{'date-btn': true, 'col-width': true, 'active': item.active}"
@click="handleSelectDate(index)"
>
<p>{{item.date.split('/')[1] + '.' + item.date.split('/')[2]}}</p>
<p>{{weekList[item.week]}}</p>
</el-button>
</div>
</div>
<el-button icon="el-icon-d-arrow-right" type="text" :disabled="currentWeek === 5" @click="handleWeek(true)"></el-button>
</div>
</template>
<script>
import { appointDays } from '@/common/constants'
export default {
name: 'TimeDate',
data() {
return {
// 7天为一个周期,预约时间为35天,一共5个周期,当前周期
currentWeek: 1,
// 日期
dateIndex: 0,
weekList: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
dateList: new Array(appointDays).fill(null).map((item, index) => {
var date = new Date(new Date().setDate(new Date().getDate() + index))
return {
date: date.toLocaleDateString(),
week: date.getDay(),
active: !index
}
}),
// 时间
appointStatusList: ['空', '余', '满']
}
},
props: {
appointData: {
type: Array,
default: () => []
},
hoursList: {
type: Array,
default: () => []
}
},
mounted() { },
methods: {
// 日期选择
handleSelectDate(currentIndex) {
this.dateList[this.dateIndex].active = false
this.dateIndex = currentIndex
this.dateList[currentIndex].active = true
},
handleAppoint(date, hourIndex) {
this.$emit('handleAppoint', { date: date.date, hour: this.hoursList[hourIndex].hour })
},
handleWeek(isAdd) {
isAdd ? this.currentWeek++ : this.currentWeek--
}
}
}
</script>
<style lang="scss" scoped>
@import './css/timeDateStyle.scss';
</style>