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/components/ProductionDetailsTable.vue |   28 ++--
 src/api/production/index.js                                |   38 ++++++
 src/views/production/index.vue                             |   86 ++++----------
 src/views/production/components/ProductionDialog.vue       |  192 +++++---------------------------
 4 files changed, 106 insertions(+), 238 deletions(-)

diff --git a/src/api/production/index.js b/src/api/production/index.js
index f0ad4e5..9cb0823 100644
--- a/src/api/production/index.js
+++ b/src/api/production/index.js
@@ -10,4 +10,42 @@
     })
 }
 
+// /productionMaster/list
+// 涓昏〃鍒楄〃
+export function getProductionMasterList(query) {
+    return request({
+        url: '/productionMaster/list',
+        method: 'get',
+        params: query
+    })
+}
+
+// /production/list
+// 鐢熶骇鍔犲伐涓存椂鏁版嵁
+export function getProductionList(query) {
+    return request({
+        url: '/production/list',
+        method: 'get',
+        params: query
+    })
+}
+
+// /productionMaster/addOrEditPM
+// 鏂板鎴栦慨鏀逛富琛�
+export function addOrEditPM(data) {
+    return request({
+        url: '/productionMaster/addOrEditPM',
+        method: 'post',
+        data: data
+    })
+}
+
+
+// 鏌ヨ鐢熶骇鍔犲伐-姝e紡搴撶叅绉嶅垪琛�
+export function getOfficialById(id) {
+    return request({
+        url: '/officialInventory/official/' + id,
+        method: 'get'
+    })
+}
 
diff --git a/src/views/production/components/ProductionDetailsTable.vue b/src/views/production/components/ProductionDetailsTable.vue
index e8adfc4..1d1ca7a 100644
--- a/src/views/production/components/ProductionDetailsTable.vue
+++ b/src/views/production/components/ProductionDetailsTable.vue
@@ -1,7 +1,7 @@
 <template>
   <el-table :data="tableData" :border="border" style="width: 100%">
-    <el-table-column label="鐓ょ" min-width="120">
-      <template #default="{ row, $index }">
+    <el-table-column label="鐓ょ" min-width="120" >
+      <template #default="{ row, $index }" >
         <el-input 
           v-model="row.coalType" 
           placeholder="璇疯緭鍏ョ叅绉�"
@@ -9,17 +9,6 @@
         />
       </template>
     </el-table-column>
-    
-    <el-table-column label="鐑��" min-width="120">
-      <template #default="{ row, $index }">
-        <el-input 
-          v-model="row.calorificValue" 
-          placeholder="璇疯緭鍏ョ儹鍊�"
-          @input="handleInput('calorificValue', $index, $event)"
-        />
-      </template>
-    </el-table-column>
-    
     <el-table-column label="鐢熶骇鏁伴噺" min-width="120">
       <template #default="{ row, $index }">
         <el-input 
@@ -49,10 +38,10 @@
     <el-table-column label="鑳借�楁垚鏈�" min-width="120">
       <template #default="{ row, $index }">
         <el-input 
-          v-model="row.energyCost" 
+          v-model="row.energyConsumptionCost" 
           placeholder="璇疯緭鍏ヨ兘鑰楁垚鏈�"
           type="number"
-          @input="handleInput('energyCost', $index, $event)"
+          @input="handleInput('energyConsumptionCost', $index, $event)"
         >
           <template #suffix>
             <i style="font-style:normal;">鍏�</i>
@@ -106,6 +95,15 @@
         </el-input>
       </template>
     </el-table-column>
+    <el-table-column label="鐢熶骇浜�" min-width="120">
+      <template #default="{ row, $index }">
+        <el-input 
+          v-model="row.producer" 
+          placeholder="鐢熶骇浜�"
+          @input="handleInput('producer', $index, $event)"
+        />
+      </template>
+    </el-table-column>
       <el-table-column v-if="showOperations" label="鎿嶄綔" width="120" fixed="right">
       <template #default="{ $index }">
         <el-button 
diff --git a/src/views/production/components/ProductionDialog.vue b/src/views/production/components/ProductionDialog.vue
index 226b70e..b75a3e2 100644
--- a/src/views/production/components/ProductionDialog.vue
+++ b/src/views/production/components/ProductionDialog.vue
@@ -125,6 +125,16 @@
 const columns = [
   { label: "渚涘簲鍟嗗悕绉�", prop: "supplierName" },
   { label: "鐓ょ", prop: "coal" },
+  { label: "鍗曚环(涓嶅惈绋�)", prop: "priceExcludingTax" },
+  { label: "搴撳瓨鏁伴噺", prop: "inventoryQuantity" },
+  {
+    label: "浣跨敤鏁伴噺",
+    prop: "used",
+    editable: true,
+    width: 120,
+    editType: "number",
+  },
+
 ];
 const detailsTableData = ref([
   
@@ -133,14 +143,12 @@
   currentRow.value = row;
 };
 const formalDatabaseColumns = ref([
-  { prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", width: 150 },
-  { prop: "coal", label: "鐓ょ绫诲瀷", width: 120 },
-  { prop: "unit", label: "鍗曚綅", width: 100 },
-  { prop: "inventoryQuantity", label: "搴撳瓨鏁伴噺", width: 100 },
-  { prop: "priceIncludingTax", label: "鍗曚环锛堝惈绋庯級", width: 120 },
-  { prop: "totalPriceIncludingTax", label: "鎬讳环锛堝惈绋庯級", width: 120 },
-  { prop: "priceExcludingTax", label: "鍗曚环(涓嶅惈绋�)", width: 120 },
-  { prop: "totalPriceExcludingTax", label: "鎬讳环(涓嶅惈绋�)", width: 120 },
+  { prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minwidth: 150 },
+  { prop: "coal", label: "鐓ょ绫诲瀷", minwidth: 60 },
+  { prop: "inventoryQuantity", label: "搴撳瓨鏁伴噺", minwidth: 80 },
+  { prop: "unit", label: "鍗曚綅", minwidth: 100 },
+  { prop: "priceExcludingTax", label: "鍗曚环锛堜笉鍚◣锛�", minwidth: 80 },
+  { prop: "createTime", label: "鐧昏鏃ユ湡", minwidth: 400 },
 ]);
 // 琛ㄥ崟鏁版嵁
 const formData = reactive({
@@ -169,156 +177,9 @@
 const formalDatabaseData = ref([]);
 const formalDatabaseSelectedData = ref([]);
 formalDatabaseData.value = [
-  {
-    id: 1,
-    name: "渚涘簲鍟咥",
-    type: "鍔ㄥ姏鐓�",
-    unit: "鍚�",
-    number: 120,
-    money: 500,
-    money1: 200,
-    money2: 200,
-    money3: 300,
-    money4: "楂樹綅",
-    createUser: "admin",
-    createTime: "2025-06-01",
-  },
-  {
-    id: 2,
-    name: "渚涘簲鍟咥",
-    type: "鍔ㄥ姏鐓�",
-    unit: "鍚�",
-    number: 100,
-    money: 600,
-    money1: 300,
-    money2: 300,
-    money3: 300,
-    money4: "浣庝綅",
-    createUser: "admin",
-    createTime: "2025-06-01",
-  },
-  {
-    id: 3,
-    name: "渚涘簲鍟咮",
-    type: "鐒︾叅",
-    unit: "鍚�",
-    number: 300,
-    money: 789,
-    money1: 400,
-    money2: 400,
-    money3: 400,
-    money4: "楂樹綅",
-    createUser: "admin",
-    createTime: "2025-06-01",
-  },
-  {
-    id: 4,
-    name: "渚涘簲鍟咮",
-    type: "鐒︾叅",
-    unit: "鍚�",
-    number: 256,
-    money: 800,
-    money1: 420,
-    money2: 420,
-    money3: 420,
-    money4: "浣庝綅",
-    createUser: "admin",
-    createTime: "2025-06-01",
-  },
-  {
-    id: 5,
-    name: "渚涘簲鍟咰",
-    type: "鏃犵儫鐓�",
-    unit: "鍚�",
-    number: 256,
-    money: 700,
-    money1: 300,
-    money2: 300,
-    money3: 300,
-    money4: "楂樹綅",
-    createUser: "admin",
-    createTime: "2025-06-01",
-  },
-  {
-    id: 6,
-    name: "渚涘簲鍟咥",
-    type: "鍔ㄥ姏鐓�",
-    unit: "鍚�",
-    number: 120,
-    money: 500,
-    money1: 200,
-    money2: 200,
-    money3: 300,
-    money4: "楂樹綅",
-    createUser: "admin",
-    createTime: "2025-06-01",
-  },
-  {
-    id: 7,
-    name: "渚涘簲鍟咥",
-    type: "鍔ㄥ姏鐓�",
-    unit: "鍚�",
-    number: 100,
-    money: 600,
-    money1: 300,
-    money2: 300,
-    money3: 300,
-    money4: "浣庝綅",
-    createUser: "admin",
-    createTime: "2025-06-01",
-  },
-  {
-    id: 8,
-    name: "渚涘簲鍟咮",
-    type: "鐒︾叅",
-    unit: "鍚�",
-    number: 300,
-    money: 789,
-    money1: 400,
-    money2: 400,
-    money3: 400,
-    money4: "楂樹綅",
-    createUser: "admin",
-    createTime: "2025-06-01",
-  },
-  {
-    id: 9,
-    name: "渚涘簲鍟咮",
-    type: "鐒︾叅",
-    unit: "鍚�",
-    number: 256,
-    money: 800,
-    money1: 420,
-    money2: 420,
-    money3: 420,
-    money4: "浣庝綅",
-    createUser: "admin",
-    createTime: "2025-06-01",
-  },
-  {
-    id: 10,
-    name: "渚涘簲鍟咰",
-    type: "鏃犵儫鐓�",
-    unit: "鍚�",
-    number: 256,
-    money: 700,
-    money1: 300,
-    money2: 300,
-    money3: 300,
-    money4: "楂樹綅",
-    createUser: "admin",
-    createTime: "2025-06-01",
-  },
 ];
-
-// 琛ㄥ崟楠岃瘉瑙勫垯
-const rules = {
-  category: [{ required: true, message: "璇烽�夋嫨鐓ょ", trigger: "change" }],
-};
-
 // 鍒濆鍖�
 const Initialization = () => {
-  console.log("鍒濆鍖栨暟鎹�");
   tableData.value = [];
 };
 defineExpose({
@@ -338,13 +199,14 @@
       (row) => row.id === item.id
     );
     if (!existingItem) {
-      tableData.value.push([item, {
-        used: 0, // 娣诲姞榛樿鐨勪娇鐢ㄦ暟閲�
-      }]);
+      tableData.value.push(
+        Object.assign({}, item, {
+          used: 0, // 鍒濆浣跨敤鏁伴噺涓�0
+        })
+      );
     }
   });
   innerVisible.value = false;
-  console.log("閫変腑鐨勬暟鎹�:", tableData.value);
 };
 const handleSelectionChange = (selection) => {
   formalDatabaseSelectedData.value = selection;
@@ -358,7 +220,13 @@
 
 // 鎻愪氦琛ㄥ崟
 const handleSubmit = async () => {
+  console.log("鎻愪氦琛ㄥ崟鏁版嵁:", tableData.value);
   console.log(detailsTableData.value);
+  let data = {
+    productionList: detailsTableData.value,
+    productionInventoryList: tableData.value,
+  };
+  console.log("鎻愪氦鏁版嵁", data);
   // dialogVisible.value = false;
 };
 
@@ -393,13 +261,13 @@
 const addNewRow = () => {
   detailsTableData.value.push({
     coalType: "",
-    calorificValue: "",
     productionQuantity: "",
     laborCost: "",
-    energyCost: "",
+    energyConsumptionCost: "",
     equipmentDepreciation: "",
     purchasePrice: "",
-    totalCost: "",
+    autoCalculate: "0.00",
+    producer:"",
   });
 };
 
diff --git a/src/views/production/index.vue b/src/views/production/index.vue
index 0e9b005..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,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();
 };
 

--
Gitblit v1.9.3