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