From 5a4edca45d9d966560c276b6b158f2e65a96f72c Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: Fri, 30 Jan 2026 16:39:34 +0800
Subject: [PATCH] 添加产品修改

---
 src/views/usermng/product.vue |   53 +++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/src/views/usermng/product.vue b/src/views/usermng/product.vue
index c200030..781739b 100644
--- a/src/views/usermng/product.vue
+++ b/src/views/usermng/product.vue
@@ -37,7 +37,7 @@
           </el-option>
         </el-select>
         <el-button v-if="getBtnPermission('add')" class="filter-item" style="margin-left: 10px;" type="primary"
-                   icon="el-icon-plus" @click="showCreateHandle">旧系统信息录入
+                   icon="el-icon-plus" @click="showCreateHandle">万能码信息录入
         </el-button>
         <el-upload v-if="userType === 1"
             class="filter-item"
@@ -51,7 +51,7 @@
             :on-success="onSuccessHandler"
             :on-error="onErrorHandler"
             :auto-upload="true">
-            <el-dropdown  @command="handleCommand" split-button trigger="hover" type="primary" style="margin-left: 10px;" icon="el-icon-plus" :disabled="uploadBtnControl">旧系统信息导入
+            <el-dropdown  @command="handleCommand" split-button trigger="hover" type="primary" style="margin-left: 10px;" icon="el-icon-plus" :disabled="uploadBtnControl">万能码信息导入
                 <el-button type="primary" slot="trigger" :disabled="uploadBtnControl"></el-button>
                 <el-dropdown-menu slot="dropdown">
                     <el-dropdown-item icon="el-icon-plus"  command="download"  >下载模板</el-dropdown-item>
@@ -136,7 +136,8 @@
         </el-table-column>
         <el-table-column label="操作" align="center" width="240" class-name="small-padding fixed-width">
           <template slot-scope="scope">
-            <el-button v-if="getBtnPermission('edit')" type="text" @click="showEditHandle(scope.row)">查看</el-button>
+              <el-button v-if="getBtnPermission('edit')" type="text" @click="showEditHandle('update',scope.row)">修改</el-button>
+            <el-button v-if="getBtnPermission('edit')" type="text" @click="showEditHandle('editor',scope.row)">查看</el-button>
             <el-button v-if="getBtnPermission('delete')" type="text" style="color:red;"
                        @click="deleteHandle(scope.row)">删除
             </el-button>
@@ -157,7 +158,7 @@
         @current-change="handleCurrentChange"
       />
     </div>
-    <el-dialog :title="dialogStatus==='create'|| dialogStatus === 'createNew'?'新增':'查看'" :visible.sync="dialogFormVisible"
+    <el-dialog :title="dialogStatus==='create'|| dialogStatus === 'createNew'?'新增':dialogStatus === 'update'?'修改':'查看'" :visible.sync="dialogFormVisible"
                :modal-append-to-body="false" :close-on-click-modal="false" width="700px">
       <el-form ref="dataForm" :rules="dataFormRules" :model="dataForm" label-position="right" label-width="140px"
                style="margin-left:50px;width:500px;" element-loading-text="保存中...">
@@ -178,7 +179,7 @@
             </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="产品小类:" prop="type">
+        <el-form-item label="产品小类:" prop="secondaryType">
           <el-select v-model="dataForm.secondaryType" clearable placeholder="请选择" :disabled="dialogStatus==='editor'"
                      @change="selectChange">
             <el-option
@@ -240,7 +241,7 @@
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button @click="dialogFormVisible = false">取消</el-button>
-        <el-button type="primary" @click="submitHandle">确认</el-button>
+        <el-button type="primary" @click="debouncedSubmit">确认</el-button>
       </div>
     </el-dialog>
     <div style="clear: both;"></div>
@@ -256,7 +257,7 @@
       deleteProduct,
       getMajorCategoryTree,
       getManufacturerTree, getPermitLevelTree, getSecondaryCategoryTree,
-      productList,
+      productList, updateOldProduct,
       updateProduct
   } from "../../api/product";
   import {parseError} from "../../utils/messageDialog";
@@ -337,13 +338,16 @@
       ...mapGetters([
         'userType',
         'username'
-      ])
+      ]),
+        debouncedSubmit() {
+            return this.debounce(this.submitHandle, 800);
+        }
     },
     methods: {
-      async selectChange(){
+      async selectChange(second){
         this.$forceUpdate();
         this.dataForm.level = '';
-        let res = await getPermitLevelTree(this.dataForm.secondaryType);
+        let res = await getPermitLevelTree(second || this.dataForm.secondaryType);
         this.permitLevelOptions = res.data;
       },
       getProductMajorCategory(){
@@ -412,14 +416,22 @@
           parseError({error: error, vm: _this})
         })
       },
+        debounce(func, wait) {
+            let timeout;
+            return (...args) => {
+                clearTimeout(timeout);
+                timeout = setTimeout(() => {
+                    func.apply(this, args);
+                }, wait);
+            };
+        },
       submitHandle:function(){
           if (this.dialogStatus === 'create') {
               this.createHandle();
           }else if (this.dialogStatus === 'createNew') {
               this.createNewHandle();
           }else {
-              // this.updateHandle();
-              this.dialogFormVisible = false;
+              this.updateHandle();
           }
       },
       createHandle: function () {
@@ -524,6 +536,7 @@
           id: '',
           name: '',
           type: '',
+        secondaryType: '',
           directionCode: '',
           manufacturer: '',
           specification: '',
@@ -557,7 +570,7 @@
             const userName = Cookies.get('userName');
             const name = Cookies.get('name');
             _this.dataForm['modifiedBy'] = name + '(' + userName + ')';
-            updateProduct(_this.dataForm).then(response => {
+              updateOldProduct(_this.dataForm).then(response => {
               const res = response.data
               if (res.code == 200) {
                 _this.dialogFormVisible = false
@@ -575,10 +588,17 @@
           }
         })
       },
-      showEditHandle: function (row) {
+      showEditHandle: async function (type,row) {
         this.resetDataForm();
-        this.dialogStatus = 'editor';
-        this.dataFormSetValue(row);
+          if(type == 'editor'){
+              this.dialogStatus = 'editor';
+          }else{
+              this.dialogStatus = 'update';
+          }
+          await this.getProductSecondaryCategory(row.type)
+
+          await this.selectChange(row.secondaryType)
+          await this.dataFormSetValue(row);
         this.dialogFormVisible = true;
         this.$nextTick(() => {
           this.$refs['dataForm'].clearValidate()
@@ -588,6 +608,7 @@
         this.dataForm.id = row.id;
         this.dataForm.name = row.name;
         this.dataForm.type = row.type;
+          this.dataForm.secondaryType = row.secondaryType;
         this.dataForm.directionCode = row.directionCode;
         this.dataForm.manufacturer = row.companyNumber;
         this.dataForm.specification = row.specification;

--
Gitblit v1.9.2