Эх сурвалжийг харах

feat: 大会员产品信息逻辑完善

cuiyalong 4 сар өмнө
parent
commit
c3c4b386f7

+ 13 - 8
src/store/order.js

@@ -248,11 +248,11 @@ export default {
       const productLength = getters.userProductInfoList.length
       let productCheck = false
       if (productLength === 1) {
-        const productForm = getters.userProductInfoList[0]?.productCardInfo?.form || {}
-        const productCode = getters.userProductInfoList[0]?.productCardInfo?.result?.productType
+        const productForm = getters.userProductInfoList[0]
+        const productCode = productForm?.productSpecification
         // 售卖 && 购买/续费/试用  才可以
         const passPaymentTypeArr = [1, 2, 4]
-        const salePass = passPaymentTypeArr.includes(productForm.paymentType)
+        const salePass = passPaymentTypeArr.includes(productForm?.paymentType)
         // 6:dyh002:商机版2.0、7:dyh003:专家版2.30190:dyh004:商机版2.0(单省版)
         // 以上几种才可以创建电子协议
         const passProductTypeArr = ['dyh002', 'dyh003', 'dyh004']
@@ -455,11 +455,16 @@ export default {
     },
     async getPrice({ state, commit }, payload = {}) {
       const { type, productInfo } = payload
-      const params = orderParams(type).priceParams({
-        pageForm: state.pageForm,
-        productInfo,
-        type,
-      })
+      let params = {}
+      try {
+        params = orderParams(type).priceParams({
+          pageForm: state.pageForm,
+          productInfo,
+          type,
+        })
+      } catch (error) {
+        console.log(type, error)
+      }
       if (!params) return
       commit('setLoadingState', { key: 'price', value: true })
       try {

+ 12 - 11
src/views/create-order/components/product-info-submodule/ServiceList.vue

@@ -24,9 +24,9 @@
                       {{ sc.label }}
                       <el-select
                         v-if="Array.isArray(sc.options) && sc.options.length > 1"
-                        v-model="sc.selected"
+                        :value="sc.selected"
                         class="el-select-w120"
-                        @change="onSelectedChange"
+                        @input="onSelectedChange(sc, $event)"
                         :disabled="disabled || !sc.checked"
                         size="mini"
                         :placeholder="'0' + sc.optionsUnit">
@@ -380,6 +380,7 @@ export default {
                 disabled: item.disabled,
               }
             }).filter(item => !item.hide).sort((a, b) => a.s_count_year - b.s_count_year)
+            obj.optionsValueList = obj.options.map(r => r.value)
 
             // 3. 数据获取和赋值问题
 
@@ -450,7 +451,8 @@ export default {
     onScCheckboxChange(sc, e) {
       sc.checked = e
     },
-    onSelectedChange() {
+    onSelectedChange(sc, e) {
+      sc.selected = e
       this.onChange()
     },
     onChange() {
@@ -481,7 +483,7 @@ export default {
     },
     getState() {
       const { selectedInfoList } = this.getSelected()
-      return selectedInfoList.map(s => s.value)
+      return selectedInfoList.map(s => s.selected)
     },
     setState(selectedIds = []) {
       const target = selectedIds
@@ -489,10 +491,11 @@ export default {
       this.serviceList.forEach(service => {
         const childrenValue = []
         service.children.forEach(serve => {
-          const value = serve.value
-          if (target.includes(value)) {
-            childrenValue.push(value)
+          const t = serve.options.find(item => target.includes(item.value))
+          if (t) {
+            childrenValue.push(t.value)
             serve.checked = true
+            serve.selected = t.value
           }
         })
         service.childrenValue = childrenValue
@@ -502,14 +505,12 @@ export default {
       const target = disabledIds
       if (!Array.isArray(target)) return
       this.serviceList.forEach(service => {
-        const childrenValue = []
         service.children.forEach(serve => {
-          const value = serve.value
-          if (target.includes(value)) {
+          const t = serve.options.find(item => target.includes(item.value))
+          if (t) {
             serve.disabled = true
           }
         })
-        service.childrenValue = childrenValue
       })
     },
     splitChunkWith(list, fn) {

+ 2 - 1
src/views/create-order/components/schema-form/params.js

@@ -4,6 +4,7 @@ import { schemaKeyMap, productKeyMap } from '@/views/create-order/data'
 import { mul } from '@/utils/number'
 
 import { SvipParamsGroup } from './params/svip'
+import { BigMemberParamsGroup } from './params/bigmember'
 import { dateFormatter } from '@/utils/globalFun'
 // import { SalePersonTableRow, PayBackTableRow } from '@/views/create-order/data/interface'
 
@@ -13,7 +14,7 @@ export function orderParams (type) {
   if (type === productKeyMap.cjdy) {
     return new SvipParamsGroup(type)
   } else if (type === productKeyMap.dhy) {
-    return console.log(123)
+    return new BigMemberParamsGroup(type)
   }
 }
 

+ 39 - 3
src/views/create-order/components/schema-form/params/base.js

@@ -1,5 +1,41 @@
+import { getCommonParams, getCommonFilterParams } from "./common";
+import { productTypeMap } from '@/views/create-order/data'
+
 export class Parameters {
-  priceParams() {}
+  // 价格接口参数
+  priceParams({ pageForm, productInfo, type } = {}) {
+    // 参数为productArr中的某一项
+    const params = this.getProductArrParams({ pageForm, productInfo, type })
+  
+    if (!params.phone) return
+    if (!params.productType) return
+    if (!params.product_code) return
+    if (!params.filter?.buy_cycle) return
+    if (!params.filter?.buy_type) return
+  
+    return params
+  }
+
+  // 接口文档:http://172.31.31.204:4001/project/346/interface/api/3856
+  // BuyAccountCount  int `json:"buyAccountCount"`  //购买数量(仅购买主体是企业,个人版不需要)
+  // GiftAccountCount int `json:"giftAccountCount"` //赠送数量(仅购买主体是企业,个人版不需要)
+  // BuyCycle         int `json:"buy_cycle"`        //购买周期
+  // BuyType          int `json:"buy_type"`         //购买周期 类型 1天 2月 3年 4季度
+  // GiftCycle        int `json:"give_cycle"`       //赠送周期
+  // GiftType         int `json:"give_type"`        //赠送周期 类型 1天 2月 3年 4季度
+  // Supplement       string `json:"supplement" doc:"补充服务"`
+  getProductArrParams({ pageForm, productInfo, type }) {
+    const commonParams = getCommonParams(pageForm, productInfo)
+    const productForm = productInfo?.productCardInfo?.form || {}
+    const p = {
+      productType: productTypeMap[type],
+      ...commonParams,
+    }
+
+    const filter = getCommonFilterParams({ pageForm, productForm })
+
+    p.filter = filter
 
-  getProductArrParams() {}
-}
+    return p
+  }
+}

+ 66 - 0
src/views/create-order/components/schema-form/params/bigmember.js

@@ -0,0 +1,66 @@
+import { Parameters } from './base'
+import { getCommonParams, getCommonFilterParams } from "./common";
+import { productTypeMap } from '@/views/create-order/data'
+import store from '@/store'
+
+export class BigMemberParamsGroup extends Parameters {
+
+  constructor(type) {
+    super()
+    this.type = type
+  }
+
+  // 接口文档:http://172.31.31.204:4001/project/346/interface/api/3856
+  // ComboId          int `json:"comboId"`
+  // BuyAccountCount  int `json:"buyAccountCount"`  //购买数量
+  // GiftAccountCount int `json:"giftAccountCount"` //赠送数量
+
+  // BuyCycle   int      `json:"buy_cycle"`  //购买周期
+  // BuyType    int      `json:"buy_type"`   //购买周期 类型 1天 2月 3年 4季度
+  // GiftCycle  int      `json:"give_cycle"` //赠送周期
+  // GiftType   int      `json:"give_type"`  //赠送周期 类型 1天 2月 3年 4季度
+  // ServiceIds []string `json:"serviceIds"` //服务id
+
+  // SupServiceIds     []string `json:"supServiceIds"`
+  // FinalAccountCount int      `json:"finalAccountCount"` //当前套餐最终
+  // FinalAreaCount    int      `json:"finalAreaCount"`
+
+  getProductArrParams({ pageForm, productInfo, type }) {
+    const commonParams = getCommonParams(pageForm, productInfo)
+    const productForm = productInfo?.productCardInfo?.form || {}
+    const p = {
+      productType: productTypeMap[type],
+      ...commonParams,
+    }
+
+    const comboId = this.getComboId(commonParams.product_code)
+    const commonFilter = getCommonFilterParams({ pageForm, productForm })
+    const filter = {
+      ...commonFilter,
+      comboId,
+      serviceIds: productForm.serviceList,
+    }
+
+    // filter.SupServiceIds = productForm.SupServiceIds
+
+    p.filter = filter
+
+    return p
+  }
+
+  getComboId(productType) {
+    const bigServiceInfo = store.state.order.conf.bigServiceInfo || {}
+    if (Array.isArray(bigServiceInfo.comboLists) && bigServiceInfo.customService) {
+      const specList = bigServiceInfo.comboLists.concat(bigServiceInfo.customService)
+      const target = specList.filter(r => !!r).find(item => item.code === productType)
+      if (target) {
+        return target.id
+      }
+    }
+  }
+}
+
+
+
+
+

+ 14 - 0
src/views/create-order/components/schema-form/params/common.js

@@ -39,3 +39,17 @@ export function getCommonParams(pageForm, productInfo) {
     paybackOpenServer,
   }
 }
+
+export function getCommonFilterParams({ pageForm, productForm } = {}) {
+  const filter = {}
+  if (pageForm.buySubject === 2) {
+    // 企业版
+    filter.buyAccountCount = productForm.subAccountNumbers?.payCount
+    filter.giftAccountCount = productForm.subAccountNumbers?.freeCount
+  }
+  filter.buy_cycle = productForm.validityPeriod?.payCount
+  filter.buy_type = productForm.validityPeriod?.payUnit
+  filter.give_cycle = productForm.validityPeriod?.freeCount || 0
+  filter.give_type = productForm.validityPeriod?.freeUnit
+  return filter
+}

+ 9 - 0
src/views/create-order/components/schema-form/params/rmgl.js

@@ -0,0 +1,9 @@
+import { Parameters } from './base'
+
+export class RMGLParamsGroup extends Parameters {
+
+  constructor(type) {
+    super()
+    this.type = type
+  }
+}

+ 0 - 50
src/views/create-order/components/schema-form/params/svip.js

@@ -1,60 +1,10 @@
 import { Parameters } from './base'
-import { getCommonParams } from "./common";
-import { schemaKeyMap, productTypeMap } from '@/views/create-order/data'
 
 export class SvipParamsGroup extends Parameters {
-
   constructor(type) {
     super()
     this.type = type
   }
-  // 价格接口参数
-  priceParams({ pageForm, productInfo, type } = {}) {
-    // 参数为productArr中的某一项
-    const params = this.getProductArrParams({ pageForm, productInfo, type })
-  
-    if (!params.phone) return
-    if (!params.productType) return
-    if (!params.product_code) return
-    if (!params.filter?.buy_cycle) return
-    if (!params.filter?.buy_type) return
-  
-    return params
-  }
-
-  // 接口文档:http://172.31.31.204:4001/project/346/interface/api/3856
-  // 计算价格的方法
-  // BuyAccountCount  int `json:"buyAccountCount"`  //购买数量(仅购买主体是企业,个人版不需要)
-  // GiftAccountCount int `json:"giftAccountCount"` //赠送数量(仅购买主体是企业,个人版不需要)
-  // BuyCycle         int `json:"buy_cycle"`        //购买周期
-  // BuyType          int `json:"buy_type"`         //购买周期 类型 1天 2月 3年 4季度
-  // GiftCycle        int `json:"give_cycle"`       //赠送周期
-  // GiftType         int `json:"give_type"`        //赠送周期 类型 1天 2月 3年 4季度
-  // Supplement       string `json:"supplement" doc:"补充服务"`
-  getProductArrParams({ pageForm, productInfo, type }) {
-    const commonParams = getCommonParams(pageForm, productInfo)
-      const productForm = productInfo?.productCardInfo?.form || {}
-      const p = {
-        productType: productTypeMap[type],
-        ...commonParams,
-      }
-
-      const filter = {}
-      if (pageForm.buySubject === 2) {
-        // 企业版
-        filter.buyAccountCount = productForm.subAccountNumbers?.payCount
-        filter.giftAccountCount = productForm.subAccountNumbers?.freeCount
-      }
-      filter.buy_cycle = productForm.validityPeriod?.payCount
-      filter.buy_type = productForm.validityPeriod?.payUnit
-      filter.give_cycle = productForm.validityPeriod?.freeCount || 0
-      filter.give_type = productForm.validityPeriod?.freeUnit
-      // filter.supplement = productForm.supplement
-
-      p.filter = filter
-
-      return p
-  }
 }
 
 

+ 0 - 1
src/views/create-order/components/schema-form/products/bigmember.js

@@ -63,7 +63,6 @@ function createServiceListSchema({ state } = {}) {
 export function createBigMemberSchemaList(conf) {
   const info = conf.info || {}
   const state = conf.state || {}
-  console.log(info)
   
   let schema = connectArr(
     // 销售策略、付费类型、关联订单

+ 61 - 0
src/views/create-order/components/schema-form/products/rmgl.js

@@ -0,0 +1,61 @@
+import {
+  connectArr,
+  createSchemaItem,
+  createMainSubAccountSchema,
+  createValidityPeriodSchema,
+  createContractAmountSchema,
+  createCommonSchemaList,
+} from './common'
+import RadioGroup from '@/views/create-order/components/product-info-submodule/RadioGroup'
+import {
+  schemaKeyMap,
+} from '@/views/create-order/data'
+
+function createProductSpecificationSchema({ info, state }) {
+  let options = []
+  if (Array.isArray(info.product_list)) {
+    options = info.product_list.map(p => {
+      return {
+        ...p,
+        label: p.name,
+        value: p.code,
+        disabled: false,
+      }
+    })
+  }
+  const validateArr = options
+  const key = schemaKeyMap.specification
+  const defaultValue = validateArr[0].value
+
+  return createSchemaItem({
+    show: false, // 规格只有一项,不展示,默认选中
+    label: '产品规格',
+    key,
+    className: 'product-specification',
+    component: RadioGroup,
+    defaultValue: state[key] || defaultValue,
+    required: true,
+    props: {
+      options: validateArr,
+    }
+  })
+}
+
+export function createRMGLSchemaList(conf) {
+  const info = conf.info || {}
+  const state = conf.state || {}
+  
+  let schema = connectArr(
+    // 销售策略、付费类型、关联订单
+    createCommonSchemaList({ info, state }),
+    // 商品规格
+    createProductSpecificationSchema({ info, state }),
+    // 主子账号
+    createMainSubAccountSchema(),
+    // 有效周期
+    createValidityPeriodSchema(),
+    // 合同金额
+    createContractAmountSchema({ info, state }),
+  )
+  return schema
+}

+ 33 - 25
src/views/create-order/components/schema-form/schema-form.vue

@@ -216,13 +216,7 @@ export default {
       const needChange = this.needChangeSchema()
       if (!needChange) return
       this.$nextTick(() => {
-        // 注意:此处函数不允许异步动态修改props。会造成递归循环调用
-        if (this.productType === productKeyMap.cjdy) {
-          this.groupCjdySchema()
-        } else if (this.productType === productKeyMap.dhy) {
-          this.changeDhySchema()
-        }
-        this.checkSchemaRule()
+        this.dynamicChangeSchema()
       })
     }, 10),
     getPriceRequest: debounce(async function getPrice(p) {
@@ -496,18 +490,22 @@ export default {
         // 无法计算商品价格
       }
     },
-    // 组合以及定制:超级订阅规则
-    groupCjdySchema() {
+    dynamicChangeSchema() {
+      // 注意:此处函数不允许异步动态修改props。会造成递归循环调用
+      if (this.productType === productKeyMap.cjdy) {
+        this.groupCjdySchema()
+      } else if (this.productType === productKeyMap.dhy) {
+        this.changeDhySchema()
+      } else if (this.productType === productKeyMap.rmgl) {
+        this.changeRMGLSchema()
+      }
+      this.checkSchemaRule()
+    },
+    commonGroupChangeSchema() {
       // 付费类型相关调整
       this.commonChangePaymentSchema()
       // 关联订单
       this.commonChangeRelateOrderSchema()
-      // 升级内容
-      this.commonChangeUpgradeContentSchema()
-      // 产品规格
-      this.commonChangeSpecificationSchema()
-      // 续费升级
-      this.cjdyChangeSpecificationSchema()
       // 账号数量
       this.commonChangeAccountNumberSchema()
       // 服务周期
@@ -515,12 +513,19 @@ export default {
       // 合同金额
       this.commonChangeContractAmount()
     },
+    // 组合以及定制:超级订阅规则
+    groupCjdySchema() {
+      this.commonGroupChangeSchema()
+      // 升级内容
+      this.commonChangeUpgradeContentSchema()
+      // 产品规格
+      this.commonChangeSpecificationSchema()
+      // 续费升级
+      this.cjdyChangeSpecificationSchema()
+    },
     // 组合以及定制:大会员规则
     changeDhySchema() {
-      // 付费类型相关调整
-      this.commonChangePaymentSchema()
-      // 关联订单
-      this.commonChangeRelateOrderSchema()
+      this.commonGroupChangeSchema()
       // 升级内容
       this.commonChangeUpgradeContentSchema()
       // 产品规格
@@ -528,12 +533,15 @@ export default {
       // this.dhyChangeSpecificationSchema()
       // 服务列表
       this.changeDhyServiceList()
-      // 账号数量
-      this.commonChangeAccountNumberSchema()
-      // 服务周期
-      // this.commonChangeValidityPeriod()
-      // 合同金额
-      // this.commonChangeContractAmount()
+    },
+    changeRMGLSchema() {
+      this.commonGroupChangeSchema()
+      // 升级内容
+      this.commonChangeUpgradeContentSchema()
+      // 产品规格
+      this.commonChangeSpecificationSchema()
+      // 续费升级
+      this.cjdyChangeSpecificationSchema()
     },
     changeDhyServiceList() {
       const ma = this.getSchemaItemWithKey(schemaKeyMap.serviceList)

+ 3 - 0
src/views/create-order/components/schema-form/schema.js

@@ -1,5 +1,6 @@
 import { createSvipSchemaList } from './products/svip'
 import { createBigMemberSchemaList } from './products/bigmember'
+import { createRMGLSchemaList } from './products/rmgl'
 import { schemaKeyMap, productKeyMap } from '@/views/create-order/data'
 
 // 生成规则
@@ -14,6 +15,8 @@ export function createSchemaListWithType(conf = {}) {
     schemaList = createSvipSchemaList(conf)
   } else if (type === productKeyMap.dhy) {
     schemaList = createBigMemberSchemaList(conf)
+  } else if (type === productKeyMap.rmgl) {
+    schemaList = createRMGLSchemaList(conf)
   }
   return schemaList
 }

+ 1 - 0
src/views/create-order/data/var.js

@@ -3,6 +3,7 @@ export const ActivityProductName = '活动产品'
 export const productKeyMap = {
   cjdy: 'cjdy', // 超级订阅
   dhy: 'dyh', // 大会员
+  rmgl: 'rmgl', // 人脉管理
 }
 
 export const productTypeMap = {