| | |
| | | <template> |
| | | div<template> |
| | | <el-dialog |
| | | v-model="dialogVisible" |
| | | :title="dialogType === 'add' ? '新增生产加工' : '编辑生产加工'" |
| | |
| | | @close="handleClose" |
| | | > |
| | | <el-button type="primary" @click="handlData">选择数据</el-button> |
| | | <ETable |
| | | v-if="tableData.length > 0" |
| | | <ETableModify |
| | | :columns="columns" |
| | | height="200" |
| | | @cell-edit="handleCellEdit" |
| | |
| | | @row-click="handleRowClick" |
| | | :editableColumns="['used']" |
| | | /> |
| | | <div v-if="tableData.length > 0" class="empty-table"> |
| | | <div class="empty-table"> |
| | | <h1>生产明细</h1> |
| | | <el-row :gutter="10"> |
| | | <el-col :span="2"> |
| | |
| | | @input-change="handleDetailsChange" |
| | | @delete-row="handleDeleteRow" |
| | | /> |
| | | |
| | | </div> |
| | | <div style="margin-top: 20px;" v-else>暂无数据,请选择配置数据</div> |
| | | |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | |
| | | v-model="innerVisible" |
| | | width="1000" |
| | | title="选择配置数据" |
| | | center |
| | | append-to-body |
| | | > |
| | | <ETable |
| | | @selection-change="handleSelectionChange" |
| | | :showOperations="false" |
| | | :columns="formalDatabaseDataColumns" |
| | | :columns="formalDatabaseColumns" |
| | | :tableData="formalDatabaseData" |
| | | height="400" |
| | | @cell-edit="handleCellEdit" |
| | |
| | | |
| | | <script setup> |
| | | import { ref, reactive, watch } from "vue"; |
| | | import ETable from "@/components/Table/EtableModify.vue"; |
| | | import ETable from "@/components/Table/ETable.vue"; |
| | | import ETableModify from "@/components/Table/EtableModify.vue"; |
| | | import ProductionDetailsTable from "./ProductionDetailsTable.vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { Delete, Warning, Plus } from "@element-plus/icons-vue"; |
| | | import { getOfficialAll } from "@/api/production/index.js"; |
| | | |
| | | const props = defineProps({ |
| | | visible: { |
| | |
| | | const tableData = ref([]); |
| | | const currentRow = ref(null); |
| | | const columns = [ |
| | | { label: "煤种", prop: "category" }, |
| | | { label: "热值", prop: "Calorific" }, |
| | | { label: "库存数量", prop: "stock" }, |
| | | { label: "本次使用数量", prop: "used" }, |
| | | { label: "供应商名称", prop: "supplierName" }, |
| | | { label: "煤种", prop: "coal" }, |
| | | { label: "单价(不含税)", prop: "priceExcludingTax" }, |
| | | { label: "库存数量", prop: "inventoryQuantity" }, |
| | | { |
| | | label: "使用数量", |
| | | prop: "used", |
| | | editable: true, |
| | | width: 120, |
| | | editType: "number", |
| | | }, |
| | | |
| | | ]; |
| | | const detailsTableData = ref([ |
| | | { |
| | | coalType: "", |
| | | calorificValue: "", |
| | | productionQuantity: "", |
| | | laborCost: "", |
| | | energyCost: "", |
| | | equipmentDepreciation: "", |
| | | purchasePrice: "", |
| | | totalCost: "", |
| | | }, |
| | | |
| | | ]); |
| | | const handleRowClick = (row) => { |
| | | currentRow.value = row; |
| | | }; |
| | | const formalDatabaseDataColumns = ref([ |
| | | { prop: "name", label: "供应商名称", width: 150 }, |
| | | { prop: "type", label: "煤种类型", width: 120 }, |
| | | { prop: "unit", label: "单位", width: 100 }, |
| | | { prop: "number", label: "采购数量", width: 100 }, |
| | | { prop: "money", label: "单价(含税)", width: 120 }, |
| | | { prop: "money1", label: "总价(含税)", width: 120 }, |
| | | { prop: "money2", label: "税率", width: 80 }, |
| | | { prop: "money3", label: "不含税单价", width: 120 }, |
| | | { prop: "createUser", label: "登记人", width: 100 }, |
| | | { prop: "createTime", label: "登记日期", width: 150 }, |
| | | const formalDatabaseColumns = ref([ |
| | | { 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({ |
| | |
| | | reviewer: "", |
| | | date: "", |
| | | }); |
| | | const handlData = () => { |
| | | const handlData =async () => { |
| | | innerVisible.value = true; |
| | | let res = await getOfficialAll(); |
| | | console.log("获取配置数据", res); |
| | | if (res.code === 200) { |
| | | formalDatabaseData.value = res.data; |
| | | } else { |
| | | ElMessage.error("获取配置数据失败"); |
| | | } |
| | | }; |
| | | 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({ |
| | |
| | | (row) => row.id === item.id |
| | | ); |
| | | if (!existingItem) { |
| | | tableData.value.push({ |
| | | id: item.id, |
| | | category: item.type, |
| | | Calorific: item.money4, |
| | | stock: item.number, |
| | | used: 0, // 初始使用数量为0 |
| | | }); |
| | | tableData.value.push( |
| | | Object.assign({}, item, { |
| | | used: 0, // 初始使用数量为0 |
| | | }) |
| | | ); |
| | | } |
| | | }); |
| | | innerVisible.value = false; |
| | |
| | | |
| | | // 提交表单 |
| | | 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; |
| | | }; |
| | | |
| | |
| | | const addNewRow = () => { |
| | | detailsTableData.value.push({ |
| | | coalType: "", |
| | | calorificValue: "", |
| | | productionQuantity: "", |
| | | laborCost: "", |
| | | energyCost: "", |
| | | energyConsumptionCost: "", |
| | | equipmentDepreciation: "", |
| | | purchasePrice: "", |
| | | totalCost: "", |
| | | autoCalculate: "0.00", |
| | | producer:"", |
| | | }); |
| | | }; |
| | | |
| | |
| | | .el-row > .el-col > h1 { |
| | | font-weight: bolder; |
| | | } |
| | | .empty-table > .el-row{ |
| | | margin-bottom: 12px; |
| | | } |
| | | </style> |