application-management.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <script setup lang="ts">
  2. import { computed, ref, watch } from 'vue';
  3. import { useRouter } from 'vue-router';
  4. import { useUserStore } from '@vben/stores';
  5. import { $t } from '@/locales';
  6. import { getMyApplicationListApi, type UserApi } from '#/api';
  7. import { useLoginModalStore } from '#/store';
  8. interface Props {
  9. jurisdiction: boolean;
  10. }
  11. const props = defineProps<Props>();
  12. const router = useRouter();
  13. const userStore = useUserStore();
  14. const isLogin = computed(() => !!userStore.userInfo);
  15. const loginModalStore = useLoginModalStore();
  16. const applicationList = ref<UserApi.ApplicationModel[]>([]);
  17. const loading = ref(false);
  18. async function fetchApplicationList() {
  19. if (!isLogin.value) {
  20. return;
  21. }
  22. try {
  23. loading.value = true;
  24. const result = await getMyApplicationListApi({
  25. currentPage: 1,
  26. pageSize: 10,
  27. orderByProperty: 'name',
  28. Ascending: true,
  29. totalPage: 1,
  30. totalCount: 1,
  31. filters: [
  32. {
  33. name: 'isEnable',
  34. value: 1,
  35. },
  36. {
  37. name: 'type',
  38. value: 'application',
  39. },
  40. ],
  41. });
  42. if (result?.result?.model) {
  43. applicationList.value = result.result.model;
  44. }
  45. } catch (error) {
  46. console.error('获取应用列表失败:', error);
  47. } finally {
  48. loading.value = false;
  49. }
  50. }
  51. function handleMore() {
  52. if (!isLogin.value) {
  53. loginModalStore.open();
  54. return;
  55. }
  56. router.push({
  57. path: '/application-management',
  58. query: {
  59. type: '1',
  60. },
  61. });
  62. }
  63. watch(
  64. () => isLogin.value,
  65. (newValue) => {
  66. if (newValue) {
  67. fetchApplicationList();
  68. }
  69. },
  70. { immediate: true },
  71. );
  72. </script>
  73. <template>
  74. <div class="info-card border-box h-[217px] w-full rounded-lg p-5 shadow-md">
  75. <div class="items-flex-start flex justify-between">
  76. <div>
  77. <h2 class="text-lg font-bold">
  78. {{ $t('homeModule.applicationManagement') }}
  79. </h2>
  80. <div class="text-xs text-[#9A9BA3]">Application Management</div>
  81. </div>
  82. <img
  83. alt="more"
  84. class="h-[29px] w-[29px] cursor-pointer"
  85. src="@/assets/image/home-more.png"
  86. @click="handleMore"
  87. />
  88. </div>
  89. <p
  90. v-if="!isLogin"
  91. class="mt-4 w-[714px] text-sm text-xs leading-relaxed text-[#9A9BA3]"
  92. >
  93. {{ $t('homeModule.applicationManagementIntroduction') }}
  94. </p>
  95. <div v-else-if="props.jurisdiction && isLogin" class="mt-[38px]">
  96. <div v-if="applicationList.length > 0" class="flex flex-wrap gap-[18px]">
  97. <div
  98. v-for="(item, index) in applicationList"
  99. :key="index"
  100. class="flex h-[37px] cursor-pointer items-center rounded-[11px] bg-[#fff] p-[6px_10px] shadow-md"
  101. >
  102. <img
  103. :src="`/File/Download?fileId=${item.imgLogoFileId}`"
  104. alt=""
  105. class="h-[24px] w-auto object-contain"
  106. />
  107. <span
  108. class="ml-[10px] font-['Open_Sans'] text-[13px] font-medium text-[#000]"
  109. >
  110. {{ item.name }}
  111. </span>
  112. </div>
  113. </div>
  114. <div
  115. v-else
  116. class="mx-auto mt-[-20px] flex flex-col items-center justify-center text-center"
  117. >
  118. <img
  119. alt=""
  120. class="block h-[80px] w-[85px]"
  121. src="@/assets/image/jurisdiction.png"
  122. />
  123. {{ $t('auth.emptyContent') }}
  124. </div>
  125. </div>
  126. <div
  127. v-else
  128. class="mt-[10px] flex flex-col items-center justify-center text-center"
  129. >
  130. <img
  131. alt=""
  132. class="block h-[80px] w-[85px]"
  133. src="@/assets/image/empty.png"
  134. />
  135. {{ $t('auth.noPermission') }}
  136. </div>
  137. </div>
  138. </template>
  139. <style scoped>
  140. .info-card {
  141. overflow: hidden;
  142. background: url('@/assets/image/ApplicationManagement.png') no-repeat center
  143. center;
  144. background-size: cover;
  145. border-radius: 26px;
  146. }
  147. </style>