From 4d4795b9a78614dc4338b5c7b10830605ac02210 Mon Sep 17 00:00:00 2001
From: 于杰 <1210123631@qq.com>
Date: 星期五, 01 八月 2025 11:12:53 +0800
Subject: [PATCH] 解决前端模拟计算,数据丢失问题,解决前端调整界面,掰片与优化结果不匹配问题

---
 north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/Compute.vue |  104 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 85 insertions(+), 19 deletions(-)

diff --git a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/Compute.vue b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/Compute.vue
index 5b542e5..a0e9c6d 100644
--- a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/Compute.vue
+++ b/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 瑙﹀彂鑷畾涔変簨浠讹紝灏嗗伐绋嬪彿浼犻�掔粰鐖剁粍浠讹紝鐢辩埗缁勪欢鍘昏皟鐢ㄦ帴鍙h幏鍙栨暟鎹�
-  emit('fetch-data', inputValue.value);
- 
- 
+  const projectNumber = inputValue.value;
+  if (!projectNumber) {
+    ElMessage.warning('璇疯緭鍏ュ伐绋嬪彿');
+    return;
+  }
+  // 閫氱煡鐖剁粍浠舵洿鏂帮紙鍙�夛級
+  emit('fetch-data', projectNumber);
+  // 瀛愮粍浠惰嚜宸辫皟鐢ㄦ帴鍙f洿鏂版暟鎹�
+  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

--
Gitblit v1.8.0