TeamDetailDrawer.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <el-drawer v-model="showDrawer" direction="rtl" @close="clearData">
  3. <div class="team-detail__info">
  4. <div class="team-detail__info__team-name">{{ teamAndPersonInfo?.teamName }}</div>
  5. <div class="team-detail__info__member-count">
  6. 共 <span>{{ teamAndPersonInfo?.memberCount || 0 }}</span> 人
  7. </div>
  8. </div>
  9. <div class="team-detail__level" v-for="level in levelAndPersonList" :key="level.positionLevel">
  10. <div class="team-detail__level__title">
  11. {{ level.title }}
  12. </div>
  13. <div class="team-detail__level__content">
  14. <div v-for="(person, index) in level.personList" :key="index">{{ person }}</div>
  15. </div>
  16. </div>
  17. <div class="team-detail__description">
  18. <div class="team-detail__description__title"> 队伍职责 </div>
  19. <div class="team-detail__description__content"> {{ teamAndPersonInfo?.description }} </div>
  20. </div>
  21. </el-drawer>
  22. </template>
  23. <script setup lang="ts">
  24. import { ref, watch } from 'vue';
  25. import { queryEmergencyTeamDetail } from '@/api/emergency-organization/teams';
  26. import { TeamAndPersonInfoType } from '../team-management/type';
  27. const props = defineProps<{ selectedTeamId: number | null }>();
  28. type LevelAndPersonType = {
  29. positionLevel: number;
  30. title: string;
  31. personList: string[];
  32. };
  33. const showDrawer = ref(false);
  34. const teamAndPersonInfo = ref<TeamAndPersonInfoType>();
  35. const levelAndPersonList = ref<LevelAndPersonType[]>([]);
  36. function drawerShow() {
  37. showDrawer.value = true;
  38. }
  39. function clearData() {
  40. teamAndPersonInfo.value = undefined;
  41. levelAndPersonList.value = [];
  42. }
  43. // 按照职位等级排序队伍人员
  44. function setLevelAndPerson() {
  45. const levelMap: { [key: number]: LevelAndPersonType } = {};
  46. teamAndPersonInfo.value?.personnelList.map((person) => {
  47. if (!(person.positionLevel in levelMap)) {
  48. levelMap[person.positionLevel] = { positionLevel: person.positionLevel, title: person.title, personList: [] };
  49. }
  50. levelMap[person.positionLevel].personList.push(person.realname);
  51. });
  52. for (let level in levelMap) {
  53. levelAndPersonList.value.push(levelMap[level]);
  54. }
  55. }
  56. watch(
  57. () => showDrawer.value,
  58. async () => {
  59. if (showDrawer.value) {
  60. teamAndPersonInfo.value = await queryEmergencyTeamDetail(props.selectedTeamId!);
  61. setLevelAndPerson();
  62. }
  63. },
  64. );
  65. defineExpose({
  66. drawerShow,
  67. });
  68. </script>
  69. <style scoped lang="scss">
  70. .team-detail__info {
  71. display: flex;
  72. justify-content: space-between;
  73. align-items: center;
  74. margin-bottom: 20px;
  75. &__team-name {
  76. font-size: 20px;
  77. font-weight: bold;
  78. }
  79. &__member-count {
  80. span {
  81. color: #1777ff;
  82. }
  83. }
  84. }
  85. .team-detail__level {
  86. display: flex;
  87. align-items: center;
  88. margin-bottom: 10px;
  89. padding: 10px 0;
  90. border-left: 3px solid #1777ff;
  91. background-color: #e5effe;
  92. &__title {
  93. flex: 1;
  94. height: inherit;
  95. padding: 0 10px;
  96. color: #1777ff;
  97. text-align: center;
  98. white-space: nowrap;
  99. }
  100. &__content {
  101. flex: 10;
  102. display: flex;
  103. flex-wrap: wrap;
  104. padding: 0 15px;
  105. gap: 15px;
  106. border-left: 1px solid #c5c3c3;
  107. }
  108. }
  109. .team-detail__description {
  110. margin-top: 20px;
  111. &__title {
  112. margin-bottom: 10px;
  113. font-size: 20px;
  114. font-weight: bold;
  115. }
  116. &__content {
  117. color: #aaaaaa;
  118. white-space: pre-wrap;
  119. }
  120. }
  121. </style>