Преглед изворни кода

feat: 优化价格计算精度

cuiyalong пре 3 месеци
родитељ
комит
50c809fd46

+ 2 - 2
src/store/order.js

@@ -13,7 +13,7 @@ import { checkRequired } from "@/views/create-order/hooks/checkRequired"
 import { getRandomString } from '@/utils/utils'
 import { cloneDeep } from "lodash"
 import { showMessage, showNotify } from '@/views/create-order/hooks/toast'
-import { add, calcDiscountRate } from '@/utils/number'
+import { add, sub, calcDiscountRate } from '@/utils/number'
 import { productKeyMap } from '@/views/create-order/data'
 
 class OrderProductCardItem {
@@ -236,7 +236,7 @@ export default {
     },
     salesMoneyTotal(state, getters) {
       // 销售业绩=合同金额-渠道佣金
-      return getters.pageTotalMoney.contract - state.pageForm.channelCommission
+      return sub(getters.pageTotalMoney.contract, state.pageForm.channelCommission)
     },
     // 预计回款金额
     exceptPaybackMoney(_, getters) {

+ 5 - 5
src/views/create-order/components/baseInfoModule.vue

@@ -1,14 +1,14 @@
 <template>
   <!-- 基本信息 -->
   <el-form ref="form" :model="form" :rules="rules" label-width="126px" class="order-base-info-container">
-    <el-form-item label="购买主体" prop="buySubject" :required="required.buySubject">
+    <el-form-item label="购买主体" :required="required.buySubject">
       <RadioGroup
         :value="form.buySubject"
         @input="onElInput($event, 'buySubject')"
         :options="conf.buySubjectOptions"
       />
     </el-form-item>
-    <el-form-item label="公司名称" prop="companyName" :required="companyRequired">
+    <el-form-item label="公司名称" :required="companyRequired">
       <el-input
         :value="form.companyName"
         @input="onElInput($event, 'companyName')"
@@ -19,7 +19,7 @@
     </el-form-item>
     <el-row :gutter="2">
       <el-col :span="12">
-        <el-form-item label="联系人姓名" prop="username">
+        <el-form-item label="联系人姓名">
           <el-input
             :value="form.username"
             @input="onElInput($event, 'username')"
@@ -30,7 +30,7 @@
         </el-form-item>
       </el-col>
       <el-col :span="12">
-        <el-form-item label="联系人手机号" prop="userTel" :required="required.userTel">
+        <el-form-item label="联系人手机号" :required="required.userTel">
           <el-input
             :value="form.userTel"
             @input="onElInput($event, 'userTel')"
@@ -43,7 +43,7 @@
     </el-row>
     <el-row :gutter="2">
       <el-col :span="12">
-        <el-form-item label="开通权益手机号" prop="accountTel" :required="required.accountTel">
+        <el-form-item label="开通权益手机号" :required="required.accountTel">
         <el-input
           :value="form.accountTel"
           @input="onElInput($event, 'accountTel')"

+ 9 - 5
src/views/create-order/components/product-info-submodule/AccountNumbers.vue

@@ -6,7 +6,7 @@
       @input="onInputChange"
       class="number-input"
       :disabled="disabled"
-      :placeholder="placeholder"
+      :placeholder="payInputPlaceholder"
       maxlength="3"
       :min="1"
     ></number-input>
@@ -18,7 +18,7 @@
         @input="onInputChange"
         :disabled="disabled"
         class="number-input"
-        :placeholder="placeholder"
+        :placeholder="freeInputPlaceholder"
         maxlength="3"
         :min="1"
       ></number-input>
@@ -50,7 +50,11 @@ export default {
       type: Number,
       default: 10,
     },
-    placeholder: {
+    payInputPlaceholder: {
+      type: String,
+      default: '请输入付费账号数量'
+    },
+    freeInputPlaceholder: {
       type: String,
       default: '请输入账号数量'
     },
@@ -74,8 +78,8 @@ export default {
     setState(e = {}) {
       if (!e) return
       const { payCount, freeCount } = e
-      this.payCount = payCount || 0
-      this.freeCount = freeCount || 0
+      this.payCount = payCount || ''
+      this.freeCount = freeCount || ''
     },
     getState() {
       return {

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

@@ -40,7 +40,7 @@
             @input="onNumberInputChange('free')"
             class="number-input"
             :readonly="disabled"
-            placeholder="请输入赠送周期"
+            placeholder="请输入有效周期"
             maxlength="3"
           ></number-input>
           <el-select

+ 37 - 2
src/views/create-order/components/schema-form/schema-form.vue

@@ -417,7 +417,7 @@ export default {
       } else {
         // 不展示合同金额
         this.$set(m.props, 'showContractMoney', false)
-        m.label = '标准售价'
+        m.label = ''
       }
     },
     // common: 通用修改付费类型相关逻辑
@@ -749,16 +749,44 @@ export default {
       this.commonChangeUpgradeContentSchema(value)
       // 产品规格
       this.commonChangeSpecificationSchema(value)
+      this.commonChangeValidityCountSchema()
     },
     changeDataPackSchema(value) {
       this.commonGroupChangeSchema(value)
       // 数据条数
       this.commonChangeValidityDataCount(value)
+      this.commonChangeValidityCountSchema()
     },
     changeMarketingSchema() {
       // 数据条数更新,重新查询价格
       this.getPriceRequest()
     },
+    // 数据条数
+    commonChangeValidityCountSchema(value = this.value) {
+      const m = this.getSchemaItemWithKey(schemaKeyMap.validityCount)
+      if (!m) {
+        return console.error('没找到schema: ', schemaKeyMap.validityCount)
+      }
+
+      const { saleGifts } = value
+      // 2.产品属性为“会员服务”:
+      if (this.utilCheckIsSourcePack()) {
+        m.show = true
+        // (1)销售策略为“售卖”:
+        if (saleGifts === 1) {
+          // 1)付费类型为购买、试用,展示如下图:
+          //  1 付费:文本框,非必填,仅可输入1和正整数,单位可选:月(初始值)、天
+          //  2 赠送:文本框,非必填,仅可输入0和正整数,单位同付费,不支持选择。
+          //  3  合计:付费+赠送,初始值为-,单位同付费,如若为0,则提示“请输入有效周期”;
+          this.$set(m.props, 'showPayInput', true)
+        } else if (saleGifts === 2) {
+          // 赠送
+          this.$set(m.props, 'showPayInput', false)
+        }
+      } else {
+        // m.show = false
+      }
+    },
     changeDhyServiceList(value = this.value || {}) {
       const ma = this.getSchemaItemWithKey(schemaKeyMap.serviceList)
       if (!ma) {
@@ -922,7 +950,14 @@ export default {
       }
       if (changedArr.includes('saleGifts')) {
         // 销售策略变更,清空有效周期(通用规则)
-        this.refreshValue({ validityPeriod: {} })
+        const obj = {}
+        if (this.value.validityPeriod) {
+          obj.validityPeriod = {}
+        }
+        if (this.value[schemaKeyMap.validityCount]) {
+          obj[schemaKeyMap.validityCount] = {}
+        }
+        this.refreshValue(obj)
       }
       if (changedArr.includes('saleGifts') || changedArr.includes(schemaKeyMap.specification)) {
         // 付费类型变更,如果有主账号数量,则清空