Browse Source

feat: 数据变更清空逻辑调整

cuiyalong 2 months ago
parent
commit
9202a1b7fe

+ 1 - 1
src/views/create-order/components/ProductInfoCardList.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="product-info-card-list">
-    <div class="product-info-card-item" v-for="(product, index) in productCardList" :key="product.id">
+    <div class="product-info-card-item" v-for="(product, index) in productCardList" :key="product._id">
       <ProductCard
         :title="product.title + (index+1)"
         :subtitle="product.subtitle"

+ 10 - 8
src/views/create-order/components/schema-form/schema-form.vue

@@ -1193,34 +1193,36 @@ export default {
       }
       if (this.activityCard) return
       if (changedArr.includes('saleGifts') || changedArr.includes(schemaKeyMap.payment)) {
-        // 销售策略变更,清空有效周期(通用规则)
         const obj = {}
+        // 销售策略变更,清空有效周期(通用规则)
         if (this.value.validityPeriod) {
           obj.validityPeriod = {}
         }
         if (this.value[schemaKeyMap.validityCount]) {
           obj[schemaKeyMap.validityCount] = {}
         }
+        const buyType = [1, 4].includes(this.value[schemaKeyMap.payment]) 
+        if (changedArr.includes(schemaKeyMap.payment) && buyType) {
+          obj[schemaKeyMap.relatedOrders] = []
+        }
         this.refreshValue(obj)
       }
       if (changedArr.includes('saleGifts') || changedArr.includes(schemaKeyMap.specification) || changedArr.includes(schemaKeyMap.payment)) {
+        const obj = {}
         // 付费类型变更,如果有主账号数量,则清空
         if (this.value.subAccountNumbers) {
           const subAccountNumbers = { payCount: '', freeCount: '' }
-          this.refreshValue({ subAccountNumbers })
+          obj.subAccountNumbers = subAccountNumbers
         }
         // 清空合同金额
         // 销售策略变为赠送,则合同金额默认值改为0
         if (this.value.saleGifts === 2) {
           // 1售卖  2赠送
-          this.refreshValue({
-            [schemaKeyMap.contractAmount]: Object.assign({}, this.value[schemaKeyMap.contractAmount], { contractMoney: '0' }) 
-          })
+          obj[schemaKeyMap.contractAmount] = Object.assign({}, this.value[schemaKeyMap.contractAmount], { contractMoney: '0' })
         } else {
-          this.refreshValue({
-            [schemaKeyMap.contractAmount]: Object.assign({}, this.value[schemaKeyMap.contractAmount], { contractMoney: '', standardMoney: '' }) 
-          })
+          obj[schemaKeyMap.contractAmount] = Object.assign({}, this.value[schemaKeyMap.contractAmount], { contractMoney: '', standardMoney: '' })
         }
+        this.refreshValue(obj)
       }
 
       console.log(`以下字段变更了:${this.productType}`, changedArr)

+ 1 - 1
src/views/create-order/data/interface.js

@@ -54,7 +54,7 @@ export class OrderProductCardItem {
   constructor(title, subtitle2, conf = {}) {
     this.title = title || '产品'
     this.subtitle2 = subtitle2
-    this.id = getRandomString()
+    this._id = getRandomString()
 
     const {
       productCode,