| | |
| | | <template> |
| | | <el-table :data="tableData" :border="border" style="width: 100%"> |
| | | <el-table-column label="煤料类型" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <el-select |
| | | clearable |
| | | v-model="row.type" |
| | | placeholder="请选择煤料类型" |
| | | filterable |
| | | :key="`coalId-select-${$index}-${typeList.length}`" |
| | | :disabled="isViewMode" |
| | | > |
| | | <el-option |
| | | v-for="(item, index) of typeList" |
| | | :key="`option-${index}-${item.value}`" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="煤种" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <el-select |
| | |
| | | |
| | | <el-table-column label="能耗成本" min-width="120"> |
| | | <template #default="{ row, $index }"> |
| | | <!-- 不能为负数 --> |
| | | <el-input |
| | | v-model="row.energyConsumptionCost" |
| | | placeholder="请输入能耗成本" |
| | | type="number" |
| | | min="0" |
| | | step="0.01" |
| | | @input="handleInput('energyConsumptionCost', $index, $event)" |
| | | :disabled="isViewMode" |
| | | > |
| | |
| | | <script setup name="ProductionDetailsTable"> |
| | | import {ref, computed, watch, onMounted, nextTick} from "vue"; |
| | | import {Delete} from "@element-plus/icons-vue"; |
| | | import {ElMessage} from "element-plus"; |
| | | import {getCoalFieldList} from "@/api/basicInformation/coalQualityMaintenance"; |
| | | import {getCoalInfoList} from "@/api/production"; |
| | | import {userListAll} from "@/api/publicApi"; |
| | | |
| | | const typeList = [ |
| | | { |
| | | label: "成品", |
| | | value: 1, |
| | | }, |
| | | { |
| | | label: "原料", |
| | | value: 2, |
| | | } |
| | | ] |
| | | const props = defineProps({ |
| | | modelValue: { |
| | | type: Array, |
| | |
| | | |
| | | // 处理输入变化 |
| | | const handleInput = (field, index, value) => { |
| | | // 确保输入值是数字或空字符串而且非负数 |
| | | if (!/^\d*\.?\d*$/.test(value) && value !== "") { |
| | | ElMessage.error("请输入有效的数字"); |
| | | return; |
| | | } |
| | | const newData = [...tableData.value]; |
| | | newData[index][field] = value; |
| | | |
| | |
| | | // 计算总成本 |
| | | const calculateTotalCost = (row) => { |
| | | const laborCost = parseFloat(row.laborCost) || 0; |
| | | const energyCost = parseFloat(row.energyCost) || 0; |
| | | const energyCost = parseFloat(row.energyConsumptionCost) || 0; |
| | | const equipmentDepreciation = parseFloat(row.equipmentDepreciation) || 0; |
| | | const purchasePrice = parseFloat(row.purchasePrice) || 0; |
| | | |
| | |
| | | purchasePrice: "", |
| | | totalCost: "", |
| | | producerId: "", |
| | | type: 1, |
| | | ...rowData, |
| | | }; |
| | | tableData.value = [...tableData.value, defaultRow]; |