|
|
@@ -0,0 +1,106 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <div class="filter-bar">
|
|
|
+ <el-select v-model="statusFilter" placeholder="审核状态" @change="loadData">
|
|
|
+ <el-option label="全部" value="" />
|
|
|
+ <el-option label="待审核" value="pending" />
|
|
|
+ <el-option label="已通过" value="approved" />
|
|
|
+ <el-option label="已拒绝" value="rejected" />
|
|
|
+ </el-select>
|
|
|
+ <el-input v-model="keyword" placeholder="搜索..." prefix-icon="el-icon-search" clearable @keyup.enter.native="handleSearch" @clear="handleSearch" style="width:200px" />
|
|
|
+ <el-button size="small" @click="loadData" :loading="loading">刷新</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="table-scroll-wrap"><div style="overflow:auto;max-height:calc(100vh - 300px);">
|
|
|
+ <el-table :data="list" v-loading="loading" border stripe style="min-width:900px;">
|
|
|
+ <el-table-column prop="id" label="ID" width="60" />
|
|
|
+ <el-table-column prop="nickname" label="昵称" width="120" />
|
|
|
+ <el-table-column prop="realName" label="真实姓名" width="120" />
|
|
|
+ <el-table-column prop="phone" label="手机号" width="140" />
|
|
|
+ <el-table-column label="审核状态" width="100">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-tag :type="statusType(row.nutritionistStatus)">{{ statusLabel(row.nutritionistStatus) }}</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="180" fixed="right">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <template v-if="row.nutritionistStatus === 'pending'">
|
|
|
+ <el-button size="mini" type="success" @click="handleApprove(row)">通过</el-button>
|
|
|
+ <el-button size="mini" type="danger" @click="showReject(row)">拒绝</el-button>
|
|
|
+ </template>
|
|
|
+ <span v-else class="no-op">—</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table></div></div>
|
|
|
+
|
|
|
+ <el-dialog title="拒绝原因" :visible.sync="rejectDialogVisible" width="400px">
|
|
|
+ <el-input v-model="rejectReason" type="textarea" :rows="3" placeholder="请输入拒绝原因" />
|
|
|
+ <span slot="footer">
|
|
|
+ <el-button @click="rejectDialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="danger" @click="confirmReject">确认拒绝</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getNutritionistApplications, approveNutritionist, rejectNutritionist } from '@/api/admin'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'NutritionistAudit',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ list: [], loading: false, keyword: '', statusFilter: 'pending',
|
|
|
+ rejectDialogVisible: false, rejectTarget: null, rejectReason: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() { this.loadData() },
|
|
|
+ methods: {
|
|
|
+ statusType(s) { return { pending: 'warning', approved: 'success', rejected: 'danger' }[s] || 'info' },
|
|
|
+ statusLabel(s) { return { pending: '待审核', approved: '已通过', rejected: '已拒绝' }[s] || s },
|
|
|
+ handleSearch() { this.loadData() },
|
|
|
+ async loadData() {
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ const res = await getNutritionistApplications({
|
|
|
+ status: this.statusFilter || undefined,
|
|
|
+ keyword: this.keyword || undefined, page: 1, size: 50
|
|
|
+ })
|
|
|
+ if (res.data && res.data.records) {
|
|
|
+ this.list = res.data.records
|
|
|
+ } else if (res.data && Array.isArray(res.data)) {
|
|
|
+ this.list = res.data
|
|
|
+ } else {
|
|
|
+ this.list = []
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e)
|
|
|
+ this.$message.error('加载失败')
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async handleApprove(row) {
|
|
|
+ try {
|
|
|
+ await approveNutritionist(row.id)
|
|
|
+ this.$message.success('已通过')
|
|
|
+ this.loadData()
|
|
|
+ } catch (e) { this.$message.error('操作失败') }
|
|
|
+ },
|
|
|
+ showReject(row) { this.rejectTarget = row; this.rejectReason = ''; this.rejectDialogVisible = true },
|
|
|
+ async confirmReject() {
|
|
|
+ if (!this.rejectReason) return this.$message.warning('请填写拒绝原因')
|
|
|
+ try {
|
|
|
+ await rejectNutritionist(this.rejectTarget.id, this.rejectReason)
|
|
|
+ this.$message.success('已拒绝')
|
|
|
+ this.rejectDialogVisible = false
|
|
|
+ this.loadData()
|
|
|
+ } catch (e) { this.$message.error('操作失败') }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.filter-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; padding: 12px; background: #fff; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.08); }
|
|
|
+.no-op { color: #ccc; }
|
|
|
+</style>
|