| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- <template>
- <view class="container">
- <view class="header">
- <text class="title">预约管理</text>
- <text class="subtitle">查看并管理测评预约</text>
- </view>
- <!-- 状态筛选 -->
- <view class="filter-bar">
- <view class="filter-item" :class="{ active: filterStatus === null }" @click="filterStatus = null">
- <text>全部</text>
- </view>
- <view class="filter-item" :class="{ active: filterStatus === 0 }" @click="filterStatus = 0">
- <text>待确认</text>
- </view>
- <view class="filter-item" :class="{ active: filterStatus === 1 }" @click="filterStatus = 1">
- <text>已确认</text>
- </view>
- <view class="filter-item" :class="{ active: filterStatus === 2 }" @click="filterStatus = 2">
- <text>已完成</text>
- </view>
- </view>
- <!-- 预约列表 -->
- <view class="appointment-list">
- <view class="appointment-card" v-for="item in filteredList" :key="item.id">
- <view class="card-header">
- <view class="child-info">
- <text class="child-name">孩子ID: {{ item.memberId || '未指定' }}</text>
- </view>
- <view class="status-badge" :class="'status-' + item.status">
- <text>{{ getStatusText(item.status) }}</text>
- </view>
- </view>
- <view class="card-body">
- <view class="info-row">
- <text class="label">预约日期</text>
- <text class="value">{{ item.appointmentDate || '未设置' }}</text>
- </view>
- <view class="info-row">
- <text class="label">预约时间</text>
- <text class="value">{{ item.appointmentTime || '未设置' }}</text>
- </view>
- <view class="info-row" v-if="item.notes">
- <text class="label">备注</text>
- <text class="value">{{ item.notes }}</text>
- </view>
- <view class="info-row">
- <text class="label">创建时间</text>
- <text class="value">{{ formatTime(item.createdAt) }}</text>
- </view>
- </view>
- <view class="card-actions">
- <button v-if="item.status === 0" class="btn-confirm" size="mini" @click="handleConfirm(item.id)">确认预约</button>
- <button v-if="item.status === 1" class="btn-complete" size="mini" @click="handleComplete(item.id)">录入结果</button>
- <button v-if="item.status === 0" class="btn-cancel" size="mini" @click="handleCancel(item.id)">取消</button>
- </view>
- </view>
- </view>
- <view class="empty-state" v-if="filteredList.length === 0">
- <text class="empty-icon">📋</text>
- <text class="empty-text">暂无预约记录</text>
- </view>
- <view class="bottom-space"></view>
- </view>
- </template>
- <script>
- import { getGuideAppointments, confirmAppointment, cancelAppointment } from '../../utils/api.js'
- import { parseDate } from '../../utils/format.js'
- export default {
- data() {
- return {
- appointments: [],
- filterStatus: null
- }
- },
- computed: {
- filteredList() {
- if (this.filterStatus === null) return this.appointments
- return this.appointments.filter(item => item.status === this.filterStatus)
- }
- },
- onShow() {
- this.loadAppointments()
- },
- methods: {
- async loadAppointments() {
- try {
- const res = await getGuideAppointments()
- if (res.code === 200) {
- this.appointments = res.data || []
- }
- } catch (e) {
- console.error('加载预约列表失败', e)
- }
- },
- getStatusText(status) {
- const map = { 0: '待确认', 1: '已确认', 2: '已完成', 3: '已取消', 4: '未到' }
- return map[status] || '未知'
- },
- formatTime(ts) {
- if (!ts) return ''
- const d = parseDate(ts)
- if (!d) return ''
- return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`
- },
- handleConfirm(id) {
- uni.showModal({
- title: '确认预约',
- content: '确认此预约?',
- success: async (res) => {
- if (res.confirm) {
- try {
- const result = await confirmAppointment(id)
- if (result.code === 200) {
- uni.showToast({ title: '已确认', icon: 'success' })
- this.loadAppointments()
- }
- } catch (e) {
- uni.showToast({ title: '操作失败', icon: 'none' })
- }
- }
- }
- })
- },
- handleComplete(id) {
- uni.navigateTo({ url: '/pages/assessment/record?appointmentId=' + id })
- },
- handleCancel(id) {
- uni.showModal({
- title: '取消预约',
- content: '确定取消此预约?',
- success: async (res) => {
- if (res.confirm) {
- try {
- const result = await cancelAppointment(id)
- if (result.code === 200) {
- uni.showToast({ title: '已取消', icon: 'success' })
- this.loadAppointments()
- }
- } catch (e) {
- uni.showToast({ title: '操作失败', icon: 'none' })
- }
- }
- }
- })
- }
- }
- }
- </script>
- <style scoped>
- .container {
- padding: 30rpx;
- background: #F8F8F8;
- min-height: 100vh;
- }
- .header {
- text-align: center;
- padding: 40rpx 0 30rpx;
- }
- .title {
- font-size: 48rpx;
- font-weight: bold;
- color: #333;
- display: block;
- margin-bottom: 16rpx;
- }
- .subtitle {
- font-size: 26rpx;
- color: #666;
- }
- .filter-bar {
- display: flex;
- gap: 16rpx;
- margin-bottom: 30rpx;
- padding: 16rpx;
- background: #fff;
- border-radius: 20rpx;
- }
- .filter-item {
- flex: 1;
- text-align: center;
- padding: 12rpx 0;
- border-radius: 10rpx;
- font-size: 26rpx;
- color: #666;
- background: #F8F8F8;
- }
- .filter-item.active {
- background: #667eea;
- color: #fff;
- }
- .appointment-list {
- display: flex;
- flex-direction: column;
- gap: 24rpx;
- }
- .appointment-card {
- background: #fff;
- border-radius: 20rpx;
- padding: 30rpx;
- }
- .card-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- padding-bottom: 16rpx;
- border-bottom: 1rpx solid #eee;
- }
- .child-name {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- }
- .status-badge {
- padding: 6rpx 16rpx;
- border-radius: 8rpx;
- font-size: 22rpx;
- }
- .status-0 { background: #FFF3E0; color: #FF9800; }
- .status-1 { background: #E3F2FD; color: #2196F3; }
- .status-2 { background: #E8F5E9; color: #4CAF50; }
- .status-3 { background: #F5F5F5; color: #9E9E9E; }
- .status-4 { background: #FFEBEE; color: #F44336; }
- .card-body {
- margin-bottom: 20rpx;
- }
- .info-row {
- display: flex;
- justify-content: space-between;
- padding: 10rpx 0;
- font-size: 26rpx;
- }
- .label { color: #999; }
- .value { color: #333; }
- .card-actions {
- display: flex;
- gap: 16rpx;
- padding-top: 16rpx;
- border-top: 1rpx dashed #eee;
- }
- .btn-confirm {
- flex: 1;
- background: #667eea;
- color: #fff;
- font-size: 26rpx;
- border-radius: 10rpx;
- }
- .btn-complete {
- flex: 1;
- background: #4CAF50;
- color: #fff;
- font-size: 26rpx;
- border-radius: 10rpx;
- }
- .btn-cancel {
- flex: 1;
- background: #F5F5F5;
- color: #999;
- font-size: 26rpx;
- border-radius: 10rpx;
- }
- .empty-state {
- text-align: center;
- padding: 120rpx 0;
- }
- .empty-icon {
- font-size: 80rpx;
- display: block;
- margin-bottom: 20rpx;
- }
- .empty-text {
- font-size: 28rpx;
- color: #999;
- display: block;
- }
- .bottom-space {
- height: 140rpx;
- }
- </style>
|