head-com.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="head-com">
  3. <div class="head-com-left">
  4. <CusEllipsis v-if="initDuty" :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. initDuty: false
  43. })
  44. const dutyPeopleCpt = computed(() => {
  45. let str = ''
  46. const dutyHallLeader = `值班厅领导:${store.state.app.dutyInfo?.dutyHallLeader ? store.state.dictionary.dutyHallLeaderMap.get(store.state.app.dutyInfo.dutyHallLeader) : '无'}`
  47. const totalClass = `总值班:${store.state.app.dutyInfo?.totalClass ? store.state.dictionary.totalClassMap.get(store.state.app.dutyInfo.totalClass) : '无'}`
  48. const shiftLeader = `带班领导:${store.state.app.dutyInfo?.shiftLeader ? store.state.dictionary.shiftLeaderMap.get(store.state.app.dutyInfo.shiftLeader) : '无'}`
  49. const dutyPerson = `值班员:${store.state.app.dutyInfo?.dutyPerson ? store.state.app.dutyInfo.dutyPerson.split(',').map(v => store.state.dictionary.dutyPersonMap.get(v)).join('、') : '无'}`
  50. str += `${dutyHallLeader} ${totalClass} ${shiftLeader} ${dutyPerson}`
  51. return str
  52. })
  53. const currentDateCpt = computed(() => {
  54. let d = ''
  55. switch (new Date(store.state.app.timestamp).getDay()) {
  56. case 0: d = '星期日'
  57. break
  58. case 1: d = '星期一'
  59. break
  60. case 2: d = '星期二'
  61. break
  62. case 3: d = '星期三'
  63. break
  64. case 4: d = '星期四'
  65. break
  66. case 5: d = '星期五'
  67. break
  68. case 6: d = '星期六'
  69. break
  70. }
  71. return that.$util.YMDHms(store.state.app.timestamp) + ' ' + d
  72. })
  73. const onLogout = () => {
  74. ElMessageBox.confirm('请确认是否退出登录!', '提示', {
  75. confirmButtonText: '确定',
  76. cancelButtonText: '取消',
  77. type: "warning",
  78. }).then(() => {
  79. that.$api.logout()
  80. toLogin()
  81. }).catch(() => {})
  82. }
  83. // 获取字典
  84. const initDictionary = () => {
  85. Promise.all([
  86. store.dispatch('dictionary/LOAD_DICT_LIST', 'duty_hall_leader'),
  87. store.dispatch('dictionary/LOAD_DICT_LIST', 'total_class'),
  88. store.dispatch('dictionary/LOAD_DICT_LIST', 'shift_leader'),
  89. store.dispatch('dictionary/LOAD_DICT_LIST', 'duty_person'),
  90. ]).then(() => {
  91. state.initDuty = true
  92. })
  93. }
  94. onMounted(() => {
  95. initDictionary()
  96. store.dispatch('app/LOAD_DUTY_INFO')
  97. })
  98. return {
  99. ...toRefs(state),
  100. dutyPeopleCpt,
  101. currentDateCpt,
  102. onLogout
  103. }
  104. },
  105. })
  106. </script>
  107. <style scoped lang="scss">
  108. .head-com {
  109. width: 100%;
  110. height: 100%;
  111. display: flex;
  112. justify-content: space-between;
  113. padding-top: 42px;
  114. box-sizing: border-box;
  115. background-image: url("@/assets/images/layout/head_bg.png");
  116. background-size: 100% 100%;
  117. font-size: 14px;
  118. font-family: PingFang SC-Regular, PingFang SC;
  119. font-weight: 400;
  120. color: #2EB8FF;
  121. line-height: 20px;
  122. .head-com-left {
  123. width: 30%;
  124. margin-left: 30px;
  125. height: fit-content;
  126. word-spacing: 16px;
  127. }
  128. .head-com-right {
  129. margin-right: 30px;
  130. height: fit-content;
  131. display: flex;
  132. .icon-date, .icon-user {
  133. width: 16px;
  134. height: 16px;
  135. margin-right: 8px;
  136. margin-top: 1px;
  137. }
  138. .date {
  139. margin-right: 16px;
  140. }
  141. .name {
  142. margin-right: 4px;
  143. }
  144. .dept {
  145. margin-right: 16px;
  146. }
  147. .button {
  148. background-image: url("@/assets/images/layout/head_exit.png");
  149. background-repeat: no-repeat;
  150. background-size: 100% 100%;
  151. width: 54px;
  152. height: 26px;
  153. color: #FFFFFF;
  154. display: flex;
  155. justify-content: center;
  156. }
  157. }
  158. }
  159. </style>