mailList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <div>
  3. <div style="padding-left: 20px">
  4. <el-icon @click="handleRefresh" style="cursor: pointer">
  5. <Refresh />
  6. </el-icon>
  7. </div>
  8. <div style="padding: 10px 15px; width: 100%">
  9. <el-table
  10. :data="tableData.data"
  11. style="width: 100%"
  12. :height="tableHeight"
  13. v-loading="loading"
  14. >
  15. <el-table-column label="状态" width="70">
  16. <template #default="{ row, $index }">
  17. <div style="cursor: pointer" @click="handleRowClick(row, $index)">
  18. <span v-if="row.flags && !row.flags.includes('6')">
  19. <img
  20. src="@/assets/images/mail/message.png"
  21. alt=""
  22. title="未读"
  23. class="messageImg"
  24. />
  25. </span>
  26. <span
  27. v-if="
  28. row.flags !== undefined &&
  29. row.flags !== null &&
  30. row.flags === ''
  31. "
  32. >
  33. <img
  34. src="@/assets/images/mail/message.png"
  35. alt=""
  36. title="未读"
  37. class="messageImg"
  38. />
  39. </span>
  40. <span
  41. v-if="
  42. row.flags &&
  43. row.flags.includes('6') &&
  44. row.flags.includes('1')
  45. "
  46. >
  47. <img
  48. src="@/assets/images/mail/replied.png"
  49. alt=""
  50. title="已回复"
  51. class="messageImg"
  52. />
  53. </span>
  54. <span v-if="row.flags && row.flags.includes('6')">
  55. <img
  56. src="@/assets/images/mail/message-open.png"
  57. alt=""
  58. title="已读"
  59. class="messageImg"
  60. />
  61. </span>
  62. </div>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="fromPersonalName" label="发件人" width="150">
  66. <template #default="{ row, $index }">
  67. <div class="contentClass" @click="handleRowClick(row, $index)">
  68. {{ row.fromPersonalName }}
  69. </div>
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="fromEmail" label="发件人地址" width="210">
  73. <template #default="{ row, $index }">
  74. <div class="contentClass" @click="handleRowClick(row, $index)">
  75. {{ row.fromEmail }}
  76. </div>
  77. </template>
  78. </el-table-column>
  79. <el-table-column prop="subject" label="主题">
  80. <template #default="{ row, $index }">
  81. <div class="contentClass" @click="handleRowClick(row, $index)">
  82. {{ row.subject }}
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="sendDate" label="时间" width="160">
  87. <template #default="{ row, $index }">
  88. <div style="cursor: pointer" @click="handleRowClick(row, $index)">
  89. {{ row.sendDate }}
  90. </div>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <el-pagination
  95. style="margin-top: 15px"
  96. v-model:current-page="tableData.pagination.pageNum"
  97. v-model:page-size="tableData.pagination.pageSize"
  98. :page-sizes="[15, 30, 50, 100]"
  99. layout="sizes, prev, pager, next"
  100. :total="tableData.pagination.total"
  101. prev-text="上一页"
  102. next-text="下一页"
  103. @current-change="handleCurrentChange"
  104. @size-change="handleSizeChange"
  105. />
  106. </div>
  107. </div>
  108. </template>
  109. <script setup>
  110. import byTable from "@/components/byTable/index";
  111. import useMailStore from "@/store/modules/mail";
  112. const { proxy } = getCurrentInstance();
  113. const mailStore = useMailStore();
  114. let loading = ref(false);
  115. const tableHeight = ref(0);
  116. tableHeight.value = window.innerHeight - 270;
  117. const tableData = reactive({
  118. data: [],
  119. pagination: {
  120. pageNum: 1,
  121. pageSize: 15,
  122. total: 0,
  123. },
  124. });
  125. const config = computed(() => {
  126. return [
  127. {
  128. attrs: {
  129. label: "状态",
  130. slot: "icon",
  131. width: 70,
  132. },
  133. },
  134. {
  135. attrs: {
  136. label: "发件人",
  137. prop: "fromPersonalName",
  138. },
  139. },
  140. {
  141. attrs: {
  142. label: "发件人地址",
  143. prop: "fromEmail",
  144. },
  145. },
  146. {
  147. attrs: {
  148. label: "主题",
  149. prop: "subject",
  150. },
  151. },
  152. {
  153. attrs: {
  154. label: "时间",
  155. prop: "sendDate",
  156. },
  157. },
  158. ];
  159. });
  160. const getList = () => {
  161. if (mailStore.currentMenu.listPageType === "10") {
  162. loading.value = true;
  163. proxy
  164. .post("/mailService/getMessagePage", {
  165. ...mailStore.currentMenu,
  166. ...tableData.pagination,
  167. })
  168. .then((res) => {
  169. tableData.data = res.rows;
  170. mailStore.mailDataList = res.rows;
  171. tableData.pagination.total = res.total;
  172. loading.value = false;
  173. });
  174. } else if (mailStore.currentMenu.listPageType === "20") {
  175. loading.value = true;
  176. proxy
  177. .post("/myFolderMessage/page", {
  178. myFolderId: mailStore.currentMenu.folderId,
  179. type: mailStore.selectMail.type,
  180. ...tableData.pagination,
  181. })
  182. .then((res) => {
  183. tableData.data = res.rows;
  184. mailStore.mailDataList = res.rows;
  185. tableData.pagination.total = res.total;
  186. loading.value = false;
  187. });
  188. } else if (mailStore.currentMenu.listPageType === "30") {
  189. loading.value = true;
  190. proxy
  191. .post("/myTagMessage/page", {
  192. myTagId: mailStore.currentMenu.folderId,
  193. type: mailStore.selectMail.type,
  194. ...tableData.pagination,
  195. })
  196. .then((res) => {
  197. tableData.data = res.rows;
  198. mailStore.mailDataList = res.rows;
  199. tableData.pagination.total = res.total;
  200. loading.value = false;
  201. });
  202. }
  203. };
  204. const handleRefresh = () => {
  205. tableData.pagination = {
  206. pageNum: 1,
  207. pageSize: 15,
  208. };
  209. // getList();
  210. };
  211. const handleRowClick = (row, index) => {
  212. mailStore.currentMailIndex = index;
  213. const menu = {
  214. title: row.subject.slice(0, 4) + "...",
  215. type: mailStore.selectMail.type,
  216. messageId: row.id,
  217. id: "detail" + "," + row.id,
  218. time: row.sendDate,
  219. subject: row.subject,
  220. row: { ...row },
  221. };
  222. const menuItem = mailStore.mailMenuList.find((x) => x.id === menu.id);
  223. if (menuItem === undefined) {
  224. mailStore.mailMenuList.push(menu);
  225. }
  226. mailStore.currentMenu = menu;
  227. mailStore.currentId = menu.id;
  228. };
  229. const init = () => {
  230. getList();
  231. };
  232. const handleCurrentChange = (val) => {
  233. tableData.pagination.pageNum = val;
  234. getList();
  235. };
  236. const handleSizeChange = (val) => {
  237. tableData.pagination.pageSize = val;
  238. getList();
  239. };
  240. defineExpose({
  241. initFn: init,
  242. });
  243. </script>
  244. <style lang="scss" scoped>
  245. .messageImg {
  246. width: 18px;
  247. height: 18px;
  248. transform: translateY(5px);
  249. }
  250. .el-pagination {
  251. padding-left: 30vw;
  252. }
  253. .contentClass {
  254. cursor: pointer;
  255. overflow: hidden;
  256. white-space: nowrap;
  257. text-overflow: ellipsis;
  258. }
  259. </style>