index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <!-- @format -->
  2. <script lang="ts" setup>
  3. import dayjs from 'dayjs'
  4. import { PageSizeEnum } from '~/enums/sizeEnum'
  5. import { getNoticeListApi } from '@/api/model/notice'
  6. import { useCommonStore } from '@/stores/modules/common'
  7. const commonStore = useCommonStore()
  8. const tableData = ref([])
  9. const currentPage = ref(1)
  10. const page_size = ref(10)
  11. const total = ref(1)
  12. const visible = ref(false)
  13. const detailData = ref()
  14. async function getTableList(
  15. pageNo = PageSizeEnum.PAGE,
  16. pageSize = PageSizeEnum.PAGE_SIZE,
  17. ) {
  18. try {
  19. const res: any = await getNoticeListApi({
  20. pageNo,
  21. pageSize,
  22. })
  23. total.value = res.total
  24. tableData.value = res.records.map((item: any) => {
  25. return {
  26. ...item,
  27. sendTime: dayjs(item.sendTime).format('YYYY-MM-DD'),
  28. }
  29. })
  30. await commonStore.getNoticeRemind()
  31. }
  32. catch (e) {
  33. console.log(e)
  34. }
  35. }
  36. function changePage(page: number, pageSize: number) {
  37. currentPage.value = page
  38. getTableList(page, pageSize)
  39. }
  40. function tableRowClassName({ rowIndex }: any) {
  41. if (rowIndex % 2 === 0)
  42. return 'warning-row'
  43. return ''
  44. }
  45. function onDetail(row: any) {
  46. visible.value = true
  47. detailData.value = row
  48. }
  49. getTableList()
  50. </script>
  51. <template>
  52. <div>
  53. <el-table
  54. :data="tableData"
  55. style="width: 100%"
  56. :row-class-name="tableRowClassName"
  57. >
  58. <el-table-column prop="title" label="Notification Name" />
  59. <el-table-column prop="sendTime" label="Notification Time" />
  60. <el-table-column fixed="right" label="Action">
  61. <template #default="{ row }">
  62. <el-button
  63. class="!text-#C58C64 !h-40px !b-unset !bg-transparent hover:!bg-transparent hover:!text-#C58C64 hover:!underline"
  64. >
  65. <div class="text-primary" @click="onDetail(row)">
  66. View details
  67. </div>
  68. </el-button>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <div v-if="tableData.length" class="mt-25px flex justify-end">
  73. <el-pagination
  74. :page-size="page_size"
  75. class="custom-pagination"
  76. :pager-count="10"
  77. layout="prev, pager, next"
  78. :total="total"
  79. @change="changePage"
  80. />
  81. </div>
  82. <Business-account-notice-detail-modal v-if="visible" v-model:visible="visible" :detail="detailData" />
  83. </div>
  84. </template>
  85. <style lang="less" scoped>
  86. ::v-deep(.el-table) {
  87. color: #333;
  88. .el-table__header-wrapper {
  89. .el-table__header {
  90. height: 50px;
  91. .el-table__cell {
  92. color: #333;
  93. font-weight: 400 !important;
  94. background-color: #fff2e1;
  95. }
  96. }
  97. }
  98. .el-table__row {
  99. height: 68px;
  100. &.warning-row {
  101. --el-table-tr-bg-color: #f7f7f7;
  102. }
  103. }
  104. }
  105. </style>