application-management.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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: 7,
  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. function handleClick(item: UserApi.ApplicationModel) {
  64. const baseUrl = location.origin + location.pathname;
  65. window.open(
  66. `${baseUrl}#/jumpToEnterprise?enterpriseCode=${item.code}&webSite=${item.webSite}`,
  67. '_blank',
  68. );
  69. }
  70. watch(
  71. () => isLogin.value,
  72. (newValue) => {
  73. if (newValue) {
  74. fetchApplicationList();
  75. }
  76. },
  77. { immediate: true },
  78. );
  79. </script>
  80. <template>
  81. <div class="info-card border-box h-[217px] w-full rounded-lg p-5 shadow-md">
  82. <div class="items-flex-start flex justify-between">
  83. <div>
  84. <h2 class="text-lg font-bold">
  85. {{ $t('homeModule.applicationManagement') }}
  86. </h2>
  87. <div class="text-xs text-[#9A9BA3]">Application Management</div>
  88. </div>
  89. <img
  90. v-if="props.jurisdiction"
  91. alt="more"
  92. class="h-[29px] w-[29px] cursor-pointer"
  93. src="@/assets/image/home-more.png"
  94. @click="handleMore"
  95. />
  96. </div>
  97. <p
  98. v-if="!isLogin"
  99. class="mt-4 w-[714px] text-sm text-xs leading-relaxed text-[#9A9BA3]"
  100. >
  101. {{ $t('homeModule.applicationManagementIntroduction') }}
  102. </p>
  103. <div v-else-if="props.jurisdiction && isLogin" class="mt-[38px]">
  104. <div v-if="applicationList.length > 0" class="flex flex-wrap gap-[18px]">
  105. <div
  106. v-for="(item, index) in applicationList"
  107. :key="index"
  108. class="flex h-[37px] cursor-pointer items-center rounded-[11px] bg-[#fff] p-[6px_10px] shadow-md"
  109. @click="handleClick(item)"
  110. >
  111. <img
  112. :src="`/File/Download?fileId=${item.imgLogoFileId}`"
  113. alt=""
  114. class="h-[24px] w-auto object-contain"
  115. />
  116. <span
  117. class="ml-[10px] font-['Open_Sans'] text-[13px] font-medium text-[#000]"
  118. >
  119. {{ item.name }}
  120. </span>
  121. </div>
  122. </div>
  123. <div
  124. v-else
  125. class="mx-auto mt-[-20px] flex flex-col items-center justify-center text-center"
  126. >
  127. <img
  128. alt=""
  129. class="block h-[80px] w-[85px]"
  130. src="@/assets/image/jurisdiction.png"
  131. />
  132. {{ $t('auth.emptyContent') }}
  133. </div>
  134. </div>
  135. <div
  136. v-else
  137. class="mt-[10px] flex flex-col items-center justify-center text-center"
  138. >
  139. <img
  140. alt=""
  141. class="block h-[80px] w-[85px]"
  142. src="@/assets/image/empty.png"
  143. />
  144. {{ $t('auth.noPermission') }}
  145. </div>
  146. </div>
  147. </template>
  148. <style scoped>
  149. .info-card {
  150. overflow: hidden;
  151. background: url('@/assets/image/ApplicationManagement.png') no-repeat center
  152. center;
  153. background-size: cover;
  154. border-radius: 26px;
  155. }
  156. </style>