mailList.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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 style="cursor: pointer" @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 style="cursor: pointer" @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 style="cursor: pointer" @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. <!-- <byTable
  108. :source="tableData.data"
  109. :pagination="tableData.pagination"
  110. :config="config"
  111. :loading="loading"
  112. :hideSearch="true"
  113. highlight-current-row
  114. :action-list="[]"
  115. :table-events="{
  116. //element talbe事件都能传
  117. 'row-click': handleRowClick,
  118. }"
  119. @get-list="getList"
  120. >
  121. <template #icon="{ item }">
  122. <div>
  123. <span v-if="!item.flags.includes('6')">
  124. <img
  125. src="@/assets/images/mail/message.png"
  126. alt=""
  127. title="未读"
  128. class="messageImg"
  129. />
  130. </span>
  131. <span v-if="item.flags.includes('6') && item.flags.includes('1')">
  132. <img
  133. src="@/assets/images/mail/replied.png"
  134. alt=""
  135. title="已回复"
  136. class="messageImg"
  137. />
  138. </span>
  139. <span v-if="item.flags.includes('6')">
  140. <img
  141. src="@/assets/images/mail/message-open.png"
  142. alt=""
  143. title="已读"
  144. class="messageImg"
  145. />
  146. </span>
  147. </div>
  148. </template>
  149. </byTable> -->
  150. </div>
  151. </template>
  152. <script setup>
  153. import byTable from "@/components/byTable/index";
  154. import useMailStore from "@/store/modules/mail";
  155. const { proxy } = getCurrentInstance();
  156. const mailStore = useMailStore();
  157. let loading = ref(false);
  158. const tableHeight = ref(0);
  159. tableHeight.value = window.innerHeight - 270;
  160. const tableData = reactive({
  161. data: [],
  162. pagination: {
  163. pageNum: 1,
  164. pageSize: 15,
  165. total: 0,
  166. },
  167. });
  168. const config = computed(() => {
  169. return [
  170. {
  171. attrs: {
  172. label: "状态",
  173. slot: "icon",
  174. width: 70,
  175. },
  176. },
  177. {
  178. attrs: {
  179. label: "发件人",
  180. prop: "fromPersonalName",
  181. },
  182. },
  183. {
  184. attrs: {
  185. label: "发件人地址",
  186. prop: "fromEmail",
  187. },
  188. },
  189. {
  190. attrs: {
  191. label: "主题",
  192. prop: "subject",
  193. },
  194. },
  195. {
  196. attrs: {
  197. label: "时间",
  198. prop: "sendDate",
  199. },
  200. },
  201. ];
  202. });
  203. const getList = () => {
  204. if (mailStore.currentMenu.listPageType === "10") {
  205. loading.value = true;
  206. proxy
  207. .post("/mailService/getMessagePage", {
  208. ...mailStore.currentMenu,
  209. ...tableData.pagination,
  210. })
  211. .then((res) => {
  212. tableData.data = res.rows;
  213. mailStore.mailDataList = res.rows;
  214. tableData.pagination.total = res.total;
  215. loading.value = false;
  216. });
  217. } else if (mailStore.currentMenu.listPageType === "20") {
  218. loading.value = true;
  219. proxy
  220. .post("/myFolderMessage/page", {
  221. myFolderId: mailStore.currentMenu.folderId,
  222. type: mailStore.selectMail.type,
  223. ...tableData.pagination,
  224. })
  225. .then((res) => {
  226. tableData.data = res.rows;
  227. mailStore.mailDataList = res.rows;
  228. tableData.pagination.total = res.total;
  229. loading.value = false;
  230. });
  231. } else if (mailStore.currentMenu.listPageType === "30") {
  232. loading.value = true;
  233. proxy
  234. .post("/myTagMessage/page", {
  235. myTagId: mailStore.currentMenu.folderId,
  236. type: mailStore.selectMail.type,
  237. ...tableData.pagination,
  238. })
  239. .then((res) => {
  240. tableData.data = res.rows;
  241. mailStore.mailDataList = res.rows;
  242. tableData.pagination.total = res.total;
  243. loading.value = false;
  244. });
  245. }
  246. };
  247. const handleRefresh = () => {
  248. tableData.pagination = {
  249. pageNum: 1,
  250. pageSize: 15,
  251. };
  252. getList();
  253. };
  254. const handleRowClick = (row, index) => {
  255. mailStore.currentMailIndex = index;
  256. const menu = {
  257. title: row.subject.slice(0, 4) + "...",
  258. type: mailStore.selectMail.type,
  259. messageId: row.id,
  260. id: "detail" + "," + row.id,
  261. time: row.sendDate,
  262. row: { ...row },
  263. };
  264. const menuItem = mailStore.mailMenuList.find((x) => x.id === menu.id);
  265. if (menuItem === undefined) {
  266. mailStore.mailMenuList.push(menu);
  267. }
  268. mailStore.currentMenu = menu;
  269. mailStore.currentId = menu.id;
  270. };
  271. const init = () => {
  272. getList();
  273. };
  274. const handleCurrentChange = (val) => {
  275. tableData.pagination.pageNum = val;
  276. getList();
  277. };
  278. const handleSizeChange = (val) => {
  279. tableData.pagination.pageSize = val;
  280. getList();
  281. };
  282. defineExpose({
  283. initFn: init,
  284. });
  285. </script>
  286. <style lang="scss" scoped>
  287. .messageImg {
  288. width: 18px;
  289. height: 18px;
  290. transform: translateY(5px);
  291. }
  292. .el-pagination {
  293. padding-left: 30vw;
  294. }
  295. </style>