From 6fe8cfb3cc0d40d92c1107879771678bf94ef570 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 16 四月 2026 16:32:00 +0800
Subject: [PATCH] Merge branch 'dev_河南_鹤壁天沐玻璃厂' of http://114.132.189.42:9002/r/product-inventory-management into dev_河南_鹤壁天沐玻璃厂

---
 src/views/basicData/product/index.vue |  980 ++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 581 insertions(+), 399 deletions(-)

diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index cf83ff4..a74a294 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -2,63 +2,57 @@
   <div class="app-container product-view">
     <div class="left">
       <div>
-        <el-input
-          v-model="search"
-          style="width: 210px"
-          placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�"
-          @change="searchFilter"
-          @clear="searchFilter"
-          clearable
-          prefix-icon="Search"
-        />
-        <el-button
-          type="primary"
-          @click="openProDia('addOne')"
-          style="margin-left: 10px"
-          >鏂板浜у搧澶х被</el-button
-        >
+        <el-input v-model="search"
+                  style="width: 210px"
+                  placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�"
+                  @input="searchFilter"
+                  @change="searchFilter"
+                  @clear="searchFilter"
+                  clearable
+                  prefix-icon="Search" />
+        <el-button type="primary"
+                   @click="openProDia('addOne')"
+                   style="margin-left: 10px">鏂板浜у搧澶х被</el-button>
       </div>
       <div ref="containerRef">
-        <el-tree
-          ref="tree"
-          v-loading="treeLoad"
-          :data="list"
-          @node-click="handleNodeClick"
-          :expand-on-click-node="false"
-          default-expand-all
-          :default-expanded-keys="expandedKeys"
-          :draggable="true"
-          :filter-node-method="filterNode"
-          :props="{ children: 'children', label: 'label' }"
-          highlight-current
-          node-key="id"
-          style="
-            height: calc(100vh - 190px);
-            overflow-y: scroll;
-            scrollbar-width: none;
-          "
-        >
+        <el-tree ref="tree"
+                 v-loading="treeLoad"
+                 :data="list"
+                 @node-click="handleNodeClick"
+                 :expand-on-click-node="false"
+                 :default-expanded-keys="expandedKeys"
+                 :filter-node-method="filterNode"
+                 :props="{ children: 'children', label: 'label' }"
+                 highlight-current
+                 node-key="id"
+                 class="product-tree-scroll"
+                 style="height: calc(100vh - 190px); overflow-y: auto">
           <template #default="{ node, data }">
             <div class="custom-tree-node">
-              <span>{{ node.label }}</span>
+              <span class="tree-node-content">
+                <el-icon class="orange-icon">
+                  <component :is="data.children && data.children.length > 0
+                  ? node.expanded ? 'FolderOpened' : 'Folder' : 'Tickets'" />
+                </el-icon>
+                <span class="tree-node-label">{{ data.label }}</span>
+              </span>
               <div>
-                <el-button
-                  type="primary"
-                  link
-                  @click="openProDia('edit', data)"
-                >
+                <el-button type="primary"
+                           link
+                           @click="openProDia('edit', data)">
                   缂栬緫
                 </el-button>
-                <el-button type="primary" link @click="openProDia('add', data)">
+                <el-button type="primary"
+                           link
+                           @click="openProDia('add', data)"
+                           :disabled="node.level >= 3">
                   娣诲姞浜у搧
                 </el-button>
-                <el-button
-                  v-if="!node.childNodes.length"
-                  style="margin-left: 4px"
-                  type="danger"
-                  link
-                  @click="remove(node, data)"
-                >
+                <el-button v-if="!node.childNodes.length"
+                           style="margin-left: 4px"
+                           type="danger"
+                           link
+                           @click="remove(node, data)">
                   鍒犻櫎
                 </el-button>
               </div>
@@ -68,98 +62,134 @@
       </div>
     </div>
     <div class="right">
-      <div style="margin-bottom: 10px" v-if="isShowButton">
-        <el-button type="primary" @click="openModelDia('add')">
+      <div style="margin-bottom: 10px"
+           v-if="isShowButton">
+        <el-button type="primary"
+                   @click="openModelDia('add')">
           鏂板瑙勬牸鍨嬪彿
         </el-button>
-        <ImportExcel @uploadSuccess="getModelList" />
-        <el-button
-          type="danger"
-          @click="handleDelete"
-          style="margin-left: 10px"
-          plain
-        >
+        <ImportExcel :product-id="currentId"
+                     @uploadSuccess="getModelList" />
+        <el-button type="danger"
+                   @click="handleDelete"
+                   style="margin-left: 10px"
+                   plain>
           鍒犻櫎
         </el-button>
       </div>
-      <PIMTable
-        rowKey="id"
-        :column="tableColumn"
-        :tableData="tableData"
-        :page="page"
-        :isSelection="true"
-        @selection-change="handleSelectionChange"
-        :tableLoading="tableLoading"
-        @pagination="pagination"
-      ></PIMTable>
+      <PIMTable rowKey="id"
+                :column="tableColumn"
+                :tableData="tableData"
+                :page="page"
+                :isSelection="true"
+                @selection-change="handleSelectionChange"
+                :tableLoading="tableLoading"
+                @pagination="pagination"></PIMTable>
     </div>
-    <el-dialog v-model="productDia" title="浜у搧" width="400px">
-      <el-form
-        :model="form"
-        label-width="140px"
-        label-position="top"
-        :rules="rules"
-        ref="formRef"
-      >
+    <el-dialog v-model="productDia"
+               title="浜у搧"
+               width="400px"
+               @keydown.enter.prevent>
+      <el-form :model="form"
+               label-width="140px"
+               label-position="top"
+               :rules="rules"
+               ref="formRef">
         <el-row :gutter="30">
           <el-col :span="24">
-            <el-form-item label="浜у搧鍚嶇О锛�" prop="productName">
-              <el-input
-                v-model="form.productName"
-                placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
-                clearable
-              />
+            <el-form-item label="浜у搧鍚嶇О锛�"
+                          prop="productName">
+              <el-input v-model="form.productName"
+                        placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
+                        maxlength="20"
+                        show-word-limit
+                        clearable
+                        @keydown.enter.prevent />
             </el-form-item>
           </el-col>
         </el-row>
       </el-form>
       <template #footer>
         <div class="dialog-footer">
-          <el-button type="primary" @click="submitForm">纭</el-button>
+          <el-button type="primary"
+                     @click="submitForm">纭</el-button>
           <el-button @click="closeProDia">鍙栨秷</el-button>
         </div>
       </template>
     </el-dialog>
-    <el-dialog
-      v-model="modelDia"
-      title="瑙勬牸鍨嬪彿"
-      width="400px"
-      @close="closeModelDia"
-    >
-      <el-form
-        :model="modelForm"
-        label-width="140px"
-        label-position="top"
-        :rules="modelRules"
-        ref="modelFormRef"
-      >
+    <el-dialog v-model="modelDia"
+               title="瑙勬牸鍨嬪彿"
+               width="400px"
+               @close="closeModelDia"
+               @keydown.enter.prevent>
+      <el-form :model="modelForm"
+               label-width="140px"
+               label-position="top"
+               :rules="modelRules"
+               ref="modelFormRef">
         <el-row>
           <el-col :span="24">
-            <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="model">
-              <el-input
-                v-model="modelForm.model"
-                placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
-                clearable
-              />
+            <el-form-item label="瑙勬牸鍨嬪彿锛�"
+                          prop="model">
+              <el-input v-model="modelForm.model"
+                        placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
+                        clearable
+                        @keydown.enter.prevent />
             </el-form-item>
           </el-col>
         </el-row>
         <el-row>
           <el-col :span="24">
-            <el-form-item label="鍗曚綅锛�" prop="unit">
-              <el-input
-                v-model="modelForm.unit"
-                placeholder="璇疯緭鍏ュ崟浣�"
-                clearable
-              />
+            <el-form-item label="鍘氬害锛�"
+                          prop="thickness">
+              <el-input v-model="modelForm.thickness"
+                        placeholder="璇疯緭鍏ュ帤搴�"
+                        clearable
+                        @keydown.enter.prevent
+                        @blur="modelForm.thickness = formatThicknessTo15(modelForm.thickness)" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="鍗曚綅锛�"
+                          prop="unit">
+              <el-input v-model="modelForm.unit"
+                        placeholder="璇疯緭鍏ュ崟浣�"
+                        clearable
+                        @keydown.enter.prevent />
             </el-form-item>
           </el-col>
         </el-row>
       </el-form>
       <template #footer>
         <div class="dialog-footer">
-          <el-button type="primary" @click="submitModelForm">纭</el-button>
+          <el-button type="primary"
+                     @click="submitModelForm">纭</el-button>
           <el-button @click="closeModelDia">鍙栨秷</el-button>
+        </div>
+      </template>
+    </el-dialog>
+    <!-- 浜岀淮鐮佸璇濇 -->
+    <el-dialog v-model="qrCodeDialog"
+               title="浜у搧浜岀淮鐮�"
+               width="400px">
+      <div class="qrcode-container">
+        <img v-if="qrCodeUrl"
+             :src="qrCodeUrl"
+             class="qrcode-image" />
+        <div v-else
+             class="loading">鐢熸垚涓�...</div>
+      </div>
+      <div style="text-align: center;">
+        {{ qrCodeName }}
+      </div>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="qrCodeDialog = false">鍏抽棴</el-button>
+          <el-button type="primary"
+                     @click="saveQrCodeAsImage"
+                     :disabled="!qrCodeUrl">淇濆瓨涓哄浘鐗�</el-button>
         </div>
       </template>
     </el-dialog>
@@ -167,313 +197,465 @@
 </template>
 
 <script setup>
-import { ref } from "vue";
-import { ElMessageBox } from "element-plus";
-import {
-  addOrEditProduct,
-  addOrEditProductModel,
-  delProduct,
-  delProductModel,
-  modelListPage,
-  productTreeList,
-} from "@/api/basicData/product.js";
-import ImportExcel from "./ImportExcel/index.vue";
+  import { ref, getCurrentInstance, toRefs, reactive } from "vue";
+  import { ElMessageBox } from "element-plus";
+  import QRCode from "qrcode";
+  import { saveAs } from "file-saver";
+  import {
+    addOrEditProduct,
+    addOrEditProductModel,
+    delProduct,
+    delProductModel,
+    modelListPage,
+    productTreeList,
+  } from "@/api/basicData/product.js";
+  import ImportExcel from "./ImportExcel/index.vue";
 
-const { proxy } = getCurrentInstance();
-const tree = ref(null);
-const containerRef = ref(null);
+  const { proxy } = getCurrentInstance();
+  const tree = ref(null);
+  const containerRef = ref(null);
 
-const productDia = ref(false);
-const modelDia = ref(false);
-const modelOperationType = ref("");
-const search = ref("");
-const currentId = ref("");
-const currentParentId = ref("");
-const operationType = ref("");
-const treeLoad = ref(false);
-const list = ref([]);
-const expandedKeys = ref([]);
-const tableColumn = ref([
-  {
-    label: "瑙勬牸鍨嬪彿",
-    prop: "model",
-  },
-  {
-    label: "鍗曚綅",
-    prop: "unit",
-  },
-  {
-    dataType: "action",
-    label: "鎿嶄綔",
-    align: "center",
-    operation: [
-      {
-        name: "缂栬緫",
-        type: "text",
-        clickFun: (row) => {
-          openModelDia("edit", row);
+  const productDia = ref(false);
+  const modelDia = ref(false);
+  const qrCodeDialog = ref(false);
+  const qrCodeUrl = ref("");
+  const currentProductId = ref("");
+  const modelOperationType = ref("");
+  const search = ref("");
+  const currentId = ref("");
+  const currentParentId = ref("");
+  const operationType = ref("");
+  const treeLoad = ref(false);
+  const list = ref([]);
+  const expandedKeys = ref([]);
+  const tableColumn = ref([
+    {
+      label: "瑙勬牸鍨嬪彿",
+      prop: "model",
+    },
+    {
+      label: "鍘氬害",
+      prop: "thickness",
+      // 鍒楄〃灞曠ず鏃剁粺涓�淇濈暀 15 浣嶅皬鏁�
+      formatData: val => formatThicknessTo15(val),
+    },
+    {
+      label: "鍗曚綅",
+      prop: "unit",
+    },
+    {
+      dataType: "action",
+      label: "鎿嶄綔",
+      align: "center",
+      operation: [
+        {
+          name: "缂栬緫",
+          type: "text",
+          clickFun: row => {
+            openModelDia("edit", row);
+          },
         },
-      },
-    ],
-  },
-]);
-const tableData = ref([]);
-const tableLoading = ref(false);
-const isShowButton = ref(false);
-const selectedRows = ref([]);
-const page = reactive({
-  current: 1,
-  size: 10,
-  total: 0,
-});
-const data = reactive({
-  form: {
-    productName: "",
-  },
-  rules: {
-    productName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-  },
-  modelForm: {
-    model: "",
-    unit: "",
-  },
-  modelRules: {
-    model: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-    unit: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-  },
-});
-const { form, rules, modelForm, modelRules } = toRefs(data);
-// 鏌ヨ浜у搧鏍�
-const getProductTreeList = () => {
-  treeLoad.value = true;
-  productTreeList()
-    .then((res) => {
-      list.value = res;
-      list.value.forEach((a) => {
-        expandedKeys.value.push(a.label);
-      });
-      treeLoad.value = false;
-    })
-    .catch((err) => {
-      treeLoad.value = false;
-    });
-};
-// 杩囨护浜у搧鏍�
-const searchFilter = () => {
-  proxy.$refs.tree.filter(search.value);
-};
-// 鎵撳紑浜у搧寮规
-const openProDia = (type, data) => {
-  operationType.value = type;
-  productDia.value = true;
-  form.value.productName = "";
-  if (type === "edit") {
-    form.value.productName = data.productName;
-  }
-};
-// 鎵撳紑瑙勬牸鍨嬪彿寮规
-const openModelDia = (type, data) => {
-  modelOperationType.value = type;
-  modelDia.value = true;
-  modelForm.value.model = "";
-  modelForm.value.model = "";
-  modelForm.value.id = "";
-  if (type === "edit") {
-    modelForm.value = { ...data };
-  }
-};
-// 鎻愪氦浜у搧鍚嶇О淇敼
-const submitForm = () => {
-  proxy.$refs.formRef.validate((valid) => {
-    if (valid) {
-      if (operationType.value === "add") {
-        form.value.parentId = currentId.value;
-        form.value.id = "";
-      } else if (operationType.value === "addOne") {
-        form.value.id = "";
-        form.value.parentId = "";
-      } else {
-        form.value.id = currentId.value;
-        form.value.parentId = "";
-      }
-      addOrEditProduct(form.value).then((res) => {
-        proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
-        closeProDia();
-        getProductTreeList();
-      });
-    }
+        {
+          name: "鐢熸垚浜岀淮鐮�",
+          type: "text",
+          clickFun: row => {
+            generateQrcode(row);
+          },
+        },
+      ],
+    },
+  ]);
+  const tableData = ref([]);
+  const tableLoading = ref(false);
+  const isShowButton = ref(false);
+  const selectedRows = ref([]);
+  const page = reactive({
+    current: 1,
+    size: 10,
+    total: 0,
   });
-};
-// 鍏抽棴浜у搧寮规
-const closeProDia = () => {
-  proxy.$refs.formRef.resetFields();
-  productDia.value = false;
-};
-// 鍒犻櫎浜у搧
-const remove = (node, data) => {
-  let ids = [];
-  ids.push(data.id);
-  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
-    confirmButtonText: "纭",
-    cancelButtonText: "鍙栨秷",
-    type: "warning",
-  })
-    .then(() => {
-      tableLoading.value = true;
-      delProduct(ids)
-        .then((res) => {
-          proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+  const data = reactive({
+    form: {
+      productName: "",
+    },
+    rules: {
+      productName: [
+        { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+        { max: 20, message: "浜у搧鍚嶇О涓嶈兘瓒呰繃20涓瓧绗�", trigger: "blur" },
+      ],
+    },
+    modelForm: {
+      model: "",
+      thickness: "",
+    },
+    modelRules: {
+      model: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+      thickness: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+    },
+  });
+  const { form, rules, modelForm, modelRules } = toRefs(data);
+
+  // 鎶婂帤搴︽牸寮忓寲鎴愬浐瀹� 15 浣嶅皬鏁帮紙鐢ㄤ簬灞曠ず/鎻愪氦锛�
+  const formatThicknessTo15 = val => {
+    if (val === null || val === undefined) return "";
+    const s = String(val).trim();
+    if (s === "") return "";
+    const n = Number(s);
+    if (Number.isNaN(n)) return s;
+    return n.toFixed(15);
+  };
+  // 鏌ヨ浜у搧鏍�
+  const getProductTreeList = () => {
+    treeLoad.value = true;
+    productTreeList()
+      .then(res => {
+        list.value = res;
+        list.value.forEach(a => {
+          expandedKeys.value.push(a.label);
+        });
+        treeLoad.value = false;
+      })
+      .catch(err => {
+        treeLoad.value = false;
+      });
+  };
+  // 杩囨护浜у搧鏍�
+  const searchFilter = () => {
+    proxy.$refs.tree.filter(search.value);
+  };
+  // 鎵撳紑浜у搧寮规
+  const openProDia = (type, data) => {
+    operationType.value = type;
+    productDia.value = true;
+    form.value.productName = "";
+    if (type === "edit") {
+      form.value.productName = data.productName;
+    }
+  };
+  // 鎵撳紑瑙勬牸鍨嬪彿寮规
+  const openModelDia = (type, data) => {
+    modelOperationType.value = type;
+    modelDia.value = true;
+    modelForm.value.model = "";
+    modelForm.value.id = "";
+    modelForm.value.thickness = "";
+    if (type === "edit") {
+      modelForm.value = { ...data };
+    }
+  };
+  // 鎻愪氦浜у搧鍚嶇О淇敼
+  const submitForm = () => {
+    proxy.$refs.formRef.validate(valid => {
+      if (valid) {
+        if (operationType.value === "add") {
+          form.value.parentId = currentId.value;
+          form.value.id = "";
+        } else if (operationType.value === "addOne") {
+          form.value.id = "";
+          form.value.parentId = "";
+        } else {
+          form.value.id = currentId.value;
+          form.value.parentId = "";
+        }
+        addOrEditProduct(form.value).then(res => {
+          proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+          closeProDia();
           getProductTreeList();
-        })
-        .finally(() => {
-          tableLoading.value = false;
         });
-    })
-    .catch(() => {
-      proxy.$modal.msg("宸插彇娑�");
+      }
     });
-};
-// 閫夋嫨浜у搧
-const handleNodeClick = (val, node, el) => {
-  // 鍒ゆ柇鏄惁涓哄彾瀛愯妭鐐�
-  isShowButton.value = !(val.children && val.children.length > 0);
-  // 鍙湁鍙跺瓙鑺傜偣鎵嶆墽琛屼互涓嬮�昏緫
-  currentId.value = val.id;
-  currentParentId.value = val.parentId;
-  getModelList();
-};
+  };
+  // 鍏抽棴浜у搧寮规
+  const closeProDia = () => {
+    proxy.$refs.formRef.resetFields();
+    productDia.value = false;
+  };
 
-// 鎻愪氦瑙勬牸鍨嬪彿淇敼
-const submitModelForm = () => {
-  proxy.$refs.modelFormRef.validate((valid) => {
-    if (valid) {
-      modelForm.value.productId = currentId.value;
-      addOrEditProductModel(modelForm.value).then((res) => {
-        proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
-        closeModelDia();
-        getModelList();
+  // 鍒犻櫎浜у搧
+  const remove = (node, data) => {
+    let ids = [];
+    ids.push(data.id);
+    ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
+      confirmButtonText: "纭",
+      cancelButtonText: "鍙栨秷",
+      type: "warning",
+    })
+      .then(() => {
+        tableLoading.value = true;
+        delProduct(ids)
+          .then(res => {
+            proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+            getProductTreeList();
+          })
+          .finally(() => {
+            tableLoading.value = false;
+          });
+      })
+      .catch(() => {
+        proxy.$modal.msg("宸插彇娑�");
       });
-    }
-  });
-};
-// 鍏抽棴鍨嬪彿寮规
-const closeModelDia = () => {
-  proxy.$refs.modelFormRef.resetFields();
-  modelDia.value = false;
-};
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
-  selectedRows.value = selection;
-};
+  };
+  const fatherName = ref("");
+  // 閫夋嫨浜у搧
+  const handleNodeClick = (val, node, el) => {
+    // 鍒ゆ柇鏄惁涓哄彾瀛愯妭鐐�
+    isShowButton.value = !(val.children && val.children.length > 0);
+    // 鍙湁鍙跺瓙鑺傜偣鎵嶆墽琛屼互涓嬮�昏緫
+    currentId.value = val.id;
+    currentParentId.value = val.parentId;
+    fatherName.value = val.label;
+    getModelList();
+  };
 
-// 鏌ヨ瑙勬牸鍨嬪彿
-const pagination = (obj) => {
-  page.current = obj.page;
-  page.size = obj.limit;
-  getModelList();
-};
-const getModelList = () => {
-  tableLoading.value = true;
-  modelListPage({
-    id: currentId.value,
-    current: page.current,
-    size: page.size,
-  }).then((res) => {
-    console.log("res", res);
-    tableData.value = res.records;
-    page.total = res.total;
-    tableLoading.value = false;
-  });
-};
-// 鍒犻櫎瑙勬牸鍨嬪彿
-const handleDelete = () => {
-  let ids = [];
-  if (selectedRows.value.length > 0) {
-    ids = selectedRows.value.map((item) => item.id);
-  } else {
-    proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
-    return;
-  }
-  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
-    confirmButtonText: "纭",
-    cancelButtonText: "鍙栨秷",
-    type: "warning",
-  })
-    .then(() => {
-      tableLoading.value = true;
-      delProductModel(ids)
-        .then((res) => {
-          proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+  // 鎻愪氦瑙勬牸鍨嬪彿淇敼
+  const submitModelForm = () => {
+    proxy.$refs.modelFormRef.validate(valid => {
+      if (valid) {
+        modelForm.value.productId = currentId.value;
+        modelForm.value.thickness = formatThicknessTo15(
+          modelForm.value.thickness
+        );
+        addOrEditProductModel(modelForm.value).then(res => {
+          proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+          closeModelDia();
           getModelList();
-        })
-        .finally(() => {
-          tableLoading.value = false;
         });
-    })
-    .catch(() => {
-      proxy.$modal.msg("宸插彇娑�");
+      }
     });
-};
-// 璋冪敤tree杩囨护鏂规硶 涓枃鑻辫繃婊�
-const filterNode = (value, data, node) => {
-  if (!value) {
-    //濡傛灉鏁版嵁涓虹┖锛屽垯杩斿洖true,鏄剧ず鎵�鏈夌殑鏁版嵁椤�
-    return true;
-  }
-  // 鏌ヨ鍒楄〃鏄惁鏈夊尮閰嶆暟鎹紝灏嗗�煎皬鍐欙紝鍖归厤鑻辨枃鏁版嵁
-  let val = value.toLowerCase();
-  return chooseNode(val, data, node); // 璋冪敤杩囨护浜屽眰鏂规硶
-};
-// 杩囨护鐖惰妭鐐� / 瀛愯妭鐐� (濡傛灉杈撳叆鐨勫弬鏁版槸鐖惰妭鐐逛笖鑳藉尮閰嶏紝鍒欒繑鍥炶鑺傜偣浠ュ強鍏朵笅鐨勬墍鏈夊瓙鑺傜偣锛涘鏋滃弬鏁版槸瀛愯妭鐐癸紝鍒欒繑鍥炶鑺傜偣鐨勭埗鑺傜偣銆俷ame鏄腑鏂囧瓧绗︼紝enName鏄嫳鏂囧瓧绗�.
-const chooseNode = (value, data, node) => {
-  if (data.label.indexOf(value) !== -1) {
-    return true;
-  }
-  const level = node.level;
-  // 濡傛灉浼犲叆鐨勮妭鐐规湰韬氨鏄竴绾ц妭鐐瑰氨涓嶇敤鏍¢獙浜�
-  if (level === 1) {
-    return false;
-  }
-  // 鍏堝彇褰撳墠鑺傜偣鐨勭埗鑺傜偣
-  let parentData = node.parent;
-  // 閬嶅巻褰撳墠鑺傜偣鐨勭埗鑺傜偣
-  let index = 0;
-  while (index < level - 1) {
-    // 濡傛灉鍖归厤鍒扮洿鎺ヨ繑鍥烇紝姝ゅname鍊兼槸涓枃瀛楃锛宔nName鏄嫳鏂囧瓧绗︺�傚垽鏂尮閰嶄腑鑻辨枃杩囨护
-    if (parentData.data.label.indexOf(value) !== -1) {
+  };
+  // 鍏抽棴鍨嬪彿寮规
+  const closeModelDia = () => {
+    proxy.$refs.modelFormRef.resetFields();
+    modelDia.value = false;
+  };
+  // 琛ㄦ牸閫夋嫨鏁版嵁
+  const handleSelectionChange = selection => {
+    selectedRows.value = selection;
+  };
+
+  // 鏌ヨ瑙勬牸鍨嬪彿
+  const pagination = obj => {
+    page.current = obj.page;
+    page.size = obj.limit;
+    getModelList();
+  };
+  const getModelList = () => {
+    tableLoading.value = true;
+    modelListPage({
+      id: currentId.value,
+      current: page.current,
+      size: page.size,
+    }).then(res => {
+      console.log("res", res);
+      tableData.value = res.records;
+      page.total = res.total;
+      tableLoading.value = false;
+    });
+  };
+  // 鍒犻櫎瑙勬牸鍨嬪彿
+  const handleDelete = () => {
+    let ids = [];
+    if (selectedRows.value.length > 0) {
+      ids = selectedRows.value.map(item => item.id);
+    } else {
+      proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+      return;
+    }
+    ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
+      confirmButtonText: "纭",
+      cancelButtonText: "鍙栨秷",
+      type: "warning",
+    })
+      .then(() => {
+        tableLoading.value = true;
+        delProductModel(ids)
+          .then(res => {
+            proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+            getModelList();
+          })
+          .finally(() => {
+            tableLoading.value = false;
+          });
+      })
+      .catch(() => {
+        proxy.$modal.msg("宸插彇娑�");
+      });
+  };
+  // 璋冪敤tree杩囨护鏂规硶 涓枃鑻辫繃婊�
+  const filterNode = (value, data, node) => {
+    if (!value) {
+      //濡傛灉鏁版嵁涓虹┖锛屽垯杩斿洖true,鏄剧ず鎵�鏈夌殑鏁版嵁椤�
       return true;
     }
-    // 鍚﹀垯鐨勮瘽鍐嶅線涓婁竴灞傚仛鍖归厤
-    parentData = parentData.parent;
-    index++;
-  }
-  // 娌″尮閰嶅埌杩斿洖false
-  return false;
-};
-getProductTreeList();
+    // 鍏抽敭瀛椾笌鑺傜偣 label 鍧囨寜灏忓啓姣旇緝锛岃嫳鏂囨ā绯婂尮閰嶄笉鍖哄垎澶у皬鍐欙紙濡� LOW / low 鍙尮閰� Low-E锛�
+    const val = String(value).trim().toLowerCase();
+    if (!val) return true;
+    return chooseNode(val, data, node); // 璋冪敤杩囨护浜屽眰鏂规硶
+  };
+  // 杩囨护鐖惰妭鐐� / 瀛愯妭鐐� (濡傛灉杈撳叆鐨勫弬鏁版槸鐖惰妭鐐逛笖鑳藉尮閰嶏紝鍒欒繑鍥炶鑺傜偣浠ュ強鍏朵笅鐨勬墍鏈夊瓙鑺傜偣锛涘鏋滃弬鏁版槸瀛愯妭鐐癸紝鍒欒繑鍥炶鑺傜偣鐨勭埗鑺傜偣銆俷ame鏄腑鏂囧瓧绗︼紝enName鏄嫳鏂囧瓧绗�.
+  const chooseNode = (value, data, node) => {
+    const labelLower = String(data.label ?? "").toLowerCase();
+    if (labelLower.indexOf(value) !== -1) {
+      return true;
+    }
+    const level = node.level;
+    // 濡傛灉浼犲叆鐨勮妭鐐规湰韬氨鏄竴绾ц妭鐐瑰氨涓嶇敤鏍¢獙浜�
+    if (level === 1) {
+      return false;
+    }
+    // 鍏堝彇褰撳墠鑺傜偣鐨勭埗鑺傜偣
+    let parentData = node.parent;
+    // 閬嶅巻褰撳墠鑺傜偣鐨勭埗鑺傜偣
+    let index = 0;
+    while (index < level - 1) {
+      // 濡傛灉鍖归厤鍒扮洿鎺ヨ繑鍥烇紱涓� filterNode 涓�鑷达紝鏍囩涓庡叧閿瓧鍧囨寜灏忓啓姣旇緝锛岃嫳鏂囨ā绯婂尮閰嶄笉鍖哄垎澶у皬鍐�
+      const parentLabelLower = String(parentData.data.label ?? "").toLowerCase();
+      if (parentLabelLower.indexOf(value) !== -1) {
+        return true;
+      }
+      // 鍚﹀垯鐨勮瘽鍐嶅線涓婁竴灞傚仛鍖归厤
+      parentData = parentData.parent;
+      index++;
+    }
+    // 娌″尮閰嶅埌杩斿洖false
+    return false;
+  };
+  const qrCodeName = ref("");
+
+  // 鐢熸垚浜岀淮鐮�
+  const generateQrcode = async row => {
+    try {
+      currentProductId.value = row.id;
+      qrCodeName.value = fatherName.value + "-" + row.model;
+      // 浣跨敤row.id鐢熸垚浜岀淮鐮�
+      const qrCodeData = row.id.toString();
+      // 鐢熸垚浜岀淮鐮乁RL
+      qrCodeUrl.value = await QRCode.toDataURL(qrCodeData, {
+        width: 300,
+        margin: 1,
+      });
+      // 鎵撳紑浜岀淮鐮佸璇濇
+      qrCodeDialog.value = true;
+    } catch (error) {
+      console.error("鐢熸垚浜岀淮鐮佸け璐�:", error);
+      proxy.$modal.msgError("鐢熸垚浜岀淮鐮佸け璐�");
+    }
+  };
+
+  // 淇濆瓨浜岀淮鐮佷负鍥剧墖
+  const saveQrCodeAsImage = () => {
+    if (!qrCodeUrl.value) return;
+
+    try {
+      // 浠嶥ata URL鍒涘缓Blob
+      const blob = dataURLToBlob(qrCodeUrl.value);
+      // 浣跨敤file-saver淇濆瓨鍥剧墖
+      saveAs(blob, `${qrCodeName.value}.png`);
+      proxy.$modal.msgSuccess("淇濆瓨鎴愬姛");
+    } catch (error) {
+      console.error("淇濆瓨鍥剧墖澶辫触:", error);
+      proxy.$modal.msgError("淇濆瓨鍥剧墖澶辫触");
+    }
+  };
+
+  // 灏咲ata URL杞崲涓築lob
+  const dataURLToBlob = dataURL => {
+    const arr = dataURL.split(",");
+    const mime = arr[0].match(/:(.*?);/)[1];
+    const bstr = atob(arr[1]);
+    let n = bstr.length;
+    const u8arr = new Uint8Array(n);
+    while (n--) {
+      u8arr[n] = bstr.charCodeAt(n);
+    }
+    return new Blob([u8arr], { type: mime });
+  };
+
+  getProductTreeList();
 </script>
 
 <style scoped>
-.product-view {
-  display: flex;
-}
-.left {
-  width: 380px;
-  padding: 16px;
-  background: #ffffff;
-}
-.right {
-  width: calc(100% - 380px);
-  padding: 16px;
-  margin-left: 20px;
-  background: #ffffff;
-}
-.custom-tree-node {
-  flex: 1;
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
-  font-size: 14px;
-  padding-right: 8px;
-}
+  .product-view {
+    display: flex;
+  }
+  .left {
+    width: 450px;
+    min-width: 450px;
+    padding: 16px;
+    background: #ffffff;
+  }
+  .right {
+    flex: 1;
+    min-width: 0;
+    padding: 16px;
+    margin-left: 20px;
+    background: #ffffff;
+  }
+  .custom-tree-node {
+    flex: 1;
+    min-width: 0;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    font-size: 14px;
+    padding-right: 8px;
+  }
+  .tree-node-content {
+    flex: 1;
+    min-width: 0;
+    display: flex;
+    align-items: center;
+    height: 100%;
+    overflow: hidden;
+  }
+  .tree-node-content .orange-icon {
+    flex-shrink: 0;
+  }
+  .tree-node-label {
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+  }
+  .orange-icon {
+    color: orange;
+    font-size: 18px;
+    margin-right: 8px; /* 鍥炬爣涓庢枃瀛椾箣闂村姞鐐归棿璺� */
+  }
+  .product-tree-scroll {
+    scrollbar-width: thin;
+    scrollbar-color: #c0c4cc #f5f7fa;
+  }
+  .product-tree-scroll::-webkit-scrollbar {
+    width: 8px;
+  }
+  .product-tree-scroll::-webkit-scrollbar-track {
+    background: #f5f7fa;
+    border-radius: 4px;
+  }
+  .product-tree-scroll::-webkit-scrollbar-thumb {
+    background: #c0c4cc;
+    border-radius: 4px;
+  }
+  .product-tree-scroll::-webkit-scrollbar-thumb:hover {
+    background: #909399;
+  }
+
+  /* 浜岀淮鐮佹牱寮� */
+  .qrcode-container {
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    padding: 20px;
+    min-height: 300px;
+  }
+
+  .qrcode-image {
+    max-width: 100%;
+    height: auto;
+  }
+
+  .loading {
+    font-size: 16px;
+    color: #606266;
+  }
 </style>

--
Gitblit v1.9.3