table.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <v-card class="pa-3" elevation="5">
  3. <CtForm ref="CtFormRef" :items="formItems" class="mt-3">
  4. <template #formBtn>
  5. <v-btn color="primary" class="elevation-5" @click.stop="handleSearch">搜 索</v-btn>
  6. <v-btn variant="outlined" color="primary" class="elevation-5 ml-3" @click.stop="handleReset">重 置</v-btn>
  7. </template>
  8. </CtForm>
  9. </v-card>
  10. <v-card class="mt-3" elevation="5">
  11. <CtTable
  12. :items="items"
  13. class="pa-3"
  14. :headers="headers"
  15. :loading="false"
  16. :elevation="0"
  17. :isTools="false"
  18. :showPage="true"
  19. :total="total"
  20. :page-info="query"
  21. itemKey="id"
  22. @pageHandleChange="handleChangePage"
  23. >
  24. <template #actions="{ item }">
  25. <v-btn variant="text" color="primary" @click.stop="handleDetail(item)">详 情</v-btn>
  26. </template>
  27. </CtTable>
  28. </v-card>
  29. <v-navigation-drawer v-model="showDetail" absolute location="left" rounded temporary width="500" class="pa-5">
  30. 详情
  31. </v-navigation-drawer>
  32. </template>
  33. <script setup>
  34. defineOptions({ name: 'newlyAppointedTable'})
  35. import { ref } from 'vue'
  36. const total = ref(0)
  37. const query = ref({
  38. pageSize: 10,
  39. pageNo: 1
  40. })
  41. const items = ref([
  42. { id: 1, name: '张三', area: '北京', hotel: '北京王府半岛酒店' },
  43. { id: 2, name: '李四', area: '上海', hotel: '上海外滩茂悦大酒店' },
  44. { id: 3, name: '王五', area: '广州', hotel: '广州富力丽思卡尔顿酒店' },
  45. ])
  46. const headers = [
  47. { title: '姓名', key: 'name', sortable: false },
  48. { title: '地区', key: 'area', sortable: false },
  49. { title: '酒店', key: 'hotel', sortable: false },
  50. { title: '操作', key: 'actions', sortable: false, align: 'center' }
  51. ]
  52. const CtFormRef = ref()
  53. const formItems = ref({
  54. options: [
  55. {
  56. type: 'text',
  57. key: 'name',
  58. value: '',
  59. label: '姓名',
  60. hideDetails: true,
  61. col: 3
  62. },
  63. {
  64. type: 'text',
  65. key: 'area',
  66. value: '',
  67. label: '地区',
  68. hideDetails: true,
  69. flexStyle: 'mx-3',
  70. col: 3
  71. },
  72. {
  73. type: 'text',
  74. key: 'hotel',
  75. value: '',
  76. label: '酒店',
  77. hideDetails: true,
  78. col: 3
  79. },
  80. {
  81. slotName: 'formBtn',
  82. col: 3,
  83. flexStyle: 'ml-3'
  84. }
  85. ]
  86. })
  87. const handleChangePage = (e) => {
  88. query.value.pageNo = e
  89. }
  90. const handleSearch = () => {}
  91. const handleReset = () => {}
  92. const showDetail = ref(false)
  93. const handleDetail = (item) => {
  94. console.log(item, 'detail')
  95. showDetail.value = true
  96. }
  97. </script>
  98. <style scoped lang="scss">
  99. </style>