houzhongjian
2024-07-11 759b1c71011abd6b58c37d2566f3f3c208c2f1b2
提交 | 用户 | 时间
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="score" />
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: "Demo03CourseList",
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.getDemo03CourseListByStudentId(this.studentId);
59         this.list = res.data;
60       } finally {
61         this.loading = false;
62       }
63     },
64     /** 搜索按钮操作 */
65     handleQuery() {
66       this.queryParams.pageNo = 1;
67       this.getList();
68     },
69   }
70 };
71 </script>