DemoStudentContactList.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <!-- 列表 -->
  3. <ContentWrap>
  4. <el-button type="primary" plain @click="openForm('create')">
  5. <Icon icon="ep:plus" class="mr-5px" /> 新增
  6. </el-button>
  7. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  8. <el-table-column label="编号" align="center" prop="id" />
  9. <el-table-column label="手机" align="center" prop="mobile" />
  10. </el-table>
  11. </ContentWrap>
  12. <!-- 表单弹窗:添加/修改 -->
  13. <DemoStudentContactForm ref="formRef" @success="getList" />
  14. </template>
  15. <script setup lang="ts">
  16. import DemoStudentContactForm from './DemoStudentContactForm.vue'
  17. const props = defineProps<{
  18. studentId: undefined // 学生编号
  19. }>()
  20. const loading = ref(false) // 列表的加载中
  21. const total = ref(0) // 列表的总页数
  22. const list = ref([]) // 列表的数据
  23. const queryParams = reactive({
  24. pageNo: 1,
  25. pageSize: 10,
  26. studentId: undefined
  27. })
  28. /** 监听主表的关联字段的变化,加载对应的子表数据 */
  29. watch(
  30. () => props.studentId,
  31. (val) => {
  32. queryParams.studentId = val
  33. handleQuery()
  34. },
  35. { immediate: false }
  36. )
  37. /** 查询列表 */
  38. const getList = async () => {
  39. loading.value = true
  40. try {
  41. // const data = await DemoStudentApi.getDemoStudentPage(queryParams)
  42. list.value = [
  43. {
  44. id: props.studentId,
  45. mobile: '15601691300'
  46. }
  47. ]
  48. total.value = 10
  49. } finally {
  50. loading.value = false
  51. }
  52. }
  53. /** 搜索按钮操作 */
  54. const handleQuery = () => {
  55. queryParams.pageNo = 1
  56. getList()
  57. }
  58. /** 添加/修改操作 */
  59. const formRef = ref()
  60. const openForm = (type: string, id?: number) => {
  61. formRef.value.open(type, id)
  62. }
  63. </script>