AssessmentAssign.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="assessment-assign admin-page">
  3. <el-card>
  4. <PageHeader slot="header" title="测评待分配规划师">
  5. <el-button type="primary" size="small" icon="el-icon-refresh" @click="loadList">刷新</el-button>
  6. </PageHeader>
  7. <div class="adm-table-wrap">
  8. <el-table height="100%" :data="list" v-loading="loading" border stripe empty-text="暂无可分配记录">
  9. <el-table-column prop="id" label="ID" width="70">
  10. <template slot="header">
  11. <span class="sort-header" @click.stop="onSortClick('id', $event)">ID<span v-if="sortIndex('id') !== null" class="sort-index" :class="sortClass('id') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('id') }}</span>{{ sortIcon('id') }}</span>
  12. </template>
  13. </el-table-column>
  14. <el-table-column label="用户" width="120">
  15. <template slot-scope="{ row }">{{ row.userName }}</template>
  16. </el-table-column>
  17. <el-table-column label="孩子" width="120">
  18. <template slot-scope="{ row }">{{ row.childName }}</template>
  19. </el-table-column>
  20. <el-table-column label="预约日期" width="120">
  21. <template slot-scope="{ row }">{{ row.appointmentDate || '-' }}</template>
  22. </el-table-column>
  23. <el-table-column label="预约时间" width="90">
  24. <template slot-scope="{ row }">{{ row.appointmentTime || '-' }}</template>
  25. </el-table-column>
  26. <el-table-column label="类型" width="80">
  27. <template slot-scope="{ row }">
  28. <StatusTag type="primary" size="mini" :text="row.appointmentType === 'initial' ? '初测' : row.appointmentType === 'retest' ? '复测' : (row.appointmentType || '-')" />
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="备注" min-width="160" show-overflow-tooltip>
  32. <template slot-scope="{ row }">{{ row.notes || '-' }}</template>
  33. </el-table-column>
  34. <el-table-column label="创建时间" width="160">
  35. <template slot="header">
  36. <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>
  37. </template>
  38. <template slot-scope="{ row }">{{ row.createdAt }}</template>
  39. </el-table-column>
  40. <el-table-column label="操作" width="220" fixed="right">
  41. <template slot-scope="{ row }">
  42. <el-button size="mini" type="primary" @click="openAssignDialog(row)">分配规划师</el-button>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. </div>
  47. <el-pagination
  48. @size-change="handleSizeChange"
  49. @current-change="handleCurrentChange"
  50. :current-page="page"
  51. :page-sizes="[10, 20, 50]"
  52. :page-size="size"
  53. :total="total"
  54. layout="total, sizes, prev, pager, next, jumper"
  55. class="pagination-wrap"
  56. />
  57. </el-card>
  58. <el-dialog title="分配规划师" :visible.sync="assignDialogVisible" width="480px">
  59. <div v-loading="guidesLoading">
  60. <el-form label-width="100px">
  61. <el-form-item label="预约ID">
  62. <el-input :value="currentAppointmentId" disabled />
  63. </el-form-item>
  64. <el-form-item label="用户">
  65. <el-input :value="currentUserName" disabled />
  66. </el-form-item>
  67. <el-form-item label="孩子">
  68. <el-input :value="currentChildName" disabled />
  69. </el-form-item>
  70. <el-form-item label="选择规划师">
  71. <el-select v-model="selectedGuideId" placeholder="请选择规划师" class="form-full" filterable>
  72. <el-option
  73. v-for="g in guides"
  74. :key="g.id"
  75. :label="g.nickname + (g.realName ? ' (' + g.realName + ')' : '') + (g.teacherNo ? ' - ' + g.teacherNo : '')"
  76. :value="g.id"
  77. />
  78. </el-select>
  79. </el-form-item>
  80. </el-form>
  81. </div>
  82. <div slot="footer">
  83. <el-button @click="assignDialogVisible = false">取消</el-button>
  84. <el-button type="primary" @click="confirmAssign" :loading="assigning">确认分配</el-button>
  85. </div>
  86. </el-dialog>
  87. </div>
  88. </template>
  89. <script>
  90. import { getPendingAssessmentList, getAvailableGuides, assignGuide } from '@/api/admin'
  91. import SortMixin from '@/mixins/SortMixin'
  92. import ListStateMixin from '@/mixins/ListStateMixin'
  93. export default {
  94. name: 'AssessmentAssign',
  95. mixins: [SortMixin, ListStateMixin],
  96. computed: {
  97. tableHeight() {
  98. return window.innerHeight - 300
  99. }
  100. },
  101. data() {
  102. return {
  103. sortableColumns: { id: 'ID', createdAt: '创建时间' },
  104. loading: false,
  105. list: [],
  106. page: 1,
  107. size: 10,
  108. total: 0,
  109. assignDialogVisible: false,
  110. guidesLoading: false,
  111. assigning: false,
  112. guides: [],
  113. currentAppointmentId: null,
  114. currentUserName: '',
  115. currentChildName: '',
  116. selectedGuideId: null
  117. }
  118. },
  119. mounted() {
  120. this.loadList()
  121. },
  122. methods: {
  123. async loadList() {
  124. this.loading = true
  125. try {
  126. const params = { page: this.page, size: this.size }
  127. this.applySortToParams(params)
  128. const res = await getPendingAssessmentList(params)
  129. this.list = res.data.records || []
  130. this.total = res.data.total || 0
  131. } catch (e) {
  132. this.$message.error(e.message || '加载失败')
  133. } finally {
  134. this.loading = false
  135. }
  136. },
  137. handleSizeChange(val) {
  138. this.size = val
  139. this.page = 1
  140. this.loadList()
  141. },
  142. handleCurrentChange(val) {
  143. this.page = val
  144. this.loadList()
  145. },
  146. async openAssignDialog(row) {
  147. this.currentAppointmentId = row.id
  148. this.currentUserName = row.userName
  149. this.currentChildName = row.childName
  150. this.selectedGuideId = null
  151. this.assignDialogVisible = true
  152. this.guidesLoading = true
  153. try {
  154. const res = await getAvailableGuides()
  155. this.guides = res.data || []
  156. } catch (e) {
  157. this.$message.error(e.message || '加载规划师列表失败')
  158. } finally {
  159. this.guidesLoading = false
  160. }
  161. },
  162. async confirmAssign() {
  163. if (!this.selectedGuideId) {
  164. this.$message.warning('请选择规划师')
  165. return
  166. }
  167. this.assigning = true
  168. try {
  169. await assignGuide(this.currentAppointmentId, this.selectedGuideId)
  170. this.$message.success('分配成功')
  171. this.assignDialogVisible = false
  172. this.loadList()
  173. } catch (e) {
  174. this.$message.error(e.message || '分配失败')
  175. } finally {
  176. this.assigning = false
  177. }
  178. }
  179. }
  180. }
  181. </script>
  182. <style scoped>
  183. .pagination-wrap {
  184. margin-top: 24px;
  185. text-align: right;
  186. }
  187. /* == C 批内联清理工具类 == */
  188. .form-full { width: 100%; }
  189. </style>