index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <script lang="ts" setup name="DBTypeIndex">
  2. import { ElMessage, ElMessageBox } from 'element-plus'
  3. import DBType from './components/DBType.vue'
  4. import { deleteDbTypeById, getDbTypeByList } from '@/api/database/dbTypeApi'
  5. const state = reactive({
  6. loading: false,
  7. // 表格是否自适应高度
  8. tableAutoHeight: false,
  9. // 搜索
  10. search: {
  11. keywords: '',
  12. },
  13. // 列表数据
  14. dataList: [],
  15. })
  16. const appCatRef = ref()
  17. const getDataList = async () => {
  18. state.loading = true
  19. const { data } = await getDbTypeByList({})
  20. state.dataList = data
  21. state.loading = false
  22. }
  23. onMounted(() => {
  24. getDataList()
  25. })
  26. function onCreate() {}
  27. function onDBTypeAdd() {
  28. appCatRef.value.showAddModel()
  29. }
  30. function onDBTypeEdit(row: any) {
  31. const appCatId = row.appCatId
  32. appCatRef.value.showEditModel(appCatId)
  33. }
  34. function onDBTypeDel(row: any) {
  35. ElMessageBox.confirm(`确认删除「${row.dbTypeTitle}」吗?`, '确认信息').then(async () => {
  36. await deleteDbTypeById(row.appCatId)
  37. await getDataList()
  38. ElMessage.success({
  39. message: '删除成功',
  40. center: true,
  41. })
  42. }).catch(() => {})
  43. }
  44. </script>
  45. <template>
  46. <div :class="{ 'absolute-container': state.tableAutoHeight }">
  47. <page-header title="数据库接入设定">
  48. <template #content>
  49. <div>
  50. 系统支持多种数据库接入,用于设定接入参数
  51. </div>
  52. </template>
  53. <el-button-group>
  54. <el-button type="primary" size="large" plain @click="onDBTypeAdd">
  55. <template #icon>
  56. <el-icon>
  57. <svg-icon name="ep:plus" />
  58. </el-icon>
  59. </template>
  60. 新增
  61. </el-button>
  62. </el-button-group>
  63. </page-header>
  64. <page-main>
  65. <el-table v-loading="state.loading" class="list-table" :data="state.dataList" border stripe highlight-current-row height="100%">
  66. <el-table-column type="index" label="序号" width="60" header-align="center" align="center" />
  67. <el-table-column prop="appCatTitle" label="名称" header-align="center" align="center" width="200" />
  68. <el-table-column prop="appCatDesc" label="说明" />
  69. <el-table-column label="操作" width="250" align="center" fixed="right">
  70. <template #default="scope">
  71. <el-button type="primary" size="small" plain @click="onDBTypeEdit(scope.row)">
  72. 编辑
  73. </el-button>
  74. <el-button v-if="!scope.row.isFixed" type="danger" size="small" plain @click="onDBTypeDel(scope.row)">
  75. 删除
  76. </el-button>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. </page-main>
  81. <DBType ref="appCatRef" @success="getDataList" />
  82. </div>
  83. </template>
  84. <style lang="scss" scoped>
  85. .absolute-container {
  86. position: absolute;
  87. width: 100%;
  88. height: 100%;
  89. display: flex;
  90. flex-direction: column;
  91. .page-header {
  92. margin-bottom: 0;
  93. }
  94. .page-main {
  95. // 让 page-main 的高度自适应
  96. flex: 1;
  97. overflow: auto;
  98. display: flex;
  99. flex-direction: column;
  100. .search-container {
  101. margin-bottom: 0;
  102. }
  103. }
  104. }
  105. </style>