houzhongyi
2024-07-11 e7c1260db32209a078a962aaa0ad5492c35774fb
提交 | 用户 | 时间
e7c126 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="description" />
7                 <el-table-column label="出生日期" align="center" prop="birthday" width="180">
8                   <template v-slot="scope">
9                     <span>{{ parseTime(scope.row.birthday) }}</span>
10                   </template>
11                 </el-table-column>
12                 <el-table-column label="性别" align="center" prop="sex">
13                   <template v-slot="scope">
14                     <dict-tag :type="DICT_TYPE.SYSTEM_USER_SEX" :value="scope.row.sex" />
15                   </template>
16                 </el-table-column>
17                 <el-table-column label="是否有效" align="center" prop="enabled">
18                   <template v-slot="scope">
19                     <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.enabled" />
20                   </template>
21                 </el-table-column>
22                 <el-table-column label="头像" align="center" prop="avatar" />
23                 <el-table-column label="附件" align="center" prop="video" />
24                 <el-table-column label="备注" align="center" prop="memo" />
25                 <el-table-column label="创建时间" align="center" prop="createTime" width="180">
26                   <template v-slot="scope">
27                     <span>{{ parseTime(scope.row.createTime) }}</span>
28                   </template>
29                 </el-table-column>
30     <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
31       <template v-slot="scope">
32         <el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)"
33                    v-hasPermi="['infra:student:update']">修改</el-button>
34         <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
35                    v-hasPermi="['infra:student:delete']">删除</el-button>
36       </template>
37     </el-table-column>
38   </el-table>
39   </div>
40 </template>
41
42 <script>
43   import * as StudentApi from '@/api/infra/demo';
44   export default {
45     name: "StudentTeacherList",
46     props:[
47       'studentId'
48     ],// 学生编号(主表的关联字段)
49     data() {
50       return {
51         // 遮罩层
52         loading: true,
53         // 列表的数据
54         list: [],
55       };
56     },
57     created() {
58       this.getList();
59     },
60     watch:{/** 监听主表的关联字段的变化,加载对应的子表数据 */
61         studentId:{
62             handler(val) {
63               this.queryParams.studentId = val;
64               if (val){
65                 this.handleQuery();
66               }
67             },
68             immediate: true
69       }
70     },
71     methods: {
72       /** 查询列表 */
73       async getList() {
74         try {
75           this.loading = true;
76                 const res = await  StudentApi.getStudentTeacherByStudentId(this.studentId);
77                 const data = res.data;
78                 if (!data) {
79                   return;
80                 }
81                 this.list.push(data);
82         } finally {
83           this.loading = false;
84         }
85       },
86       /** 搜索按钮操作 */
87       handleQuery() {
88         this.queryParams.pageNo = 1;
89         this.getList();
90       },
91     }
92   };
93 </script>