From 0f4dc4ea8a7de1ffdf34a640c79c29d55b79321c Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期五, 13 六月 2025 17:53:27 +0800
Subject: [PATCH] 添加生产管理接口及优化表格字段

---
 src/views/production/index.vue |  108 ++++++++++++++++++------------------------------------
 1 files changed, 36 insertions(+), 72 deletions(-)

diff --git a/src/views/production/index.vue b/src/views/production/index.vue
index 8872835..d298680 100644
--- a/src/views/production/index.vue
+++ b/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,37 +36,39 @@
 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: "鐓ょ", width: 150 },
-  { prop: "unit", label: "鍗曚綅", width: 120 },
-  { prop: "productionVolume", label: "鐢熶骇鏁伴噺", width: 150 },
-  { prop: "laborCost", label: "浜哄伐鎴愭湰", width: 150 },
-  { prop: "materialCost", label: "鍘熸枡鎴愭湰", width: 120 },
-  { prop: "equipmentCost", label: "璁惧璐圭敤", width: 143 },
-  { prop: "totalCost", label: "鎬绘垚鏈�", width: 150 },
-  { prop: "totalPrice", label: "鎬诲敭浠�", width: 150 },
-  { prop: "profit", label: "鍒╂鼎", width: 100 },
-  { prop: "reviewer", label: "澶嶈浜�", width: 120 },
-  { prop: "date", label: "鏃ユ湡", width: 150 },
+  { prop: "category", label: "鐓ょ", minWidth: 150 },
+  { prop: "unit", label: "鍗曚綅", minWidth: 120 },
+  { prop: "productionVolume", label: "鐢熶骇鏁伴噺", minWidth: 150 },
+  { prop: "laborCost", label: "浜哄伐鎴愭湰", minWidth: 150 },
+  { prop: "materialCost", label: "鍘熸枡鎴愭湰", minWidth: 120 },
+  { prop: "equipmentCost", label: "璁惧璐圭敤", minWidth: 143 },
+  { prop: "totalCost", label: "鎬绘垚鏈�", minWidth: 150 },
+  { prop: "totalPrice", label: "鎬诲敭浠�", minWidth: 150 },
+  { prop: "profit", label: "鍒╂鼎", minWidth: 100 },
+  { prop: "reviewer", label: "澶嶈浜�", minWidth: 120 },
+  { prop: "date", label: "鏃ユ湡", minWidth: 150 },
 ];
 
 // 鎼滅储琛ㄥ崟鏁版嵁
-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();
 };
 

--
Gitblit v1.9.3