AssessmentOrders.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div class="assessment-orders admin-page">
  3. <el-card>
  4. <PageHeader slot="header" title="测评预约管理">
  5. <div class="filter-bar">
  6. <el-input
  7. v-model="keyword"
  8. placeholder="搜索用户/规划师..."
  9. prefix-icon="el-icon-search"
  10. clearable
  11. style="width: 200px; margin-right: 10px;"
  12. @keyup.enter.native="handleSearch"
  13. @clear="handleSearch"
  14. />
  15. <el-select v-model="statusFilter" placeholder="预约状态" clearable @change="handleSearch" style="width: 140px; margin-right: 10px;">
  16. <el-option label="全部状态" value="" />
  17. <el-option label="待确认" :value="0" />
  18. <el-option label="已确认" :value="1" />
  19. <el-option label="已完成" :value="2" />
  20. <el-option label="已取消" :value="3" />
  21. <el-option label="未到" :value="4" />
  22. </el-select>
  23. <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
  24. </div>
  25. </PageHeader>
  26. <div class="adm-table-wrap">
  27. <el-table height="100%" :data="list" v-loading="loading" border stripe empty-text="暂无测评预约">
  28. <el-table-column label="用户" width="110">
  29. <template slot-scope="{ row }">{{ row.userName || '-' }}</template>
  30. </el-table-column>
  31. <el-table-column label="孩子" width="100">
  32. <template slot-scope="{ row }">{{ row.childName || '-' }}</template>
  33. </el-table-column>
  34. <el-table-column label="测评方案" min-width="140" show-overflow-tooltip>
  35. <template slot-scope="{ row }">{{ row.packageName || '-' }}</template>
  36. </el-table-column>
  37. <el-table-column label="当前规划师" width="120">
  38. <template slot-scope="{ row }">
  39. <span v-if="row.guideName">{{ row.guideName }}</span>
  40. <StatusTag v-else size="mini" type="info" text="未分配" />
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="预约日期" width="120">
  44. <template slot-scope="{ row }">{{ row.appointmentDate || '-' }}</template>
  45. </el-table-column>
  46. <el-table-column label="预约时间" width="100">
  47. <template slot-scope="{ row }">{{ row.appointmentTime || '-' }}</template>
  48. </el-table-column>
  49. <el-table-column label="预约类型" width="100">
  50. <template slot-scope="{ row }">{{ row.appointmentType || '-' }}</template>
  51. </el-table-column>
  52. <el-table-column label="状态" width="100">
  53. <template slot-scope="{ row }">
  54. <el-tag :type="statusType(row.status)" size="mini">{{ statusLabel(row.status) }}</el-tag>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="创建时间" width="155">
  58. <template slot-scope="{ row }">{{ formatTime(row.createdAt) }}</template>
  59. <template slot="header">
  60. <span class="sort-header" @click.stop="onSortClick('createdAt', $event)">创建时间<span v-if="sortIndex('createdAt') !== null" class="sort-index" :class="sortClass('createdAt') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('createdAt') }}</span>{{ sortIcon('createdAt') }}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="操作" width="130" fixed="right">
  64. <template slot-scope="{ row }">
  65. <el-button
  66. size="mini"
  67. type="primary"
  68. plain
  69. @click="openChangeGuideDialog(row)"
  70. :disabled="row.status === 3"
  71. >修改规划师</el-button>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </div>
  76. <el-pagination
  77. @size-change="handleSizeChange"
  78. @current-change="handleCurrentChange"
  79. :current-page="page"
  80. :page-sizes="[10, 20, 50]"
  81. :page-size="size"
  82. :total="total"
  83. layout="total, sizes, prev, pager, next, jumper"
  84. class="pagination-wrap"
  85. />
  86. </el-card>
  87. <!-- 修改规划师 Dialog -->
  88. <el-dialog title="修改规划师" :visible.sync="changeGuideDialogVisible" width="500px">
  89. <div v-if="currentOrder" v-loading="guidesLoading">
  90. <el-descriptions :column="1" border size="small" style="margin-bottom: 20px;">
  91. <el-descriptions-item label="用户">{{ currentOrder.userName }}</el-descriptions-item>
  92. <el-descriptions-item label="孩子">{{ currentOrder.childName }}</el-descriptions-item>
  93. <el-descriptions-item label="测评方案">{{ currentOrder.packageName || '-' }}</el-descriptions-item>
  94. <el-descriptions-item label="预约日期">{{ currentOrder.appointmentDate || '-' }}</el-descriptions-item>
  95. <el-descriptions-item label="当前规划师">
  96. <span v-if="currentOrder.guideName">{{ currentOrder.guideName }}</span>
  97. <span v-else style="color: #999;">未分配</span>
  98. </el-descriptions-item>
  99. </el-descriptions>
  100. <el-form label-width="100px">
  101. <el-form-item label="新规划师">
  102. <el-select
  103. v-model="selectedGuideId"
  104. placeholder="请选择规划师"
  105. style="width: 100%;"
  106. filterable
  107. >
  108. <el-option
  109. v-for="g in guides"
  110. :key="g.id"
  111. :label="g.nickname + (g.realName ? ' (' + g.realName + ')' : '') + (g.teacherNo ? ' - ' + g.teacherNo : '')"
  112. :value="g.id"
  113. />
  114. </el-select>
  115. </el-form-item>
  116. </el-form>
  117. </div>
  118. <div slot="footer">
  119. <el-button @click="changeGuideDialogVisible = false">取消</el-button>
  120. <el-button type="primary" @click="confirmChangeGuide" :loading="changing">确认修改</el-button>
  121. </div>
  122. </el-dialog>
  123. </div>
  124. </template>
  125. <script>
  126. import SortMixin from '@/mixins/SortMixin'
  127. import { getAssessmentOrderList, changeAssessmentGuide, getAvailableGuides } from '@/api/admin'
  128. export default {
  129. name: 'AssessmentOrders',
  130. mixins: [SortMixin],
  131. computed: {
  132. tableHeight() {
  133. return window.innerHeight - 320
  134. }
  135. },
  136. data() {
  137. return {
  138. loading: false,
  139. list: [],
  140. page: 1,
  141. size: 20,
  142. total: 0,
  143. keyword: '',
  144. statusFilter: '',
  145. // 修改规划师
  146. changeGuideDialogVisible: false,
  147. currentOrder: null,
  148. selectedGuideId: null,
  149. guides: [],
  150. guidesLoading: false,
  151. changing: false,
  152. sortableColumns: { createdAt: '创建时间' }
  153. }
  154. },
  155. mounted() {
  156. this.loadList()
  157. },
  158. methods: {
  159. handleSearch() {
  160. this.page = 1
  161. this.loadList()
  162. },
  163. async loadList() {
  164. this.loading = true
  165. try {
  166. var params = { page: this.page, size: this.size }
  167. if (this.statusFilter) {
  168. params.status = this.statusFilter
  169. }
  170. if (this.keyword) {
  171. params.keyword = this.keyword
  172. }
  173. if (this.sortState.length > 0) params.sort = this.sortState
  174. var res = await getAssessmentOrderList(params)
  175. this.list = res.data.records || []
  176. this.total = res.data.total || 0
  177. } catch (e) {
  178. this.$message.error(e.message || '加载测评订单失败')
  179. } finally {
  180. this.loading = false
  181. }
  182. },
  183. handleSizeChange(val) {
  184. this.size = val
  185. this.page = 1
  186. this.loadList()
  187. },
  188. handleCurrentChange(val) {
  189. this.page = val
  190. this.loadList()
  191. },
  192. async openChangeGuideDialog(row) {
  193. this.currentOrder = row
  194. this.selectedGuideId = row.guideId || null
  195. this.changeGuideDialogVisible = true
  196. this.guidesLoading = true
  197. try {
  198. var res = await getAvailableGuides()
  199. this.guides = res.data || []
  200. } catch (e) {
  201. this.$message.error(e.message || '加载规划师列表失败')
  202. } finally {
  203. this.guidesLoading = false
  204. }
  205. },
  206. async confirmChangeGuide() {
  207. if (!this.selectedGuideId) {
  208. this.$message.warning('请选择规划师')
  209. return
  210. }
  211. if (this.currentOrder.guideId === this.selectedGuideId) {
  212. this.$message.warning('新规划师与当前规划师相同')
  213. return
  214. }
  215. this.changing = true
  216. try {
  217. await changeAssessmentGuide(this.currentOrder.id, this.selectedGuideId)
  218. this.$message.success('规划师修改成功')
  219. this.changeGuideDialogVisible = false
  220. this.loadList()
  221. } catch (e) {
  222. this.$message.error(e.message || '修改规划师失败')
  223. } finally {
  224. this.changing = false
  225. }
  226. },
  227. statusType(status) {
  228. var map = { 0: 'warning', 1: 'primary', 2: 'success', 3: 'info', 4: 'danger' }
  229. return map[status] !== undefined ? map[status] : 'info'
  230. },
  231. statusLabel(status) {
  232. var map = { 0: '待确认', 1: '已确认', 2: '已完成', 3: '已取消', 4: '未到' }
  233. return map[status] !== undefined ? map[status] : (status !== null && status !== undefined ? status : '-')
  234. },
  235. }
  236. }
  237. </script>
  238. <style scoped>
  239. .assessment-orders .admin-page-header {
  240. display: flex;
  241. justify-content: space-between;
  242. align-items: center;
  243. flex-wrap: wrap;
  244. gap: 10px;
  245. }
  246. .filter-bar {
  247. display: flex;
  248. align-items: center;
  249. }
  250. .pagination-wrap {
  251. margin-top: 20px;
  252. text-align: right;
  253. }
  254. .sort-header {
  255. cursor: pointer;
  256. user-select: none;
  257. font-weight: 500;
  258. font-size: 12px;
  259. }
  260. .sort-header:hover {
  261. color: #409eff;
  262. }
  263. .sort-tag {
  264. margin-left: 8px;
  265. cursor: pointer;
  266. white-space: nowrap;
  267. }
  268. </style>