张诺
2 天以前 0f4dc4ea8a7de1ffdf34a640c79c29d55b79321c
添加生产管理接口及优化表格字段
已修改4个文件
344 ■■■■■ 文件已修改
src/api/production/index.js 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/production/components/ProductionDetailsTable.vue 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/production/components/ProductionDialog.vue 192 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/production/index.vue 86 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
    })
}
// 查询生产加工-正式库煤种列表
export function getOfficialById(id) {
    return request({
        url: '/officialInventory/official/' + id,
        method: 'get'
    })
}
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 
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: "供应商A",
    type: "动力煤",
    unit: "吨",
    number: 120,
    money: 500,
    money1: 200,
    money2: 200,
    money3: 300,
    money4: "高位",
    createUser: "admin",
    createTime: "2025-06-01",
  },
  {
    id: 2,
    name: "供应商A",
    type: "动力煤",
    unit: "吨",
    number: 100,
    money: 600,
    money1: 300,
    money2: 300,
    money3: 300,
    money4: "低位",
    createUser: "admin",
    createTime: "2025-06-01",
  },
  {
    id: 3,
    name: "供应商B",
    type: "焦煤",
    unit: "吨",
    number: 300,
    money: 789,
    money1: 400,
    money2: 400,
    money3: 400,
    money4: "高位",
    createUser: "admin",
    createTime: "2025-06-01",
  },
  {
    id: 4,
    name: "供应商B",
    type: "焦煤",
    unit: "吨",
    number: 256,
    money: 800,
    money1: 420,
    money2: 420,
    money3: 420,
    money4: "低位",
    createUser: "admin",
    createTime: "2025-06-01",
  },
  {
    id: 5,
    name: "供应商C",
    type: "无烟煤",
    unit: "吨",
    number: 256,
    money: 700,
    money1: 300,
    money2: 300,
    money3: 300,
    money4: "高位",
    createUser: "admin",
    createTime: "2025-06-01",
  },
  {
    id: 6,
    name: "供应商A",
    type: "动力煤",
    unit: "吨",
    number: 120,
    money: 500,
    money1: 200,
    money2: 200,
    money3: 300,
    money4: "高位",
    createUser: "admin",
    createTime: "2025-06-01",
  },
  {
    id: 7,
    name: "供应商A",
    type: "动力煤",
    unit: "吨",
    number: 100,
    money: 600,
    money1: 300,
    money2: 300,
    money3: 300,
    money4: "低位",
    createUser: "admin",
    createTime: "2025-06-01",
  },
  {
    id: 8,
    name: "供应商B",
    type: "焦煤",
    unit: "吨",
    number: 300,
    money: 789,
    money1: 400,
    money2: 400,
    money3: 400,
    money4: "高位",
    createUser: "admin",
    createTime: "2025-06-01",
  },
  {
    id: 9,
    name: "供应商B",
    type: "焦煤",
    unit: "吨",
    number: 256,
    money: 800,
    money1: 420,
    money2: 420,
    money3: 420,
    money4: "低位",
    createUser: "admin",
    createTime: "2025-06-01",
  },
  {
    id: 10,
    name: "供应商C",
    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:"",
  });
};
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();
};