From 7c733f2e8d6b3c688ea741183f2b5d60686e841e Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期四, 21 九月 2023 11:06:36 +0800
Subject: [PATCH] 编辑产品接口联调及增加必填项校验

---
 src/views/productManage/product/AddProductDialog.vue |   53 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/src/views/productManage/product/AddProductDialog.vue b/src/views/productManage/product/AddProductDialog.vue
index 206aa69..b8542b9 100644
--- a/src/views/productManage/product/AddProductDialog.vue
+++ b/src/views/productManage/product/AddProductDialog.vue
@@ -47,7 +47,7 @@
           <div class="basic-info-view">
             <el-row>
               <el-col :span="23">
-                <div style="margin-left: 20px">浜у搧鍚嶇О</div>
+                <div style="margin-left: 20px"><span style="color: #f56c6c">*</span>浜у搧鍚嶇О</div>
                 <el-form-item label="" prop="name" label-width="20px">
                   <el-input v-model="editConfig.infomation.name" placeholder="" :disabled="!showFooter"></el-input>
                 </el-form-item>
@@ -105,8 +105,8 @@
                       <el-option v-for="item in strategyOptions" :key="item.id" :label="item.name" :value="item.id">
                       </el-option>
                     </el-select>
-                    <div>鍙偍瀛樼殑浜у搧鏄偍绠$悊搴撳瓨姘村钩鐨勫疄鐗╅」鐩��</div>
-                    <div>鎮ㄥ彲浠ュ湪鍙戣揣鍓嶄负鍏跺紑鍏风粨绠楀崟銆�</div>
+                    <div class="font_size_13" style="color: gray">鍙偍瀛樼殑浜у搧鏄偍绠$悊搴撳瓨姘村钩鐨勫疄鐗╅」鐩��</div>
+                    <div class="font_size_13" style="color: gray">鎮ㄥ彲浠ュ湪鍙戣揣鍓嶄负鍏跺紑鍏风粨绠楀崟銆�</div>
                   </el-form-item>
                   <el-form-item label="鐗╂枡绫诲瀷" prop="model" style="margin-left: 20px">
                     <el-select
@@ -259,6 +259,7 @@
                       :precision="2"
                       :controls="false"
                       style="width: 85%"
+                      :disabled="!showFooter"
                     ></el-input-number>
                     <span> kg</span>
                   </el-form-item>
@@ -270,6 +271,7 @@
                       :precision="2"
                       :controls="false"
                       style="width: 85%"
+                      :disabled="!showFooter"
                     ></el-input-number>
                     <span> m鲁</span>
                   </el-form-item>
@@ -285,9 +287,10 @@
                       v-model="editConfig.infomation.deliveryAdvanceTime"
                       placeholder="璇疯緭鍏�"
                       :min="0"
-                      :precision="2"
+                      :precision="0"
                       :controls="false"
                       style="width: 85%"
+                      :disabled="!showFooter"
                     ></el-input-number>
                     <span> 澶╂暟</span>
                   </el-form-item>
@@ -296,9 +299,10 @@
                       v-model="editConfig.infomation.customerTaxes"
                       placeholder="璇疯緭鍏�"
                       :min="0"
-                      :precision="2"
+                      :precision="0"
                       :controls="false"
                       style="width: 85%"
+                      :disabled="!showFooter"
                     ></el-input-number>
                     <span> 澶╂暟</span>
                   </el-form-item>
@@ -477,7 +481,7 @@
 <script>
 // import CommonFormTableView from "@/components/makepager/CommonFormTableView"
 import { getProductCategoryList } from "@/api/product/productCategory"
-import { getProductList, addProduct } from "@/api/product/product"
+import { getProductList, addProduct, updateProduct } from "@/api/product/product"
 
 let inputElement = null
 export default {
@@ -489,7 +493,7 @@
         return {
           visible: false,
           title: "鏂板缓",
-          infomation: { type: [] }
+          infomation: {}
         }
       }
     }
@@ -501,11 +505,10 @@
       dialogWidth: "50%",
       editConfig: this.editCommonConfig,
       rules: {
-        client_name: [{ required: true, message: "璇烽�夋嫨瀹㈡埛鍚嶇О", trigger: "change" }],
-        number: [{ required: true, message: "璇疯緭鍏ラ��娆惧崟缂栧彿", trigger: "blur" }],
-        refundDate: [{ required: true, message: "璇烽�夋嫨閫�娆炬棩鏈�", trigger: "change" }],
-        memberId: [{ required: true, message: "璇烽�夋嫨閿�鍞礋璐d汉", trigger: "change" }],
-        sale_return_nunber: [{ required: true, message: "璇烽�夋嫨閿�鍞��璐у崟", trigger: "change" }]
+        name: [{ required: true, message: "璇疯緭鍏ヤ骇鍝佸悕绉�", trigger: "blur" }],
+        model: [{ required: true, message: "璇烽�夋嫨鐗╂枡绫诲瀷", trigger: "change" }],
+        salePrice: [{ required: true, message: "璇疯緭鍏ラ攢鍞环鏍�", trigger: "blur" }],
+        unit: [{ required: true, message: "璇疯緭鍏ュ崟浣�", trigger: "blur" }]
       },
       memberOptions: [
         {
@@ -630,16 +633,21 @@
       this.setTableForm()
     },
     // 淇濆瓨
-    async saveClick() {
+    saveClick(formName) {
       console.log(this.editConfig.infomation)
-      await addProduct({
-        ...this.editConfig.infomation
-      }).then((res) => {
-        console.log(res)
-        this.editConfig.visible = false
-        if (res.code === 200) {
-          this.$message.success("娣诲姞鎴愬姛")
-          this.$parent.getData()
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          let requestUrl = this.editConfig.title === "鏂板缓" ? addProduct : updateProduct
+          requestUrl({
+            ...this.editConfig.infomation
+          }).then((res) => {
+            console.log(res)
+            this.editConfig.visible = false
+            if (res.code === 200) {
+              this.$message.success("娣诲姞鎴愬姛")
+              this.$parent.getData()
+            }
+          })
         }
       })
     },
@@ -905,5 +913,8 @@
     line-height: 30px;
     font-size: 13px;
   }
+  .el-input__inner {
+    text-align: left;
+  }
 }
 </style>

--
Gitblit v1.8.0