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

feat: 新增销售费用模块

cuiyalong 2 сар өмнө
parent
commit
73fd041931

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

@@ -4,7 +4,8 @@
       :value="value"
       @input="onInput"
       :readonly="disabled"
-      :min="1"
+      :min="min"
+      :decimal="decimal"
       class="number-input"
       :placeholder="placeholder"
       :maxlength="maxlength"
@@ -42,6 +43,15 @@ export default {
       type: String,
       default: '个',
     },
+    min: {
+      type: Number,
+      default: 1
+    },
+    // 保留n位小数
+    decimal: {
+      type: Number,
+      default: 0
+    },
   },
   methods: {
     onInput(e) {

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

@@ -277,7 +277,7 @@ export default {
       return {
         productTypeText: service.name || '-',
         empowerCountText: service.empowerCount ? `${service.empowerCount}个` : '-',
-        serviceEndTimeText: dateFormatter(service.serviceEndTime, 'yyyy-MM-dd'),
+        serviceEndTimeText: service.serviceEndTime ? dateFormatter(service.serviceEndTime, 'yyyy-MM-dd') : '-',
         buySubjectText: service.buySubject === 1 ? '个人' : '企业',
         phone: service.phone,
         short_phone: maskPhone(service.phone),

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

@@ -344,7 +344,7 @@ export function createContractAmountSchema({ state }) {
 }
 
 // 赠品数量
-export function createGiftNumSchema({ label } = {}) {
+export function createGiftNumSchema({ label, props } = {}) {
   return createSchemaItem({
     label: label || '赠品数量',
     key: 'giftNum',
@@ -352,6 +352,7 @@ export function createGiftNumSchema({ label } = {}) {
     component: CountNumber,
     changedSchema: true,
     required: true,
+    props: props || {}
   })
 }
 

+ 18 - 2
src/views/create-order/components/schema-form/products/marketing.js

@@ -10,8 +10,17 @@ import {
   createAdditionalRemarksSchema,
 } from './common'
 import { productGroupKeyMap } from '@/views/create-order/data'
+import { productKeyMap } from '@/views/create-order/data'
 
-
+function createXSFYSchema() {
+  const props = {
+    unitText: '元',
+    min: 0,
+    decimal: 2,
+    placeholder: '请输入销售费用'
+  }
+  return createGiftNumSchema({ label: '销售费用', props })
+}
 
 export function createMarketingSchemaList(conf) {
   const info = conf.info || {}
@@ -23,7 +32,14 @@ export function createMarketingSchemaList(conf) {
   }
 
   // 赠品数量
-  let giftNumSchema = productGroupKeyMap.entityProduct.includes(info.code) ? createGiftNumSchema() : undefined
+  let giftNumSchema = undefined
+  if (info.code === productKeyMap.xsfy) {
+    // 销售费用
+    giftNumSchema = createXSFYSchema()
+  } else {
+    giftNumSchema = productGroupKeyMap.entityProduct.includes(info.code) ? createGiftNumSchema() : undefined
+  }
+
   // 广告来源
   let ggSourceSchema = productGroupKeyMap.ggProduct.includes(info.code) ? createGGSourceSchema() : undefined
 

+ 14 - 4
src/views/create-order/components/schema-form/schema-form.vue

@@ -276,6 +276,7 @@ export default {
         'validityCount',
         'validityPeriod',
         'contractAmount',
+        'subAccountNumbers',
       ]
       const waitingRestoreForm = this.thisProductInfoListItem.productCardInfo?.waitingRestoreForm
       if (waitingRestoreForm && Object.keys(waitingRestoreForm).length > 0) {
@@ -819,7 +820,8 @@ export default {
         // 续费。取当前关联订单服务中的个数
         if (re && re.empowerCount) {
           // 赋值
-          const subAccountNumbers = { payCount: re.empowerCount }
+          const payCount = re.empowerCount - 1 <= 0 ? 1 : re.empowerCount - 1
+          const subAccountNumbers = { payCount }
           Object.assign(refreshObj, { subAccountNumbers })
           // 禁用
         }
@@ -1208,9 +1210,17 @@ export default {
           this.refreshValue({ subAccountNumbers })
         }
         // 清空合同金额
-        this.refreshValue({
-          [schemaKeyMap.contractAmount]: Object.assign({}, this.value[schemaKeyMap.contractAmount], { contractMoney: '', standardMoney: '' }) 
-        })
+        // 销售策略变为赠送,则合同金额默认值改为0
+        if (this.value.saleGifts === 2) {
+          // 1售卖  2赠送
+          this.refreshValue({
+            [schemaKeyMap.contractAmount]: Object.assign({}, this.value[schemaKeyMap.contractAmount], { contractMoney: '0' }) 
+          })
+        } else {
+          this.refreshValue({
+            [schemaKeyMap.contractAmount]: Object.assign({}, this.value[schemaKeyMap.contractAmount], { contractMoney: '', standardMoney: '' }) 
+          })
+        }
       }
 
       console.log(`以下字段变更了:${this.productType}`, changedArr)

+ 1 - 1
src/views/create-order/data/interface.js

@@ -26,7 +26,7 @@ export const defaultPageFormValue = {
 
   // 协议信息-电子协议
   e_contract_type: 1, // 电子协议类型
-  e_contract_userA_type: 1, // 协议甲方类型
+  e_contract_userA_type: 1, // 协议甲方类型 1个人 2企业
   e_contract_userA_name: '', // 协议甲方
   e_contract_userA_contacts_name: '', // 协议甲方联系人
   e_contract_userA_contacts_tel: '', // 协议甲方联系方式

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

@@ -27,6 +27,8 @@ export const productKeyMap = {
   ds: 'ds', // 打赏
 
   swzp: 'swzp', // 实物赠品
+  xnzp: 'xnzp', // 虚拟赠品
+  xsfy: 'xsfy', // 销售费用
 }
 
 // 产品分类分组
@@ -71,6 +73,8 @@ export const productGroupKeyMap = {
   // 实物
   entityProduct: [
     productKeyMap.swzp,
+    productKeyMap.xnzp,
+    productKeyMap.xsfy,
   ],
 }
 
@@ -110,6 +114,7 @@ export const productTypeMap = {
   kcfx: '课程分销',
   swzp: '实物赠品',
   xnzp: '虚拟赠品',
+  xsfy: '销售费用',
 }
 
 export const schemaKeyMap = {

+ 9 - 1
src/views/create-order/hooks/checkRequired.js

@@ -7,6 +7,7 @@ import store from '@/store'
 export async function checkRequired({ pageForm, productInfoList } = {}) {
   const p = pageForm
   const pInfoList = productInfoList
+  const showOnlineContractForm = store.getters['order/showOnlineContractForm']
 
   // 基本信息校验
   if (!p.buySubject) {
@@ -72,7 +73,7 @@ export async function checkRequired({ pageForm, productInfoList } = {}) {
   }
   // 协议信息校验
   // 区分是否要签电子协议(从store中取值)
-  const needESign = false // showOnlineContractForm 
+  const needESign = showOnlineContractForm // showOnlineContractForm 
   if (needESign) {
     // 如购买主体或甲方类型为“企业”,则公司名称必填
     const entMark = pageForm.buySubject === 2 || pageForm.e_contract_userA_type === 2
@@ -80,6 +81,13 @@ export async function checkRequired({ pageForm, productInfoList } = {}) {
       showMessage('公司名称必填')
       return
     }
+    // 如购买主体是个人,但是签约主体是企业,则企业名称必填
+    const personMark = pageForm.buySubject === 1 && pageForm.e_contract_userA_type === 2
+    if (personMark && !pageForm.companyName) {
+      showMessage('公司名称必填')
+      return
+    }
+
     if (!pageForm.e_contract_type) {
       showMessage('电子协议类型必填')
       return

+ 3 - 1
src/views/create-order/hooks/utils.js

@@ -2,6 +2,7 @@ import store from '@/store'
 import { SalePersonTableRow } from '@/views/create-order/data/interface'
 import { add, sub, div, calcDiscountRate } from '@/utils/number'
 import { productKeyMap } from '@/views/create-order/data'
+import { hasValue } from '@/utils/utils'
 
 // 生成无手机号函数
 export function createNoPhoneNumber() { 
@@ -155,7 +156,7 @@ export function getCardTotalAmount(moneyList) {
   let rate = ''
   moneyList.forEach(item => {
     let hc = item?.contractMoney
-    let check = hc !== undefined && hc !== '' && hc !== null
+    let check = hasValue(hc)
     hasContract = hasContract || check
 
     let c = Number(item?.contractMoney || 0)
@@ -189,6 +190,7 @@ export function getCardTotalAmount(moneyList) {
     contract,
     standard,
     rate,
+    // channelCommission, // 销售费用
   }
 }