From f7a2fcdda7f1120498c5c5f75c5a99955fc54b43 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期二, 16 十二月 2025 16:54:09 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/ERP_override
---
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/Compute.vue | 187 ++++++++++++++++++++++++++++++++++------------
1 files changed, 138 insertions(+), 49 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 379488d..afa7e0c 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
@@ -1,5 +1,5 @@
<script setup>
-import {onMounted, reactive, ref, watch} from "vue";
+import {onMounted, reactive, ref, watch, inject} from "vue";
import {useI18n} from "vue-i18n";
import {Platform, Search, SuccessFilled} from "@element-plus/icons-vue";
import useUserInfoStore from "@/stores/userInfo";
@@ -24,6 +24,8 @@
}
});
+// 娉ㄥ叆 projectNo
+const injectedProjectNo = inject('projectNo', null);
const selectOptions = [
{
@@ -45,7 +47,7 @@
const optionVal = ref(50)
// 瀹氫箟瑁呰浇鐜�
-const percentage1 = ref(80)
+const percentage1 = ref(50)
const percentage2 = ref(50)
// 瀹氫箟鍏朵粬琛ㄥ崟鏁版嵁
@@ -60,9 +62,27 @@
// 瀹氫箟鍝嶅簲寮忔暟鎹紝鐢ㄤ簬缁戝畾宸ョ▼鍙疯緭鍏ユ鐨勫��
let inputValue=ref(null)
if(props.project!==undefined){
- inputValue= ref(props.project.projectNumber);
- quantity.value=props.project.quantity
+ inputValue = ref(props.project.projectNumber);
+ quantity.value = props.project.quantity
+} else if(props.projectNo) {
+ inputValue.value = props.projectNo;
+} else if(injectedProjectNo) {
+ // 浠� provide/inject 鑾峰彇 projectNo
+ inputValue.value = injectedProjectNo.value || injectedProjectNo;
+}else {
+ // 浠� localStorage 鑾峰彇
+ const storedProjectNo = localStorage.getItem('currentProjectNo');
+ if (storedProjectNo) {
+ inputValue.value = storedProjectNo;
+ }
}
+
+// 娣诲姞 watch 鐩戝惉娉ㄥ叆鐨� projectNo
+watch(() => injectedProjectNo, (newVal) => {
+ if(newVal && !inputValue.value) {
+ inputValue.value = newVal.value || newVal;
+ }
+}, { immediate: true });
const fetchSettings = async (username) => {
try {
@@ -80,8 +100,8 @@
spacingLong.value=parsedData.tempering.yAxisInterval;
heatingTime.value=parsedData.tempering.temperingTime;
}
-
-
+
+
} else {
console.error('璇锋眰澶辫触锛岀姸鎬佺爜:', response.code);
}
@@ -145,6 +165,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 +208,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 +232,113 @@
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 = () => {
+
+
+const handleSimulationClick = async () => {
+
+ try {
+ const projectNumber = inputValue.value;
+ if (!projectNumber) {
+ ElMessage.warning('璇疯緭鍏ュ伐绋嬪彿');
+ return;
+ }
+
+ const res = await request.post(`/glassOptimize/getProjectState/${projectNumber}`);
+ if (Number(res.code) === 200) {
+ const projectData = res.data.data;
+
+ // 妫�鏌� tempering_state 鐘舵��
+ if (projectData.tempering_state === 1) {
+ // 濡傛灉宸插畬鎴愭ā鎷熻绠楋紝鎻愮ず鐢ㄦ埛骞堕樆姝㈢户缁墽琛�
+ ElMessage.warning('宸插畬鎴愭ā鎷熻绠楋紝涓嶅厑璁搁噸澶嶈绠�');
+ return;
+ }
+ } else {
+ ElMessage.warning(res.msg);
+ return;
+ }
+ } catch (error) {
+ ElMessage.error('妫�鏌ュ伐绋嬬姸鎬佸け璐ワ紝璇风◢鍚庨噸璇�');
+ console.error('妫�鏌ュ伐绋嬬姸鎬佸け璐�:', error);
+ return;
+ }
+
+
+ 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
@@ -241,6 +354,7 @@
const handleSave = () => {
+ console.log('褰撳墠淇濆瓨鐨勬暟鎹�:', props.data);
if(props.state==3){
let projectData = ref({
@@ -375,31 +489,6 @@
</div>
</div>
-<!-- <div class="demo-progress" style="margin-top: -10px">
- <div style="display: flex; align-items: center">
- <span>鐞嗙墖绗肩┖闂插害</span>
- <!– 杩涘害鏉¤缃� –>
- <el-slider
- style="max-width: 400px; flex: 1; margin-left: 10px"
- v-model="percentage2"
- :min="0"
- :max="100"
- :step="1"/>
- <span style="margin-left: 20px ; width: 35px;">{{ percentage2 }}%</span>
- <span style="float: right ; margin-left: 150px;">
- 鍔犵儹鏃堕棿(绉�)<el-select style="width: 50px;height: 30px" v-model="rotateMode">
- <el-option
- v-for="item in selectOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- 闀胯酱闂撮殧 <vxe-input size="small" class="input" clearable v-model="spacingLong"></vxe-input>
- 鐐夐暱(mm) <vxe-input size="small" class="input" clearable v-model="furnaceLength"></vxe-input>
- </span>
- </div>
- </div>-->
</div>
<div style="height: 50%">
<vxe-grid
--
Gitblit v1.8.0