appointments.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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.memberId || '未指定' }}</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. import { parseDate } from '../../utils/format.js'
  68. export default {
  69. data() {
  70. return {
  71. appointments: [],
  72. filterStatus: null
  73. }
  74. },
  75. computed: {
  76. filteredList() {
  77. if (this.filterStatus === null) return this.appointments
  78. return this.appointments.filter(item => item.status === this.filterStatus)
  79. }
  80. },
  81. onShow() {
  82. this.loadAppointments()
  83. },
  84. methods: {
  85. async loadAppointments() {
  86. try {
  87. const res = await getGuideAppointments()
  88. if (res.code === 200) {
  89. this.appointments = res.data || []
  90. }
  91. } catch (e) {
  92. console.error('加载预约列表失败', e)
  93. }
  94. },
  95. getStatusText(status) {
  96. const map = { 0: '待确认', 1: '已确认', 2: '已完成', 3: '已取消', 4: '未到' }
  97. return map[status] || '未知'
  98. },
  99. formatTime(ts) {
  100. if (!ts) return ''
  101. const d = parseDate(ts)
  102. if (!d) return ''
  103. 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')}`
  104. },
  105. handleConfirm(id) {
  106. uni.showModal({
  107. title: '确认预约',
  108. content: '确认此预约?',
  109. success: async (res) => {
  110. if (res.confirm) {
  111. try {
  112. const result = await confirmAppointment(id)
  113. if (result.code === 200) {
  114. uni.showToast({ title: '已确认', icon: 'success' })
  115. this.loadAppointments()
  116. }
  117. } catch (e) {
  118. uni.showToast({ title: '操作失败', icon: 'none' })
  119. }
  120. }
  121. }
  122. })
  123. },
  124. handleComplete(id) {
  125. uni.navigateTo({ url: '/pages/assessment/record?appointmentId=' + id })
  126. },
  127. handleCancel(id) {
  128. uni.showModal({
  129. title: '取消预约',
  130. content: '确定取消此预约?',
  131. success: async (res) => {
  132. if (res.confirm) {
  133. try {
  134. const result = await cancelAppointment(id)
  135. if (result.code === 200) {
  136. uni.showToast({ title: '已取消', icon: 'success' })
  137. this.loadAppointments()
  138. }
  139. } catch (e) {
  140. uni.showToast({ title: '操作失败', icon: 'none' })
  141. }
  142. }
  143. }
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style scoped>
  150. .container {
  151. padding: 30rpx;
  152. background: #F8F8F8;
  153. min-height: 100vh;
  154. }
  155. .header {
  156. text-align: center;
  157. padding: 40rpx 0 30rpx;
  158. }
  159. .title {
  160. font-size: 48rpx;
  161. font-weight: bold;
  162. color: #333;
  163. display: block;
  164. margin-bottom: 16rpx;
  165. }
  166. .subtitle {
  167. font-size: 26rpx;
  168. color: #666;
  169. }
  170. .filter-bar {
  171. display: flex;
  172. gap: 16rpx;
  173. margin-bottom: 30rpx;
  174. padding: 16rpx;
  175. background: #fff;
  176. border-radius: 20rpx;
  177. }
  178. .filter-item {
  179. flex: 1;
  180. text-align: center;
  181. padding: 12rpx 0;
  182. border-radius: 10rpx;
  183. font-size: 26rpx;
  184. color: #666;
  185. background: #F8F8F8;
  186. }
  187. .filter-item.active {
  188. background: #667eea;
  189. color: #fff;
  190. }
  191. .appointment-list {
  192. display: flex;
  193. flex-direction: column;
  194. gap: 24rpx;
  195. }
  196. .appointment-card {
  197. background: #fff;
  198. border-radius: 20rpx;
  199. padding: 30rpx;
  200. }
  201. .card-header {
  202. display: flex;
  203. justify-content: space-between;
  204. align-items: center;
  205. margin-bottom: 20rpx;
  206. padding-bottom: 16rpx;
  207. border-bottom: 1rpx solid #eee;
  208. }
  209. .child-name {
  210. font-size: 30rpx;
  211. font-weight: bold;
  212. color: #333;
  213. }
  214. .status-badge {
  215. padding: 6rpx 16rpx;
  216. border-radius: 8rpx;
  217. font-size: 22rpx;
  218. }
  219. .status-0 { background: #FFF3E0; color: #FF9800; }
  220. .status-1 { background: #E3F2FD; color: #2196F3; }
  221. .status-2 { background: #E8F5E9; color: #4CAF50; }
  222. .status-3 { background: #F5F5F5; color: #9E9E9E; }
  223. .status-4 { background: #FFEBEE; color: #F44336; }
  224. .card-body {
  225. margin-bottom: 20rpx;
  226. }
  227. .info-row {
  228. display: flex;
  229. justify-content: space-between;
  230. padding: 10rpx 0;
  231. font-size: 26rpx;
  232. }
  233. .label { color: #999; }
  234. .value { color: #333; }
  235. .card-actions {
  236. display: flex;
  237. gap: 16rpx;
  238. padding-top: 16rpx;
  239. border-top: 1rpx dashed #eee;
  240. }
  241. .btn-confirm {
  242. flex: 1;
  243. background: #667eea;
  244. color: #fff;
  245. font-size: 26rpx;
  246. border-radius: 10rpx;
  247. }
  248. .btn-complete {
  249. flex: 1;
  250. background: #4CAF50;
  251. color: #fff;
  252. font-size: 26rpx;
  253. border-radius: 10rpx;
  254. }
  255. .btn-cancel {
  256. flex: 1;
  257. background: #F5F5F5;
  258. color: #999;
  259. font-size: 26rpx;
  260. border-radius: 10rpx;
  261. }
  262. .empty-state {
  263. text-align: center;
  264. padding: 120rpx 0;
  265. }
  266. .empty-icon {
  267. font-size: 80rpx;
  268. display: block;
  269. margin-bottom: 20rpx;
  270. }
  271. .empty-text {
  272. font-size: 28rpx;
  273. color: #999;
  274. display: block;
  275. }
  276. .bottom-space {
  277. height: 140rpx;
  278. }
  279. </style>