| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-card> |
| | | <!-- æ ç¾é¡µ --> |
| | | <el-tabs |
| | | v-model="activeTab" |
| | | class="info-tabs" |
| | | > |
| | | <el-tab-pane |
| | | v-for="tab in tabs" |
| | | :key="tab.name" |
| | | :label="tab.label" |
| | | :name="tab.name" |
| | | /> |
| | | </el-tabs> |
| | | |
| | | <div> |
| | | <data-table |
| | | :border="true" |
| | | :columns="columns" |
| | | :loading="loading" |
| | | style="width: 100%; height: calc(100vh - 29em)" |
| | | :show-selection="true" |
| | | :table-data="tableData" |
| | | :operationsWidth="200" |
| | | :showOperations="false" |
| | | /> |
| | | </div> |
| | | <pagination |
| | | v-if="total > 0" |
| | | :layout="'total, prev, pager, next, jumper'" |
| | | :limit="pageSizes" |
| | | :page="pageNum" |
| | | :total="total" |
| | | @pagination="handPagination" |
| | | /> |
| | | </el-card> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { |
| | | onMounted, |
| | | reactive, |
| | | ref, |
| | | } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { getCarboncubeList } from "@/api/carboncubes/index.js"; |
| | | import DataTable from "@/components/Table/ETable.vue"; |
| | | import Pagination from "@/components/Pagination/index.vue"; |
| | | |
| | | // 页é¢ç¶ææ§å¶ |
| | | const loading = ref(false); |
| | | const activeTab = ref("PURCHASE"); |
| | | |
| | | // æ ç¾é¡µé
ç½® |
| | | const tabs = reactive([ |
| | | { name: "PURCHASE", label: "å°è´§ç£
å" }, |
| | | { name: "SELL", label: "åè´§ç£
å" }, |
| | | ]); |
| | | |
| | | // åé¡µç¶æç®¡ç |
| | | const pageNum = ref(1); |
| | | const pageSizes = ref(10); |
| | | const total = ref(0); |
| | | |
| | | // è¡¨æ ¼ç¶æç®¡ç |
| | | const tableData = ref([]); |
| | | const columns = computed(() => { |
| | | const baseColumns = [ |
| | | { prop: "coal", label: "ç
¤ç§ç±»å", minWidth: 170 }, |
| | | { prop: "billNumber", label: "ç£
åç¼å·", minWidth: 100 }, |
| | | { prop: "number", label: "æ°é", minWidth: 150 }, |
| | | { prop: "priceIncludingTax", label: "å«ç¨åä»·", minWidth: 120 }, |
| | | { prop: "createUser", label: "ç»è®°äºº", minWidth: 120 }, |
| | | { prop: "createTime", label: "ç»è®°æ¥æ", minWidth: 120 }, |
| | | ]; |
| | | |
| | | // æ ¹æ®ç±»åæ·»å ä¸åç第ä¸å |
| | | if (activeTab.value === "SELL") { |
| | | return [ |
| | | { prop: "customerName", label: "客æ·åç§°", minWidth: 100 }, |
| | | ...baseColumns |
| | | ]; |
| | | } else { |
| | | return [ |
| | | { prop: "supplierName", label: "ä¾åºååç§°", minWidth: 100 }, |
| | | ...baseColumns |
| | | ]; |
| | | } |
| | | }); |
| | | |
| | | watch(() => [pageNum.value, pageSizes.value, activeTab.value], () => getList()); |
| | | |
| | | const handPagination = (val) => { |
| | | pageNum.value = val.page; |
| | | pageSizes.value = val.limit; |
| | | getList(); |
| | | }; |
| | | |
| | | const getList = () => { |
| | | loading.value = true; |
| | | const apiParams = { |
| | | current: pageNum.value, |
| | | pageSize: pageSizes.value, |
| | | orderType: activeTab.value, |
| | | }; |
| | | getCarboncubeList(apiParams).then((res) => { |
| | | if (res.code !== 200) { |
| | | ElMessage.error("è·åæ°æ®å¤±è´¥ï¼" + (res?.msg || "æªç¥é误")); |
| | | return; |
| | | } |
| | | |
| | | tableData.value = res.data.records || []; |
| | | total.value = res.total || 0; |
| | | }).catch((err) => { |
| | | console.log(err); |
| | | }).finally(() => { |
| | | loading.value = false; |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |
| | | </script> |