| | |
| | | |
| | | // 用于存储从后端获取到的数据,初始化为空数组 |
| | | const receivedData = ref([]); |
| | | |
| | | const emit = defineEmits(['update:project']); |
| | | const fetchProjectInfo = 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]; // 注意这里是 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 = {}; |