dengzedong
2024-12-19 85b2001c0ec2f1adc598db3bf47ad457dcca7074
提交 | 用户 | 时间
e7c126 1 <template>
H 2   <div class="app-container">
3     <!-- 搜索工作栏 -->
4     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
5       <el-form-item label="名字" prop="name">
6         <el-input v-model="queryParams.name" placeholder="请输入名字" clearable @keyup.enter.native="handleQuery"/>
7       </el-form-item>
8       <el-form-item label="出生日期" prop="birthday">
9         <el-date-picker clearable v-model="queryParams.birthday" type="date" value-format="yyyy-MM-dd" placeholder="选择出生日期" />
10       </el-form-item>
11       <el-form-item label="性别" prop="sex">
12         <el-select v-model="queryParams.sex" placeholder="请选择性别" clearable size="small">
13           <el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_USER_SEX)"
14                        :key="dict.value" :label="dict.label" :value="dict.value"/>
15         </el-select>
16       </el-form-item>
17       <el-form-item label="是否有效" prop="enabled">
18         <el-select v-model="queryParams.enabled" placeholder="请选择是否有效" clearable size="small">
19           <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INFRA_BOOLEAN_STRING)"
20                        :key="dict.value" :label="dict.label" :value="dict.value"/>
21         </el-select>
22       </el-form-item>
23       <el-form-item label="创建时间" prop="createTime">
24         <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
25                         range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
26       </el-form-item>
27       <el-form-item>
28         <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
29         <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
30       </el-form-item>
31     </el-form>
32
33     <!-- 操作工具栏 -->
34     <el-row :gutter="10" class="mb8">
35       <el-col :span="1.5">
36         <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
37                    v-hasPermi="['infra:student:create']">新增</el-button>
38       </el-col>
39       <el-col :span="1.5">
40         <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
41                    v-hasPermi="['infra:student:export']">导出</el-button>
42       </el-col>
43               <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
44     </el-row>
45
46             <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
47               <!-- 子表的列表 -->
48         <el-table-column type="expand">
49           <template #default="scope">
50             <el-tabs value="studentContact">
51                   <el-tab-pane label="学生联系人" name="studentContact">
52                     <StudentContactList :student-id="scope.row.id" />
53                   </el-tab-pane>
54                   <el-tab-pane label="学生班主任" name="studentTeacher">
55                     <StudentTeacherList :student-id="scope.row.id" />
56                   </el-tab-pane>
57             </el-tabs>
58           </template>
59         </el-table-column>
60       <el-table-column label="编号" align="center" prop="id">
61         <template v-slot="scope">
62           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.id" />
63         </template>
64       </el-table-column>
65       <el-table-column label="名字" align="center" prop="name">
66         <template v-slot="scope">
67           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.name" />
68         </template>
69       </el-table-column>
70       <el-table-column label="简介" align="center" prop="description">
71         <template v-slot="scope">
72           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.description" />
73         </template>
74       </el-table-column>
75       <el-table-column label="出生日期" align="center" prop="birthday" width="180">
76         <template v-slot="scope">
77           <span>{{ parseTime(scope.row.birthday) }}</span>
78         </template>
79       </el-table-column>
80       <el-table-column label="性别" align="center" prop="sex">
81         <template v-slot="scope">
82           <dict-tag :type="DICT_TYPE.SYSTEM_USER_SEX" :value="scope.row.sex" />
83         </template>
84       </el-table-column>
85       <el-table-column label="是否有效" align="center" prop="enabled">
86         <template v-slot="scope">
87           <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.enabled" />
88         </template>
89       </el-table-column>
90       <el-table-column label="头像" align="center" prop="avatar">
91         <template v-slot="scope">
92           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.avatar" />
93         </template>
94       </el-table-column>
95       <el-table-column label="附件" align="center" prop="video">
96         <template v-slot="scope">
97           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.video" />
98         </template>
99       </el-table-column>
100       <el-table-column label="备注" align="center" prop="memo">
101         <template v-slot="scope">
102           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.memo" />
103         </template>
104       </el-table-column>
105       <el-table-column label="创建时间" align="center" prop="createTime" width="180">
106         <template v-slot="scope">
107           <span>{{ parseTime(scope.row.createTime) }}</span>
108         </template>
109       </el-table-column>
110       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
111         <template v-slot="scope">
112           <el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)"
113                      v-hasPermi="['infra:student:update']">修改</el-button>
114           <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
115                      v-hasPermi="['infra:student:delete']">删除</el-button>
116         </template>
117       </el-table-column>
118     </el-table>
119     <!-- 分页组件 -->
120     <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
121                 @pagination="getList"/>
122     <!-- 对话框(添加 / 修改) -->
123     <StudentForm ref="formRef" @success="getList" />
124     </div>
125 </template>
126
127 <script>
128 import * as StudentApi from '@/api/infra/demo';
129 import StudentForm from './StudentForm.vue';
130     import StudentContactList from './components/StudentContactList.vue';
131     import StudentTeacherList from './components/StudentTeacherList.vue';
132 export default {
133   name: "Student",
134   components: {
135           StudentForm,
136           StudentContactList,
137           StudentTeacherList,
138   },
139   data() {
140     return {
141       // 遮罩层
142       loading: true,
143       // 导出遮罩层
144       exportLoading: false,
145       // 显示搜索条件
146       showSearch: true,
147               // 总条数
148         total: 0,
149       // 学生列表
150       list: [],
151       // 是否展开,默认全部展开
152       isExpandAll: true,
153       // 重新渲染表格状态
154       refreshTable: true,
155       // 选中行
156       currentRow: {},
157       // 查询参数
158       queryParams: {
159                     pageNo: 1,
160             pageSize: 10,
161         name: null,
162         birthday: null,
163         sex: null,
164         enabled: null,
165         createTime: [],
166       },
167             };
168   },
169   created() {
170     this.getList();
171   },
172   methods: {
173     /** 查询列表 */
174     async getList() {
175       try {
176       this.loading = true;
177               const res = await StudentApi.getStudentPage(this.queryParams);
178         this.list = res.data.list;
179         this.total = res.data.total;
180       } finally {
181         this.loading = false;
182       }
183     },
184     /** 搜索按钮操作 */
185     handleQuery() {
186       this.queryParams.pageNo = 1;
187       this.getList();
188     },
189     /** 重置按钮操作 */
190     resetQuery() {
191       this.resetForm("queryForm");
192       this.handleQuery();
193     },
194     /** 添加/修改操作 */
195     openForm(id) {
196       this.$refs["formRef"].open(id);
197     },
198     /** 删除按钮操作 */
199     async handleDelete(row) {
200       const id = row.id;
201       await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
202       try {
203        await StudentApi.deleteStudent(id);
204        await this.getList();
205        this.$modal.msgSuccess("删除成功");
206       } catch {}
207     },
208     /** 导出按钮操作 */
209     async handleExport() {
210       await this.$modal.confirm('是否确认导出所有学生数据项?');
211       try {
212         this.exportLoading = true;
213         const res = await StudentApi.exportStudentExcel(this.queryParams);
214         this.$download.excel(res.data, '学生.xls');
215       } catch {
216       } finally {
217         this.exportLoading = false;
218       }
219     },
220               }
221 };
222 </script>