From f99393ab00efa105eeef8dd87e65bbc5daba56e5 Mon Sep 17 00:00:00 2001
From: 于杰 <1210123631@qq.com>
Date: 星期一, 24 十一月 2025 15:58:08 +0800
Subject: [PATCH] 增加功能,工程信息界面可以临时添加小片数据并临时优化

---
 north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/ProjectDetail.vue |  126 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 117 insertions(+), 9 deletions(-)

diff --git a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/ProjectDetail.vue b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/ProjectDetail.vue
index 4e4b7d7..91edf89 100644
--- a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/page/ProjectDetail.vue
+++ b/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: '鍥惧舰鍙﹀瓨涓篋XF',},
           {code: 'exportOPTIMA', name: '瀵煎嚭鏁版嵁鍒癘PTIMA',},
-          {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銆乭eight銆乹uantity 璁剧疆涓烘暟鍊肩被鍨�
+      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') {
@@ -493,14 +602,14 @@
         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 +682,6 @@
       }
     }
 );
-
 // 鍗曠嫭澶勭悊閫変腑鍘熺墖鏁版嵁鐨勯�昏緫
 watch(
     () => props.CheckboxChangeData,

--
Gitblit v1.8.0