소스 검색

feat: 优化

cuiyalong 3 달 전
부모
커밋
cea411ac8e

+ 1 - 0
src/utils/mixins/selector-v-model.js

@@ -11,6 +11,7 @@ export const selectorVModelMixin = {
   watch: {
     value: {
       immediate: true,
+      deep: true,
       handler(n) {
         this.setState(n)
       }

+ 17 - 1
src/views/create-order/components/product-info-submodule/CheckboxGroup.vue

@@ -14,6 +14,10 @@
 export default {
   name: 'CheckboxGroup',
   props: {
+    multiple: {
+      type: Boolean,
+      default: true
+    },
     value: {
       type: Array,
       default() {
@@ -42,7 +46,19 @@ export default {
   },
   methods: {
     onCheckboxInput(e) {
-      this.$emit('input', e)
+      if (this.multiple) {
+        this.$emit('input', e)
+      } else {
+        if (this.value.length >= 1) {
+          const clicked = this.getDifference(e, this.value)
+          this.$emit('input', clicked)
+        } else {
+          this.$emit('input', e)
+        }
+      }
+    },
+    getDifference(arr1, arr2) {
+      return arr1.filter(item =>!arr2.includes(item));
     },
     getState() {
       return this.value

+ 29 - 7
src/views/create-order/components/schema-form/schema-form.vue

@@ -20,6 +20,8 @@ import { schemaKeyMap, productKeyMap, productGroupKeyMap, productTypeMap } from
 import { cloneDeep, debounce } from 'lodash'
 import { deepEqual } from '@/utils/object'
 
+const dhy001 = 'dyh001'
+
 // 深对比两个对象,找出值不相同的字段的 key 并以数组形式返回
 function deepCompareObjects(newVal, oldVal) {
   const differentKeys = [];
@@ -752,27 +754,28 @@ export default {
 
       const { [schemaKeyMap.specification]: specification } = value
       const { [schemaKeyMap.payment]: payment } = value
-      ma.show = specification === 'dyh001'  // 自定义规格才展示
+      ma.show = specification === dhy001  // 自定义规格才展示
       
       // 1.付费类型为“续费”,则禁用服务列表全部,不支持修改;
       // 2.如果是升级,则禁用已选的
       if (payment === 1) {
         // 购买,恢复,不禁用
         this.$set(ma.props, 'disabled', false)
-        this.$set(ma.props, 'disabledService', [])
+        this.$set(ma.props, 'alreadyBuyIds', [])
       } else if (payment === 2) {
         // 付费类型为“续费”,则禁用服务列表全部,不支持修改;
         this.$set(ma.props, 'disabled', true)
-        this.$set(ma.props, 'disabledService', [])
+        this.$set(ma.props, 'alreadyBuyIds', [])
       } else if (payment === 3) {
         // 2.如果是升级,则禁用已选的
         let disabledService = []
-        this.$set(ma.props, 'disabled', false)
         const t = this.selectedRelatedOrder
         if (t && Array.isArray(t.serviceList)) {
           disabledService = t.serviceList
         }
-        this.$set(ma.props, 'disabledService', disabledService)
+        this.$set(ma.props, 'disabled', false)
+        this.$set(ma.props, 'serviceEndTime', t.serviceEndTimeText || '')
+        this.$set(ma.props, 'alreadyBuyIds', disabledService)
       }
     },
     // 检查code是否是当前产品的规格
@@ -821,7 +824,8 @@ export default {
         if (upgradeContent.length === 1 && upgradeContent.includes(2)) {
           // 仅为增购子账号:默认为关联订单的产品规格,其他产品规格不展示;
           this.$set(ma.props, 'onlyShowSelected', true)
-        } else if (!upgradeContent.includes(2)) {
+          this.$set(ma.props, 'disabled', true)
+        } else if (upgradeContent.includes(1)) {
           // 有“补充服务”或为空:仅可选择不低于关联订单的产品规格,其他产品规格不展示;
           this.$set(ma.props, 'onlyShowSelected', false)
           this.$set(ma.props, 'disabled', false)
@@ -879,7 +883,25 @@ export default {
     dhyChangeSpecificationSchema() {
       // (注:特殊处理,大会员自定义版默认展示),其他产品规格不展示。
       const ma = this.getSchemaItemWithKey(schemaKeyMap.specification)
-
+      // const { [schemaKeyMap.specification]: spec } = this.value
+      const { [schemaKeyMap.payment]: payment } = this.value
+      if (payment === 3) {
+        // 续费+升级服务(在commonChangeSpecificationSchema中已经判断):默认切换到自定义
+        this.refreshValue({ [schemaKeyMap.specification]: dhy001 })
+        // 禁用其他服务
+        this.$set(ma.props, 'disabled', true)
+        // 后续禁用在serviceList中判断
+        const sv = this.getSchemaItemWithKey(schemaKeyMap.serviceList)
+        if (!sv) {
+          return console.error('没找到schema: ', schemaKeyMap.serviceList)
+        }
+        const t = this.selectedRelatedOrder
+        if (t && Array.isArray(t.serviceList)) {
+          // this.$set(sv.props, '', t.serviceList)
+          // this.$set(sv.props, '', t.serviceList)
+        }
+        this.$set(ma.props, 'onlyShowSelected', true)
+      }
     },
     onChangedFields(changedArr) {
       if (this.checkNeedRefreshPrice(changedArr)) {