head-com.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <div class="head-com">
  3. <div class="head-com-left">
  4. <CusEllipsis :value="dutyPeopleCpt"/>
  5. </div>
  6. <div class="head-com-right">
  7. <img class="icon-date" src="@/assets/images/layout/head_icon-1.png">
  8. <div class="date">{{currentDateCpt}}</div>
  9. <img class="icon-user" src="@/assets/images/layout/head_icon-2.png">
  10. <div class="name">{{$store.state.app.userInfo?.displayName}}</div>
  11. <div class="dept">{{$store.state.app.userInfo?.dept?.organizationName}}</div>
  12. <div class="button __hover" @click="onLogout">退出</div>
  13. </div>
  14. </div>
  15. </template>
  16. <script lang="ts">
  17. import {
  18. defineComponent,
  19. computed,
  20. onMounted,
  21. ref,
  22. reactive,
  23. watch,
  24. getCurrentInstance,
  25. ComponentInternalInstance,
  26. toRefs,
  27. nextTick
  28. } from 'vue'
  29. import {useStore} from 'vuex'
  30. import {useRouter, useRoute} from 'vue-router'
  31. import {toLogin} from "@/utils/permissions";
  32. import {ElMessageBox} from "element-plus";
  33. export default defineComponent({
  34. name: '',
  35. components: {},
  36. setup() {
  37. const store = useStore();
  38. const router = useRouter();
  39. const route = useRoute();
  40. const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
  41. const state = reactive({
  42. })
  43. const dutyPeopleCpt = computed(() => {
  44. let str = ''
  45. const dutyHallLeader = `值班厅领导:${store.state.app.dutyInfo?.dutyHallLeader ? store.state.dictionary.dutyHallLeaderMap.get(store.state.app.dutyInfo.dutyHallLeader) : '无'}`
  46. const totalClass = `总值班:${store.state.app.dutyInfo?.totalClass ? store.state.dictionary.totalClassMap.get(store.state.app.dutyInfo.totalClass) : '无'}`
  47. const shiftLeader = `带班领导:${store.state.app.dutyInfo?.shiftLeader ? store.state.dictionary.shiftLeaderMap.get(store.state.app.dutyInfo.shiftLeader) : '无'}`
  48. const dutyPerson = `值班员:${store.state.app.dutyInfo?.dutyPerson ? store.state.app.dutyInfo.dutyPerson.split(',').map(v => store.state.dictionary.dutyPersonMap.get(v)) : '无'}`
  49. str += `${dutyHallLeader} ${totalClass} ${shiftLeader} ${dutyPerson}`
  50. return str
  51. })
  52. const currentDateCpt = computed(() => {
  53. let d = ''
  54. switch (new Date(store.state.app.timestamp).getDay()) {
  55. case 0: d = '星期日'
  56. break
  57. case 1: d = '星期一'
  58. break
  59. case 2: d = '星期二'
  60. break
  61. case 3: d = '星期三'
  62. break
  63. case 4: d = '星期四'
  64. break
  65. case 5: d = '星期五'
  66. break
  67. case 6: d = '星期六'
  68. break
  69. }
  70. return that.$util.YMDHms(store.state.app.timestamp) + ' ' + d
  71. })
  72. const onLogout = () => {
  73. ElMessageBox.confirm('请确认是否退出登录!', '提示', {
  74. confirmButtonText: '确定',
  75. cancelButtonText: '取消',
  76. type: "warning",
  77. }).then(() => {
  78. that.$api.logout()
  79. toLogin()
  80. }).catch(() => {})
  81. }
  82. // 获取字典
  83. const initDictionary = () => {
  84. store.dispatch('dictionary/LOAD_DICT_LIST', 'duty_hall_leader')
  85. store.dispatch('dictionary/LOAD_DICT_LIST', 'total_class')
  86. store.dispatch('dictionary/LOAD_DICT_LIST', 'shift_leader')
  87. store.dispatch('dictionary/LOAD_DICT_LIST', 'duty_person')
  88. }
  89. onMounted(() => {
  90. initDictionary()
  91. store.dispatch('app/LOAD_DUTY_INFO')
  92. })
  93. return {
  94. ...toRefs(state),
  95. dutyPeopleCpt,
  96. currentDateCpt,
  97. onLogout
  98. }
  99. },
  100. })
  101. </script>
  102. <style scoped lang="scss">
  103. .head-com {
  104. width: 100%;
  105. height: 100%;
  106. display: flex;
  107. justify-content: space-between;
  108. padding-top: 42px;
  109. box-sizing: border-box;
  110. background-image: url("@/assets/images/layout/head_bg.png");
  111. background-size: 100% 100%;
  112. font-size: 14px;
  113. font-family: PingFang SC-Regular, PingFang SC;
  114. font-weight: 400;
  115. color: #2EB8FF;
  116. line-height: 20px;
  117. .head-com-left {
  118. width: 30%;
  119. margin-left: 30px;
  120. height: fit-content;
  121. }
  122. .head-com-right {
  123. margin-right: 30px;
  124. height: fit-content;
  125. display: flex;
  126. .icon-date, .icon-user {
  127. width: 16px;
  128. height: 16px;
  129. margin-right: 8px;
  130. margin-top: 1px;
  131. }
  132. .date {
  133. margin-right: 16px;
  134. }
  135. .name {
  136. margin-right: 4px;
  137. }
  138. .dept {
  139. margin-right: 16px;
  140. }
  141. .button {
  142. background-image: url("@/assets/images/layout/head_exit.png");
  143. background-repeat: no-repeat;
  144. background-size: 100% 100%;
  145. width: 54px;
  146. height: 26px;
  147. color: #FFFFFF;
  148. display: flex;
  149. justify-content: center;
  150. }
  151. }
  152. }
  153. </style>