src/views/productionManagement/productionOrder/New.vue
@@ -225,7 +225,14 @@
            <el-table-column label="产品名称" prop="productName" min-width="120" />
            <el-table-column label="单位产出需要数量" min-width="140">
              <template #default="{ row }">
                <el-input-number v-model="row.unitQuantity" :min="0" :precision="2" size="small" style="width: 100%" />
                <el-input-number
                  v-model="row.unitQuantity"
                  :min="0"
                  :precision="2"
                  size="small"
                  style="width: 100%"
                  @change="(val) => handleUnitQuantityChange(val, row)"
                />
              </template>
            </el-table-column>
            <el-table-column label="需求数量" min-width="120">
@@ -419,7 +426,8 @@
    const items = res.data || [];
    processRouteItemsOptions.value = items;
    
    // 自动添加工序
    // 自动添加工序,计划数使用基本信息的需求数量
    const demandQty = formState.value.quantity || 1;
    processRouteItems.value = items.map(item => ({
      processId: item.processId,
      processName: item.processName,
@@ -427,7 +435,7 @@
      userPower: item.userPower ? item.userPower.split(',') : [],
      planStartTime: "",
      planEndTime: "",
      planNum: 1,
      planNum: demandQty,
      isQuality: item.isQuality || false,
    }));
  });
@@ -477,16 +485,39 @@
  });
};
// 监听需求数量变化,重新计算物料需求数量
// 监听物料清单变化,当单位产出需要数量变化时重新计算需求数量
watch(() => productStructureRecords.value, (newRecords, oldRecords) => {
  if (oldRecords && oldRecords.length > 0) {
    oldRecords.forEach((oldItem, index) => {
      const newItem = newRecords[index];
      if (oldItem && newItem && newItem.unitQuantity !== oldItem.unitQuantity) {
        newItem.demandedQuantity = (newItem.unitQuantity || 1) * (formState.value.quantity || 1);
      }
    });
  }
}, { deep: true });
// 监听需求数量变化,重新计算物料需求数量和工序计划数
watch(() => formState.value.quantity, (newQty) => {
  // 更新物料清单的需求数量
  if (productStructureRecords.value.length > 0 && newQty) {
    productStructureRecords.value = productStructureRecords.value.map(item => ({
      ...item,
      demandedQuantity: (item.unitQuantity || 1) * newQty
    }));
    productStructureRecords.value.forEach(item => {
      item.demandedQuantity = (item.unitQuantity || 1) * newQty;
    });
  }
  // 更新工序的计划数
  if (processRouteItems.value.length > 0 && newQty) {
    processRouteItems.value.forEach(item => {
      item.planNum = newQty;
    });
  }
});
// 单位产出需要数量变化处理
const handleUnitQuantityChange = (val, row) => {
  row.demandedQuantity = (val || 1) * (formState.value.quantity || 1);
};
// 工序选择变化处理
const handleProcessChange = (processId, row) => {
  const selectedProcess = processRouteItemsOptions.value.find(item => item.processId === processId);