index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div>
  3. <Breadcrumb />
  4. <TabFilter v-model="activeTab" :options="options" @change="handleTabChange" />
  5. <TableCard :data="tableData" :columns="columns" v-model:page-no="pageNo" v-model:page-size="pageSize"
  6. @change="handleChange" :total="total" @selection-change="handleSelectionChange">
  7. <template #toolbar-left>
  8. <el-button type="primary" :icon="CirclePlus" size="large" class="is-solid"
  9. @click="dialogForm.visible = true">添加实例</el-button>
  10. <el-button type="primary" disabled :icon="Delete" size="large" class="is-solid">删除</el-button>
  11. <el-button type="primary" disabled :icon="MoreFilled" size="large" class="is-solid">更多</el-button>
  12. <el-button type="primary" :icon="Refresh" size="large" class="is-solid">刷新</el-button>
  13. </template>
  14. <template #toolbar-right>
  15. <el-input :prefix-icon="Search" v-model="searchKeyword" size="large" placeholder="请输入关键词搜索" style="width: 300px"
  16. clearable />
  17. <el-button :icon="Search" type="primary" class="is-solid" size="large">搜索</el-button>
  18. <el-button :icon="Upload" type="primary" class="is-solid" size="large">导出</el-button>
  19. </template>
  20. <template #column-status="{ row }">
  21. <el-tag :type="row.status === '正常' ? 'success' : 'danger'">
  22. {{ row.status }}
  23. </el-tag>
  24. </template>
  25. <template #column-noHeartbeat="{ row }">
  26. <el-switch v-model="row.noHeartbeat"></el-switch>
  27. </template>
  28. <template #column-enableLTS="{ row }">
  29. <el-switch v-model="row.enableLTS"></el-switch>
  30. </template>
  31. <template #column-autoReconnect="{ row }">
  32. <el-switch v-model="row.autoReconnect"></el-switch>
  33. </template>
  34. <template #column-operation="{ row }">
  35. <el-button type="primary" link>管理详情</el-button>
  36. <el-button type="primary" link>升级</el-button>
  37. <el-button type="primary" link>编辑</el-button>
  38. <el-button type="warning" link>续费</el-button>
  39. <el-button type="danger" link>删除</el-button>
  40. </template>
  41. </TableCard>
  42. <AddOrEdit v-model:visible="dialogForm.visible" />
  43. </div>
  44. </template>
  45. <script setup lang="ts">
  46. import AddOrEdit from './components/AddOrEdit.vue'
  47. import TabFilter from '@/components/TabFilter/index.vue'
  48. import TableCard from '@/components/TableCard/index.vue'
  49. import { CirclePlus, Delete, MoreFilled, Refresh, Search, Upload } from '@element-plus/icons-vue'
  50. const activeTab = ref('all')
  51. const searchKeyword = ref('')
  52. const selectedRows = ref<any[]>([])
  53. const state = reactive({
  54. pageNo: 1,
  55. pageSize: 10,
  56. total: 20
  57. })
  58. const dialogForm = reactive({
  59. visible: false
  60. })
  61. const { pageNo, pageSize, total } = toRefs(state)
  62. const options = [
  63. { label: '全部', value: 'all' },
  64. { label: '正常', value: 'normal' },
  65. { label: '即将到期', value: 'expiring' },
  66. { label: '禁用', value: 'disabled' }
  67. ]
  68. const columns = [
  69. { type: 'selection' as const, width: 55 },
  70. { prop: 'name', label: '实例唯一标识', minWidth: 120 },
  71. { prop: 'userId', label: '所属用户', },
  72. { prop: 'address', label: '实例名称', },
  73. { prop: 'expireTime', label: '到期时间', },
  74. { prop: 'instanceType', label: '实例类型', },
  75. { prop: 'status', label: '状态', },
  76. { prop: 'noHeartbeat', label: '无心跳通讯', minWidth: 120 },
  77. { prop: 'noDataTimeout', label: '无数据超时时间', minWidth: 130 },
  78. { prop: 'enableLTS', label: '是否启用LTS', minWidth: 120 },
  79. { prop: 'autoReconnect', label: '断线自动重连', minWidth: 120 },
  80. { prop: 'maxConcurrent', label: '客户端最大并发数', minWidth: 150 },
  81. { prop: 'createTime', label: '创建时间', minWidth: 150 },
  82. { prop: 'operation', label: '操作', minWidth: 280, isAction: true }
  83. ]
  84. const tableData = ref([
  85. {
  86. name: '实例1',
  87. userId: '用户1',
  88. address: '实例1',
  89. expireTime: '2023-12-31',
  90. instanceType: '普通实例',
  91. status: '正常',
  92. noHeartbeat: true,
  93. noDataTimeout: '10秒',
  94. enableLTS: true,
  95. autoReconnect: false,
  96. maxConcurrent: '100',
  97. createTime: '2023-01-01 10:00:00'
  98. }
  99. ])
  100. function handleTabChange(value: string | number) {
  101. console.log('切换到:', value)
  102. }
  103. function handleChange(page: number, size: number) {
  104. console.log('分页变化:', page, size)
  105. }
  106. function handleSelectionChange(selection: any[]) {
  107. selectedRows.value = selection
  108. }
  109. </script>
  110. <style lang="scss" scoped></style>