appointments.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <text class="title">预约管理</text>
  5. <text class="subtitle">查看并管理测评预约</text>
  6. </view>
  7. <!-- 状态筛选 -->
  8. <view class="filter-bar">
  9. <view class="filter-item" :class="{ active: filterStatus === null }" @click="filterStatus = null">
  10. <text>全部</text>
  11. </view>
  12. <view class="filter-item" :class="{ active: filterStatus === 0 }" @click="filterStatus = 0">
  13. <text>待确认</text>
  14. </view>
  15. <view class="filter-item" :class="{ active: filterStatus === 1 }" @click="filterStatus = 1">
  16. <text>已确认</text>
  17. </view>
  18. <view class="filter-item" :class="{ active: filterStatus === 2 }" @click="filterStatus = 2">
  19. <text>已完成</text>
  20. </view>
  21. </view>
  22. <!-- 预约列表 -->
  23. <view class="appointment-list">
  24. <view class="appointment-card" v-for="item in filteredList" :key="item.id">
  25. <view class="card-header">
  26. <view class="child-info">
  27. <text class="child-name">孩子ID: {{ item.childId || '未指定' }}</text>
  28. </view>
  29. <view class="status-badge" :class="'status-' + item.status">
  30. <text>{{ getStatusText(item.status) }}</text>
  31. </view>
  32. </view>
  33. <view class="card-body">
  34. <view class="info-row">
  35. <text class="label">预约日期</text>
  36. <text class="value">{{ item.appointmentDate || '未设置' }}</text>
  37. </view>
  38. <view class="info-row">
  39. <text class="label">预约时间</text>
  40. <text class="value">{{ item.appointmentTime || '未设置' }}</text>
  41. </view>
  42. <view class="info-row" v-if="item.notes">
  43. <text class="label">备注</text>
  44. <text class="value">{{ item.notes }}</text>
  45. </view>
  46. <view class="info-row">
  47. <text class="label">创建时间</text>
  48. <text class="value">{{ formatTime(item.createdAt) }}</text>
  49. </view>
  50. </view>
  51. <view class="card-actions">
  52. <button v-if="item.status === 0" class="btn-confirm" size="mini" @click="handleConfirm(item.id)">确认预约</button>
  53. <button v-if="item.status === 1" class="btn-complete" size="mini" @click="handleComplete(item.id)">录入结果</button>
  54. <button v-if="item.status === 0" class="btn-cancel" size="mini" @click="handleCancel(item.id)">取消</button>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="empty-state" v-if="filteredList.length === 0">
  59. <text class="empty-icon">📋</text>
  60. <text class="empty-text">暂无预约记录</text>
  61. </view>
  62. <view class="bottom-space"></view>
  63. </view>
  64. </template>
  65. <script>
  66. import { getGuideAppointments, confirmAppointment, cancelAppointment } from '../../utils/api.js'
  67. export default {
  68. data() {
  69. return {
  70. appointments: [],
  71. filterStatus: null
  72. }
  73. },
  74. computed: {
  75. filteredList() {
  76. if (this.filterStatus === null) return this.appointments
  77. return this.appointments.filter(item => item.status === this.filterStatus)
  78. }
  79. },
  80. onShow() {
  81. this.loadAppointments()
  82. },
  83. methods: {
  84. async loadAppointments() {
  85. try {
  86. const res = await getGuideAppointments()
  87. if (res.code === 200) {
  88. this.appointments = res.data || []
  89. }
  90. } catch (e) {
  91. console.error('加载预约列表失败', e)
  92. }
  93. },
  94. getStatusText(status) {
  95. const map = { 0: '待确认', 1: '已确认', 2: '已完成', 3: '已取消', 4: '未到' }
  96. return map[status] || '未知'
  97. },
  98. formatTime(ts) {
  99. if (!ts) return ''
  100. const d = new Date(ts)
  101. 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')}`
  102. },
  103. handleConfirm(id) {
  104. uni.showModal({
  105. title: '确认预约',
  106. content: '确认此预约?',
  107. success: async (res) => {
  108. if (res.confirm) {
  109. try {
  110. const result = await confirmAppointment(id)
  111. if (result.code === 200) {
  112. uni.showToast({ title: '已确认', icon: 'success' })
  113. this.loadAppointments()
  114. }
  115. } catch (e) {
  116. uni.showToast({ title: '操作失败', icon: 'none' })
  117. }
  118. }
  119. }
  120. })
  121. },
  122. handleComplete(id) {
  123. uni.navigateTo({ url: '/pages/assessment/record?appointmentId=' + id })
  124. },
  125. handleCancel(id) {
  126. uni.showModal({
  127. title: '取消预约',
  128. content: '确定取消此预约?',
  129. success: async (res) => {
  130. if (res.confirm) {
  131. try {
  132. const result = await cancelAppointment(id)
  133. if (result.code === 200) {
  134. uni.showToast({ title: '已取消', icon: 'success' })
  135. this.loadAppointments()
  136. }
  137. } catch (e) {
  138. uni.showToast({ title: '操作失败', icon: 'none' })
  139. }
  140. }
  141. }
  142. })
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped>
  148. .container {
  149. padding: 30rpx;
  150. background: #F8F8F8;
  151. min-height: 100vh;
  152. }
  153. .header {
  154. text-align: center;
  155. padding: 40rpx 0 30rpx;
  156. }
  157. .title {
  158. font-size: 48rpx;
  159. font-weight: bold;
  160. color: #333;
  161. display: block;
  162. margin-bottom: 16rpx;
  163. }
  164. .subtitle {
  165. font-size: 26rpx;
  166. color: #666;
  167. }
  168. .filter-bar {
  169. display: flex;
  170. gap: 16rpx;
  171. margin-bottom: 30rpx;
  172. padding: 16rpx;
  173. background: #fff;
  174. border-radius: 20rpx;
  175. }
  176. .filter-item {
  177. flex: 1;
  178. text-align: center;
  179. padding: 12rpx 0;
  180. border-radius: 10rpx;
  181. font-size: 26rpx;
  182. color: #666;
  183. background: #F8F8F8;
  184. }
  185. .filter-item.active {
  186. background: #667eea;
  187. color: #fff;
  188. }
  189. .appointment-list {
  190. display: flex;
  191. flex-direction: column;
  192. gap: 24rpx;
  193. }
  194. .appointment-card {
  195. background: #fff;
  196. border-radius: 20rpx;
  197. padding: 30rpx;
  198. }
  199. .card-header {
  200. display: flex;
  201. justify-content: space-between;
  202. align-items: center;
  203. margin-bottom: 20rpx;
  204. padding-bottom: 16rpx;
  205. border-bottom: 1rpx solid #eee;
  206. }
  207. .child-name {
  208. font-size: 30rpx;
  209. font-weight: bold;
  210. color: #333;
  211. }
  212. .status-badge {
  213. padding: 6rpx 16rpx;
  214. border-radius: 8rpx;
  215. font-size: 22rpx;
  216. }
  217. .status-0 { background: #FFF3E0; color: #FF9800; }
  218. .status-1 { background: #E3F2FD; color: #2196F3; }
  219. .status-2 { background: #E8F5E9; color: #4CAF50; }
  220. .status-3 { background: #F5F5F5; color: #9E9E9E; }
  221. .status-4 { background: #FFEBEE; color: #F44336; }
  222. .card-body {
  223. margin-bottom: 20rpx;
  224. }
  225. .info-row {
  226. display: flex;
  227. justify-content: space-between;
  228. padding: 10rpx 0;
  229. font-size: 26rpx;
  230. }
  231. .label { color: #999; }
  232. .value { color: #333; }
  233. .card-actions {
  234. display: flex;
  235. gap: 16rpx;
  236. padding-top: 16rpx;
  237. border-top: 1rpx dashed #eee;
  238. }
  239. .btn-confirm {
  240. flex: 1;
  241. background: #667eea;
  242. color: #fff;
  243. font-size: 26rpx;
  244. border-radius: 10rpx;
  245. }
  246. .btn-complete {
  247. flex: 1;
  248. background: #4CAF50;
  249. color: #fff;
  250. font-size: 26rpx;
  251. border-radius: 10rpx;
  252. }
  253. .btn-cancel {
  254. flex: 1;
  255. background: #F5F5F5;
  256. color: #999;
  257. font-size: 26rpx;
  258. border-radius: 10rpx;
  259. }
  260. .empty-state {
  261. text-align: center;
  262. padding: 120rpx 0;
  263. }
  264. .empty-icon {
  265. font-size: 80rpx;
  266. display: block;
  267. margin-bottom: 20rpx;
  268. }
  269. .empty-text {
  270. font-size: 28rpx;
  271. color: #999;
  272. display: block;
  273. }
  274. .bottom-space {
  275. height: 140rpx;
  276. }
  277. </style>