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
47         v-loading="loading"
48         :data="list"
49         :stripe="true"
50         :highlight-current-row="true"
51         :show-overflow-tooltip="true"
52         @current-change="handleCurrentChange"
53       >
54                       <el-table-column label="编号" align="center" prop="id">
55         <template v-slot="scope">
56           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.id" />
57         </template>
58       </el-table-column>
59       <el-table-column label="名字" align="center" prop="name">
60         <template v-slot="scope">
61           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.name" />
62         </template>
63       </el-table-column>
64       <el-table-column label="简介" align="center" prop="description">
65         <template v-slot="scope">
66           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.description" />
67         </template>
68       </el-table-column>
69       <el-table-column label="出生日期" align="center" prop="birthday" width="180">
70         <template v-slot="scope">
71           <span>{{ parseTime(scope.row.birthday) }}</span>
72         </template>
73       </el-table-column>
74       <el-table-column label="性别" align="center" prop="sex">
75         <template v-slot="scope">
76           <dict-tag :type="DICT_TYPE.SYSTEM_USER_SEX" :value="scope.row.sex" />
77         </template>
78       </el-table-column>
79       <el-table-column label="是否有效" align="center" prop="enabled">
80         <template v-slot="scope">
81           <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.enabled" />
82         </template>
83       </el-table-column>
84       <el-table-column label="头像" align="center" prop="avatar">
85         <template v-slot="scope">
86           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.avatar" />
87         </template>
88       </el-table-column>
89       <el-table-column label="附件" align="center" prop="video">
90         <template v-slot="scope">
91           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.video" />
92         </template>
93       </el-table-column>
94       <el-table-column label="备注" align="center" prop="memo">
95         <template v-slot="scope">
96           <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.memo" />
97         </template>
98       </el-table-column>
99       <el-table-column label="创建时间" align="center" prop="createTime" width="180">
100         <template v-slot="scope">
101           <span>{{ parseTime(scope.row.createTime) }}</span>
102         </template>
103       </el-table-column>
104       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
105         <template v-slot="scope">
106           <el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)"
107                      v-hasPermi="['infra:student:update']">修改</el-button>
108           <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
109                      v-hasPermi="['infra:student:delete']">删除</el-button>
110         </template>
111       </el-table-column>
112     </el-table>
113     <!-- 分页组件 -->
114     <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
115                 @pagination="getList"/>
116     <!-- 对话框(添加 / 修改) -->
117     <StudentForm ref="formRef" @success="getList" />
118       <!-- 子表的列表 -->
119       <el-tabs v-model="subTabsName">
120             <el-tab-pane label="学生联系人" name="studentContact">
121               <StudentContactList v-if="currentRow.id" :student-id="currentRow.id" />
122             </el-tab-pane>
123             <el-tab-pane label="学生班主任" name="studentTeacher">
124               <StudentTeacherList v-if="currentRow.id" :student-id="currentRow.id" />
125             </el-tab-pane>
126       </el-tabs>
127   </div>
128 </template>
129
130 <script>
131 import * as StudentApi from '@/api/infra/demo';
132 import StudentForm from './StudentForm.vue';
133     import StudentContactList from './components/StudentContactList.vue';
134     import StudentTeacherList from './components/StudentTeacherList.vue';
135 export default {
136   name: "Student",
137   components: {
138           StudentForm,
139           StudentContactList,
140           StudentTeacherList,
141   },
142   data() {
143     return {
144       // 遮罩层
145       loading: true,
146       // 导出遮罩层
147       exportLoading: false,
148       // 显示搜索条件
149       showSearch: true,
150               // 总条数
151         total: 0,
152       // 学生列表
153       list: [],
154       // 是否展开,默认全部展开
155       isExpandAll: true,
156       // 重新渲染表格状态
157       refreshTable: true,
158       // 选中行
159       currentRow: {},
160       // 查询参数
161       queryParams: {
162                     pageNo: 1,
163             pageSize: 10,
164         name: null,
165         birthday: null,
166         sex: null,
167         enabled: null,
168         createTime: [],
169       },
170                       /** 子表的列表 */
171               subTabsName: 'studentContact'
172     };
173   },
174   created() {
175     this.getList();
176   },
177   methods: {
178     /** 查询列表 */
179     async getList() {
180       try {
181       this.loading = true;
182               const res = await StudentApi.getStudentPage(this.queryParams);
183         this.list = res.data.list;
184         this.total = res.data.total;
185       } finally {
186         this.loading = false;
187       }
188     },
189     /** 搜索按钮操作 */
190     handleQuery() {
191       this.queryParams.pageNo = 1;
192       this.getList();
193     },
194     /** 重置按钮操作 */
195     resetQuery() {
196       this.resetForm("queryForm");
197       this.handleQuery();
198     },
199     /** 添加/修改操作 */
200     openForm(id) {
201       this.$refs["formRef"].open(id);
202     },
203     /** 删除按钮操作 */
204     async handleDelete(row) {
205       const id = row.id;
206       await this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?')
207       try {
208        await StudentApi.deleteStudent(id);
209        await this.getList();
210        this.$modal.msgSuccess("删除成功");
211       } catch {}
212     },
213     /** 导出按钮操作 */
214     async handleExport() {
215       await this.$modal.confirm('是否确认导出所有学生数据项?');
216       try {
217         this.exportLoading = true;
218         const res = await StudentApi.exportStudentExcel(this.queryParams);
219         this.$download.excel(res.data, '学生.xls');
220       } catch {
221       } finally {
222         this.exportLoading = false;
223       }
224     },
225               /** 选中行操作 */
226         handleCurrentChange(row) {
227          this.currentRow = row;
228           /** 子表的列表 */
229           this.subTabsName = 'studentContact';
230         },
231         }
232 };
233 </script>