TimeDate.vue
4.13 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!-- 日期时间 - 选择器 -->
<template>
<div class="time-selector">
<div class="time-selector-header">
<p>邀约日历</p>
<p>2020年</p>
</div>
<div class="time-selector-container">
<template class="date-left-tips">
<div class="date-tips-time">
<p>上午9:00</p>
<p>中午12:00</p>
<p>晚上18:00</p>
</div>
<p class="date-y-line" />
</template>
<el-button class="arrow-left-icon"
icon="el-icon-d-arrow-left"
type="text"
:disabled="currentWeek === 1"
@click="handleWeek(false)" />
<template>
<div class="date-picker">
<div v-for="(item, index) in dateList.slice(currentWeek * 7 - 7, currentWeek * 7)"
:key="index"
class="wrapper">
<span>
<p v-for="(info, infoIndex) in appointData[index].infoList"
:key="infoIndex">
<el-popover open-delay="600"
placement="bottom-start"
title=""
trigger="hover"
width="200"
:disabled="info.status === 0">
<div>
<p>1、客户姓名,时间,项目</p>
<p>2、客户姓名,时间,项目</p>
<p>余位数:8</p>
</div>
<el-button slot="reference"
class="col-width hour-template"
:class="{ 'status-full': info.status === 2, 'status-remain': info.status === 1 }"
@click="handleAppoint(item, infoIndex)">
{{ appointStatusList[info.status] }}
</el-button>
</el-popover>
</p>
</span>
</div>
</div>
<p class="date-x-line" />
<div class="date-picker">
<div v-for="(item, index) in dateList.slice(currentWeek * 7 - 7, currentWeek * 7)"
:key="index"
class="wrapper">
<el-button class="date-btn col-width"
type="text"
:class="{ 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>
</template>
<el-button icon="el-icon-d-arrow-right"
type="text"
:disabled="currentWeek === 5"
@click="handleWeek(true)" />
</div>
</div>
</template>
<script>
import { appointDays } from "@/common/format";
export default {
name: "TimeDate",
props: {
appointData: {
type: Array,
default: () => [],
},
hoursList: {
type: Array,
default: () => [],
},
},
data() {
return {
// 7天为一个周期,预约时间为35天,一共5个周期,当前周期
currentWeek: 1,
// 日期
dateIndex: 0,
weekList: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
dateList: new Array(appointDays).fill(null).map((item, index) => {
let date = new Date(new Date().setDate(new Date().getDate() + index));
return {
date: date.toLocaleDateString(),
week: date.getDay(),
active: !index,
};
}),
// 时间
appointStatusList: ["空", "余", "满"],
};
},
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>