Przeglądaj źródła

feat: 调整升级内容默认选中逻辑

cuiyalong 3 tygodni temu
rodzic
commit
d54a931259

+ 19 - 3
src/views/create-order/components/schema-form/schema-form.vue

@@ -1442,14 +1442,30 @@ export default {
       }
 
       if (changedArr.includes(schemaKeyMap.payment)) {
+        const objPayment = {}
+        // 大会员购买续费服务列表重置
         if (this.utilsCheckBuyAndTrail() && this.value[schemaKeyMap.serviceList]) {
           const ma = this.getSchemaItemWithKey(schemaKeyMap.serviceList)
           if (ma) {
-            this.refreshValue({
-              serviceList: ma.defaultValue
-            })
+            objPayment.serviceList = ma.defaultValue
+          }
+        }
+        // 升级内容
+        const { isUpgrade } = this.utilsGetPaymentType()
+        if (isUpgrade) {
+          const uc = this.getSchemaItemWithKey(schemaKeyMap.upgradeContent)
+          if (uc) {
+            // 如果可选项大于1个,则默认值为空
+            // 如果可选项小于等于1个,则默认值为第一个可选
+            const enableValue = uc.props.options.filter(c => !c.disabled)
+            if (enableValue.length <= 1) {
+              objPayment[schemaKeyMap.upgradeContent] = enableValue[0].value
+            } else {
+              objPayment[schemaKeyMap.upgradeContent] = []
+            }
           }
         }
+        this.refreshValue(objPayment)
       }
 
       console.log(`以下字段变更了:${this.productType}`, changedArr)