From 8396695ccec67407b465a6f30503298df7803d84 Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期二, 09 四月 2024 14:59:05 +0800
Subject: [PATCH] 产品,添加单位管理

---
 src/views/productManage/product/AddProductDialog.vue |   65 +++++++++++++-------------------
 1 files changed, 27 insertions(+), 38 deletions(-)

diff --git a/src/views/productManage/product/AddProductDialog.vue b/src/views/productManage/product/AddProductDialog.vue
index 6de1c2b..3be77ba 100644
--- a/src/views/productManage/product/AddProductDialog.vue
+++ b/src/views/productManage/product/AddProductDialog.vue
@@ -141,11 +141,12 @@
 
                   <el-form-item label="鍗曚綅" prop="unit">
                     <el-select
+                      :disabled="!showFooter"
                       v-model="editConfig.infomation.unit"
                       placeholder="鍗曚綅"
                       filterable
-                      @change="$forceUpdate()"
-                      style="width: calc(100% - 30px)"
+                      @change="Gtechange"
+                      style="width: 85%"
                     >
                       <el-option
                         v-for="ele in unitList"
@@ -537,7 +538,6 @@
     <BomDialog
       ref="editDialog"
       :editRow="editRow"
-      @sucessSet="handleGetBomKindDictList"
       @handleConfirmSave="handleConfirmSave"
       :workList="unitList"
       title="璁¢噺鍗曚綅"
@@ -548,8 +548,8 @@
 <script>
 import IconCropper from "./IconCropper"
 import { getProductCategoryList } from "@/api/product/productCategory"
-import { getProductList, addProduct, updateProduct } from "@/api/product/product"
-import { uploadFiles, getUserInfo } from "@/api/common/other"
+import { getProductList, addProduct, updateProduct,saveUnitDict } from "@/api/product/product"
+import { uploadFiles, getUserInfo, } from "@/api/common/other"
 import codeMixin from "@/components/mixin/codeMixin"
 import { getDataByType } from "@/api/data"
 import BomDialog from "./components/bomDialog";
@@ -597,7 +597,7 @@
         id: [{ required: true, validator: this.validateCheckCode, trigger: ["change", "blur"] }],
         model: [{ required: true, message: "璇烽�夋嫨鐗╂枡绫诲瀷", trigger: "change" }],
         // salePrice: [{ required: true, message: "璇疯緭鍏ラ攢鍞环鏍�", trigger: "blur" }],
-        unit: [{ required: true, message: "璇疯緭鍏ュ崟浣�", trigger: ["change", "blur"] }],
+        unit: [{ required: true, message: "璇疯緭鍏ュ崟浣�", trigger: ["blur"] }],
         // 閲囪喘绫诲瀷
         purchaseTypeList: [{ required: true, message: "璇烽�夋嫨", trigger: "blur" }]
       },
@@ -687,39 +687,18 @@
   methods: {
     // 鍗曚綅
     handleUnitShow() {
-      this.handleGetBomKindDictList();
       this.editRow.editDialogVisible = true;
     },
-    //  鍗曚綅
-    handleGetBomKindDictList(val) {
-      console.log(val)
-      // postGetUnitDictList().then((res) => {
-      //   this.unitList = res.data;
-      //   if (val) {
-      //     for (let i in this.unitList) {
-      //       if (this.unitList[i].isDefault) {
-      //         this.form.unit = this.form.unit
-      //           ? this.form.unit
-      //           : this.unitList[i].name;
-      //         // this.$set(this.form, "unit", this.form.unit);
-      //         break;
-      //       }
-      //     }
-      //   }
-      // });
-    },
-    handleConfirmSave(data) {
-      console.log(data)
-      // postGetSaveSUnitDict({ data: data }).then((res) => {
-      //   if (res.code == 200) {
-      //     this.$message({
-      //       message: "鎿嶄綔鎴愬姛锛�",
-      //       type: "success",
-      //     });
-      //     this.$refs.editDialog.editDialogVisible = false;
-      //     this.handleGetBomKindDictList();
-      //   }
-      // });
+    handleConfirmSave(dataList) {
+      saveUnitDict({ data: dataList }).then((res) => {
+        if (res.code == 200) {
+          this.$message({
+            message: "鎿嶄綔鎴愬姛锛�",
+            type: "success",
+          });
+          this.getUnitInfo()
+        }
+      });
       this.editRow.editDialogVisible = false;
 
     },
@@ -1000,11 +979,21 @@
         this.showSale = param
       }
     },
+    Gtechange(){
+      this.$forceUpdate()
+    },
     // 鑾峰彇鍗曚綅鍒楄〃鏁版嵁
     async getUnitInfo(){
       await getUnitInfo().then((res)=>{
+        if( this.editConfig.title==="鏂板缓"){
+          res.data.map((item)=>{
+            if(item.isDefault){
+              this.editConfig.infomation.unit=item.name
+            }
+          })
+        }
         this.editRow.BomTableData = res.data;
-        console.log( this.editRow.BomTableData,"鐪嬩笅",res.data)
+        this.unitList=res.data
       })
     }
   }

--
Gitblit v1.8.0