| | |
| | | import ComputeDetail from "@/views/pp/glassOptimize/page/ComputeDetail.vue"; |
| | | import Compute from "@/views/pp/glassOptimize/page/Compute.vue"; |
| | | import {onMounted, ref} from 'vue'; |
| | | import {ElMessage} from "element-plus"; |
| | | import {ElMessage, ElLoading} from "element-plus"; |
| | | import request from "@/utils/request"; |
| | | |
| | | const props = defineProps({ |
| | | projectNo : String |
| | | }); |
| | | |
| | | const computed = ref(null); |
| | | const computedCard = ref(null); |
| | | const computedData = ref({ |
| | | // 要传递给子组件的数据 |
| | | }); |
| | | |
| | | // 监听子组件ComputeCard的数据 |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | const handleCardData = (data) => { |
| | | |
| | | computedCard.value = data; |
| | | // 将 computed.value 合并到 computedCard.value 的最外层 |
| | | computedCard.value = { |
| | | ...computed.value, |
| | | ...computedCard.value |
| | | }; |
| | | }; |
| | | |
| | | // 监听子组件ComputeDetail的数据 |
| | | const handleData = (data) => { |
| | | computed.value = data; |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | if (props.projectNo) { |
| | | handleFetchData(props.projectNo); |
| | | handleTableData(data); |
| | | handleDataReceive(data); |
| | | } |
| | | }); |
| | | |
| | | // 在父组件中定义处理接收数据的函数 |
| | | const handleDataReceive= async (data) => { |
| | | console.log('接收到子组件的数据2:', data); |
| | | // 处理数据,例如更新父组件的状态或调用后端API |
| | | |
| | | } |
| | | |
| | | |
| | | // 用于存储从后端获取到的数据,初始化为空数组 |
| | | const receivedData = ref([]); |
| | | |
| | | |
| | | console.log(receivedData) |
| | | const handleFetchData = async (projectNumber) => { |
| | | try { |
| | | const res = await request.post(`/glassOptimize/selectProjectCompute/${projectNumber}`); |
| | |
| | | } |
| | | }; |
| | | |
| | | const handleTableData= async (data) => { |
| | | // 处理接收到的表格数据 |
| | | console.log('父组件接收到的数据1:', data); |
| | | } |
| | | |
| | | const handleSimulation = async () => { |
| | | const loading = ElLoading.service({ |
| | | lock: true, |
| | | text: '正在计算中,请稍候...', |
| | | background: 'rgba(0, 0, 0, 0.7)' |
| | | }); |
| | | console.log('发送到后端的数据',computedCard.value) |
| | | const mockData = { |
| | | code: 200, |
| | | data: [ |
| | | { |
| | | "glass_details": [ |
| | | { |
| | | "angle": 0.0, |
| | | "glass_type": 3, |
| | | "height": 862, |
| | | "layers_number": 2, |
| | | "order_number": 33, |
| | | "process_id": "NG24120028A005", |
| | | "technology_number": 2, |
| | | "tempering_feed_sequence": 14, |
| | | "tempering_layout_id": 15, |
| | | "width": 814, |
| | | "x_coordinate": 1582.0, |
| | | "y_coordinate": 3768.0 |
| | | }, |
| | | { |
| | | "angle": 0.1, |
| | | "glass_type": 4, |
| | | "height": 862, |
| | | "layers_number": 2, |
| | | "order_number": 33, |
| | | "process_id": "NG24120028A005", |
| | | "technology_number": 2, |
| | | "tempering_feed_sequence": 14, |
| | | "tempering_layout_id": 15, |
| | | "width": 814, |
| | | "x_coordinate": 1582.0, |
| | | "y_coordinate": 3768.0 |
| | | } |
| | | ], |
| | | "guidance": 15, |
| | | "rackinfos": [ |
| | | "NG24120026A003-2", |
| | | "NG24120027A003-2", |
| | | "NG24120028A005-2" |
| | | ], |
| | | "ratioResult": [ |
| | | { |
| | | "area": 10.53, |
| | | "glass_total": 15, |
| | | "ratio": 0.74, |
| | | "tempering_layout_id": "13" |
| | | }, |
| | | { |
| | | "area": 10.53, |
| | | "glass_total": 15, |
| | | "ratio": 0.74, |
| | | "tempering_layout_id": "14" |
| | | }, |
| | | { |
| | | "area": 9.82, |
| | | "glass_total": 14, |
| | | "ratio": 0.69, |
| | | "tempering_layout_id": "15" |
| | | } |
| | | ], |
| | | "resultSum": [15.0, 0.74] |
| | | } |
| | | ] |
| | | }; |
| | | if (mockData.code === 200) { |
| | | loading.close(); |
| | | ElMessage.success('模拟计算成功!'); |
| | | } |
| | | // 更新computedData |
| | | computedData.value = mockData; |
| | | // try { |
| | | // if (!computed.value ) { |
| | | // ElMessage.warning('请先加载数据再进行模拟计算'); |
| | | // return; |
| | | // } |
| | | |
| | | // // 显示加载提示 |
| | | // const loading = ElLoading.service({ |
| | | // lock: true, |
| | | // text: '正在计算中,请稍候...', |
| | | // background: 'rgba(0, 0, 0, 0.7)' |
| | | // }); |
| | | |
| | | // try { |
| | | // // 将数据提交到后端 |
| | | // const response = await request.post('/glassOptimize/simulationCalculate', { |
| | | |
| | | // data: computedCard.value |
| | | |
| | | // }); |
| | | |
| | | // if (response.code === 200) { |
| | | // ElMessage.success('模拟计算成功!'); |
| | | // } else { |
| | | // ElMessage.error(response.msg || '模拟计算失败'); |
| | | // } |
| | | // } catch (error) { |
| | | // console.error('请求失败:', error); |
| | | // ElMessage.error('网络异常,请稍后再试'); |
| | | // } finally { |
| | | // // 关闭加载提示 |
| | | // loading.close(); |
| | | // } |
| | | // } catch (error) { |
| | | // console.error('请求失败:', error); |
| | | // ElMessage.error('网络异常,请稍后再试'); |
| | | // } |
| | | }; |
| | | |
| | | |
| | | |
| | | //接受子组件ComputeCard的流程卡号 |
| | | let projectRow = ref({ |
| | | processId:null, |
| | |
| | | |
| | | <template> |
| | | <div style="width: 100%; height: 100%;"> |
| | | |
| | | |
| | | <div id="compute"> |
| | | <compute @fetch-data="handleFetchData" :project-no="props.projectNo"/> |
| | | <compute :data="computedData" @fetch-data="handleFetchData" :project-no="props.projectNo" @sendData="handleData" @simulate-click="handleSimulation" /> |
| | | </div> |
| | | |
| | | <div id="computeCard"> |
| | | <compute-card :table-data="receivedData" |
| | | :process-id="projectRow.processId===null?null:projectRow.processId" |
| | | @upProcessId="handleUpdateProcessId" |
| | | @upProcessId="handleUpdateProcessId" @sendData="handleCardData" |
| | | /> |
| | | </div> |
| | | |
| | | <div id="computeDetail"> |
| | | <compute-detail :process-id="projectRow.processId===null?null:projectRow.processId" /> |
| | | <compute-detail :process-id="projectRow.processId===null?null:projectRow.processId" /> |
| | | </div> |
| | | |
| | | |
| | | </div> |
| | | </template> |
| | | |