From 08e9a67dd679f311e79a27b04cd0c53a30b4bccf Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期四, 04 六月 2026 18:33:22 +0800
Subject: [PATCH] aaa

---
 company_admin/src/components/business/OperaGoodsWindow.vue |   37 +++++++++++++++++++++++++++++++------
 1 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/company_admin/src/components/business/OperaGoodsWindow.vue b/company_admin/src/components/business/OperaGoodsWindow.vue
index cd62c60..7ef2c34 100644
--- a/company_admin/src/components/business/OperaGoodsWindow.vue
+++ b/company_admin/src/components/business/OperaGoodsWindow.vue
@@ -21,10 +21,19 @@
           </el-select>
         </el-form-item>
         <el-form-item label="鍟嗗搧绫诲埆" prop="categoryId">
-          <!-- @change="changeCategory(form.categoryId)" -->
-          <el-select v-model="form.categoryId" filterable placeholder="璇烽�夋嫨锛屽崟閫�">
+          <el-select v-model="form.categoryId" filterable placeholder="璇烽�夋嫨涓�绾х被鍒�" @change="onCategoryChange">
             <el-option
               v-for="item in categoryList"
+              :key="item.id"
+              :label="item.name"
+              :value="item.id">
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="浜岀骇绫诲埆">
+          <el-select v-model="form.subCategoryId" clearable filterable placeholder="鍙�夛紝璇烽�夋嫨浜岀骇绫诲埆">
+            <el-option
+              v-for="item in subCategoryList"
               :key="item.id"
               :label="item.name"
               :value="item.id">
@@ -99,6 +108,7 @@
   import GlobalWindow from '@/components/common/GlobalWindow'
   import { brand } from '@/api/system/common.js'
   import { findListForGoodsId, create, updateById, companyCreate, companyUpdateById } from '@/api/business/goods.js'
+  import { fetchChildren } from '@/api/business/category.js'
   export default {
     name: 'OperaGoodsWindow',
     extends: BaseOpera,
@@ -113,6 +123,7 @@
           id: null,
           name: '',
           categoryId: '',
+          subCategoryId: '',
           brandId: '',
           zdPrice: '',
           price: '',
@@ -148,6 +159,7 @@
         },
         options: [],
         categoryList: [],
+        subCategoryList: [],
         brandList: []
       }
     },
@@ -328,18 +340,31 @@
               this.brandList = res
             })
         },
+        onCategoryChange (val) {
+          this.form.subCategoryId = ''
+          this.subCategoryList = []
+          if (val) {
+            fetchChildren(val).then(res => {
+              this.subCategoryList = res || []
+            })
+          }
+        },
         getcategory(type) {
           findListForGoodsId(this.form.id || '')
             .then(res => {
-              this.categoryList = res
+              this.categoryList = (res || []).filter(item => !item.parentId)
+              if (this.form.categoryId) {
+                fetchChildren(this.form.categoryId).then(list => {
+                  this.subCategoryList = list || []
+                })
+              }
               if (type === 1) {
                 this.categoryList.forEach(item => {
                   if (item.id === this.form.categoryId) {
                     this.form.goodsParamList = JSON.parse(JSON.stringify(item.paramList))
-                    this.form.goodsParamList.forEach(item => {
-                      item.pramaId = item.id
+                    this.form.goodsParamList.forEach(p => {
+                      p.pramaId = p.id
                     })
-                    console.log(this.form.goodsParamList)
                   }
                 })
               }

--
Gitblit v1.9.3