From a93f0e3923cd9e74f4b86a6e8f8f13b0163dcf38 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期五, 01 八月 2025 14:30:11 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override

---
 north-glass-erp/northglass-erp/src/views/pp/glassOptimize/GlassComputed.vue           |   17 ++++-
 north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue   |   12 ++--
 north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/Compute.vue            |  103 ++++++++++++++++++++++++++++------
 north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/RectRenderer.vue       |    2 
 north-glass-erp/northglass-erp/src/views/pp/glassOptimizeThirdParty/GlassComputed.vue |    2 
 5 files changed, 106 insertions(+), 30 deletions(-)

diff --git a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/GlassComputed.vue b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/GlassComputed.vue
index 73d9f5f..0b5b60f 100644
--- a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/GlassComputed.vue
+++ b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/GlassComputed.vue
@@ -58,7 +58,7 @@
 
 // 鐢ㄤ簬瀛樺偍浠庡悗绔幏鍙栧埌鐨勬暟鎹紝鍒濆鍖栦负绌烘暟缁�
 const receivedData = ref([]);
-
+const emit = defineEmits(['update:project']);
 const fetchProjectInfo = async (projectNumber) => {
   try {
     const res = await request.post(`/glassOptimize/getProjectByProjectNo/${projectNumber}`);
@@ -67,10 +67,21 @@
     if (Number(res.code) === 200 && res.data && res.data.data && res.data.data.length > 0) {
       // 姝g‘璁块棶宓屽鐨勬暟鎹粨鏋�
       const projectData = res.data.data[0]; // 娉ㄦ剰杩欓噷鏄� res.data.data[0]
-
+      const updatedProject = {
+        ...props.project,
+        glass_thickness: projectData.glass_thickness || '',
+        glass_type: projectData.glass_type || ''
+      };
       console.log('鑾峰彇鍒扮殑glass_thickness:', projectData.glass_thickness);
       console.log('鑾峰彇鍒扮殑glass_type:', projectData.glass_type);
-
+      // // 閫氳繃 emit 鏇存柊 project
+      emit('update:project', updatedProject);
+      // 鏇存柊 computed.value
+      computed.value = {
+        ...computed.value,
+        glass_thickness: projectData.glass_thickness,
+        glass_type: projectData.glass_type
+      };
       // 纭繚computed.value宸插垵濮嬪寲
       if (!computed.value) {
         computed.value = {};
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..7122771 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,85 @@
   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);
+
+
+
       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
diff --git a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue
index af996d4..df8057f 100644
--- a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue
+++ b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/OptimizationRect.vue
@@ -266,7 +266,7 @@
   return {
     position: 'absolute',
     left: `${layout.leftTrim * scale}px`,
-    top: `${layout.upTrim * scale}px`,
+    bottom: `${layout.upTrim * scale}px`,
     width: `${layout.width * scale}px`,
     height: `${layout.height * scale}px`,
     overflow: 'visible',
@@ -314,7 +314,7 @@
   return {
     position: 'absolute',
     left: `${glassDetail.x * scale}px`,
-    bottom: `${glassDetail.y * scale}px`,
+    top: `${glassDetail.y * scale}px`,
     width: `${glassDetail.width * scale}px`,
     height: `${glassDetail.height * scale}px`,
     backgroundColor: glassDetail.isRemain ? '#f0f0f0' : themeColor.value,
@@ -632,7 +632,7 @@
     if (Math.abs(glassDetail.y - otherRect.y) < threshold) {
       glassDetail.y = Math.round((glassDetail.y + otherRect.y) / 2);
     }
-    // 鍨傜洿瀵归綈涓嬭竟缂�
+    // 鍨傜洿瀵归綈涓婅竟缂�
     if (Math.abs((glassDetail.y + glassDetail.height) - (otherRect.y + otherRect.height)) < threshold) {
       glassDetail.y = Math.round((otherRect.y + otherRect.height - glassDetail.height));
     }
@@ -962,7 +962,7 @@
 
 //鍚戜笂绉诲姩璁$畻鍧愭爣
 const getAvailableSpaceUp = (glassDetail, layout, obstacles) => {
-  let maxSpace = layout.height - (glassDetail.y + glassDetail.height);
+  let maxSpace = layout.height - glassDetail.y - glassDetail.height;
   obstacles.forEach(obstacle => {
     if (obstacle.y > glassDetail.y + glassDetail.height &&
         obstacle.x <= glassDetail.x + glassDetail.width &&
@@ -1028,7 +1028,7 @@
       event.preventDefault();
       if (!moveInterval) {
         moveInterval = setInterval(() => {
-          moveRect(layoutIndex, rectIndex, 'up');
+          moveRect(layoutIndex, rectIndex, 'down');
         }, 50);
       }
       break;
@@ -1036,7 +1036,7 @@
       event.preventDefault();
       if (!moveInterval) {
         moveInterval = setInterval(() => {
-          moveRect(layoutIndex, rectIndex, 'down');
+          moveRect(layoutIndex, rectIndex, 'up');
         }, 50);
       }
       break;
diff --git a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/RectRenderer.vue b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/RectRenderer.vue
index 9ae3ea2..411dd7f 100644
--- a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/RectRenderer.vue
+++ b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/RectRenderer.vue
@@ -197,7 +197,7 @@
   return {
     position: 'absolute',
     left: `${glassDetail.x * scale}px`,
-    bottom: `${glassDetail.y * scale}px`,
+    top: `${glassDetail.y * scale}px`,
     width: `${glassDetail.width * scale}px`,
     height: `${glassDetail.height * scale}px`,
     backgroundColor: glassDetail.isRemain ? '#f0f0f0' : '#a0d8ef',
diff --git a/north-glass-erp/northglass-erp/src/views/pp/glassOptimizeThirdParty/GlassComputed.vue b/north-glass-erp/northglass-erp/src/views/pp/glassOptimizeThirdParty/GlassComputed.vue
index 8373b04..2da7386 100644
--- a/north-glass-erp/northglass-erp/src/views/pp/glassOptimizeThirdParty/GlassComputed.vue
+++ b/north-glass-erp/northglass-erp/src/views/pp/glassOptimizeThirdParty/GlassComputed.vue
@@ -219,7 +219,7 @@
     };
     if (mockData.code === 200) {
     loading.close();
-    ElMessage.success('妯℃嫙璁$畻鎴愬姛!');
+    // ElMessage.success('妯℃嫙璁$畻鎴愬姛!');
     }
     // 鏇存柊computedData
     computedData.value = mockData;

--
Gitblit v1.8.0