张诺
2 天以前 0f4dc4ea8a7de1ffdf34a640c79c29d55b79321c
src/views/production/index.vue
@@ -1,8 +1,8 @@
<template>
  <div class="production-container">
        <el-form :inline="true" :model="searchForm" class="search-form" style="width: 100%">
        <el-form :inline="true" :model="queryParams" class="search-form" style="width: 100%">
          <el-form-item label="搜索">
            <el-input v-model="searchForm.searchAll" placeholder="请输入关键词" clearable />
            <el-input v-model="queryParams.searchAll" placeholder="请输入关键词" clearable />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="handleSearch">查询</el-button>
@@ -15,8 +15,14 @@
      <el-button type="info" :icon="Download">导出</el-button>
      <ETable :loading="loading" :table-data="tableData" :columns="columns" @selection-change="handleSelectionChange"
        @edit="handleEdit" @view-detail="handleViewDetail" :show-selection="true" :border="true" :maxHeight="480" />
      <Pagination v-model:currentPage="pagination.currentPage" v-model:pageSize="pagination.pageSize"
        :total="pagination.total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
      <Pagination
        :total="total"
        :page="queryParams.current"
        :limit="queryParams.size"
        :show-total="true"
        @pagination="handlePageChange"
        :layout="'total, prev, pager, next, jumper'"
      ></Pagination>
    </el-card>
    <ProductionDialog v-model:visible="dialogVisible"  ref="childRef" :type="dialogType"
      @success="handleDialogSuccess" />
@@ -30,6 +36,7 @@
import ProductionDialog from "./components/ProductionDialog.vue";
import ETable from "@/components/Table/ETable.vue";
import Pagination from "@/components/Pagination/index.vue";
import { getProductionMasterList } from "@/api/production";
const childRef = ref(null);
const columns = [
  { prop: "category", label: "煤种", minWidth: 150 },
@@ -46,21 +53,22 @@
];
// 搜索表单数据
const searchForm = reactive({
  searchAll:""
});
// 表格数据
const tableData = ref([]);
const loading = ref(false);
const total = ref(0);
// 分页数据
const pagination = reactive({
  currentPage: 1,
  pageSize: 10,
  total: 0,
const queryParams = reactive({
  searchAll:"",
  current: 1,
  size: 10, // 固定每页10条
});
const handlePageChange = ({ page }) => {
  console.log("分页变化:", { page });
  queryParams.current = page;
  getList();
};
// 选中的行数据
const selectedRows = ref([]);
@@ -77,51 +85,9 @@
const getList = async () => {
  loading.value = true;
  try {
    const params = {
      ...searchForm,
      pageNum: pagination.currentPage,
      pageSize: pagination.pageSize,
    };
    // const res = await getProductionList(params)
    // 假数据
    const res = {
      data: {
        list: [
          {
            sequence: 1,
            category: "无烟煤",
            unit: "吨",
            productionVolume: 100,
            laborCost: "300",
            materialCost: "200",
            equipmentCost: "100",
            totalCost: "600",
            totalPrice: "800",
            profit: "200",
            reviewer: "张三",
            date: "2023-10-01",
          },
          {
            sequence: 12,
            category: "无烟煤",
            unit: "吨",
            productionVolume: 100,
            laborCost: "3100",
            materialCost: "2020",
            equipmentCost: "1300",
            totalCost: "6030",
            totalPrice: "8300",
            profit: "2300",
            reviewer: "张三",
            date: "2025-10-02",
          },
        ],
        total: 2,
      },
    };
    tableData.value = res.data.list;
    pagination.total = res.data.total;
    const res = await getProductionMasterList({...queryParams});
    tableData.value = res.data.records || [];
    total.value = res.data.total || 0;
  } catch (error) {
    ElMessage.error("获取数据失败");
  } finally {
@@ -142,8 +108,6 @@
// 重置搜索
const handleReset = () => {
  searchForm.keyword = "";
  searchForm.addUser = "";
  handleSearch();
};
@@ -243,7 +207,7 @@
// 处理每页显示数量变化
const handleSizeChange = (val) => {
  pagination.pageSize = val;
  pagination.size = val;
  getList();
};