index.vue 2.7 KB

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