提交 | 用户 | 时间
|
759b1c
|
1 |
<template> |
H |
2 |
<div class="app-container"> |
|
3 |
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> |
|
4 |
<el-table-column label="编号" align="center" prop="id" /> |
|
5 |
<el-table-column label="名字" align="center" prop="name" /> |
|
6 |
<el-table-column label="班主任" align="center" prop="teacher" /> |
|
7 |
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
|
8 |
<template v-slot="scope"> |
|
9 |
<span>{{ parseTime(scope.row.createTime) }}</span> |
|
10 |
</template> |
|
11 |
</el-table-column> |
|
12 |
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
|
13 |
<template v-slot="scope"> |
|
14 |
<el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)" |
|
15 |
v-hasPermi="['infra:demo03-student:update']">修改</el-button> |
|
16 |
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" |
|
17 |
v-hasPermi="['infra:demo03-student:delete']">删除</el-button> |
|
18 |
</template> |
|
19 |
</el-table-column> |
|
20 |
</el-table> |
|
21 |
</div> |
|
22 |
</template> |
|
23 |
|
|
24 |
<script> |
|
25 |
import * as Demo03StudentApi from '@/api/infra/demo03-inner'; |
|
26 |
export default { |
|
27 |
name: "Demo03GradeList", |
|
28 |
props:[ |
|
29 |
'studentId' |
|
30 |
],// 学生编号(主表的关联字段) |
|
31 |
data() { |
|
32 |
return { |
|
33 |
// 遮罩层 |
|
34 |
loading: true, |
|
35 |
// 列表的数据 |
|
36 |
list: [], |
|
37 |
}; |
|
38 |
}, |
|
39 |
created() { |
|
40 |
this.getList(); |
|
41 |
}, |
|
42 |
watch:{/** 监听主表的关联字段的变化,加载对应的子表数据 */ |
|
43 |
studentId:{ |
|
44 |
handler(val) { |
|
45 |
this.queryParams.studentId = val; |
|
46 |
if (val){ |
|
47 |
this.handleQuery(); |
|
48 |
} |
|
49 |
}, |
|
50 |
immediate: true |
|
51 |
} |
|
52 |
}, |
|
53 |
methods: { |
|
54 |
/** 查询列表 */ |
|
55 |
async getList() { |
|
56 |
try { |
|
57 |
this.loading = true; |
|
58 |
const res = await Demo03StudentApi.getDemo03GradeByStudentId(this.studentId); |
|
59 |
const data = res.data; |
|
60 |
if (!data) { |
|
61 |
return; |
|
62 |
} |
|
63 |
this.list.push(data); |
|
64 |
} finally { |
|
65 |
this.loading = false; |
|
66 |
} |
|
67 |
}, |
|
68 |
/** 搜索按钮操作 */ |
|
69 |
handleQuery() { |
|
70 |
this.queryParams.pageNo = 1; |
|
71 |
this.getList(); |
|
72 |
}, |
|
73 |
} |
|
74 |
}; |
|
75 |
</script> |