indexh.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <ContentWrap>
  3. <div style="width: 100%; height: 500px">
  4. <el-auto-resizer>
  5. <template #default="{ height, width }">
  6. <el-table-v2 :columns="columns" :data="tableData" :width="width" :height="height" fixed />
  7. </template>
  8. </el-auto-resizer>
  9. <el-pagination
  10. :current-page="queryParms.pageNo"
  11. :page-size="queryParms.pageSize"
  12. layout="total, prev, pager, next"
  13. :total="tableTotal"
  14. @size-change="getList"
  15. @current-change="getList"
  16. />
  17. </div>
  18. </ContentWrap>
  19. </template>
  20. <script setup lang="ts">
  21. import { Column, TableV2FixedDir } from 'element-plus'
  22. import * as NoticeApi from '@/api/system/notice'
  23. import { XTextButton } from '@/components/XButton'
  24. const { t } = useI18n() // 国际化
  25. const columns: Column<any>[] = [
  26. {
  27. key: 'id',
  28. dataKey: 'id', //需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填id
  29. title: 'id', //显示在单元格表头的文本
  30. width: 80, //当前列的宽度,必须设置
  31. fixed: true //是否固定列
  32. },
  33. {
  34. key: 'title',
  35. dataKey: 'title',
  36. title: '公告标题',
  37. width: 180
  38. },
  39. {
  40. key: 'type',
  41. dataKey: 'type',
  42. title: '公告类型',
  43. width: 180
  44. },
  45. {
  46. key: 'status',
  47. dataKey: 'status',
  48. title: t('common.status'),
  49. width: 180
  50. },
  51. {
  52. key: 'content',
  53. dataKey: 'content',
  54. title: '公告内容',
  55. width: 180
  56. },
  57. {
  58. key: 'createTime',
  59. dataKey: 'createTime',
  60. title: t('common.createTime'),
  61. width: 180
  62. },
  63. {
  64. key: 'actionbtns',
  65. dataKey: 'actionbtns', //需要渲染当前列的数据字段,如{id:9527,name:'Mike'},则填id
  66. title: '操作', //显示在单元格表头的文本
  67. width: 80, //当前列的宽度,必须设置
  68. fixed: TableV2FixedDir.RIGHT, //是否固定列
  69. align: 'center',
  70. cellRenderer: (date) =>
  71. h(XTextButton, {
  72. onClick: () => handleDelete(date.rowData),
  73. type: 'danger',
  74. preIcon: 'ep:delete',
  75. title: t('action.del')
  76. })
  77. }
  78. ]
  79. const tableData = ref([])
  80. const tableTotal = ref(0)
  81. const queryParms = reactive({
  82. title: '',
  83. status: undefined,
  84. pageNo: 1,
  85. pageSize: 10
  86. })
  87. const getList = async () => {
  88. const res = await NoticeApi.getNoticePageApi(queryParms)
  89. tableData.value = res.list
  90. tableTotal.value = res.total
  91. }
  92. const handleDelete = (row) => {
  93. console.info(row.id)
  94. }
  95. getList()
  96. </script>