mailList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <div>
  3. <div style="padding-left: 20px; display: flex; align-items: center">
  4. <el-icon @click="handleRefresh" style="cursor: pointer">
  5. <Refresh />
  6. </el-icon>
  7. <!-- <div class="vertical-line"></div>
  8. <div>
  9. <el-checkbox
  10. v-model="isCheckAll"
  11. label="全选"
  12. size="default"
  13. @change="handleChangeCheckAll"
  14. />
  15. </div>
  16. <div style="color: #666666">
  17. <span
  18. >(共998封,其中<span style="color: #39c55a"> 未读邮件 </span
  19. >6封)</span
  20. >
  21. </div>
  22. <el-button
  23. @click="handleMove"
  24. :disabled="selectData.length === 0"
  25. style="margin-left: 10px"
  26. >全部标为已读</el-button
  27. >
  28. <el-select
  29. v-model="selectTag"
  30. placeholder="标记为"
  31. style="margin: 0 10px; width: 120px"
  32. :disabled="selectData.length === 0"
  33. >
  34. <el-option
  35. v-for="item in tagData"
  36. :key="item.id"
  37. :label="item.name"
  38. :value="item.id"
  39. />
  40. </el-select>
  41. <el-tree-select
  42. v-model="selectFolder"
  43. :data="myFolderTreeData"
  44. :disabled="selectData.length === 0"
  45. placeholder="移动到"
  46. style="margin-right: 10px; width: 120px"
  47. check-strictly
  48. :render-after-expand="false"
  49. />
  50. <el-button @click="handleMove" :disabled="selectData.length === 0"
  51. >删除</el-button
  52. > -->
  53. </div>
  54. <div style="padding: 10px 15px; width: 100%">
  55. <el-table
  56. :data="tableData.data"
  57. style="width: 100%"
  58. :height="tableHeight"
  59. @selection-change="handleSelectionChange"
  60. v-loading="loading"
  61. >
  62. <!-- <el-table-column label=" " width="40" align="center">
  63. <template #default="{ row, $index }">
  64. <div>
  65. <el-checkbox
  66. v-model="row.isCheck"
  67. label=""
  68. size="default"
  69. @change="handleChangeCheck"
  70. />
  71. </div>
  72. </template>
  73. </el-table-column> -->
  74. <el-table-column label="状态" width="70">
  75. <template #default="{ row, $index }">
  76. <div style="cursor: pointer" @click="handleRowClick(row, $index)">
  77. <span v-if="row.flags && !row.flags.includes('6')">
  78. <img
  79. src="@/assets/images/mail/message.png"
  80. alt=""
  81. title="未读"
  82. class="messageImg"
  83. />
  84. </span>
  85. <span
  86. v-if="
  87. row.flags !== undefined &&
  88. row.flags !== null &&
  89. row.flags === ''
  90. "
  91. >
  92. <img
  93. src="@/assets/images/mail/message.png"
  94. alt=""
  95. title="未读"
  96. class="messageImg"
  97. />
  98. </span>
  99. <span
  100. v-if="
  101. row.flags &&
  102. row.flags.includes('6') &&
  103. row.flags.includes('1')
  104. "
  105. >
  106. <img
  107. src="@/assets/images/mail/replied.png"
  108. alt=""
  109. title="已回复"
  110. class="messageImg"
  111. />
  112. </span>
  113. <span v-if="row.flags && row.flags.includes('6')">
  114. <img
  115. src="@/assets/images/mail/message-open.png"
  116. alt=""
  117. title="已读"
  118. class="messageImg"
  119. />
  120. </span>
  121. </div>
  122. </template>
  123. </el-table-column>
  124. <el-table-column prop="fromPersonalName" label="发件人" width="150">
  125. <template #default="{ row, $index }">
  126. <div class="contentClass" @click="handleRowClick(row, $index)">
  127. {{ row.fromPersonalName }}
  128. </div>
  129. </template>
  130. </el-table-column>
  131. <el-table-column prop="fromEmail" label="发件人地址" width="210">
  132. <template #default="{ row, $index }">
  133. <el-tooltip
  134. class="box-item"
  135. effect="dark"
  136. :content="row.fromEmail"
  137. placement="top"
  138. >
  139. <div class="contentClass" @click="handleRowClick(row, $index)">
  140. {{ row.fromEmail }}
  141. </div>
  142. </el-tooltip>
  143. </template>
  144. </el-table-column>
  145. <el-table-column prop="subject" label="主题">
  146. <template #default="{ row, $index }">
  147. <div class="contentClass" @click="handleRowClick(row, $index)">
  148. {{ row.subject }}
  149. </div>
  150. </template>
  151. </el-table-column>
  152. <el-table-column prop="sendDate" label="时间" width="160">
  153. <template #default="{ row, $index }">
  154. <div style="cursor: pointer" @click="handleRowClick(row, $index)">
  155. {{ row.sendDate }}
  156. </div>
  157. </template>
  158. </el-table-column>
  159. </el-table>
  160. <el-pagination
  161. style="margin-top: 15px"
  162. v-model:current-page="tableData.pagination.pageNum"
  163. v-model:page-size="tableData.pagination.pageSize"
  164. :page-sizes="[15, 30, 50, 100]"
  165. layout="sizes, prev, pager, next"
  166. :total="tableData.pagination.total"
  167. prev-text="上一页"
  168. next-text="下一页"
  169. @current-change="handleCurrentChange"
  170. @size-change="handleSizeChange"
  171. />
  172. </div>
  173. </div>
  174. </template>
  175. <script setup>
  176. import byTable from "@/components/byTable/index";
  177. import useMailStore from "@/store/modules/mail";
  178. import useUserStore from "@/store/modules/user";
  179. const { proxy } = getCurrentInstance();
  180. const mailStore = useMailStore();
  181. let loading = ref(false);
  182. const tableHeight = ref(0);
  183. const getTableHeight = () => {
  184. tableHeight.value = window.innerHeight - 280;
  185. };
  186. getTableHeight();
  187. window.addEventListener("resize", () => {
  188. getTableHeight();
  189. });
  190. const tableData = reactive({
  191. data: [],
  192. pagination: {
  193. pageNum: 1,
  194. pageSize: 15,
  195. total: 0,
  196. },
  197. });
  198. const config = computed(() => {
  199. return [
  200. {
  201. attrs: {
  202. label: "状态",
  203. slot: "icon",
  204. width: 70,
  205. },
  206. },
  207. {
  208. attrs: {
  209. label: "发件人",
  210. prop: "fromPersonalName",
  211. },
  212. },
  213. {
  214. attrs: {
  215. label: "发件人地址",
  216. prop: "fromEmail",
  217. },
  218. },
  219. {
  220. attrs: {
  221. label: "主题",
  222. prop: "subject",
  223. },
  224. },
  225. {
  226. attrs: {
  227. label: "时间",
  228. prop: "sendDate",
  229. },
  230. },
  231. ];
  232. });
  233. const getList = () => {
  234. if (mailStore.currentMenu.listPageType === "10") {
  235. loading.value = true;
  236. proxy
  237. .post("/mailService/getMessagePage", {
  238. ...mailStore.currentMenu,
  239. ...tableData.pagination,
  240. })
  241. .then((res) => {
  242. tableData.data = res.rows.map((x) => ({ ...x, isCheck: false }));
  243. mailStore.mailDataList = res.rows.map((x) => ({
  244. ...x,
  245. isCheck: false,
  246. }));
  247. tableData.pagination.total = res.total;
  248. loading.value = false;
  249. });
  250. } else if (mailStore.currentMenu.listPageType === "20") {
  251. loading.value = true;
  252. proxy
  253. .post("/myFolderMessage/page", {
  254. myFolderId: mailStore.currentMenu.folderId,
  255. type: mailStore.selectMail.type,
  256. ...tableData.pagination,
  257. })
  258. .then((res) => {
  259. tableData.data = res.rows.map((x) => ({
  260. ...x,
  261. isCheck: false,
  262. }));
  263. mailStore.mailDataList = res.rows.map((x) => ({
  264. ...x,
  265. isCheck: false,
  266. }));
  267. tableData.pagination.total = res.total;
  268. loading.value = false;
  269. });
  270. } else if (mailStore.currentMenu.listPageType === "30") {
  271. loading.value = true;
  272. proxy
  273. .post("/myTagMessage/page", {
  274. myTagId: mailStore.currentMenu.folderId,
  275. type: mailStore.selectMail.type,
  276. ...tableData.pagination,
  277. })
  278. .then((res) => {
  279. tableData.data = res.rows.map((x) => ({
  280. ...x,
  281. isCheck: false,
  282. }));
  283. mailStore.mailDataList = res.rows.map((x) => ({
  284. ...x,
  285. isCheck: false,
  286. }));
  287. tableData.pagination.total = res.total;
  288. loading.value = false;
  289. });
  290. }
  291. };
  292. const handleRefresh = () => {
  293. tableData.pagination = {
  294. pageNum: 1,
  295. pageSize: 15,
  296. };
  297. // getList();
  298. };
  299. const handleRowClick = (row, index) => {
  300. mailStore.currentMailIndex = index;
  301. const menu = {
  302. title: row.subject.slice(0, 4) + "...",
  303. type: mailStore.selectMail.type,
  304. messageId: row.id,
  305. id: "detail" + "," + row.id,
  306. time: row.sendDate,
  307. subject: row.subject,
  308. row: { ...row },
  309. };
  310. const menuItem = mailStore.mailMenuList.find((x) => x.id === menu.id);
  311. if (menuItem === undefined) {
  312. mailStore.mailMenuList.push(menu);
  313. }
  314. mailStore.currentMenu = menu;
  315. mailStore.currentId = menu.id;
  316. };
  317. const init = () => {
  318. getList();
  319. };
  320. const handleCurrentChange = (val) => {
  321. tableData.pagination.pageNum = val;
  322. getList();
  323. };
  324. const handleSizeChange = (val) => {
  325. tableData.pagination.pageSize = val;
  326. getList();
  327. };
  328. const myFolderTreeData = ref([]);
  329. const tagData = ref([]);
  330. const getOtherData = () => {
  331. setTimeout(() => {
  332. proxy
  333. .post("/myFolder/tree", { mailboxId: mailStore.selectMail.id })
  334. .then((res) => {
  335. myFolderTreeData.value = res.map((x) => ({ ...x, value: x.id }));
  336. });
  337. }, 1000);
  338. setTimeout(() => {
  339. proxy
  340. .post("/myTag/page", {
  341. pageNum: 1,
  342. pageSize: 9999,
  343. id: useUserStore().user.userId,
  344. })
  345. .then((res) => {
  346. tagData.value = res.rows;
  347. });
  348. }, 1000);
  349. };
  350. // getOtherData();
  351. const isCheckAll = ref(false);
  352. const selectTag = ref("");
  353. const selectFolder = ref("");
  354. const selectData = ref([]);
  355. const handleChangeCheck = () => {
  356. selectData.value = tableData.data.filter((x) => x.isCheck === true);
  357. if (selectData.value.length === tableData.data.length) {
  358. isCheckAll.value = true;
  359. }
  360. };
  361. const handleChangeCheckAll = () => {
  362. tableData.data.forEach((x) => {
  363. x.isCheck = isCheckAll.value;
  364. });
  365. if (isCheckAll.value) {
  366. selectData.value = tableData.data;
  367. } else {
  368. selectData.value = [];
  369. }
  370. };
  371. defineExpose({
  372. initFn: init,
  373. });
  374. </script>
  375. <style lang="scss" scoped>
  376. // * {
  377. // font-size: 12px;
  378. // }
  379. .messageImg {
  380. width: 18px;
  381. height: 18px;
  382. transform: translateY(5px);
  383. }
  384. .el-pagination {
  385. padding-left: 30vw;
  386. }
  387. .contentClass {
  388. cursor: pointer;
  389. overflow: hidden;
  390. white-space: nowrap;
  391. text-overflow: ellipsis;
  392. }
  393. .vertical-line {
  394. width: 2px;
  395. height: 14px;
  396. background: #dddddd;
  397. margin: 0 10px;
  398. }
  399. </style>