提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<ContentWrap> |
|
3 |
<!-- 搜索工作栏 --> |
|
4 |
<el-form |
|
5 |
class="-mb-15px" |
|
6 |
:model="queryParams" |
|
7 |
ref="queryFormRef" |
|
8 |
:inline="true" |
|
9 |
label-width="68px" |
|
10 |
> |
|
11 |
<el-form-item label="名字" prop="name"> |
|
12 |
<el-input |
|
13 |
v-model="queryParams.name" |
|
14 |
placeholder="请输入名字" |
|
15 |
clearable |
|
16 |
@keyup.enter="handleQuery" |
|
17 |
class="!w-240px" |
|
18 |
/> |
|
19 |
</el-form-item> |
|
20 |
<el-form-item label="性别" prop="sex"> |
|
21 |
<el-select v-model="queryParams.sex" placeholder="请选择性别" clearable class="!w-240px"> |
|
22 |
<el-option |
|
23 |
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_USER_SEX)" |
|
24 |
:key="dict.value" |
|
25 |
:label="dict.label" |
|
26 |
:value="dict.value" |
|
27 |
/> |
|
28 |
</el-select> |
|
29 |
</el-form-item> |
|
30 |
<el-form-item label="创建时间" prop="createTime"> |
|
31 |
<el-date-picker |
|
32 |
v-model="queryParams.createTime" |
|
33 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
34 |
type="daterange" |
|
35 |
start-placeholder="开始日期" |
|
36 |
end-placeholder="结束日期" |
|
37 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
38 |
class="!w-240px" |
|
39 |
/> |
|
40 |
</el-form-item> |
|
41 |
<el-form-item> |
|
42 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
43 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
44 |
<el-button |
|
45 |
type="primary" |
|
46 |
plain |
|
47 |
@click="openForm('create')" |
|
48 |
v-hasPermi="['infra:demo03-student:create']" |
|
49 |
> |
|
50 |
<Icon icon="ep:plus" class="mr-5px" /> 新增 |
|
51 |
</el-button> |
|
52 |
<el-button |
|
53 |
type="success" |
|
54 |
plain |
|
55 |
@click="handleExport" |
|
56 |
:loading="exportLoading" |
|
57 |
v-hasPermi="['infra:demo03-student:export']" |
|
58 |
> |
|
59 |
<Icon icon="ep:download" class="mr-5px" /> 导出 |
|
60 |
</el-button> |
|
61 |
</el-form-item> |
|
62 |
</el-form> |
|
63 |
</ContentWrap> |
|
64 |
|
|
65 |
<!-- 列表 --> |
|
66 |
<ContentWrap> |
|
67 |
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> |
|
68 |
<!-- 子表的列表 --> |
|
69 |
<el-table-column type="expand"> |
|
70 |
<template #default="scope"> |
|
71 |
<el-tabs model-value="demo03Course"> |
|
72 |
<el-tab-pane label="学生课程" name="demo03Course"> |
|
73 |
<Demo03CourseList :student-id="scope.row.id" /> |
|
74 |
</el-tab-pane> |
|
75 |
<el-tab-pane label="学生班级" name="demo03Grade"> |
|
76 |
<Demo03GradeList :student-id="scope.row.id" /> |
|
77 |
</el-tab-pane> |
|
78 |
</el-tabs> |
|
79 |
</template> |
|
80 |
</el-table-column> |
|
81 |
<el-table-column label="编号" align="center" prop="id" /> |
|
82 |
<el-table-column label="名字" align="center" prop="name" /> |
|
83 |
<el-table-column label="性别" align="center" prop="sex"> |
|
84 |
<template #default="scope"> |
|
85 |
<dict-tag :type="DICT_TYPE.SYSTEM_USER_SEX" :value="scope.row.sex" /> |
|
86 |
</template> |
|
87 |
</el-table-column> |
|
88 |
<el-table-column |
|
89 |
label="出生日期" |
|
90 |
align="center" |
|
91 |
prop="birthday" |
|
92 |
:formatter="dateFormatter" |
|
93 |
width="180px" |
|
94 |
/> |
|
95 |
<el-table-column label="简介" align="center" prop="description" /> |
|
96 |
<el-table-column |
|
97 |
label="创建时间" |
|
98 |
align="center" |
|
99 |
prop="createTime" |
|
100 |
:formatter="dateFormatter" |
|
101 |
width="180px" |
|
102 |
/> |
|
103 |
<el-table-column label="操作" align="center"> |
|
104 |
<template #default="scope"> |
|
105 |
<el-button |
|
106 |
link |
|
107 |
type="primary" |
|
108 |
@click="openForm('update', scope.row.id)" |
|
109 |
v-hasPermi="['infra:demo03-student:update']" |
|
110 |
> |
|
111 |
编辑 |
|
112 |
</el-button> |
|
113 |
<el-button |
|
114 |
link |
|
115 |
type="danger" |
|
116 |
@click="handleDelete(scope.row.id)" |
|
117 |
v-hasPermi="['infra:demo03-student:delete']" |
|
118 |
> |
|
119 |
删除 |
|
120 |
</el-button> |
|
121 |
</template> |
|
122 |
</el-table-column> |
|
123 |
</el-table> |
|
124 |
<!-- 分页 --> |
|
125 |
<Pagination |
|
126 |
:total="total" |
|
127 |
v-model:page="queryParams.pageNo" |
|
128 |
v-model:limit="queryParams.pageSize" |
|
129 |
@pagination="getList" |
|
130 |
/> |
|
131 |
</ContentWrap> |
|
132 |
|
|
133 |
<!-- 表单弹窗:添加/修改 --> |
|
134 |
<Demo03StudentForm ref="formRef" @success="getList" /> |
|
135 |
</template> |
|
136 |
|
|
137 |
<script setup lang="ts"> |
|
138 |
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict' |
|
139 |
import { dateFormatter } from '@/utils/formatTime' |
|
140 |
import download from '@/utils/download' |
|
141 |
import * as Demo03StudentApi from '@/api/infra/demo/demo03/inner' |
|
142 |
import Demo03StudentForm from './Demo03StudentForm.vue' |
|
143 |
import Demo03CourseList from './components/Demo03CourseList.vue' |
|
144 |
import Demo03GradeList from './components/Demo03GradeList.vue' |
|
145 |
|
|
146 |
defineOptions({ name: 'Demo03Student' }) |
|
147 |
|
|
148 |
const message = useMessage() // 消息弹窗 |
|
149 |
const { t } = useI18n() // 国际化 |
|
150 |
|
|
151 |
const loading = ref(true) // 列表的加载中 |
|
152 |
const list = ref([]) // 列表的数据 |
|
153 |
const total = ref(0) // 列表的总页数 |
|
154 |
const queryParams = reactive({ |
|
155 |
pageNo: 1, |
|
156 |
pageSize: 10, |
|
157 |
name: null, |
|
158 |
sex: null, |
|
159 |
description: null, |
|
160 |
createTime: [] |
|
161 |
}) |
|
162 |
const queryFormRef = ref() // 搜索的表单 |
|
163 |
const exportLoading = ref(false) // 导出的加载中 |
|
164 |
|
|
165 |
/** 查询列表 */ |
|
166 |
const getList = async () => { |
|
167 |
loading.value = true |
|
168 |
try { |
|
169 |
const data = await Demo03StudentApi.getDemo03StudentPage(queryParams) |
|
170 |
list.value = data.list |
|
171 |
total.value = data.total |
|
172 |
} finally { |
|
173 |
loading.value = false |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
/** 搜索按钮操作 */ |
|
178 |
const handleQuery = () => { |
|
179 |
queryParams.pageNo = 1 |
|
180 |
getList() |
|
181 |
} |
|
182 |
|
|
183 |
/** 重置按钮操作 */ |
|
184 |
const resetQuery = () => { |
|
185 |
queryFormRef.value.resetFields() |
|
186 |
handleQuery() |
|
187 |
} |
|
188 |
|
|
189 |
/** 添加/修改操作 */ |
|
190 |
const formRef = ref() |
|
191 |
const openForm = (type: string, id?: number) => { |
|
192 |
formRef.value.open(type, id) |
|
193 |
} |
|
194 |
|
|
195 |
/** 删除按钮操作 */ |
|
196 |
const handleDelete = async (id: number) => { |
|
197 |
try { |
|
198 |
// 删除的二次确认 |
|
199 |
await message.delConfirm() |
|
200 |
// 发起删除 |
|
201 |
await Demo03StudentApi.deleteDemo03Student(id) |
|
202 |
message.success(t('common.delSuccess')) |
|
203 |
// 刷新列表 |
|
204 |
await getList() |
|
205 |
} catch {} |
|
206 |
} |
|
207 |
|
|
208 |
/** 导出按钮操作 */ |
|
209 |
const handleExport = async () => { |
|
210 |
try { |
|
211 |
// 导出的二次确认 |
|
212 |
await message.exportConfirm() |
|
213 |
// 发起导出 |
|
214 |
exportLoading.value = true |
|
215 |
const data = await Demo03StudentApi.exportDemo03Student(queryParams) |
|
216 |
download.excel(data, '学生.xls') |
|
217 |
} catch { |
|
218 |
} finally { |
|
219 |
exportLoading.value = false |
|
220 |
} |
|
221 |
} |
|
222 |
|
|
223 |
/** 初始化 **/ |
|
224 |
onMounted(() => { |
|
225 |
getList() |
|
226 |
}) |
|
227 |
</script> |