123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <!-- @format -->
- <script lang="ts" setup>
- import dayjs from 'dayjs'
- import { PageSizeEnum } from '~/enums/sizeEnum'
- import { getRFQsListApi } from '@/api/model/my'
- const emit = defineEmits(['openModel'])
- const tableData = ref([])
- const currentPage = ref(1)
- const page_size = ref(10)
- const total = ref(1)
- async function getTableList(pageNo = PageSizeEnum.PAGE, pageSize = PageSizeEnum.PAGE_SIZE) {
- try {
- const res: any = await getRFQsListApi({
- pageNo,
- pageSize,
- })
- total.value = res.total
- tableData.value = res.records.map((item: any) => {
- return {
- ...item,
- createTime: dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss'),
- }
- })
- }
- catch (e) {
- console.log(e)
- }
- }
- function changePage(page: number, pageSize: number) {
- currentPage.value = page
- getTableList(page, pageSize)
- }
- function tableRowClassName({ rowIndex }: any) {
- if (rowIndex % 2 === 0)
- return 'warning-row'
- return ''
- }
- getTableList()
- defineExpose({
- getTableList,
- })
- </script>
- <template>
- <div>
- <el-table
- :data="tableData"
- style="width: 100%"
- :row-class-name="tableRowClassName"
- >
- <el-table-column prop="productName" label="Product name" width="300" show-overflow-tooltip="true" />
- <el-table-column label="Quotations">
- <template #default="{ row }">
- <div :class="row.state === '1' && 'text-#0068FF'">
- {{ row.state === "1" ? "Quoted" : "Unquoted" }}
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="createTime" label="Created Time" />
- <el-table-column fixed="right" label="Action">
- <template #default="{ row }">
- <el-button
- class="!text-#C58C64 !h-40px !b-unset !bg-transparent hover:!bg-transparent hover:!text-#C58C64 hover:!underline"
- @click="() => $emit('openModel', row.id)"
- >
- View details
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <div v-if="tableData.length" class="mt-25px flex justify-end">
- <el-pagination
- v-model:current-page="currentPage"
- :page-size="page_size"
- :pager-count="10"
- class="custom-pagination"
- layout="prev, pager, next"
- :total="total"
- @change="changePage"
- />
- </div>
- </div>
- </template>
- <style lang="less" scoped>
- ::v-deep(.el-table) {
- color: #333;
- .el-table__header-wrapper {
- .el-table__header {
- height: 50px;
- .el-table__cell {
- color: #333;
- font-weight: 400 !important;
- background-color: #fff2e1;
- }
- }
- }
- .el-table__row {
- height: 68px;
- &.warning-row {
- --el-table-tr-bg-color: #f7f7f7;
- }
- }
- }
- </style>
|