index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <script setup lang="ts">
  2. defineOptions({
  3. name: 'modelList',
  4. })
  5. import { Plus } from '@element-plus/icons-vue'
  6. import { ElButton, ElDialog, ElEmpty, ElInput, ElMessage, ElOption, ElPagination, ElSelect, ElTable, ElTableColumn, ElTag } from 'element-plus'
  7. // import SearchForm from './components/SearchForm.vue'
  8. import type { TModel } from '@/types/model'
  9. import { fetchModel, fetchModelDetail } from '@/api/modules/model'
  10. import { formatDateGeneral } from '@/utils'
  11. const tableRef = ref()
  12. const loading = ref(false)
  13. const router = useRouter()
  14. const route = useRoute()
  15. // 搜索参数
  16. const searchParams = ref({
  17. name: '',
  18. })
  19. const dataList = ref<TModel[]>([]);
  20. // 分页信息
  21. const pagination = ref({
  22. page: 1,
  23. size: 20,
  24. total: 0,
  25. })
  26. const handleRecommend = (id: string) => {
  27. }
  28. async function fetchData() {
  29. loading.value = true
  30. const res = await fetchModel()
  31. console.log(res, 'res')
  32. if(res.code === 0){
  33. dataList.value = res.data.content
  34. console.log(dataList.value, 'dataList')
  35. pagination.value.total = res.data.total
  36. }
  37. loading.value = false
  38. }
  39. function handlePageChange(page: number) {
  40. pagination.value.page = page
  41. if(pagination.value.page !== page){
  42. fetchData()
  43. }
  44. }
  45. function handleSizeChange(size: number) {
  46. pagination.value.size = size
  47. pagination.value.page = 1
  48. fetchData()
  49. }
  50. async function handleView (row: TModel) {
  51. console.log(row, 'view')
  52. // const response = await fetchModelDetail({id: row.id})
  53. // console.log(response,33344)
  54. }
  55. onMounted(async () => {
  56. await fetchData()
  57. })
  58. </script>
  59. <template>
  60. <div class="absolute-container">
  61. <FaPageHeader title="大模型列表" />
  62. <FaPageMain class="flex-1 overflow-auto" main-class="flex-1 flex flex-col overflow-auto">
  63. <ElTable
  64. v-loading="loading"
  65. ref="tableRef" :data="dataList" stripe highlight-current-row border height="100%"
  66. >
  67. <ElTableColumn label="id" prop="id" min-width="240" />
  68. <ElTableColumn label="Name" prop="name" min-width="220" />
  69. <ElTableColumn label="service" prop="service" />
  70. <ElTableColumn label="spaceId" prop="spaceId" />
  71. <ElTableColumn label="userId" prop="userId" width="180" />
  72. <ElTableColumn label="userId" prop="customEdit" width="180" />
  73. <ElTableColumn label="createTime" prop="ctime" width="180">
  74. <template #default="scope">
  75. {{ formatDateGeneral(scope.row.ctime) }}
  76. </template>
  77. </ElTableColumn>
  78. <ElTableColumn fixed="right" label="操作" min-width="200">
  79. <template #default="{row}">
  80. <ElButton link type="primary" size="small" @click="handleView(row)">查看</ElButton>
  81. </template>
  82. </ElTableColumn>
  83. </ElTable>
  84. <div class="p-4">
  85. <ElPagination
  86. v-model:current-page="pagination.page"
  87. v-model:page-size="pagination.size"
  88. :total="pagination.total"
  89. :page-sizes="[10, 20, 50, 100]"
  90. layout="total, sizes, prev, pager, next, jumper"
  91. @size-change="handleSizeChange"
  92. @current-change="handlePageChange"
  93. />
  94. </div>
  95. </FaPageMain>
  96. </div>
  97. </template>
  98. <style scoped>
  99. .absolute-container {
  100. position: absolute;
  101. display: flex;
  102. flex-direction: column;
  103. width: 100%;
  104. height: 100%;
  105. }
  106. </style>