From cf2da3b2a63840888815c6a81cbd7948faf93533 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期一, 08 六月 2026 17:41:15 +0800
Subject: [PATCH] aaa

---
 company_admin/src/components/business/OperaGoodsWindow.vue |   51 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/company_admin/src/components/business/OperaGoodsWindow.vue b/company_admin/src/components/business/OperaGoodsWindow.vue
index 7ef2c34..3c9b085 100644
--- a/company_admin/src/components/business/OperaGoodsWindow.vue
+++ b/company_admin/src/components/business/OperaGoodsWindow.vue
@@ -209,6 +209,7 @@
               id: null,
               name: '',
               categoryId: '',
+              subCategoryId: '',
               brandId: '',
               zdPrice: '',
               price: '',
@@ -229,6 +230,45 @@
       }
     },
     methods: {
+      open (title, target) {
+        this.title = title
+        this.visible = true
+        if (target == null) {
+          this.$nextTick(() => {
+            this.$refs.form.resetFields()
+            this.form[this.configData['field.id']] = null
+            this.subCategoryList = []
+          })
+          return
+        }
+        this.$nextTick(() => {
+          for (const key in this.form) {
+            this.form[key] = target[key]
+          }
+          this.loadSubCategoryOptions()
+        })
+      },
+      buildSubmitPayload () {
+        const payload = { ...this.form, type: 0 }
+        if (payload.subCategoryId === '' || payload.subCategoryId == null) {
+          payload.subCategoryId = null
+        } else {
+          payload.subCategoryId = Number(payload.subCategoryId)
+        }
+        return payload
+      },
+      loadSubCategoryOptions () {
+        if (!this.form.categoryId) {
+          this.subCategoryList = []
+          return
+        }
+        fetchChildren(this.form.categoryId).then(res => {
+          this.subCategoryList = res || []
+          if (this.form.subCategoryId !== '' && this.form.subCategoryId != null) {
+            this.form.subCategoryId = Number(this.form.subCategoryId)
+          }
+        })
+      },
       priceCHANEG(val, type) {
         if (!/^[1-9]+[0-9]*$/.test(val)) {
           this.$message.warning('鍙兘杈撳叆姝f暣鏁�')
@@ -273,7 +313,8 @@
               this.form.attrSecodIds = ''
             }
             if (!this.form.id) {
-              companyCreate({...this.form, type: 0})
+              const payload = this.buildSubmitPayload()
+              companyCreate(payload)
                 .then(() => {
                   this.visible = false
                   this.$tip.apiSuccess('鏂板缓鎴愬姛')
@@ -286,7 +327,7 @@
                   this.isWorking = false
                 })
             } else {
-              companyUpdateById({...this.form, type: 0})
+              companyUpdateById(this.buildSubmitPayload())
                 .then(() => {
                   this.visible = false
                   this.$tip.apiSuccess('缂栬緫鎴愬姛')
@@ -353,11 +394,7 @@
           findListForGoodsId(this.form.id || '')
             .then(res => {
               this.categoryList = (res || []).filter(item => !item.parentId)
-              if (this.form.categoryId) {
-                fetchChildren(this.form.categoryId).then(list => {
-                  this.subCategoryList = list || []
-                })
-              }
+              this.loadSubCategoryOptions()
               if (type === 1) {
                 this.categoryList.forEach(item => {
                   if (item.id === this.form.categoryId) {

--
Gitblit v1.9.3