north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/Compute.vue
@@ -80,8 +80,8 @@
        spacingLong.value=parsedData.tempering.yAxisInterval;
        heatingTime.value=parsedData.tempering.temperingTime;
      }
    } else {
      console.error('请求失败,状态码:', response.code);
    }
@@ -145,6 +145,12 @@
  await firstLoading()
})
onMounted(async () => {
  if (props.project && props.project.projectNumber) {
    await fetchProjectData(props.project.projectNumber);
  }
});
const firstLoading = async() => {
    request.post(`/glassOptimize/selectOptimizeParms/${username}`).then((res) => {
      if (res.code == "200") {
@@ -182,7 +188,11 @@
  }
})
const inputValues = {
// let emit = defineEmits(['fetch-data']);
const emit = defineEmits(['fetch-data', 'sendData', 'simulate-click']);
const inputValues =  reactive({
  project_no:inputValue.value,
  glass_thickness:"",
  glass_type:"",
@@ -202,30 +212,86 @@
  rotate_mode:0,
  polys_allow_rotate: 0,
  process_cards:[]
});
const fetchProjectData = async (projectNumber) => {
  try {
    const res = await request.post(`/glassOptimize/getProjectByProjectNo/${projectNumber}`);
    if (Number(res.code) === 200 && res.data && res.data.data && res.data.data.length > 0) {
      const projectData = res.data.data[0];
      // 更新 inputValues
      inputValues.glass_thickness = projectData.glass_thickness || '';
      inputValues.glass_type = projectData.glass_type || '';
      console.log('更新后的 inputValues:', inputValues);
    } else {
      ElMessage.warning('未找到项目信息或数据格式不正确');
    }
  } catch (error) {
    console.error('请求失败:', error);
    ElMessage.error('获取项目信息失败');
  }
};
// let emit = defineEmits(['fetch-data']);
let emit = defineEmits(['fetch-data', 'sendData'])
const handleSearchClick = () => {
  // 通过 $emit 触发自定义事件,将工程号传递给父组件,由父组件去调用接口获取数据
  emit('fetch-data', inputValue.value);
  const projectNumber = inputValue.value;
  if (!projectNumber) {
    ElMessage.warning('请输入工程号');
    return;
  }
  // 通知父组件更新(可选)
  emit('fetch-data', projectNumber);
  // 子组件自己调用接口更新数据
  fetchProjectData(projectNumber);
};
const handleSimulationClick = () => {
  inputValues.project_no = inputValue.value;
  inputValues.chaos_pct = optionVal.value * 0.01; // 混排等级
  inputValues.cage_free = percentage2.value * 0.01; // 理片龙空闲度
  inputValues.heat_mode = 0; // 模式选择(默认值)
  inputValues.max_load_pct = percentage1.value * 0.01; // 最大装载率
  inputValues.max_area = 0; // 最大面积(默认值)
  inputValues.max_qty = 0; // 最大片数(默认值)
  inputValues.load_width = furnaceWidth.value;
  inputValues.load_length = furnaceLength.value;
  inputValues.x_space = spacingWidth.value;
  inputValues.y_space = spacingLong.value;
  inputValues.polys_allow_rotate = parseInt(rotateMode.value.value);
  inputValues.tempering_time = heatingTime.value || inputValues.tempering_time || 0;
  const sendData = {
    project_no: inputValues.project_no,
    glass_thickness: inputValues.glass_thickness,
    glass_type: inputValues.glass_type,
    chaos_pct: inputValues.chaos_pct, // 混排等级
    cage_free: inputValues.cage_free, // 理片龙空闲度
    tempering_time: inputValues.tempering_time,
    heat_mode: inputValues.heat_mode, // 模式选择
    max_load_pct: inputValues.max_load_pct, // 最大装载率
    max_area: inputValues.max_area, // 最大面积
    max_qty: inputValues.max_qty, // 最大片数
    load_width: inputValues.load_width,
    load_length: inputValues.load_length,
    x_space: inputValues.x_space,
    y_space: inputValues.y_space,
    load_rate: inputValues.load_rate, // 装载率(可能为空)
    furnaces_qty: inputValues.furnaces_qty, // 炉子数量(可能为空)
    rotate_mode: inputValues.rotate_mode, // 钢化旋转模式(可能为空)
    polys_allow_rotate: inputValues.polys_allow_rotate,
    process_cards: inputValues.process_cards || [] // 流程卡列表(默认空数组)
  };
  emit('sendData', sendData);
  emit('simulate-click');
      inputValues.project_no = inputValue.value;
      inputValues.glass_thickness =  props.project.glass_thickness ;
      inputValues.glass_type = props.project.glass_type;
      inputValues.tempering_time = heatingTime.value || inputValues.tempering_time || 0;
      inputValues.load_width = furnaceWidth.value
      inputValues.load_length = furnaceLength.value
      inputValues.x_space = spacingWidth.value
      inputValues.y_space = spacingLong.value
      inputValues.polys_allow_rotate = parseInt(rotateMode.value.value)
  emit('sendData', {
    ...inputValues