From 3303475ef92814062b13e251144b7c03da1d17d8 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期四, 21 十二月 2023 18:34:44 +0800
Subject: [PATCH] 销售明细单如果报价单必填则产品只能选择和报价单关联的,如果报价单非必填则可以选择所有产品

---
 src/views/sales/quotation/AddQuotationDialog.vue       |   14 +++++++++++---
 src/components/makepager/CommonFormTableView.vue       |   24 ++++++++++++++++--------
 src/views/sales/salesDetails/AddSalesDetailsDialog.vue |   15 ++++++++++++---
 3 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/src/components/makepager/CommonFormTableView.vue b/src/components/makepager/CommonFormTableView.vue
index ec70ab3..194cfc0 100644
--- a/src/components/makepager/CommonFormTableView.vue
+++ b/src/components/makepager/CommonFormTableView.vue
@@ -1,6 +1,7 @@
 <template>
   <div class="page-view">
     <el-form ref="form" :model="tableList" :show-message="false" label-position="right">
+      {{ tableList.tableData }}
       <el-table
         ref="fromTable"
         :data="tableList.tableData"
@@ -44,7 +45,7 @@
                   :disabled="!isOperate"
                   @change="
                     (val) => {
-                      commonInputChange(val, item.prop, scope.row)
+                      commonInputChange(val, item.prop, scope.row,scope)
                     }
                   "
                 ></el-input>
@@ -105,7 +106,7 @@
                   style="width: 100%; margin-right: 5px"
                   @change="
                     (val) => {
-                      commonInputChange(val, item.prop, scope.row)
+                      commonInputChange(val, item.prop, scope.row,scope)
                     }
                   "
                 ></el-input-number>
@@ -127,7 +128,7 @@
                   style="width: 100%; margin-right: 5px"
                   @change="
                     (val) => {
-                      commonInputChange(val, item.prop, scope.row)
+                      commonInputChange(val, item.prop, scope.row,scope)
                     }
                   "
                 ></el-input-number>
@@ -137,7 +138,7 @@
                   {{ (scope.row.price&&scope.row.cost)?Number(scope.row.price)-Number(scope.row.cost):'' }}
                 </template>
                 <template v-if="pageName=='quotation'&&item.prop=='margin'">
-                  {{ (scope.row.price&&scope.row.cost)?((Number(scope.row.price)-Number(scope.row.cost))*100/Number(scope.row.cost)).toFixed(2)+'%':'' }}
+                  {{ (scope.row.price&&scope.row.cost)?((Number(scope.row.price)-Number(scope.row.cost))*100/Number(scope.row.cost)).toFixed(2):'' }}
                 </template>
                 <template v-else>
                   {{ scope.row[item.prop] }}
@@ -160,7 +161,7 @@
                 style="width: 100%; margin-right: 5px"
                 @change="
                   (val) => {
-                    commonInputChange(val, item.prop, scope.row)
+                    commonInputChange(val, item.prop, scope.row,scope)
                   }
                 "
               ></el-input-number>
@@ -407,9 +408,7 @@
     add() {
       this.$emit("addProductClick")
     },
-    commonInputChange(val, prop, row) {
-      console.log(val, prop)
-      console.log(row)
+    commonInputChange(val, prop, row,scope) {
       if (prop === "amount") {
         this.tableList.tableData.map((ite) => {
           if (ite.name === row.name) {
@@ -417,6 +416,15 @@
           }
         })
       }
+      if(this.pageName=='quotation'&&prop=='cost'&&scope.row.cost){
+        let value=scope.row.cost
+        let reg2 =
+            /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
+          if (!reg2.test(value)||value==0) {
+            this.$message.error("鎴愭湰鍗曚环闇�瑕佸~鍐欏ぇ浜�0鐨�2浣嶅皬鏁帮紒")
+          } 
+        this.$forceUpdate()
+      }
       this.$emit("inputContent", val, prop, row)
     },
     // 娓呯┖
diff --git a/src/views/sales/quotation/AddQuotationDialog.vue b/src/views/sales/quotation/AddQuotationDialog.vue
index a0ac6ae..268f5f1 100644
--- a/src/views/sales/quotation/AddQuotationDialog.vue
+++ b/src/views/sales/quotation/AddQuotationDialog.vue
@@ -477,8 +477,16 @@
           if (this.isNoProduct) {
             this.$message.error("浜у搧鍚嶇О涓嶈兘涓虹┖")
           } else {
+            for (let i = 0; i < this.tableData.length; i++) {
+              if (this.tableData[i].cost||Number(this.tableData[i].cost)==0) {
+                let reg = /^\+?[1-9]\d*$/;
+                if(!reg.test(this.tableData[i].cost)){
+                  this.$message.error("鎴愭湰鍗曚环闇�瑕佸~鍐欏ぇ浜�0鐨�2浣嶅皬鏁帮紒")
+                  return true;
+                }
+              }
+            }
             const params = this.saveParams()
-            console.log(params)
             if (this.editConfig.title === "鏂板缓") {
               getAddQuotation(params).then((res) => {
                 console.log(res)
@@ -636,9 +644,9 @@
           { label: "浜у搧缂栧彿", prop: "number" },
           { label: "鍗曚綅", prop: "unit" },
           { label: "閿�鍞崟浠�", prop: "price", inputFloat: true, isRequird: true },
-          { label: "鎴愭湰鍗曚环", prop: "cost",inputFloat: true  },
+          { label: "鎴愭湰鍗曚环", prop: "cost",input: true  },
           { label: "姣涘埄", prop: "profit" },
-          { label: "姣涘埄鐜�", prop: "margin",min:90},
+          { label: "姣涘埄鐜�(%)", prop: "margin",min:90},
           { label: "鏁伴噺", prop: "amount", inputNumber: true, isRequird: true },
           { label: "浠风◣鍚堣", prop: "total", inputFloat: true }
         ]
diff --git a/src/views/sales/salesDetails/AddSalesDetailsDialog.vue b/src/views/sales/salesDetails/AddSalesDetailsDialog.vue
index 6aabb56..0477013 100644
--- a/src/views/sales/salesDetails/AddSalesDetailsDialog.vue
+++ b/src/views/sales/salesDetails/AddSalesDetailsDialog.vue
@@ -408,7 +408,7 @@
               :show-summary="showSummary"
               pageName="quotation"
               :isOperate="((autoCodeHeadersObj.bjd=='yes'&&editConfig.infomation.quotation_number)||autoCodeHeadersObj.bjd!='yes')?true:false"
-              :quotationNumber="editConfig.infomation.quotation_number"
+              :quotationNumber="autoCodeHeadersObj.bjd=='yes'?editConfig.infomation.quotation_number:''"
               :product-table-list="productTableList"
               @inputContent="inputContent"
               @addProductClick="addProductClick"
@@ -674,6 +674,15 @@
           if (this.isNoProduct) {
             this.$message.error("璇烽�夋嫨浜у搧")
           } else {
+            for (let i = 0; i < this.tableData.length; i++) {
+              if (this.tableData[i].cost||Number(this.tableData[i].cost)==0) {
+                let reg = /^\+?[1-9]\d*$/;
+                if(!reg.test(this.tableData[i].cost)){
+                  this.$message.error("鎴愭湰鍗曚环闇�瑕佸~鍐欏ぇ浜�0鐨�2浣嶅皬鏁帮紒")
+                  return true;
+                }
+              }
+            }
             const params = this.saveParams()
             if (this.editConfig.title === "鏂板缓") {
               getAddSalesDetails(params).then((res) => {
@@ -961,9 +970,9 @@
           { label: "浜у搧缂栧彿", prop: "number" },
           { label: "鍗曚綅", prop: "unit" },
           { label: "閿�鍞崟浠�", prop: "price",inputFloat: !isBjdRequird, isRequird: true },
-          { label: "鎴愭湰鍗曚环", prop: "cost",inputFloat: !isBjdRequird},
+          { label: "鎴愭湰鍗曚环", prop: "cost",input: !isBjdRequird},
           { label: "姣涘埄", prop: "profit" },
-          { label: "姣涘埄鐜�", prop: "margin",min:90},
+          { label: "姣涘埄鐜�(%)", prop: "margin",min:90},
           { label: "鏁伴噺", prop: "amount", inputNumber: true, isRequird: true },
           { label: "浠风◣鍚堣", prop: "total" }
         ]

--
Gitblit v1.8.0