index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="yd-page-container">
  3. <!-- 顶部导航栏 -->
  4. <wd-navbar
  5. title="数据源配置管理"
  6. left-arrow placeholder safe-area-inset-top fixed
  7. @click-left="handleBack"
  8. />
  9. <!-- 数据源配置列表 -->
  10. <view class="p-24rpx">
  11. <view
  12. v-for="item in list"
  13. :key="item.id"
  14. class="mb-24rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
  15. @click="handleDetail(item)"
  16. >
  17. <view class="p-24rpx">
  18. <view class="mb-16rpx flex items-center justify-between">
  19. <view class="text-32rpx text-[#333] font-semibold">
  20. {{ item.name }}
  21. </view>
  22. <view v-if="item.id === 0" class="rounded-4rpx bg-[#e6f7ff] px-12rpx py-4rpx text-24rpx text-[#1890ff]">
  23. 主数据源
  24. </view>
  25. </view>
  26. <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
  27. <text class="mr-8rpx shrink-0 text-[#999]">主键编号:</text>
  28. <text class="min-w-0 flex-1 truncate">{{ item.id }}</text>
  29. </view>
  30. <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
  31. <text class="mr-8rpx text-[#999]">数据源连接:</text>
  32. <text class="min-w-0 flex-1 truncate">{{ item.url }}</text>
  33. </view>
  34. <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
  35. <text class="mr-8rpx text-[#999]">用户名:</text>
  36. <text>{{ item.username }}</text>
  37. </view>
  38. <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
  39. <text class="mr-8rpx text-[#999]">创建时间:</text>
  40. <text>{{ formatDateTime(item.createTime) }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 空状态 -->
  45. <view v-if="!loading && list.length === 0" class="py-100rpx text-center">
  46. <wd-status-tip image="content" tip="暂无数据源配置数据" />
  47. </view>
  48. </view>
  49. <!-- 新增按钮 -->
  50. <wd-fab
  51. v-if="hasAccessByCodes(['infra:data-source-config:create'])"
  52. position="right-bottom"
  53. type="primary"
  54. :expandable="false"
  55. @click="handleAdd"
  56. />
  57. </view>
  58. </template>
  59. <script lang="ts" setup>
  60. import type { DataSourceConfig } from '@/api/infra/data-source-config'
  61. import { onMounted, ref } from 'vue'
  62. import { useToast } from 'wot-design-uni'
  63. import { getDataSourceConfigList } from '@/api/infra/data-source-config'
  64. import { useAccess } from '@/hooks/useAccess'
  65. import { navigateBackPlus } from '@/utils'
  66. import { formatDateTime } from '@/utils/date'
  67. definePage({
  68. style: {
  69. navigationBarTitleText: '',
  70. navigationStyle: 'custom',
  71. },
  72. })
  73. const { hasAccessByCodes } = useAccess()
  74. const toast = useToast()
  75. const list = ref<DataSourceConfig[]>([])
  76. const loading = ref(false)
  77. /** 返回上一页 */
  78. function handleBack() {
  79. navigateBackPlus()
  80. }
  81. /** 查询数据源配置列表 */
  82. async function getList() {
  83. loading.value = true
  84. try {
  85. toast.loading('加载中...')
  86. list.value = await getDataSourceConfigList()
  87. } finally {
  88. loading.value = false
  89. toast.close()
  90. }
  91. }
  92. /** 新增数据源配置 */
  93. function handleAdd() {
  94. uni.navigateTo({
  95. url: '/pages-infra/data-source-config/form/index',
  96. })
  97. }
  98. /** 查看详情 */
  99. function handleDetail(item: DataSourceConfig) {
  100. uni.navigateTo({
  101. url: `/pages-infra/data-source-config/detail/index?id=${item.id}`,
  102. })
  103. }
  104. /** 初始化 */
  105. onMounted(() => {
  106. getList()
  107. })
  108. </script>
  109. <style lang="scss" scoped>
  110. </style>