廖井涛
2025-12-01 21eed4f6a8065bb59d0aaf7481dfe145dba74f2a
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/ProjectDetail.vue
@@ -55,18 +55,21 @@
    {field: 'width',
      width: 100,
      title: t('order.width'),
      editRender: { name: 'input' },
      sortable: true
    },
    {
      field: 'height',
      width: 100,
      title: t('order.height'),
      editRender: { name: 'input' },
      sortable: true
    },
    {
      field: 'quantity',
      width: 150,
      title: t('order.quantity'),
      editRender: { name: 'input' },
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
@@ -212,15 +215,28 @@
    body: {
      options: [
        [
          {code: 'setAmount', name: '设置统一磨量',},
          {code: 'setAmount', name: '设置统一磨量',prefixIcon:'vxe-icon-edit'},
          {code: 'addRow', name: '添加临时小片', prefixIcon: 'vxe-icon-add', visible: true, disabled: false},
          {code: 'displayProcessCard', name: '显示流程卡',},
          {code: 'hideProcessCard', name: '隐藏流程卡',},
          {code: 'setShape', name: '设置图形',},
          {code: 'Export', name: '数据导出', prefixIcon: 'vxe-icon-download', visible: true, disabled: false},
          {code: 'safeDXF', name: '图形另存为DXF',},
          {code: 'exportOPTIMA', name: '导出数据到OPTIMA',},
          {code: 'copyChecked', name: t('basicData.selectSame'), prefixIcon: 'vxe-icon-copy', visible: true, disabled: false },
          {code: 'copyAll', name: t('basicData.sameAfterwards'), prefixIcon: 'vxe-icon-feedback', visible: true, disabled: false },
          {
            code: 'copyChecked',
            name: t('basicData.selectSame'),
            prefixIcon: 'vxe-icon-copy',
            visible: true,
            disabled: false
          },
          {
            code: 'copyAll',
            name: t('basicData.sameAfterwards'),
            prefixIcon: 'vxe-icon-feedback',
            visible: true,
            disabled: false
          },
        ],
        []
      ]
@@ -307,10 +323,89 @@
    }
  },
  {
    code: 'Export', // 导出文件操作的配置
    successMsg: '文件导出成功!',
    code: 'addRow',
    successMsg: '已添加',
    gridRef: xGrid,
    requiresRow: false,
    addNewRow: async () => {
      // 获取当前的磨量配置
      let currentGrindConfig = null;
      try {
        const res = await request.post(`/glassOptimize/getConfiguration/磨量/${username}`);
        if (res.code == "200" && res.data.data && res.data.data.length > 0) {
          const rawData = res.data.data[0];
          currentGrindConfig = {};
          for (const key in rawData) {
            if (typeof rawData[key] === 'string') {
              currentGrindConfig[key] = rawData[key].replace(/^\"|\"$/g, '');
            } else {
              currentGrindConfig[key] = rawData[key];
            }
          }
        }
      } catch (error) {
        console.warn('获取磨量配置失败:', error);
      }
      // 根据磨量配置设置默认值
      let defaultLongGrind1 = 0;
      let defaultLongGrind2 = 0;
      let defaultShortGrind1 = 0;
      let defaultShortGrind2 = 0;
      if (currentGrindConfig) {
        defaultLongGrind1 = parseFloat(currentGrindConfig.leftEdge) || 0;
        defaultLongGrind2 = parseFloat(currentGrindConfig.rightEdge) || 0;
        defaultShortGrind1 = parseFloat(currentGrindConfig.upEdge) || 0;
        defaultShortGrind2 = parseFloat(currentGrindConfig.downEdge) || 0;
      }
      // 创建新行数据,将 width、height、quantity 设置为数值类型
      const newRow = {
        order_number: 0,
        width: 0,
        height: 0,
        quantity: 0,
        longGrind1: defaultLongGrind1,
        longGrind2: defaultLongGrind2,
        shortGrind1: defaultShortGrind1,
        shortGrind2: defaultShortGrind2,
        shape: '',
        process_id: '',
        productName: '',
        price: 0,
        remark: '',
        buildingNumber: '',
        perimeter: 0,
        area: 0,
        rackNo: 1,
        layer: 1,
        glass_child: '',
        markIcon: '',
        processId: '',
        totalLayer: 0,
        patchState: 0,
        heatLayoutId: 0,
        process: '',
        orderNo: '',
        customerName: '',
        processingNote: '',
        projectName: ''
      };
      // 将新行添加到表格数据中
      const currentData = gridOptions.data || [];
      const updatedData = [...currentData, newRow];
      gridOptions.data = updatedData;
      xGrid.value.loadData(updatedData);
      // 获取新添加行的索引
      const newIndex = updatedData.length - 1;
      // 选中并编辑新行
      await nextTick();
      xGrid.value.setActiveRow(newRow);
    }
  },
  {
    code: 'safeDXF',
@@ -358,6 +453,20 @@
        if (config.code === 'Export') {
          config.gridRef.value.exportData();
          ElMessage.success(config.successMsg);
          return;
        }
        if (config.code === 'addRow') {
          // 添加确认提示弹窗,询问用户是否进行当前操作
          ElMessageBox.confirm('是否添加临时小片?', '确认操作', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            config.addNewRow();
            ElMessage.success(config.successMsg);
          }).catch(() => {
            ElMessage.info('已取消操作');
          });
          return;
        }
        if (config.code === 'copyChecked') {
@@ -487,20 +596,35 @@
    optimizeData.value.glassDetails = [];
    // 从表格中获取 glassDetail 数据,而不是从后端接口读取
    const tableData = xGrid.value.getTableData().fullData;
    let totalQuantity = 0;
    let totalArea = 0;
    tableData.forEach(item => {
      const width = parseFloat(item.width) || 0;
      const height = parseFloat(item.height) || 0;
      const quantity = parseInt(item.quantity) || 0;
      // 使用长×宽×数量来计算总面积
      totalArea += (width * height * quantity) / 1000000; // 转换为平方米
      totalQuantity += quantity;
    });
    quantitys.value = totalQuantity;
    areas.value = totalArea;
    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,
        width: parseFloat(item.width) || 0,
        height: parseFloat(item.height) || 0,
        processId: item.processId,
        layer: item.layer,
        totalLayer: item.totalLayer,
        orderSort: item.order_number,
        markIcon: item.markIcon,
        quantity: item.quantity,
        quantity: parseInt(item.quantity) || 0,
        patchState: item.patchState,
        upGrind: item.longGrind1,
        downGrind: item.longGrind2,
@@ -573,7 +697,6 @@
      }
    }
);
// 单独处理选中原片数据的逻辑
watch(
    () => props.CheckboxChangeData,
@@ -746,7 +869,7 @@
      xGrid.value.loadData(data);
      gridOptions.data = data;
      projectName.value = data[0].project_name;
      projectName.value = res.data.project.project_name;
      quantitys.value=res.data.project.glass_total
      areas.value=res.data.project.glass_total_area