index.vue
4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<template>
<!-- 搜索栏 -->
<ContentWrap>
<el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
<el-form-item label="昵称" prop="nickname">
<el-input
v-model="queryParams.nickname"
placeholder="请输入昵称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="手机号" prop="phone">
<el-input
v-model="queryParams.phone"
placeholder="请输入手机号"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" /> 重置</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表栏 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="编号" align="center" prop="id" width="80" />
<el-table-column label="头像" align="center" prop="avatar" width="80">
<template #default="scope">
<el-avatar :src="scope.row.avatar" size="small" />
</template>
</el-table-column>
<el-table-column label="昵称" align="center" prop="nickname" />
<el-table-column label="真实姓名" align="center" prop="realname" />
<el-table-column label="手机号" align="center" prop="phone" width="120" />
<el-table-column label="性别" align="center" prop="sexStr" width="100">
<template #default="scope">
<el-tag :type="scope.row.sex === 1 ? 'primary' : 'danger'">
{{ scope.row.sexStr || (scope.row.sex === 1 ? '男' : '女') }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status" width="100">
<template #default="scope">
<el-tag :type="scope.row.status === 1 ? 'success' : 'info'">
{{ scope.row.statusStr || (scope.row.status === 1 ? '正常' : '禁用') }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="180">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm(scope.row.id)"
>
编辑
</el-button>
<el-button
link
type="primary"
@click="openHealthData(scope.row.id)"
>
健康资料
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗:修改用户 -->
<StudentForm ref="formRef" @success="getList" />
<!-- 抽屉:学员健康资料 -->
<StudentHealthData ref="healthDataRef" />
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue'
import * as StudentApi from '@/api/store/student'
import StudentForm from './StudentForm.vue'
import StudentHealthData from './StudentHealthData.vue'
const loading = ref(true)
const total = ref(0)
const list = ref([])
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
phone: undefined,
nickname: undefined
})
const queryFormRef = ref()
const formRef = ref()
const healthDataRef = ref()
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await StudentApi.getStudentPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields()
handleQuery()
}
/** 打开修改弹窗 */
const openForm = (id) => {
formRef.value.open(id)
}
/** 打开健康资料抽屉 */
const openHealthData = (userId) => {
healthDataRef.value.open(userId)
}
/** 初始化 */
onMounted(() => {
getList()
})
</script>