|
@@ -1,5 +1,6 @@
|
|
<template>
|
|
<template>
|
|
<div class="order-schema-form-container">
|
|
<div class="order-schema-form-container">
|
|
|
|
+ <!-- schema-form中用到的组件,禁止在created时候立即返回一个值,会出现其他选项默认值为空的情况。应该等createSchema的默认值赋值后再进行emit -->
|
|
<SchemaFormRenderer
|
|
<SchemaFormRenderer
|
|
ref="schemaForm"
|
|
ref="schemaForm"
|
|
:key="productType"
|
|
:key="productType"
|
|
@@ -98,6 +99,12 @@ export default {
|
|
},
|
|
},
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
|
|
+ value: {
|
|
|
|
+ deep: true,
|
|
|
|
+ handler(n) {
|
|
|
|
+ this.onValueChange(n) // 用于监听哪些字段做了变动,然后进行一些操作
|
|
|
|
+ }
|
|
|
|
+ },
|
|
productType: {
|
|
productType: {
|
|
immediate: true,
|
|
immediate: true,
|
|
handler(n) {
|
|
handler(n) {
|
|
@@ -132,7 +139,6 @@ export default {
|
|
},
|
|
},
|
|
onInput(e) {
|
|
onInput(e) {
|
|
this.emitInput(e)
|
|
this.emitInput(e)
|
|
- this.afterInput() // 用于监听哪些字段做了变动,然后进行一些操作
|
|
|
|
},
|
|
},
|
|
onInitSchema() {
|
|
onInitSchema() {
|
|
this.$emit('initd')
|
|
this.$emit('initd')
|
|
@@ -172,7 +178,7 @@ export default {
|
|
this.onInput(newValue)
|
|
this.onInput(newValue)
|
|
this.onInitSchema()
|
|
this.onInitSchema()
|
|
// 更新完规则后,刷新规则相关判断
|
|
// 更新完规则后,刷新规则相关判断
|
|
- this.dynamicChangeSchema()
|
|
|
|
|
|
+ this.dynamicChangeSchema(this.value)
|
|
|
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
this.beforeGetUserPower()
|
|
this.beforeGetUserPower()
|
|
@@ -187,7 +193,7 @@ export default {
|
|
} finally {
|
|
} finally {
|
|
this.changeLoading(false)
|
|
this.changeLoading(false)
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
- this.dynamicChangeSchema()
|
|
|
|
|
|
+ this.dynamicChangeSchema(this.value)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -232,11 +238,11 @@ export default {
|
|
}
|
|
}
|
|
return r
|
|
return r
|
|
},
|
|
},
|
|
- getChangedFields() {
|
|
|
|
- return deepCompareObjects(this.value, cloneDeep(this.cacheValue))
|
|
|
|
|
|
+ getChangedFields(value) {
|
|
|
|
+ return deepCompareObjects(value, cloneDeep(this.cacheValue))
|
|
},
|
|
},
|
|
- needChangeSchema() {
|
|
|
|
- const changedFieldsArr = this.getChangedFields()
|
|
|
|
|
|
+ needChangeSchema(value) {
|
|
|
|
+ const changedFieldsArr = this.getChangedFields(value)
|
|
const changedFields = changedFieldsArr.join(',')
|
|
const changedFields = changedFieldsArr.join(',')
|
|
const res = {
|
|
const res = {
|
|
needChange: true,
|
|
needChange: true,
|
|
@@ -252,7 +258,7 @@ export default {
|
|
// 求交集
|
|
// 求交集
|
|
const needChange = needChangedArr.length !== 0
|
|
const needChange = needChangedArr.length !== 0
|
|
// 此处规则log不要注释!!!需要通过此log判断在产品类型变更后是否产生了递归调用
|
|
// 此处规则log不要注释!!!需要通过此log判断在产品类型变更后是否产生了递归调用
|
|
- // <主要是应对this.value字段少 -> this.value 字段多时的情况>
|
|
|
|
|
|
+ // <主要是应对value字段少 变到 value 字段多时的情况>
|
|
console.log('是否需要更新schema规则: ', needChange, needChangedArr) // 禁止移除
|
|
console.log('是否需要更新schema规则: ', needChange, needChangedArr) // 禁止移除
|
|
return Object.assign(res, {
|
|
return Object.assign(res, {
|
|
needChange
|
|
needChange
|
|
@@ -274,14 +280,15 @@ export default {
|
|
return this.schema.find(item => item.key === key)
|
|
return this.schema.find(item => item.key === key)
|
|
},
|
|
},
|
|
// 处理并分发各个产品卡片操作的限制
|
|
// 处理并分发各个产品卡片操作的限制
|
|
- afterInput: debounce(function() {
|
|
|
|
|
|
+ onValueChange: debounce(function(value) {
|
|
// 修改某些字段时候才会更新schema
|
|
// 修改某些字段时候才会更新schema
|
|
- const { needChange, changedFieldsArr } = this.needChangeSchema()
|
|
|
|
|
|
+ const { needChange, changedFieldsArr } = this.needChangeSchema(value)
|
|
this.onChangedFields(changedFieldsArr)
|
|
this.onChangedFields(changedFieldsArr)
|
|
if (!needChange) return
|
|
if (!needChange) return
|
|
- this.dynamicChangeSchema()
|
|
|
|
- }, 50),
|
|
|
|
|
|
+ this.dynamicChangeSchema(value)
|
|
|
|
+ }, 100),
|
|
getPriceRequest: debounce(async function getPrice(p) {
|
|
getPriceRequest: debounce(async function getPrice(p) {
|
|
|
|
+ console.log('准备获取价格...')
|
|
const commonP = {
|
|
const commonP = {
|
|
productInfo: cloneDeep(this.thisProductInfoListItem),
|
|
productInfo: cloneDeep(this.thisProductInfoListItem),
|
|
type: this.productType,
|
|
type: this.productType,
|
|
@@ -414,7 +421,12 @@ export default {
|
|
|
|
|
|
this.$set(relatedOrders.hooks, 'confirm', async (p) => {
|
|
this.$set(relatedOrders.hooks, 'confirm', async (p) => {
|
|
if (p.selected[0]) {
|
|
if (p.selected[0]) {
|
|
- this.selectedRelatedOrder = p.selected[0]
|
|
|
|
|
|
+ const t = p.selected[0]
|
|
|
|
+ this.selectedRelatedOrder = t
|
|
|
|
+ // 更新serviceList
|
|
|
|
+ if (Array.isArray(t.serviceList)) {
|
|
|
|
+ this.refreshValue({ serviceList: [...new Set(t.serviceList)] })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// 企业下,根据选中的权益判断是否可以进行续费和升级
|
|
// 企业下,根据选中的权益判断是否可以进行续费和升级
|
|
if (buySubject === 2) {
|
|
if (buySubject === 2) {
|
|
@@ -562,35 +574,29 @@ export default {
|
|
// 不展示合同金额
|
|
// 不展示合同金额
|
|
this.$set(m.props, 'showContractMoney', false)
|
|
this.$set(m.props, 'showContractMoney', false)
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (this.utilCheckIsVipService()) {
|
|
|
|
- this.getPriceRequest()
|
|
|
|
- } else {
|
|
|
|
- // 无法计算商品价格
|
|
|
|
- }
|
|
|
|
},
|
|
},
|
|
- dynamicChangeSchema() {
|
|
|
|
|
|
+ dynamicChangeSchema(value) {
|
|
// 注意:此处函数不允许异步动态修改props。可能会造成递归循环调用
|
|
// 注意:此处函数不允许异步动态修改props。可能会造成递归循环调用
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
const type = this.productType
|
|
const type = this.productType
|
|
if (type === productKeyMap.cjdy) {
|
|
if (type === productKeyMap.cjdy) {
|
|
- this.groupCjdySchema()
|
|
|
|
|
|
+ this.groupCjdySchema(value)
|
|
} else if (type === productKeyMap.dhy) {
|
|
} else if (type === productKeyMap.dhy) {
|
|
- this.changeDhySchema()
|
|
|
|
|
|
+ this.changeDhySchema(value)
|
|
} else if (productGroupKeyMap.oneSpecProduct.includes(type)) {
|
|
} else if (productGroupKeyMap.oneSpecProduct.includes(type)) {
|
|
- this.changeOneSpecSchema()
|
|
|
|
|
|
+ this.changeOneSpecSchema(value)
|
|
} else if (productGroupKeyMap.dataCountProduct.includes(type)) {
|
|
} else if (productGroupKeyMap.dataCountProduct.includes(type)) {
|
|
- this.changeDataPackSchema()
|
|
|
|
|
|
+ this.changeDataPackSchema(value)
|
|
} else if (
|
|
} else if (
|
|
productGroupKeyMap.marketingProduct.includes(type) ||
|
|
productGroupKeyMap.marketingProduct.includes(type) ||
|
|
productGroupKeyMap.ggProduct.includes(type) ||
|
|
productGroupKeyMap.ggProduct.includes(type) ||
|
|
productGroupKeyMap.entityProduct.includes(type)
|
|
productGroupKeyMap.entityProduct.includes(type)
|
|
) {
|
|
) {
|
|
- this.changeMarketingSchema()
|
|
|
|
|
|
+ this.changeMarketingSchema(value)
|
|
} else {
|
|
} else {
|
|
console.log('未配置更新规则')
|
|
console.log('未配置更新规则')
|
|
}
|
|
}
|
|
- this.checkSchemaRule()
|
|
|
|
|
|
+ this.checkSchemaRule(value)
|
|
})
|
|
})
|
|
},
|
|
},
|
|
commonGroupChangeSchema() {
|
|
commonGroupChangeSchema() {
|
|
@@ -655,6 +661,18 @@ export default {
|
|
// 1付费类型为“续费”,默认为关联订单的产品规格,不支持修改;
|
|
// 1付费类型为“续费”,默认为关联订单的产品规格,不支持修改;
|
|
// 2付费类型为“升级”且“升级内容”仅为“增购子账号”,默认为关联订单的产品规格,其他产品规格不展示;
|
|
// 2付费类型为“升级”且“升级内容”仅为“增购子账号”,默认为关联订单的产品规格,其他产品规格不展示;
|
|
// 3付费类型为“升级”且“升级内容”有“补充服务”或为空,仅可选择不低于关联订单的产品规格(注:特殊处理,大会员自定义版默认展示),其他产品规格不展示。
|
|
// 3付费类型为“升级”且“升级内容”有“补充服务”或为空,仅可选择不低于关联订单的产品规格(注:特殊处理,大会员自定义版默认展示),其他产品规格不展示。
|
|
|
|
+ if (payment === 2) {
|
|
|
|
+ // 续费,默认为关联订单的产品规格,不支持修改;
|
|
|
|
+ // 1. 恢复规格
|
|
|
|
+ // 2. 如果有已选中关联订单,禁用规格
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } else if (payment === 3) {
|
|
|
|
+ // 2付费类型为“升级”且“升级内容”仅为“增购子账号”,默认为关联订单的产品规格,其他产品规格不展示;
|
|
|
|
+ // 3付费类型为“升级”且“升级内容”有“补充服务”或为空,仅可选择不低于关联订单的产品规格(注:特殊处理,大会员自定义版默认展示),其他产品规格不展示。
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
ma.show = ma.props.options.length > 1
|
|
ma.show = ma.props.options.length > 1
|
|
},
|
|
},
|
|
cjdyChangeSpecificationSchema() {
|
|
cjdyChangeSpecificationSchema() {
|
|
@@ -663,10 +681,32 @@ export default {
|
|
// const ma = this.getSchemaItemWithKey(schemaKeyMap.payment)
|
|
// const ma = this.getSchemaItemWithKey(schemaKeyMap.payment)
|
|
},
|
|
},
|
|
onChangedFields(changedArr) {
|
|
onChangedFields(changedArr) {
|
|
- // 付费类型
|
|
|
|
- if (changedArr.includes(schemaKeyMap.payment)) {}
|
|
|
|
|
|
+ if (this.checkNeedRefreshPrice(changedArr)) {
|
|
|
|
+ this.getPriceRequest()
|
|
|
|
+ }
|
|
|
|
+ if (changedArr.includes('saleGifts')) {
|
|
|
|
+ // 销售策略变更,清空有效周期(通用规则)
|
|
|
|
+ this.refreshValue({ validityPeriod: {} })
|
|
|
|
+ }
|
|
console.log('以下字段变更了:', changedArr)
|
|
console.log('以下字段变更了:', changedArr)
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ checkNeedRefreshPrice(changedArr) {
|
|
|
|
+ const commonPassField = [
|
|
|
|
+ 'saleGifts',
|
|
|
|
+ schemaKeyMap.payment,
|
|
|
|
+ schemaKeyMap.specification,
|
|
|
|
+ 'validityPeriod',
|
|
|
|
+ ]
|
|
|
|
+
|
|
|
|
+ const type = this.productType
|
|
|
|
+ if (type === productKeyMap.dhy) {
|
|
|
|
+ commonPassField.push(schemaKeyMap.serviceList)
|
|
|
|
+ } else if (productGroupKeyMap.dataCountProduct.includes(type)) {
|
|
|
|
+ commonPassField.push(schemaKeyMap.validityCount)
|
|
|
|
+ }
|
|
|
|
+ const ins = this.getIntersection(commonPassField, changedArr)
|
|
|
|
+ return ins.length > 0
|
|
|
|
+ },
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|