Coach.vue
5.54 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<template>
<!-- 老师端显示 -->
<el-card class="account-container coach" v-if="isTeacher">
<div class="control">
<p class="control_name">我的预约</p>
<div class="select_box">
<p class="select_tag">预约日期:</p>
<el-date-picker v-model="dayName" value-format="YYYY-MM-DD" type="date" placeholder="全部" :clearable="false" @change="dayNameChange">
</el-date-picker>
</div>
</div>
<el-table v-loading="loading" :data="tableData" style="width: 100%" stripe v-if="tableData.length>0">
<el-table-column label="时间" align="center">
<template #default="props">
<p class="time">{{Moment(props.row.dayName).format('YYYY-MM-DD')}} {{props.row.startTime}}-{{props.row.endTime}}</p>
</template>
</el-table-column>
<el-table-column prop="studentName" label="学生姓名" align="center">
</el-table-column>
<el-table-column prop="class" label="班级" align="center">
</el-table-column>
<el-table-column prop="bookTypeName" label="咨询问题" align="center">
</el-table-column>
<el-table-column label="状态" align="center">
<template #default="props">
<p>{{props.row.statusName}}</p>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<div v-if="scope.row.statusName=='已预约'">
<a @click="handleAssessment(scope.row)" style="text-decoration: underline;cursor: pointer; margin-right: 10px">评估</a>
<el-popconfirm title="确定取消?" confirmButtonText="确认" cancelButtonText="取消" @confirm="handleCancelBooking(scope.row)">
<template #reference>
<a style="color:#FF3A3A;text-decoration: underline;cursor:pointer;">取消</a>
</template>
</el-popconfirm>
</div>
<div v-if="scope.row.statusName=='已有评估记录'">
<a @click="handleAssessment(scope.row)" style="text-decoration: underline;cursor: pointer; margin-right: 10px">评估</a>
</div>
</template>
</el-table-column>
</el-table>
<el-empty description="暂无内容" v-if="tableData.length==0"></el-empty>
<el-pagination :hide-on-single-page="total<=10" background layout="prev, pager, next" v-model="currentPage" :total="total" @current-change="handleCurrentChange">
</el-pagination>
</el-card>
</template>
<script>
import { onMounted, reactive, ref, toRefs } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useStore } from 'vuex'
import { ElMessage } from 'element-plus'
import axios from '@/utils/axios'
import Moment from 'moment'
export default {
name: 'Term',
setup () {
const route = useRoute()
const router = useRouter()
const store = useStore()
const state = reactive({
dayName: '',
search: '',
tableData: [],
total: 0,
currentPage: 1,
loading: false,
isTeacher: true,
UserId:store.state.userInfo?.userId
})
onMounted(() => {
if (state.isTeacher) {
// state.dayName = Moment().format('YYYY-MM-DD');
getBookingRecordTeacher()
}
})
const dayNameChange = () => {
getBookingRecordTeacher()
}
// 教师收到的预约
const getBookingRecordTeacher = () => {
state.loading = true
if (!state.UserId) return;
axios.post('/SchedualBooking/BookingRecord/Teacher/List', {
"DetailId": 0,
// "StudentId": "string",
"TeacherId": state.UserId,
"Type": 1,
"DayName": state.dayName,
// "StudentName": "string",
// "ChooseType": 1,
"PageIndex": state.currentPage,
"PageSize": 10
}).then(res => {
// console.log('教师收到的预约:', res)
let tableData = res.data;
for (let i in tableData) {
tableData[i].time = [tableData[i].startTime, tableData[i].endTime]
}
state.tableData = tableData
state.total = res.count
state.loading = false
}).catch(err => {
console.log('err', err)
})
}
// 取消预约
const handleCancelBooking = (item) => {
axios.post('/SchedualBooking/StudentBooking', {
"DetailId": item.detailId,
"StudentId": item.studentId,
"IsBooking": false,
"BookTypeName": item.bookTypeName,
"BookDescription": item.bookDescription
}).then(() => {
ElMessage.success('取消预约成功')
state.currentPage = 1;
getBookingRecordTeacher()
})
}
// 页码改变时
const handleCurrentChange = (e) => {
state.currentPage = e;
getBookingRecordTeacher()
}
// 点击进入排班
const handleAssessment = (item) => {
router.push({ path: '/assessment', query: { detailId: item.detailId,UserId:item.studentId } })
}
return {
...toRefs(state),
handleCancelBooking,
handleAssessment,
handleCurrentChange,
Moment,
dayNameChange
}
}
}
</script>
<style lang="scss" scoped>
.control {
display: flex;
align-items: center;
justify-content: space-between;
.control_name {
font-size: 23px;
font-weight: bold;
}
.el-input {
width: 300px;
}
.booking_time {
font-size: 15px;
span {
margin-left: 13px;
font-size: 14px;
line-height: 27px;
padding: 0 10px;
color: #3a84ff;
background: #f8f9fb;
border-radius: 4px;
}
}
}
.coach {
.select_box {
display: flex;
align-items: center;
}
}
</style>