Home-date.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <el-card shadow="never">
  3. <el-text type="danger">欢迎:{{ userInfos.name }}使用本系统!</el-text>
  4. <el-text type="info" class="ml20">公历:{{ formatDate(now, 'YYYY-mm-dd HH:MM:SS WWW') }}</el-text>
  5. <el-text type="info" class="ml20">农历:{{ getChineseDate() }}</el-text>
  6. <el-badge :is-dot="isDot" class="ml20" v-if="isOldHotlineUrl">
  7. <el-button class="share-button" type="primary" @click="linkOld" :disabled="!userNameEncryptionEnCode"
  8. ><SvgIcon name="iconfont icon-daohang" class="mr5" size="18px" /> 一键登录到旧系统</el-button
  9. >
  10. </el-badge>
  11. <el-button class="ml10" type="primary" @click="linkUrl" v-auth="'home:rxzf'"><SvgIcon name="iconfont icon-daohang" class="mr5" size="18px" /> 热线赋智</el-button>
  12. </el-card>
  13. </template>
  14. <script setup lang="ts">
  15. import { formatDate } from '@/utils/formatTime';
  16. import { useNow } from '@vueuse/core';
  17. import calendar from '@/utils/calendar';
  18. import { useUserInfo } from '@/stores/userInfo';
  19. import { storeToRefs } from 'pinia';
  20. import { computed, onMounted, ref } from 'vue';
  21. import { useAppConfig } from '@/stores/appConfig';
  22. import { getOldHotlineList, getUserNameApi } from '@/api/home';
  23. import { useIntervalFn } from '@vueuse/shared';
  24. const stores = useUserInfo(); // 用户信息
  25. const { userInfos } = storeToRefs(stores); // 用户信息
  26. const appConfigStore = useAppConfig();
  27. const { AppConfigInfo } = storeToRefs(appConfigStore); // 系统配置信息
  28. const now = useNow(); // 获取当前时间
  29. // 获取农历
  30. const getChineseDate = () => {
  31. const lunarDay: any = calendar.solar2lunar(new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate());
  32. return `${lunarDay.IMonthCn}${lunarDay.IDayCn} ${lunarDay.gzYear}${lunarDay.Animal}年 ${lunarDay.gzMonth}月 ${lunarDay.gzDay}日`;
  33. };
  34. // 获取加密后的用户名
  35. // encodeURIComponent
  36. const userNameEncryptionEnCode = ref(''); // 需要转码
  37. const getUserName = () => {
  38. getUserNameApi({ IsUrlEncode: true })
  39. .then((res) => {
  40. userNameEncryptionEnCode.value = res.result;
  41. getOldWorkTodo();
  42. })
  43. .catch((err) => {});
  44. };
  45. // 查询老系统的工单是否有待办 60秒查询一次
  46. const isDot = ref(false);
  47. const getOldWorkTodo = () => {
  48. getOldHotlineList()
  49. .then((res: any) => {
  50. isDot.value = res.result ?? false;
  51. })
  52. .catch((err) => {
  53. console.log('旧系统的查询工单待办失败:', err);
  54. });
  55. useIntervalFn(() => {
  56. getOldHotlineList()
  57. .then((res: any) => {
  58. isDot.value = res.result ?? false;
  59. })
  60. .catch((err) => {
  61. console.log('旧系统的查询工单待办失败:', err);
  62. });
  63. }, 60 * 1000);
  64. };
  65. // 一建登录到旧系统
  66. const linkOld = () => {
  67. window.open(AppConfigInfo.value.oldHotlineUrl + userNameEncryptionEnCode.value);
  68. };
  69. // 判断是否有这个配置地址 排除空格
  70. const isOldHotlineUrl = computed(() => {
  71. return AppConfigInfo.value.oldHotlineUrl && AppConfigInfo.value.oldHotlineUrl.trim();
  72. });
  73. // 地址跳转
  74. const linkUrl = () => {
  75. window.open(`https://rxfz.scopenai.com:18027/TokenLogin?id=${userInfos.value.id}`);
  76. };
  77. onMounted(() => {
  78. if (isOldHotlineUrl.value) {
  79. getUserName();
  80. }
  81. });
  82. </script>
  83. <style lang="scss" scoped>
  84. :deep(.el-badge__content.is-dot) {
  85. height: 12px;
  86. width: 12px;
  87. }
  88. </style>