north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/ProjectDetail.vue
@@ -116,7 +116,7 @@
      sortable: true
    },
    {
      field: 'product_name',
      field: 'productName',
      width: 150,
      title: t('order.product'),
      filters: [{data: ''}],
@@ -140,7 +140,7 @@
      sortable: true
    },
    {
      field: 'building_number',
      field: 'buildingNumber',
      width: 150,
      title: '楼层号',
      filters: [{data: ''}],
@@ -189,7 +189,7 @@
      sortable: true
    },
    {
      field: 'icon',
      field: 'markIcon',
      width: 150,
      title: '印标类型',
      filters: [{data: ''}],
@@ -446,31 +446,10 @@
};
const handleCommand = async (command) => {
  // 当选择模拟计算(command === 3)时,先检查 tempering_state 状态
  if (command === 3) {
    try {
      const res = await request.post(`/glassOptimize/getProjectState/${projectNo.value}`);
      if (Number(res.code) === 200) {
        const projectData = res.data.data;
    // 执行模拟计算
    await emit('changeDialog', command);
        // 检查 tempering_state 状态
        if (projectData.tempering_state === 1) {
          // 如果已完成模拟计算,提示用户并阻止打开
          ElMessage.warning('已完成模拟计算,不允许重复计算');
          return;
        } else if (projectData.tempering_state === 0) {
          // 如果未进行模拟计算,允许打开
          await emit('changeDialog', command);
        }
      } else {
        ElMessage.warning(res.msg);
        return;
      }
    } catch (error) {
      ElMessage.error('检查工程状态失败,请稍后重试');
      console.error('检查工程状态失败:', error);
      return;
    }
  } else {
    // 其他命令直接执行
    await emit('changeDialog', command);
@@ -506,103 +485,47 @@
    }
    emit('getSmallPieceData', 1);
    optimizeData.value.glassDetails = [];
    // 从后端接口获取 glassDetail 数据,而不是从表格中读取
    fetchGlassDetailData();
    // 从表格中获取 glassDetail 数据,而不是从后端接口读取
    const tableData = xGrid.value.getTableData().fullData;
    const glassDetailData = tableData.map(item => {
      let rackNoValue = 0;
      if (item.rackNo !== undefined && item.rackNo !== null && item.rackNo !== '') {
        rackNoValue = item.rackNo;
      }
      return {
        width: item.width,
        height: item.height,
        processId: item.processId,
        layer: item.layer,
        totalLayer: item.totalLayer,
        orderSort: item.order_number,
        markIcon: item.markIcon,
        quantity: item.quantity,
        patchState: item.patchState,
        upGrind: item.longGrind1,
        downGrind: item.longGrind2,
        leftGrind: item.shortGrind1,
        rightGrind: item.shortGrind2,
        heatLayoutId: item.heatLayoutId,
        process: item.process,
        orderNo: item.orderNo,
        customerName: item.customerName,
        processingNote: item.processingNote,
        projectName: item.projectName,
        productName: item.productName,
        buildingNumber: item.buildingNumber,
        rackNo: rackNoValue
      };
    });
    // xGrid.value.getTableData().fullData.forEach(items=>{
    //   let rackNoValue = 0;
    //   if (items.rackNo !== undefined && items.rackNo !== null && items.rackNo !== '') {
    //     rackNoValue = items.rackNo;
    //   }
    //   const detail={
    //     width :null,
    //     height :null,
    //     processId :null,
    //     layer :null,
    //     totalLayer :null,
    //     orderSort :null,
    //     markIcon :null,
    //     quantity:null,
    //     patchState :null,
    //     upGrind :null,
    //     downGrind :null,
    //     leftGrind:null,
    //     rightGrind :null,
    //     rackNo: rackNoValue
    //   }
    //   detail.width=items.width
    //   detail.height=items.height
    //   detail.processId=items.process_ids
    //   detail.layer=items.layer
    //   detail.totalLayer=items.total_layer
    //   detail.orderSort=items.order_number
    //   detail.markIcon=items.icon
    //   detail.patchState=items.patch_state
    //   detail.quantity=items.quantity
    //   detail.upGrind=items.longGrind1
    //   detail.downGrind=items.longGrind2
    //   detail.leftGrind=items.shortGrind1
    //   detail.rightGrind=items.shortGrind2
    //   detail.rackNo=items.rackNo
    //
    //   optimizeData.value.glassDetails .push(detail)
    // })
    // 更新 optimizeData 中的 glassDetails
    optimizeData.value.glassDetails = glassDetailData;
    // 打开优化对话框
    dialogVisible.value[4] = true;
  }else{
    dialogVisible.value[index] = true;
  }
};
const fetchGlassDetailData = async () => {
  try {
    const res = await request.post(`/glassOptimize/optimizeInfo/${projectNo.value}/${username}`);
    console.log(res);
    if (res.code === "200" && res.data && res.data.data) {
      // 处理从后端获取的数据
      const glassDetailData = res.data.data.map(item => {
        let rackNoValue = 0;
        if (item.rackNo !== undefined && item.rackNo !== null && item.rackNo !== '') {
          rackNoValue = item.rackNo;
        }
        return {
          width: item.width,
          height: item.height,
          processId: item.processId,
          layer: item.layer,
          totalLayer: item.totalLayer,
          orderSort: item.order_number,
          markIcon: item.markIcon,
          quantity: item.quantity,
          patchState: item.patchState,
          upGrind: item.upGrind,
          downGrind: item.downGrind,
          leftGrind: item.leftGrind,
          rightGrind:item.rightGrind,
          heatLayoutId:item.heatLayoutId,
          process:item.process,
          orderNo:item.orderNo,
          customerName:item.customerName,
          processingNote:item.processingNote,
          projectName:item.projectName,
          productName:item.productName,
          buildingNumber:item.buildingNumber,
          rackNo: rackNoValue
        };
      });
      // 更新 optimizeData 中的 glassDetails
      optimizeData.value.glassDetails = glassDetailData;
      // 打开优化对话框
      dialogVisible.value[4] = true;
      console.log('获取到的 glassDetail 数据:', glassDetailData);
    } else {
      ElMessage.error('获取玻璃详情数据失败');
    }
  } catch (error) {
    console.error('获取 glassDetail 数据出错:', error);
    ElMessage.error('获取玻璃详情数据时发生错误');
  }
};
@@ -704,34 +627,51 @@
  localStorage.setItem('projectNo', projectNo.value);
});
const saveOptimizeData = () => {
  if(orderInfo.optimizeData!==null){
    if(quantitys.value===orderInfo.optimizeData.optimalResults.glassTotalQuantity){
      console.log("保存数据1",orderInfo.optimizeData)
      request.post(`/glassOptimize/saveOptimizeData/${projectNo.value}`,orderInfo.optimizeData).then((res) => {
        if ((Number(res.code) === 200)) {
          ElMessage.success("保存成功");
        } else {
          ElMessage.warning(res.msg);
        }
const saveOptimizeData = async () => {
  try {
    // 先从后端查询工程状态
    const stateRes = await request.post(`/glassOptimize/getProjectState/${projectNo.value}`);
    if (Number(stateRes.code) === 200) {
      const projectData = stateRes.data.data;
      }).catch((error) => {
        console.error("获取数据出错:", error);
      });
    }else{
      ElMessage.warning("原片不足,小片未全部优化");
      // 检查 optimize_state 状态
      if (projectData.optimize_state === 1) {
        // 如果已完成优化,提示用户并阻止继续执行
        ElMessage.warning('已完成优化保存,不允许重复提交');
        return;
      }
    } else {
      ElMessage.warning(stateRes.msg);
      return;
    }
  }else {
    ElMessage.warning("数据未优化");
    if(orderInfo.optimizeData!==null){
      if(quantitys.value===orderInfo.optimizeData.optimalResults.glassTotalQuantity){
        console.log("保存数据1",orderInfo.optimizeData)
        request.post(`/glassOptimize/saveOptimizeData/${projectNo.value}`,orderInfo.optimizeData).then((res) => {
          if ((Number(res.code) === 200)) {
            ElMessage.success("保存成功");
          } else {
            ElMessage.warning(res.msg);
          }
        }).catch((error) => {
          console.error("获取数据出错:", error);
        });
      }else{
        ElMessage.warning("原片不足,小片未全部优化");
      }
    }else {
      ElMessage.warning("数据未优化");
    }
  } catch (error) {
    ElMessage.error('检查工程状态失败,请稍后重试');
    console.error('检查工程状态失败:', error);
  }
}
const fetchData = () => {
  //启用表格拖动选中
  addListener(xGrid.value,gridOptions,cellArea.value)
  request.post(`/glassOptimize/projectInfo/${projectNo.value}/${username}`).then((res) => {
  request.post(`/glassOptimize/optimizeInfo/${projectNo.value}/${username}`).then((res) => {
    if ((Number(res.code) === 200)) {
      let data = res.data.data;
      const grindingTrimming = res.data.grindingTrimming;