From b47614e17a20c17279eb2192329dfae559dc4a74 Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期三, 23 九月 2026 15:20:03 +0800
Subject: [PATCH] feat: 销售台账品名/材质/规格型号手工录入与材质列,回退采购台账相关改动

---
 src/views/salesManagement/salesLedger/index.vue |  152 ++++++++------------------------------------------
 1 files changed, 26 insertions(+), 126 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index d2e82b5..211937f 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -92,6 +92,7 @@
             >
               <el-table-column align="center" label="搴忓彿" type="index" />
               <el-table-column label="浜у搧澶х被" prop="productCategory" />
+              <el-table-column label="鏉愯川" prop="material" />
               <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
               <el-table-column label="鍗曚綅" prop="unit" />
               <el-table-column label="浜у搧鐘舵��" width="100px" align="center">
@@ -521,6 +522,7 @@
             width="60"
           />
           <el-table-column label="浜у搧澶х被" prop="productCategory" />
+          <el-table-column label="鏉愯川" prop="material" />
           <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
           <el-table-column label="鍗曚綅" prop="unit" />
           <el-table-column label="鏁伴噺" prop="quantity" />
@@ -705,38 +707,34 @@
       >
         <el-row :gutter="30">
           <el-col :span="24">
-            <el-form-item label="浜у搧澶х被锛�" prop="productCategory">
-              <el-tree-select
+            <el-form-item label="鍝佸悕锛�" prop="productCategory">
+              <el-input
                 v-model="productForm.productCategory"
-                placeholder="璇烽�夋嫨"
+                placeholder="璇疯緭鍏�"
                 clearable
-                filterable
-                check-strictly
-                @change="getModels"
-                :data="productOptions"
-                :render-after-expand="false"
-                style="width: 100%"
               />
             </el-form-item>
           </el-col>
         </el-row>
         <el-row :gutter="30">
           <el-col :span="24">
-            <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
-              <el-select
-                v-model="productForm.productModelId"
-                placeholder="璇烽�夋嫨"
+            <el-form-item label="鏉愯川锛�" prop="material">
+              <el-input
+                v-model="productForm.material"
+                placeholder="璇疯緭鍏�"
                 clearable
-                @change="getProductModel"
-                filterable
-              >
-                <el-option
-                  v-for="item in modelOptions"
-                  :key="item.id"
-                  :label="item.model"
-                  :value="item.id"
-                />
-              </el-select>
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="30">
+          <el-col :span="24">
+            <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="specificationModel">
+              <el-input
+                v-model="productForm.specificationModel"
+                placeholder="璇疯緭鍏�"
+                clearable
+              />
             </el-form-item>
           </el-col>
         </el-row>
@@ -1192,7 +1190,6 @@
   getProductInventory,
 } from "@/api/salesManagement/salesLedger.js";
 import { getStockInventoryByModelId } from "@/api/inventoryManagement/stockInventory.js";
-import { modelList, productTreeList } from "@/api/basicData/product.js";
 import useFormData from "@/hooks/useFormData.js";
 import dayjs from "dayjs";
 import FileUpload from "@/components/AttachmentUpload/file/index.vue";
@@ -1215,8 +1212,6 @@
 const productSelectedRows = ref([]);
 const userList = ref([]);
 const customerOption = ref([]);
-const productOptions = ref([]);
-const modelOptions = ref([]);
 const tableLoading = ref(false);
 const page = reactive({
   current: 1,
@@ -1269,6 +1264,7 @@
 const productFormData = reactive({
   productForm: {
     productCategory: "",
+    material: "",
     specificationModel: "",
     unit: "",
     quantity: "",
@@ -1280,10 +1276,10 @@
     isProduction: false,
   },
   productRules: {
-    productCategory: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
-    productModelId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+    productCategory: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    material: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
     specificationModel: [
-      { required: true, message: "璇烽�夋嫨", trigger: "change" },
+      { required: true, message: "璇疯緭鍏�", trigger: "blur" },
     ],
     unit: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
     quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
@@ -1532,14 +1528,6 @@
       tableLoading.value = false;
     });
 };
-// 鑾峰彇浜у搧澶х被tree鏁版嵁
-const getProductOptions = () => {
-  // 杩斿洖 Promise锛屼究浜庡湪缂栬緫浜у搧鏃剁瓑寰呭姞杞藉畬鎴�
-  return productTreeList().then((res) => {
-    productOptions.value = convertIdToValue(res);
-    return productOptions.value;
-  });
-};
 const formattedNumber = (row, column, cellValue) => {
   if (cellValue === undefined || cellValue === null || cellValue === "") {
     return "0.00";
@@ -1599,67 +1587,6 @@
   }
   return formattedNumber(row, column, cellValue);
 };
-// 鑾峰彇tree瀛愭暟鎹�
-const getModels = (value) => {
-  productForm.value.productCategory = findNodeById(productOptions.value, value);
-  modelList({ id: value }).then((res) => {
-    modelOptions.value = res;
-  });
-};
-const getProductModel = (value) => {
-  const index = modelOptions.value.findIndex((item) => item.id === value);
-  if (index !== -1) {
-    productForm.value.specificationModel = modelOptions.value[index].model;
-    productForm.value.unit = modelOptions.value[index].unit;
-  } else {
-    productForm.value.specificationModel = null;
-    productForm.value.unit = null;
-  }
-};
-const findNodeById = (nodes, productId) => {
-  for (let i = 0; i < nodes.length; i++) {
-    if (nodes[i].value === productId) {
-      return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣
-    }
-    if (nodes[i].children && nodes[i].children.length > 0) {
-      const foundNode = findNodeById(nodes[i].children, productId);
-      if (foundNode) {
-        return foundNode; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐�
-      }
-    }
-  }
-  return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
-};
-
-function convertIdToValue(data) {
-  return data.map((item) => {
-    const { id, children, ...rest } = item;
-    const newItem = {
-      ...rest,
-      value: id, // 灏� id 鏀逛负 value
-    };
-    if (children && children.length > 0) {
-      newItem.children = convertIdToValue(children);
-    }
-
-    return newItem;
-  });
-}
-
-// 鏍规嵁鍚嶇О鍙嶆煡浜у搧澶х被 id锛屼究浜庝粎瀛樺悕绉版椂鐨勫弽鏄�
-function findNodeIdByLabel(nodes, label) {
-  if (!label) return null;
-  for (let i = 0; i < nodes.length; i++) {
-    const node = nodes[i];
-    if (node.label === label) return node.value;
-    if (node.children && node.children.length > 0) {
-      const found = findNodeIdByLabel(node.children, label);
-      if (found !== null && found !== undefined) return found;
-    }
-  }
-  return null;
-}
-
 // 琛ㄦ牸閫夋嫨鏁版嵁
 const handleSelectionChange = (selection) => {
   // 杩囨护鎺夊瓙鏁版嵁
@@ -1930,7 +1857,7 @@
 
 const productIndex = ref(0);
 // 鎵撳紑浜у搧寮规
-const openProductForm = async (type, row, index) => {
+const openProductForm = (type, row, index) => {
   // 缂栬緫鏃舵鏌ヤ骇鍝佹槸鍚﹀凡鍙戣揣鎴栧鏍搁�氳繃
   if (type === "edit" && isProductShipped(row)) {
     proxy.$modal.msgWarning("宸插彂璐ф垨瀹℃牳閫氳繃鐨勪骇鍝佷笉鑳界紪杈�");
@@ -1946,33 +1873,6 @@
   if (type === "edit") {
     productForm.value = { ...row };
     productIndex.value = index;
-    // 缂栬緫鏃舵牴鎹骇鍝佸ぇ绫诲悕绉板弽鏌� tree 鑺傜偣 id锛屽苟鍔犺浇瑙勬牸鍨嬪彿鍒楄〃
-    try {
-      const options =
-        productOptions.value && productOptions.value.length > 0
-          ? productOptions.value
-          : await getProductOptions();
-      const categoryId = findNodeIdByLabel(
-        options,
-        productForm.value.productCategory
-      );
-      if (categoryId) {
-        const models = await modelList({ id: categoryId });
-        modelOptions.value = models || [];
-        // 鏍规嵁褰撳墠瑙勬牸鍨嬪彿鍚嶇О鍙嶆煡骞惰缃� productModelId锛屼究浜庝笅鎷夋鏄剧ず宸查�夊��
-        const currentModel = (modelOptions.value || []).find(
-          (m) => m.model === productForm.value.specificationModel
-        );
-        if (currentModel) {
-          productForm.value.productModelId = currentModel.id;
-        }
-      }
-    } catch (e) {
-      // 鍔犺浇澶辫触鏃朵繚鎸佸彲缂栬緫锛屼笉涓柇寮圭獥
-      console.error("鍔犺浇浜у搧瑙勬牸鍨嬪彿澶辫触", e);
-    }
-  } else {
-    getProductOptions();
   }
   productFormVisible.value = true;
 };

--
Gitblit v1.9.3