| | |
| | | |
| | | onMounted(() => { |
| | | if (props.project) { |
| | | console.log(props.project) |
| | | console.log('ceshiyixia',props.project) |
| | | handleFetchData(props.project.projectNumber); |
| | | //handleTableData(data); |
| | | //handleDataReceive(data); |
| | |
| | | |
| | | // 用于存储从后端获取到的数据,初始化为空数组 |
| | | 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 = {}; |
| | |
| | | } |
| | | }; |
| | | |
| | | console.log(receivedData) |
| | | |
| | | const handleFetchData = async (projectNumber) => { |
| | | try { |
| | | const res = await request.post(`/glassOptimize/selectProjectCompute/${projectNumber}`); |
| | |
| | | <div style="width: 100%; height: 100%;"> |
| | | |
| | | <div id="compute"> |
| | | <compute :data="computedData" :state="state" @fetch-data="handleFetchData" :project="props.project" @sendData="handleData" @simulate-click="handleSimulation" /> |
| | | <compute :data="computedData" :state="state" |
| | | @fetch-data="handleFetchData" |
| | | :project="props.project" |
| | | @sendData="handleData" |
| | | @simulate-click="handleSimulation" /> |
| | | </div> |
| | | |
| | | <div id="computeCard"> |