| | |
| | | @change="(value) => handleCoalSelectChange(row, value)" |
| | | filterable |
| | | :key="`coalId-select-${$index}-${weekList.length}`" |
| | | :disabled="isViewMode" |
| | | > |
| | | <el-option |
| | | v-for="(item, index) of weekList" |
| | |
| | | placeholder="请输入生产数量" |
| | | type="number" |
| | | @input="handleInput('productionQuantity', $index, $event)" |
| | | :disabled="isViewMode" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | placeholder="请输入人工成本" |
| | | type="number" |
| | | @input="handleInput('laborCost', $index, $event)" |
| | | :disabled="isViewMode" |
| | | > |
| | | <template #suffix> |
| | | <i style="font-style: normal">元</i> |
| | |
| | | placeholder="请输入能耗成本" |
| | | type="number" |
| | | @input="handleInput('energyConsumptionCost', $index, $event)" |
| | | :disabled="isViewMode" |
| | | > |
| | | <template #suffix> |
| | | <i style="font-style: normal">元</i> |
| | |
| | | placeholder="请输入设备折旧" |
| | | type="number" |
| | | @input="handleInput('equipmentDepreciation', $index, $event)" |
| | | :disabled="isViewMode" |
| | | > |
| | | <template #suffix> |
| | | <i style="font-style: normal">元</i> |
| | |
| | | placeholder="请输入采购单价" |
| | | type="number" |
| | | @input="handleInput('purchasePrice', $index, $event)" |
| | | :disabled="isViewMode" |
| | | > |
| | | <template #suffix> |
| | | <i style="font-style: normal">元</i> |
| | |
| | | type="number" |
| | | :readonly="autoCalculate" |
| | | @input="handleInput('totalCost', $index, $event)" |
| | | |
| | | > |
| | | <template #suffix> |
| | | <i style="font-style: normal">元</i> |
| | |
| | | <template #default="{ row, $index }"> |
| | | <el-select |
| | | clearable |
| | | :model-value="getUserNameById(row.producer) || row.producer" |
| | | :model-value="getUserNameById(row.producerId) || row.producerId" |
| | | placeholder="请选择生产人" |
| | | @change="(value) => handleUserSelectChange(row, value)" |
| | | filterable |
| | | :key="`producer-select-${$index}-${userList.length}`" |
| | | :disabled="isViewMode" |
| | | > |
| | | <el-option |
| | | v-for="(item, index) of userList" |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="showOperations" |
| | | label="操作" |
| | | width="120" |
| | | fixed="right" |
| | | v-if="dialogType !== 'viewRow'" |
| | | > |
| | | <template #default="{ $index }"> |
| | | <el-button |
| | |
| | | type: Boolean, |
| | | default: true, |
| | | }, |
| | | dialogType:{ |
| | | type: String, |
| | | default:'add' |
| | | } |
| | | }); |
| | | |
| | | const isViewMode = computed(() => props.dialogType === "viewRow"); |
| | | const emit = defineEmits(["update:modelValue", "input-change", "delete-row"]); |
| | | |
| | | // 使用 v-model 进行双向绑定 |
| | |
| | | }; |
| | | // 处理用户选择变化(新方法:名称选择转ID) |
| | | const handleUserSelectChange = (row, selectedName) => { |
| | | console.log("handleUserSelectChange", row, selectedName); |
| | | // 根据选择的名称找到对应的ID |
| | | const userItem = userList.value.find(item => item.value === selectedName); |
| | | if (userItem) { |
| | | row.producer = userItem.key; // 设置为ID |
| | | row.producerId = userItem.key; // 设置为ID |
| | | } else { |
| | | row.producer = ''; // 如果没找到,清空 |
| | | row.producerId = ''; // 如果没找到,清空 |
| | | } |
| | | }; |
| | | // 暴露方法给父组件使用 |
| | |
| | | equipmentDepreciation: "", |
| | | purchasePrice: "", |
| | | totalCost: "", |
| | | producer: "", |
| | | producerId: "", |
| | | ...rowData, |
| | | }; |
| | | tableData.value = [...tableData.value, defaultRow]; |