From 0a3b748bd80bc33dc5b7eb8e90a7fb394e703b07 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 21 四月 2026 15:13:02 +0800
Subject: [PATCH] feat: 设备保养新增保养项目

---
 src/views/salesManagement/salesLedger/index.vue |  233 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 231 insertions(+), 2 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index e5ca3d6..c69c168 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -32,6 +32,20 @@
                     prefix-icon="Search"
                     @change="handleQuery" />
         </el-form-item>
+        <el-form-item label="浜у搧瀹�(mm)锛�">
+          <el-input v-model="searchForm.width"
+                    placeholder="璇疯緭鍏�"
+                    clearable
+                    prefix-icon="Search"
+                    @change="handleQuery" />
+        </el-form-item>
+        <el-form-item label="浜у搧楂�(mm)锛�">
+          <el-input v-model="searchForm.height"
+                    placeholder="璇疯緭鍏�"
+                    clearable
+                    prefix-icon="Search"
+                    @change="handleQuery" />
+        </el-form-item>
         <el-form-item label="褰曞叆鏃ユ湡锛�">
           <el-date-picker v-model="searchForm.entryDate"
                           value-format="YYYY-MM-DD"
@@ -319,6 +333,14 @@
                          width="220"
                          show-overflow-tooltip
                          :formatter="formattedNumber" />
+        <el-table-column label="闈㈢Н"
+                         prop="productTotalArea"
+                         width="120"
+                         show-overflow-tooltip />
+        <el-table-column label="鏁伴噺"
+                         prop="productTotalQuantity"
+                         width="120"
+                         show-overflow-tooltip />
         <el-table-column label="鍙戣揣鐘舵��"
                          width="140"
                          align="center">
@@ -415,6 +437,7 @@
                label-width="140px"
                label-position="top"
                :rules="rules"
+               @keydown.capture="handleTabScrollFollow"
                ref="formRef">
         <!-- 鎶ヤ环鍗曞鍏ュ叆鍙o細鏀惧湪琛ㄥ崟椤堕儴锛岄�夋嫨鍚庡弽鏄惧鎴�/涓氬姟鍛樼瓑 -->
         <el-row v-if="operationType === 'add'"
@@ -1652,6 +1675,46 @@
                title="閫夋嫨鍏ュ簱浜у搧"
                width="60%"
                :close-on-click-modal="false">
+      <div style="margin-bottom: 12px;">
+        <el-form>
+          <el-form-item required>
+            <template #label>
+              <div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">
+                <span>瀹℃壒浜洪�夋嫨锛�</span>
+                <el-button type="primary"
+                           size="small"
+                           @click="addStockApproverNode"
+                           icon="Plus">鏂板鑺傜偣</el-button>
+              </div>
+            </template>
+            <div class="approver-nodes-container">
+              <div v-for="(node, index) in stockApproverNodes"
+                   :key="node.id"
+                   class="approver-node-item">
+                <div class="approver-node-header">
+                  <span class="approver-node-label">瀹℃壒鑺傜偣 {{ index + 1 }}</span>
+                  <el-button v-if="stockApproverNodes.length > 1"
+                             type="danger"
+                             size="small"
+                             text
+                             @click="removeStockApproverNode(index)"
+                             icon="Delete">鍒犻櫎</el-button>
+                </div>
+                <el-select v-model="node.userId"
+                           placeholder="璇烽�夋嫨瀹℃壒浜�"
+                           filterable
+                           clearable
+                           style="width: 100%;">
+                  <el-option v-for="item in stockApproverOptions"
+                             :key="item.userId"
+                             :label="item.userName"
+                             :value="item.userId" />
+                </el-select>
+              </div>
+            </div>
+          </el-form-item>
+        </el-form>
+      </div>
       <el-table :data="stockProductList"
                 border
                 stripe
@@ -1792,6 +1855,15 @@
   const selectedStockProductIds = ref([]);
   const stockLoading = ref(false);
   const currentStockLedgerId = ref(null);
+  const stockApproverOptions = ref([]);
+  const stockApproverNodes = ref([{ id: 1, userId: null }]);
+  let nextStockApproverId = 2;
+  const addStockApproverNode = () => {
+    stockApproverNodes.value.push({ id: nextStockApproverId++, userId: null });
+  };
+  const removeStockApproverNode = index => {
+    stockApproverNodes.value.splice(index, 1);
+  };
 
   const ledgerQrDialogVisible = ref(false);
   const ledgerQrCompositeUrl = ref("");
@@ -1908,6 +1980,8 @@
       customerName: "", // 瀹㈡埛鍚嶇О
       customerId: "", // 瀹㈡埛ID锛堟煡璇笅鎷夛級
       salesContractNo: "", // 閿�鍞悎鍚岀紪鍙�
+      width: undefined, // 浜у搧瀹�(mm)
+      height: undefined, // 浜у搧楂�(mm)
       entryDate: null, // 褰曞叆鏃ユ湡
       entryDateStart: undefined,
       entryDateEnd: undefined,
@@ -2866,14 +2940,44 @@
         delete params.customerName;
       }
     }
+    const widthValue =
+      params.width != null ? String(params.width).trim() : "";
+    if (widthValue) {
+      params.width = widthValue;
+    } else {
+      delete params.width;
+    }
+    const heightValue =
+      params.height != null ? String(params.height).trim() : "";
+    if (heightValue) {
+      params.height = heightValue;
+    } else {
+      delete params.height;
+    }
+    const shouldAutoExpandBySize = Boolean(params.width || params.height);
     delete params.customerId;
     return ledgerListPage(params)
-      .then(res => {
+      .then(async res => {
         tableLoading.value = false;
         tableData.value = res.records;
         tableData.value.map(item => {
           item.children = [];
         });
+        if (shouldAutoExpandBySize && tableData.value.length > 0) {
+          const loadChildrenTasks = tableData.value.map(item =>
+            productList({ salesLedgerId: item.id, type: 1 })
+              .then(productRes => {
+                item.children = Array.isArray(productRes?.data)
+                  ? productRes.data
+                  : [];
+              })
+              .catch(() => {
+                item.children = [];
+              })
+          );
+          await Promise.all(loadChildrenTasks);
+          expandedRowKeys.value = tableData.value.map(item => item.id);
+        }
         total.value = res.total;
         return res;
       })
@@ -2902,22 +3006,36 @@
     currentStockLedgerId.value = id;
     selectedStockProductIds.value = [];
     stockProductList.value = [];
+    stockApproverNodes.value = [{ id: 1, userId: null }];
+    nextStockApproverId = 2;
     stockDialogVisible.value = true;
     stockLoading.value = true;
 
     try {
+      const approverRes = await approveUserList({ approveType: 9 });
+      stockApproverOptions.value = Array.isArray(approverRes?.data)
+        ? approverRes.data.map(item => ({
+            userId: item.userId,
+            userName: item.userName,
+          }))
+        : [];
       const res = await productList({ salesLedgerId: id, type: 1 });
       stockProductList.value = [];
       stockProductList.value =
         res.data.filter(item => item.productStockStatus == 0 || item.productStockStatus == 1) || [];
     } catch (e) {
-      proxy?.$modal?.msgError?.("鑾峰彇浜у搧鍒楄〃澶辫触");
+      proxy?.$modal?.msgError?.("鑾峰彇浜у搧鎴栧鎵逛汉澶辫触");
     } finally {
       stockLoading.value = false;
     }
   };
 
   const submitStock = async () => {
+    const hasEmptyApprover = stockApproverNodes.value.some(node => !node.userId);
+    if (hasEmptyApprover) {
+      ElMessage.warning("璇蜂负鎵�鏈夊鎵硅妭鐐归�夋嫨瀹℃壒浜�");
+      return;
+    }
     if (selectedStockProductIds.value.length === 0) {
       ElMessage.warning("璇烽�夋嫨鑷冲皯涓�涓骇鍝佽繘琛屽叆搴�");
       return;
@@ -2935,9 +3053,16 @@
 
     proxy?.$modal?.loading?.("姝e湪鍏ュ簱锛岃绋嶅��...");
     try {
+      const approveUserIds = stockApproverNodes.value.map(node => node.userId).join(",");
+      const approveUserName = stockApproverNodes.value
+        .map(node => stockApproverOptions.value.find(item => String(item.userId) === String(node.userId))?.userName)
+        .filter(Boolean)
+        .join(",");
       await salesStock({
         salesLedgerId: currentStockLedgerId.value,
         salesLedgerProducts: selectedStockProductIds.value,
+        approveUserIds,
+        approveUserName,
       });
       proxy?.$modal?.msgSuccess?.("鍏ュ簱鎴愬姛");
       stockDialogVisible.value = false;
@@ -3040,6 +3165,58 @@
     }
     const num = Number(cellValue);
     return Number.isFinite(num) ? num.toFixed(2) : "";
+  };
+
+  const scrollElementIntoVisibleArea = target => {
+    if (!target || !(target instanceof HTMLElement)) return;
+    let parent = target.parentElement;
+    while (parent && parent !== document.body) {
+      const style = window.getComputedStyle(parent);
+      const canScrollX =
+        (style.overflowX === "auto" ||
+          style.overflowX === "scroll" ||
+          style.overflowX === "overlay") &&
+        parent.scrollWidth > parent.clientWidth;
+      const canScrollY =
+        (style.overflowY === "auto" ||
+          style.overflowY === "scroll" ||
+          style.overflowY === "overlay") &&
+        parent.scrollHeight > parent.clientHeight;
+
+      if (canScrollX || canScrollY) {
+        const parentRect = parent.getBoundingClientRect();
+        const targetRect = target.getBoundingClientRect();
+        if (canScrollX) {
+          const targetCenterX = targetRect.left + targetRect.width / 2;
+          const parentCenterX = parentRect.left + parentRect.width / 2;
+          const deltaX = targetCenterX - parentCenterX;
+          if (Math.abs(deltaX) > 2) {
+            parent.scrollLeft += deltaX;
+          }
+        }
+
+        if (canScrollY) {
+          const targetCenterY = targetRect.top + targetRect.height / 2;
+          const parentCenterY = parentRect.top + parentRect.height / 2;
+          const deltaY = targetCenterY - parentCenterY;
+          if (Math.abs(deltaY) > 2) {
+            parent.scrollTop += deltaY;
+          }
+        }
+      }
+
+      parent = parent.parentElement;
+    }
+  };
+
+  const handleTabScrollFollow = e => {
+    if (!e || e.key !== "Tab") return;
+    requestAnimationFrame(() => {
+      const active = document.activeElement;
+      if (active instanceof HTMLElement) {
+        scrollElementIntoVisibleArea(active);
+      }
+    });
   };
   // 鑾峰彇tree瀛愭暟鎹�
   const getModels = value => {
@@ -3180,6 +3357,8 @@
   const summarizeMainTable = param => {
     return proxy.summarizeTable(param, [
       "contractAmount",
+      "productTotalQuantity",
+      "productTotalArea",
       "taxInclusiveTotalPrice",
       "taxExclusiveTotalPrice",
     ]);
@@ -4684,4 +4863,54 @@
   .ledger-qr-save-btn {
     margin-bottom: 12px;
   }
+
+  .approver-nodes-container {
+    display: flex;
+    flex-wrap: wrap;
+    gap: 16px;
+    padding: 16px;
+    background-color: #f8f9fa;
+    border-radius: 4px;
+    border: 1px solid #e4e7ed;
+  }
+
+  .approver-node-item {
+    flex: 0 0 calc(33.333% - 12px);
+    min-width: 200px;
+    padding: 12px;
+    background-color: #fff;
+    border-radius: 4px;
+    border: 1px solid #dcdfe6;
+    transition: all 0.3s;
+  }
+
+  .approver-node-item:hover {
+    border-color: #409eff;
+    box-shadow: 0 2px 8px rgba(64, 158, 255, 0.1);
+  }
+
+  .approver-node-header {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 8px;
+  }
+
+  .approver-node-label {
+    font-size: 13px;
+    font-weight: 500;
+    color: #606266;
+  }
+
+  @media (max-width: 1200px) {
+    .approver-node-item {
+      flex: 0 0 calc(50% - 8px);
+    }
+  }
+
+  @media (max-width: 768px) {
+    .approver-node-item {
+      flex: 0 0 100%;
+    }
+  }
 </style>

--
Gitblit v1.9.3