| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <template>
- <div class="assessment-assign admin-page">
- <el-card>
- <PageHeader slot="header" title="测评待分配规划师">
-
- <el-button type="primary" size="small" icon="el-icon-refresh" @click="loadList">刷新</el-button>
-
- </PageHeader>
- <div class="adm-table-wrap">
- <el-table height="100%" :data="list" v-loading="loading" border stripe empty-text="暂无可分配记录">
- <el-table-column prop="id" label="ID" width="70">
- <template slot="header">
- <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>
- </template>
- </el-table-column>
- <el-table-column label="用户" width="120">
- <template slot-scope="{ row }">{{ row.userName }}</template>
- </el-table-column>
- <el-table-column label="孩子" width="120">
- <template slot-scope="{ row }">{{ row.childName }}</template>
- </el-table-column>
- <el-table-column label="预约日期" width="120">
- <template slot-scope="{ row }">{{ row.appointmentDate || '-' }}</template>
- </el-table-column>
- <el-table-column label="预约时间" width="90">
- <template slot-scope="{ row }">{{ row.appointmentTime || '-' }}</template>
- </el-table-column>
- <el-table-column label="类型" width="80">
- <template slot-scope="{ row }">
- <StatusTag type="primary" size="mini" :text="row.appointmentType === 'initial' ? '初测' : row.appointmentType === 'retest' ? '复测' : (row.appointmentType || '-')" />
- </template>
- </el-table-column>
- <el-table-column label="备注" min-width="160" show-overflow-tooltip>
- <template slot-scope="{ row }">{{ row.notes || '-' }}</template>
- </el-table-column>
- <el-table-column label="创建时间" width="160">
- <template slot="header">
- <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>
- </template>
- <template slot-scope="{ row }">{{ row.createdAt }}</template>
- </el-table-column>
- <el-table-column label="操作" width="220" fixed="right">
- <template slot-scope="{ row }">
- <el-button size="mini" type="primary" @click="openAssignDialog(row)">分配规划师</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="page"
- :page-sizes="[10, 20, 50]"
- :page-size="size"
- :total="total"
- layout="total, sizes, prev, pager, next, jumper"
- class="pagination-wrap"
- />
- </el-card>
- <el-dialog title="分配规划师" :visible.sync="assignDialogVisible" width="480px">
- <div v-loading="guidesLoading">
- <el-form label-width="100px">
- <el-form-item label="预约ID">
- <el-input :value="currentAppointmentId" disabled />
- </el-form-item>
- <el-form-item label="用户">
- <el-input :value="currentUserName" disabled />
- </el-form-item>
- <el-form-item label="孩子">
- <el-input :value="currentChildName" disabled />
- </el-form-item>
- <el-form-item label="选择规划师">
- <el-select v-model="selectedGuideId" placeholder="请选择规划师" class="form-full" filterable>
- <el-option
- v-for="g in guides"
- :key="g.id"
- :label="g.nickname + (g.realName ? ' (' + g.realName + ')' : '') + (g.teacherNo ? ' - ' + g.teacherNo : '')"
- :value="g.id"
- />
- </el-select>
- </el-form-item>
- </el-form>
- </div>
- <div slot="footer">
- <el-button @click="assignDialogVisible = false">取消</el-button>
- <el-button type="primary" @click="confirmAssign" :loading="assigning">确认分配</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getPendingAssessmentList, getAvailableGuides, assignGuide } from '@/api/admin'
- import SortMixin from '@/mixins/SortMixin'
- import ListStateMixin from '@/mixins/ListStateMixin'
- export default {
- name: 'AssessmentAssign',
- mixins: [SortMixin, ListStateMixin],
- computed: {
- tableHeight() {
- return window.innerHeight - 300
- }
- },
- data() {
- return {
- sortableColumns: { id: 'ID', createdAt: '创建时间' },
- loading: false,
- list: [],
- page: 1,
- size: 10,
- total: 0,
- assignDialogVisible: false,
- guidesLoading: false,
- assigning: false,
- guides: [],
- currentAppointmentId: null,
- currentUserName: '',
- currentChildName: '',
- selectedGuideId: null
- }
- },
- mounted() {
- this.loadList()
- },
- methods: {
- async loadList() {
- this.loading = true
- try {
- const params = { page: this.page, size: this.size }
- this.applySortToParams(params)
- const res = await getPendingAssessmentList(params)
- this.list = res.data.records || []
- this.total = res.data.total || 0
- } catch (e) {
- this.$message.error(e.message || '加载失败')
- } finally {
- this.loading = false
- }
- },
- handleSizeChange(val) {
- this.size = val
- this.page = 1
- this.loadList()
- },
- handleCurrentChange(val) {
- this.page = val
- this.loadList()
- },
- async openAssignDialog(row) {
- this.currentAppointmentId = row.id
- this.currentUserName = row.userName
- this.currentChildName = row.childName
- this.selectedGuideId = null
- this.assignDialogVisible = true
- this.guidesLoading = true
- try {
- const res = await getAvailableGuides()
- this.guides = res.data || []
- } catch (e) {
- this.$message.error(e.message || '加载规划师列表失败')
- } finally {
- this.guidesLoading = false
- }
- },
- async confirmAssign() {
- if (!this.selectedGuideId) {
- this.$message.warning('请选择规划师')
- return
- }
- this.assigning = true
- try {
- await assignGuide(this.currentAppointmentId, this.selectedGuideId)
- this.$message.success('分配成功')
- this.assignDialogVisible = false
- this.loadList()
- } catch (e) {
- this.$message.error(e.message || '分配失败')
- } finally {
- this.assigning = false
- }
- }
- }
- }
- </script>
- <style scoped>
- .pagination-wrap {
- margin-top: 24px;
- text-align: right;
- }
- /* == C 批内联清理工具类 == */
- .form-full { width: 100%; }
- </style>
|