left.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="left">
  3. <div class="top">
  4. <el-dropdown>
  5. <span class="mail">
  6. {{ selectMail.mailUser }}
  7. <el-icon class="el-icon--right">
  8. <arrow-down />
  9. </el-icon>
  10. </span>
  11. <template #dropdown>
  12. <el-dropdown-menu>
  13. <el-dropdown-item
  14. v-for="item in mailList"
  15. :key="item.id"
  16. @click="handleClickMail(item)"
  17. >{{ item.mailUser }}</el-dropdown-item
  18. >
  19. </el-dropdown-menu>
  20. </template>
  21. </el-dropdown>
  22. <el-tabs v-model="activeName" class="demo-tabs" stretch>
  23. <el-tab-pane label="邮箱" name="first">
  24. <template #label>
  25. <span>邮箱</span>
  26. </template>
  27. </el-tab-pane>
  28. <el-tab-pane label="联系人" name="second">
  29. <template #label>
  30. <span>联系人</span>
  31. </template>
  32. </el-tab-pane>
  33. <el-tab-pane label="客户" name="third">
  34. <template #label>
  35. <span>客户</span>
  36. </template>
  37. </el-tab-pane>
  38. </el-tabs>
  39. <div>
  40. <el-button type="primary" style="width: 100%" @click="handleGoWrite"
  41. >写信</el-button
  42. >
  43. </div>
  44. </div>
  45. <div class="body">
  46. <div v-if="activeName === 'first'">
  47. <ul class="mail-menu">
  48. <li
  49. class="menu-item"
  50. v-bind:class="{ 'select-menu': item.id === selectFloderId }"
  51. v-for="item in selectMail.mailFolderInfoList"
  52. :key="item.id"
  53. @click="handleOpenMenu(item)"
  54. >
  55. {{ item.name }}
  56. </li>
  57. </ul>
  58. </div>
  59. <div v-if="activeName === 'second'">b</div>
  60. <div v-if="activeName === 'third'">c</div>
  61. </div>
  62. </div>
  63. </template>
  64. <script setup>
  65. import useMailStore from "@/store/modules/mail";
  66. const mailStore = useMailStore();
  67. const { proxy } = getCurrentInstance();
  68. let selectMail = ref({});
  69. let activeName = ref("first");
  70. let selectFloderId = ref("");
  71. const mailList = ref([]);
  72. const getMialList = () => {
  73. proxy.get("/mailService/getUserEmailList").then((res) => {
  74. mailList.value = res.data;
  75. if (mailList.value.length) {
  76. selectMail.value = mailList.value[0];
  77. mailStore.selectMail = mailList.value[0];
  78. if (selectMail.value.mailFolderInfoList.length > 0) {
  79. handleOpenMenu(selectMail.value.mailFolderInfoList[0]);
  80. }
  81. }
  82. });
  83. };
  84. const handleClickMail = (item) => {
  85. selectMail.value = item;
  86. mailStore.selectMail = item;
  87. };
  88. const handleOpenMenu = (item) => {
  89. selectFloderId.value = item.id;
  90. const menu = {
  91. title: item.name,
  92. type: selectMail.value.type,
  93. folderId: item.id,
  94. id: "floder" + "," + item.id,
  95. };
  96. // 如没有这个菜单则push
  97. const menuItem = mailStore.mailMenuList.find((x) => x.id === menu.id);
  98. if (menuItem === undefined) {
  99. mailStore.mailMenuList.push(menu);
  100. }
  101. // 更新当前选择的tab数据和tab的Id值
  102. mailStore.currentMenu = menu;
  103. mailStore.currentId = menu.id;
  104. };
  105. const handleGoWrite = () => {
  106. const menu = {
  107. title: "写信",
  108. type: selectMail.value.type,
  109. id: "write",
  110. };
  111. const menuItem = mailStore.mailMenuList.find((x) => x.id === menu.id);
  112. if (menuItem === undefined) {
  113. mailStore.mailMenuList.push(menu);
  114. }
  115. mailStore.currentMenu = menu;
  116. mailStore.currentId = menu.id;
  117. };
  118. onMounted(() => {
  119. getMialList();
  120. });
  121. </script>
  122. <style lang="scss" scoped>
  123. .left {
  124. font-size: 14px;
  125. .top {
  126. padding: 10px;
  127. text-align: center;
  128. border-bottom: 1px solid #ddd;
  129. .mail {
  130. color: black;
  131. font-weight: 700;
  132. font-size: 14px;
  133. }
  134. }
  135. .body {
  136. padding: 10px;
  137. .mail-menu {
  138. list-style: none;
  139. margin-block-start: 0;
  140. margin-block-end: 0;
  141. padding: 0px;
  142. .menu-item {
  143. font-weight: 700;
  144. padding-left: 10px;
  145. font-size: 12px;
  146. width: 100%;
  147. height: 40px;
  148. line-height: 40px;
  149. border-radius: 3px;
  150. color: #696969;
  151. cursor: pointer;
  152. &:hover {
  153. background: #ddedfe;
  154. }
  155. }
  156. }
  157. }
  158. }
  159. .select-menu {
  160. background: #ddedfe;
  161. color: #169bd5 !important;
  162. }
  163. </style>