Commit 61140f45 by cen

feat: 更新订单策略组件以支持新订单类型和价格计算

- 在 OrderPopup 中添加新的字段 `searchValue` 和 `noData`,以增强组件功能
- 修改 OrderStrategy 组件,支持折扣、买赠和组合付款策略的显示和计算
- 在 SkuGoods 组件中集成 OrderStrategy,确保价格计算逻辑与订单类型一致
- 更新样式以改善组件布局和用户体验
1 parent 0ed2a431
...@@ -386,7 +386,9 @@ const componentConfig = { ...@@ -386,7 +386,9 @@ const componentConfig = {
// 绑定 CreateOrder 中的字段名 // 绑定 CreateOrder 中的字段名
idKey: 'djOrderType', idKey: 'djOrderType',
cacheData: [], cacheData: [],
loadComplete: false loadComplete: false,
searchValue: '',
noData: false
} }
} }
export default { componentConfig } export default { componentConfig }
...@@ -347,7 +347,7 @@ export default { ...@@ -347,7 +347,7 @@ export default {
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: toRpx(24) toRpx(24) 0 toRpx(24); padding: toRpx(24) toRpx(24) 0 toRpx(24);
border-top: toRpx(2) solid #ebedf0; border-top: toRpx(2) dashed #ebedf0;
box-sizing: border-box; box-sizing: border-box;
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<view class="goods-item" v-for="(goods, ind) in item.packageGoods.goodsList" :key="ind"> <view class="goods-item" v-for="(goods, ind) in item.packageGoods.goodsList" :key="ind">
<view class="goods-name">{{ goods.goodsAlias || goods.upgradeGoodsName }}</view> <view class="goods-name">{{ goods.goodsAlias || goods.upgradeGoodsName }}</view>
<!-- <view class="alias-name">商品别名:阿尔法 T5极狐非三电整车延保(新车2年6万公里)</view> --> <!-- <view class="alias-name">商品别名:阿尔法 T5极狐非三电整车延保(新车2年6万公里)</view> -->
<view class="front-gear-box"> <view class="front-gear-box pb-24">
<view class="front-gear-input-box"> <view class="front-gear-input-box">
<!-- <view class="front-gear-label" v-if="goods.merchantGoodsPosition || goods.goodsInfo.goodsTypeName">{{goods.goodsInfo.goodsType===1?formatPosition(goods.merchantGoodsPosition, positionTypeList):goods.goodsInfo.goodsTypeName}}</view> --> <!-- <view class="front-gear-label" v-if="goods.merchantGoodsPosition || goods.goodsInfo.goodsTypeName">{{goods.goodsInfo.goodsType===1?formatPosition(goods.merchantGoodsPosition, positionTypeList):goods.goodsInfo.goodsTypeName}}</view> -->
<view class="front-gear-input"> <view class="front-gear-input">
......
...@@ -2,56 +2,58 @@ ...@@ -2,56 +2,58 @@
<view> <view>
<view class="shop-list"> <view class="shop-list">
<view class="shop-item" v-for="(item, index) in list" :key="index"> <view class="shop-item" v-for="(item, index) in list" :key="index">
<view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view> <view class="flex flex-1 pb-24">
<view class="right"> <view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view>
<view class="shop-name">商品名称:{{ item.multipleSpecificationsGoods ? item.multipleSpecificationsGoods.baseGoodsName : item.goods.goodsAlias || item.goods.upgradeGoodsName || item.goods.goodsInfo.goodsName }}</view> <view class="right">
<view class="alias" v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.goodsAlias">商品别名:{{ item.multipleSpecificationsGoods.goods.goodsAlias }}</view> <view class="shop-name">商品名称:{{ item.multipleSpecificationsGoods ? item.multipleSpecificationsGoods.baseGoodsName : item.goods.goodsAlias || item.goods.upgradeGoodsName || item.goods.goodsInfo.goodsName }}</view>
<view class="front-gear-box"> <view class="alias" v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.goodsAlias">商品别名:{{ item.multipleSpecificationsGoods.goods.goodsAlias }}</view>
<view class="front-gear-input-box"> <view class="front-gear-box">
<template v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.specificationStr"> <view class="front-gear-input-box">
<view class="front-gear-label"> <template v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.specificationStr">
{{ item.multipleSpecificationsGoods.goods.specificationStr }}
</view>
</template>
<template v-if="item.goods">
<template v-if="(item.goods.merchantGoodsPosition || item.goods.upgradeGoodsPosition) && (item.goods.goodsInfo.goodsType == 1 || item.goods.upgradeGoodsType == 1 || item.goods.goodsInfo.goodsType == baseConfigData.selfBuildFilmType || item.goods.upgradeGoodsType == baseConfigData.selfBuildFilmType)">
<view class="front-gear-label"> <view class="front-gear-label">
{{ formatPosition(item.goods.merchantGoodsPosition || item.goods.upgradeGoodsPosition, positionTypeList) }} {{ item.multipleSpecificationsGoods.goods.specificationStr }}
</view> </view>
</template> </template>
<template v-if="(item.goods.goodsInfo.goodsType == 1 || item.goods.upgradeGoodsType == 1) && !item.goods.merchantGoodsPosition && !item.goods.upgradeGoodsPosition">无部位属性</template> <template v-if="item.goods">
</template> <template v-if="(item.goods.merchantGoodsPosition || item.goods.upgradeGoodsPosition) && (item.goods.goodsInfo.goodsType == 1 || item.goods.upgradeGoodsType == 1 || item.goods.goodsInfo.goodsType == baseConfigData.selfBuildFilmType || item.goods.upgradeGoodsType == baseConfigData.selfBuildFilmType)">
<view class="front-gear-input"> <view class="front-gear-label">
<view class="unit">¥</view> {{ formatPosition(item.goods.merchantGoodsPosition || item.goods.upgradeGoodsPosition, positionTypeList) }}
<template v-if="item.multipleSpecificationsGoods"> </view>
<input class="uni-input" type="digit" maxlength="9" :disabled="isDisabled" placeholder="请输入价格" placeholder-style="font-size: 14px" v-model="item.multipleSpecificationsGoods.goods.sellPrice" @blur="validatePrice($event, item, index)" /> </template>
</template> <template v-if="(item.goods.goodsInfo.goodsType == 1 || item.goods.upgradeGoodsType == 1) && !item.goods.merchantGoodsPosition && !item.goods.upgradeGoodsPosition">无部位属性</template>
<template v-else>
<input class="uni-input" type="digit" :disabled="isDisabled" maxlength="9" placeholder="请输入价格" placeholder-style="font-size: 14px" v-model="item.goods.sellPrice" @blur="validatePrice($event, item, index)" />
</template> </template>
<!-- <input class="uni-input" type="digit" maxlength="9" placeholder="请输入价格" <view class="front-gear-input">
<view class="unit">¥</view>
<template v-if="item.multipleSpecificationsGoods">
<input class="uni-input" type="digit" maxlength="9" :disabled="isDisabled" placeholder="请输入价格" placeholder-style="font-size: 14px" v-model="item.multipleSpecificationsGoods.goods.sellPrice" @blur="validatePrice($event, item, index)" />
</template>
<template v-else>
<input class="uni-input" type="digit" :disabled="isDisabled" maxlength="9" placeholder="请输入价格" placeholder-style="font-size: 14px" v-model="item.goods.sellPrice" @blur="validatePrice($event, item, index)" />
</template>
<!-- <input class="uni-input" type="digit" maxlength="9" placeholder="请输入价格"
placeholder-style="font-size: 14px" placeholder-style="font-size: 14px"
:value="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods ? item.multipleSpecificationsGoods.goods.sellPrice : item.goods.sellPrice" :value="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods ? item.multipleSpecificationsGoods.goods.sellPrice : item.goods.sellPrice"
@blur="validatePrice($event, item, index)" /> --> @blur="validatePrice($event, item, index)" /> -->
</view>
</view> </view>
</view> <view class="control">
<view class="control"> <view class="minus" @click="decreaseNumber(item)">-</view>
<view class="minus" @click="decreaseNumber(item)">-</view> <template v-if="item.multipleSpecificationsGoods">
<template v-if="item.multipleSpecificationsGoods"> <input class="uni-input control-input" type="number" maxlength="3" v-model="item.multipleSpecificationsGoods.number" @blur="validateNumber($event, item)" />
<input class="uni-input control-input" type="number" maxlength="3" v-model="item.multipleSpecificationsGoods.number" @blur="validateNumber($event, item)" /> </template>
</template> <template v-else>
<template v-else> <input class="uni-input control-input" type="number" maxlength="3" v-model="item.goods.number" @blur="validateNumber($event, item)" />
<input class="uni-input control-input" type="number" maxlength="3" v-model="item.goods.number" @blur="validateNumber($event, item)" /> </template>
</template> <!-- <input class="uni-input control-input" type="number" maxlength="3"
<!-- <input class="uni-input control-input" type="number" maxlength="3"
:value="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods ? item.multipleSpecificationsGoods.goods.number : item.goods.number" :value="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods ? item.multipleSpecificationsGoods.goods.number : item.goods.number"
@blur="validateNumber($event, item)" /> --> @blur="validateNumber($event, item)" /> -->
<view class="add" @click="increaseNumber(item)">+</view> <view class="add" @click="increaseNumber(item)">+</view>
</view>
</view> </view>
</view> </view>
<!-- 折扣 / 买赠 / 组合付款策略组件 -->
<OrderStrategy v-if="getStrategyType(item)" :strategyType="getStrategyType(item)" :value="getStrategyConfig(item)" :basePrice="getBasePrice(item)" :displayPrice="getDisplayPrice(item)" @input="onStrategyConfigChange(item, $event)" @priceChange="onPriceChange(item, $event)" />
</view> </view>
<!-- 折扣 / 买赠 / 组合付款策略组件 -->
<OrderStrategy v-if="getStrategyType(item)" :strategyType="getStrategyType(item)" :value="getStrategyConfig(item)" :basePrice="getBasePrice(item)" :displayPrice="getDisplayPrice(item)" @input="onStrategyConfigChange(item, $event)" @priceChange="onPriceChange(item, $event)" />
</view> </view>
</view> </view>
</view> </view>
...@@ -458,8 +460,6 @@ export default { ...@@ -458,8 +460,6 @@ export default {
padding: toRpx(12) toRpx(32) toRpx(12) 0; padding: toRpx(12) toRpx(32) toRpx(12) 0;
.shop-item { .shop-item {
display: flex;
align-items: center;
background-color: #f5f7fa; background-color: #f5f7fa;
border-radius: toRpx(16); border-radius: toRpx(16);
margin-bottom: toRpx(16); margin-bottom: toRpx(16);
......
<template> <template>
<view class="order"> <view class="order">
<view <view :class="['order-box', { hide: showUpload }]" :key="formKey">
:class="['order-box',{hide:showUpload}]"
:key="formKey"
>
<view class="common-title">车险信息</view> <view class="common-title">车险信息</view>
<view class="box"> <view class="box">
<scroll-view <scroll-view class="scroll-view" scroll-y="true">
class="scroll-view"
scroll-y="true"
>
<view class="box-content"> <view class="box-content">
<GlCell <GlCell :formList="formList" :formData="orderObj" @radioChange="radioChange" @inputBlur="inputBlur" @handleCell="handleCell" :titleList="titleList">
:formList="formList"
:formData="orderObj"
@radioChange="radioChange"
@inputBlur="inputBlur"
@handleCell="handleCell"
:titleList="titleList"
>
<template slot="customer"> <template slot="customer">
<view class="customer-title flex"> <view class="customer-title flex">
客户信息 客户信息
<view <view
class="customer-file flex" class="customer-file flex"
@click="handleCell({ @click="
key:'customer' handleCell({
})" key: 'customer'
})
"
> >
<view class="sprite-icon icon-customer-list"></view> <view class="sprite-icon icon-customer-list"></view>
客户档案 客户档案
...@@ -35,12 +24,7 @@ ...@@ -35,12 +24,7 @@
</template> </template>
<template slot="skuGoods"> <template slot="skuGoods">
<template v-if="orderObj.skuGoods.length"> <template v-if="orderObj.skuGoods.length">
<SkuGoods <SkuGoods :list="orderObj.skuGoods" @changeTotalPrice="changeTotalPrice" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode"></SkuGoods>
:list="orderObj.skuGoods"
@changeTotalPrice="changeTotalPrice"
:positionTypeList="positionTypeList"
:baseConfigData="baseConfigData"
></SkuGoods>
</template> </template>
<template v-if="orderObj.total > 0"> <template v-if="orderObj.total > 0">
<view class="total"> <view class="total">
...@@ -50,50 +34,26 @@ ...@@ -50,50 +34,26 @@
</template> </template>
</template> </template>
<template slot="otherPay"> <template slot="otherPay">
<view <view v-if="showPayTips" class="pay-tips">其他收款:当客户已向嘀加付款但无法使用流水补录时,新建工单应选择收款方为「嘀加收款」且支付方为「其他收款」。</view>
v-if="showPayTips"
class="pay-tips"
>其他收款:当客户已向嘀加付款但无法使用流水补录时,新建工单应选择收款方为「嘀加收款」且支付方为「其他收款」。</view>
</template> </template>
</GlCell> </GlCell>
</view> </view>
<view class="btns flex"> <view class="btns flex">
<view <view class="btn save" @click="handleEditSave">存草稿</view>
class="btn save" <view @click="submit" class="btn">{{ confirmText }}</view>
@click="handleEditSave"
>存草稿</view>
<view
@click="submit"
class="btn"
>{{confirmText}}</view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
</view> </view>
<!-- 弹窗 --> <!-- 弹窗 -->
<order-popup <order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" :popupTitle="popupTitle" />
ref="orderPopup"
:data="orderObj"
:dataKey="valueKey"
@onConfirm="onConfirm"
:externalData="externalData"
:popupType="popupType"
:popupTitle="popupTitle"
/>
<template v-if="showUpload"> <template v-if="showUpload">
<view class="upload-box"> <view class="upload-box">
<upload-proof-of-payment <upload-proof-of-payment @back="clearPayMentDocList" @confirm="uploadConfirm" />
@back="clearPayMentDocList"
@confirm="uploadConfirm"
/>
</view> </view>
</template> </template>
<!-- 支付弹框 --> <!-- 支付弹框 -->
<OrderPay <OrderPay ref="OrderPay" @closePopup="closePopup" @jumpSuccess="jumpSuccess" />
ref="OrderPay"
@closePopup="closePopup"
@jumpSuccess="jumpSuccess"
/>
</view> </view>
</template> </template>
...@@ -131,19 +91,20 @@ export default { ...@@ -131,19 +91,20 @@ export default {
}, },
watch: { watch: {
'orderObj.payee': { 'orderObj.payee': {
handler (val) { handler(val) {
this.formList[4].map(e => { this.formList[4].map(e => {
if (e.value == 'pay2Time') e.label = { if (e.value == 'pay2Time')
0: '嘀加收款时间', e.label = {
1: '4S店收款时间' 0: '嘀加收款时间',
}[val] 1: '4S店收款时间'
}[val]
}) })
}, },
immediate: true, immediate: true,
deep: true deep: true
}, },
'orderObj.payType': { 'orderObj.payType': {
handler (val) { handler(val) {
this.formList[4].map(e => { this.formList[4].map(e => {
if (e.value == 'notes') e.required = val == 7 if (e.value == 'notes') e.required = val == 7
if (e.value == 'pay2Time') e.hidden = ![2, 5, 6, 7].includes(+val) if (e.value == 'pay2Time') e.hidden = ![2, 5, 6, 7].includes(+val)
...@@ -153,7 +114,7 @@ export default { ...@@ -153,7 +114,7 @@ export default {
deep: true deep: true
}, },
transmissionOfData: { transmissionOfData: {
handler (val) { handler(val) {
const paramsData = val?.paramsData || {} const paramsData = val?.paramsData || {}
if (paramsData && paramsData.id) this.paramsData = paramsData if (paramsData && paramsData.id) this.paramsData = paramsData
}, },
...@@ -161,7 +122,7 @@ export default { ...@@ -161,7 +122,7 @@ export default {
immediate: true immediate: true
} }
}, },
data () { data() {
return { return {
paramsData: {}, paramsData: {},
saveStatus: false, saveStatus: false,
...@@ -176,13 +137,13 @@ export default { ...@@ -176,13 +137,13 @@ export default {
insurancePrice: '', insurancePrice: '',
skuGoods: [], //商品列表 skuGoods: [], //商品列表
referrerId: '', //销售顾问id referrerId: '', //销售顾问id
referrer: '',//销售顾问名称 referrer: '', //销售顾问名称
deliveryId: '',//交付专员id deliveryId: '', //交付专员id
deliveryName: '',//交付专员名称 deliveryName: '', //交付专员名称
total: '',//总价 total: '', //总价
notes: '',//备注 notes: '', //备注
carSeriesId: '', //车系id carSeriesId: '', //车系id
seat: '5',//座位数 seat: '5', //座位数
ownerGender: '男', ownerGender: '男',
salesType: '0', salesType: '0',
carInfo: {}, carInfo: {},
...@@ -204,29 +165,27 @@ export default { ...@@ -204,29 +165,27 @@ export default {
formKey: Date.now(), formKey: Date.now(),
validateState: true validateState: true
} }
}, },
computed: { computed: {
showPayTips () { showPayTips() {
return this.orderObj.payee == 0 && this.orderObj.payType == 7 return this.orderObj.payee == 0 && this.orderObj.payType == 7
}, },
confirmText () { confirmText() {
return [1, 3].includes(+this.orderObj.payType) ? '下一步·去支付' : '下一步·上传凭证' return [1, 3].includes(+this.orderObj.payType) ? '下一步·去支付' : '下一步·上传凭证'
}, },
userInfo () { userInfo() {
return uni.$storage.get('userInfo') || {} return uni.$storage.get('userInfo') || {}
} }
}, },
mounted () { mounted() {
this.baseConfigData = uni.$storage.get('mock_data') || {} this.baseConfigData = uni.$storage.get('mock_data') || {}
this.initData() this.initData()
}, },
methods: { methods: {
async getQuotationInfoById (id) { async getQuotationInfoById(id) {
try { try {
let { goodsList: quotationGoodsList } = this, data = await uni.$api.equityApi.getQuotationInfoById({ id }), let { goodsList: quotationGoodsList } = this,
data = await uni.$api.equityApi.getQuotationInfoById({ id }),
{ orderObj } = this, { orderObj } = this,
{ owner, insurancePrice, quotedPriceUpdate } = data { owner, insurancePrice, quotedPriceUpdate } = data
uni.hideLoading() uni.hideLoading()
...@@ -234,12 +193,10 @@ export default { ...@@ -234,12 +193,10 @@ export default {
orderObj.insurancePrice = this.divideByHundred(insurancePrice) orderObj.insurancePrice = this.divideByHundred(insurancePrice)
orderObj.quotedPriceUpdate = this.divideByHundred(quotedPriceUpdate) orderObj.quotedPriceUpdate = this.divideByHundred(quotedPriceUpdate)
if (!data.vdQuotationGoodsList) data.vdQuotationGoodsList = [] if (!data.vdQuotationGoodsList) data.vdQuotationGoodsList = []
orderObj.vdQuotationGoodsList = data.vdQuotationGoodsList.map( orderObj.vdQuotationGoodsList = data.vdQuotationGoodsList.map(item => {
item => { item.price = this.divideByHundred(item.goodsPrice)
item.price = this.divideByHundred(item.goodsPrice) return item
return item })
}
)
if (!owner.ownerGender) owner.ownerGender = '男' if (!owner.ownerGender) owner.ownerGender = '男'
if (owner.carSeriesId) { if (owner.carSeriesId) {
orderObj.carInfo = { orderObj.carInfo = {
...@@ -248,7 +205,7 @@ export default { ...@@ -248,7 +205,7 @@ export default {
carChildsBrandId: owner.carChildsBrandId, carChildsBrandId: owner.carChildsBrandId,
carChildsBrandName: owner.carChildsBrandName, carChildsBrandName: owner.carChildsBrandName,
carSeriesId: owner.carSeriesId, carSeriesId: owner.carSeriesId,
carSeriesName: owner.carSeriesName, carSeriesName: owner.carSeriesName
} }
orderObj.carBrandText = `${owner.carBrand}-${owner.carChildsBrandName}-${owner.carSeriesName}` orderObj.carBrandText = `${owner.carBrand}-${owner.carChildsBrandName}-${owner.carSeriesName}`
} }
...@@ -276,12 +233,8 @@ export default { ...@@ -276,12 +233,8 @@ export default {
upgradeGoodsId: item.goodsId, upgradeGoodsId: item.goodsId,
merchantGoodsId: item.goodsId, merchantGoodsId: item.goodsId,
sellPrice: this.divideByHundred(item.goodsPrice), sellPrice: this.divideByHundred(item.goodsPrice),
minSellPrice: quotationGoodsList?.find( minSellPrice: quotationGoodsList?.find(val => val?.goods?.merchantGoodsId == item.goodsId)?.goods?.minSellPrice, // 按商品数据对比补充详情商品最低价
val => val?.goods?.merchantGoodsId == item.goodsId validMinSellPrice: quotationGoodsList?.find(val => val?.goods?.merchantGoodsId == item.goodsId)?.goods?.validMinSellPrice // 按商品数据对比补充详情商品校验最低价字段
)?.goods?.minSellPrice, // 按商品数据对比补充详情商品最低价
validMinSellPrice: quotationGoodsList?.find(
val => val?.goods?.merchantGoodsId == item.goodsId
)?.goods?.validMinSellPrice // 按商品数据对比补充详情商品校验最低价字段
} }
pre.push({ pre.push({
goodsFlag: 1, goodsFlag: 1,
...@@ -297,24 +250,8 @@ export default { ...@@ -297,24 +250,8 @@ export default {
upgradeGoodsId: item.goodsId, upgradeGoodsId: item.goodsId,
sellPrice: this.divideByHundred(item.goodsPrice), sellPrice: this.divideByHundred(item.goodsPrice),
number: 1, number: 1,
minSellPrice: quotationGoodsList minSellPrice: quotationGoodsList?.find(val => val.packageGoods?.goodsList?.length && val.packageGoods?.packageCode == item?.packageId)?.packageGoods?.goodsList?.find(subV => subV.merchantGoodsId == item.goodsId)?.minSellPrice, // 按商品数据对比补充详情商品最低价
?.find( validMinSellPrice: quotationGoodsList?.find(val => val.packageGoods?.goodsList?.length && val.packageGoods?.packageCode == item?.packageId)?.packageGoods?.goodsList?.find(subV => subV.merchantGoodsId == item.goodsId)?.validMinSellPrice // 按商品数据对比补充详情商品校验最低价字段
val =>
val.packageGoods?.goodsList?.length &&
val.packageGoods?.packageCode == item?.packageId
)
?.packageGoods?.goodsList?.find(
subV => subV.merchantGoodsId == item.goodsId
)?.minSellPrice, // 按商品数据对比补充详情商品最低价
validMinSellPrice: quotationGoodsList
?.find(
val =>
val.packageGoods?.goodsList?.length &&
val.packageGoods?.packageCode == item?.packageId
)
?.packageGoods?.goodsList?.find(
subV => subV.merchantGoodsId == item.goodsId
)?.validMinSellPrice // 按商品数据对比补充详情商品校验最低价字段
} }
let index = pre.findIndex(ele => { let index = pre.findIndex(ele => {
if (ele.packageGoods) { if (ele.packageGoods) {
...@@ -332,9 +269,11 @@ export default { ...@@ -332,9 +269,11 @@ export default {
packageGoods: { packageGoods: {
...item, ...item,
packageCode: item.packageId, packageCode: item.packageId,
goodsList: [{ goodsList: [
...obj {
}] ...obj
}
]
} }
}) })
} }
...@@ -348,10 +287,8 @@ export default { ...@@ -348,10 +287,8 @@ export default {
return pre return pre
}, []) }, [])
let keyList = ['mode', 'payee', 'payType', 'referrerId', 'referrer', let keyList = ['mode', 'payee', 'payType', 'referrerId', 'referrer', 'deliveryId', 'deliveryName', 'notes', 'id', 'orderId'],
'deliveryId', 'deliveryName', 'notes', 'id', 'orderId' customerKeyList = ['owner', 'phone', 'certificateNo', 'carVin', 'seat', , 'ownerGender', 'ageRange', 'hobby', 'companion', 'carColor', 'salesType', 'city']
], customerKeyList = ['owner', 'phone', 'certificateNo', 'carVin', 'seat', ,
'ownerGender', 'ageRange', 'hobby', 'companion', 'carColor', 'salesType', 'city']
keyList.map(key => { keyList.map(key => {
if (data[key] != null) orderObj[key] = data[key] if (data[key] != null) orderObj[key] = data[key]
}) })
...@@ -367,17 +304,17 @@ export default { ...@@ -367,17 +304,17 @@ export default {
setTimeout(() => { setTimeout(() => {
this.changeTotalPrice() this.changeTotalPrice()
}, 0) }, 0)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
uni.hideLoading() uni.hideLoading()
if (error) uni.showToast({ if (error)
title: error, uni.showToast({
icon: 'none', title: error,
}) icon: 'none'
})
} }
}, },
initData () { initData() {
// 埋点 // 埋点
// uni.$track.add({ eventCode: 'app_create_order' }) // uni.$track.add({ eventCode: 'app_create_order' })
const { paramsData } = this const { paramsData } = this
...@@ -386,7 +323,7 @@ export default { ...@@ -386,7 +323,7 @@ export default {
this.getShopMerchantPointConfig() this.getShopMerchantPointConfig()
this.orderSettingList() this.orderSettingList()
}, },
async orderSettingList () { async orderSettingList() {
const { shopMerchantId } = this.userInfo, const { shopMerchantId } = this.userInfo,
params = { params = {
scene: 0, scene: 0,
...@@ -401,35 +338,39 @@ export default { ...@@ -401,35 +338,39 @@ export default {
} }
return pre return pre
}, []) }, [])
if (required.includes('carBrand')) this.formList[2].map(e => { if (required.includes('carBrand'))
if (e.value == 'carBrandText') e.required = true this.formList[2].map(e => {
}) if (e.value == 'carBrandText') e.required = true
if (required.includes('carNo')) this.formList[2].map(e => { })
if (e.value == 'carVin') e.required = true if (required.includes('carNo'))
}) this.formList[2].map(e => {
if (required.includes('idNumber')) this.formList[1].map(e => { if (e.value == 'carVin') e.required = true
if (e.value == 'certificateNo') e.required = true })
}) if (required.includes('idNumber'))
this.formList[1].map(e => {
if (e.value == 'certificateNo') e.required = true
})
} }
}, },
async getShopMerchantPointConfig () { async getShopMerchantPointConfig() {
const { shopMerchantId: merchantId } = this.userInfo, const { shopMerchantId: merchantId } = this.userInfo,
{ pointsMultiRole } = await uni.$api.equityApi.getShopMerchantPointConfig({ { pointsMultiRole } = await uni.$api.equityApi.getShopMerchantPointConfig({
merchantId merchantId
}) })
this.pointsMultiRole = pointsMultiRole this.pointsMultiRole = pointsMultiRole
if (pointsMultiRole != 'Y') this.formList[0].map(e => { if (pointsMultiRole != 'Y')
if (e.value == 'deliveryName') e.hidden = true this.formList[0].map(e => {
if (e.value == 'referrer') e.label = '推荐人' if (e.value == 'deliveryName') e.hidden = true
}) if (e.value == 'referrer') e.label = '推荐人'
})
}, },
// 选择行事件 // 选择行事件
handleCell (val) { handleCell(val) {
let { payType } = this.orderObj, let { payType } = this.orderObj,
{ pointsMultiRole } = this { pointsMultiRole } = this
this.popupTitle = '' this.popupTitle = ''
// 获取当前选中的popupType // 获取当前选中的popupType(使用 val.value 来匹配,因为表单配置中的 value 对应 popupTypeEnum 中的 key)
this.popupType = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.key) * 1 this.popupType = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.value) * 1
// 获取对应的list字段 // 获取对应的list字段
const popupConfig = this.popupTypeEnum[this.popupType] const popupConfig = this.popupTypeEnum[this.popupType]
if (popupConfig && popupConfig.list) { if (popupConfig && popupConfig.list) {
...@@ -448,15 +389,20 @@ export default { ...@@ -448,15 +389,20 @@ export default {
4: '车型', 4: '车型',
13: payType == 2 ? '4S店收款时间' : '嘀加收款时间' 13: payType == 2 ? '4S店收款时间' : '嘀加收款时间'
}[this.popupType] }[this.popupType]
this.$refs.orderPopup.open() // 确保 orderPopup 引用存在后再调用 open 方法
if (this.$refs.orderPopup && this.$refs.orderPopup.open) {
this.$refs.orderPopup.open()
} else {
console.error('OrderPopup ref is not available')
}
}, },
// 单选框change事件 // 单选框change事件
radioChange (e, val) { radioChange(e, val) {
this.$set(this.orderObj, val.value, e.detail.value) this.$set(this.orderObj, val.value, e.detail.value)
if (val.value == 'payee') this.changePayee() if (val.value == 'payee') this.changePayee()
}, },
// 弹窗确认回调 // 弹窗确认回调
onConfirm (val, flag) { onConfirm(val, flag) {
console.log(JSON.parse(JSON.stringify(val)), 'onConfirm') console.log(JSON.parse(JSON.stringify(val)), 'onConfirm')
this.externalData = [] this.externalData = []
// // const { chooseContent } = val // // const { chooseContent } = val
...@@ -467,14 +413,17 @@ export default { ...@@ -467,14 +413,17 @@ export default {
// 定义产品相关字段数组 // 定义产品相关字段数组
if (val.popupType == 19) return this.setCustomerInfo(chooseContent) if (val.popupType == 19) return this.setCustomerInfo(chooseContent)
const productFields = ['skuGoods'] const productFields = ['skuGoods']
if (_typeValue.key == 'carBrand') { if (_typeValue.key == 'djOrderType') {
// 订单类型
this.$set(this.orderObj, 'djOrderType', chooseContent.name)
this.$set(this.orderObj, 'orderTypeCode', chooseContent.value)
} else if (_typeValue.key == 'carBrand') {
// 车型 // 车型
this.$set(this.orderObj, 'carBrandText', `${chooseContent.carBrand}-${chooseContent.carChildsBrandName}-${chooseContent.carSeriesName}`) this.$set(this.orderObj, 'carBrandText', `${chooseContent.carBrand}-${chooseContent.carChildsBrandName}-${chooseContent.carSeriesName}`)
Object.assign(this.orderObj, { Object.assign(this.orderObj, {
carInfo: chooseContent carInfo: chooseContent
}) })
} } else if (productFields.includes(_typeValue.key)) {
else if (productFields.includes(_typeValue.key)) {
if (_typeValue.key == 'skuGoods') { if (_typeValue.key == 'skuGoods') {
if (!this.orderObj.skuGoods) { if (!this.orderObj.skuGoods) {
// 其他精品第一次赋值 // 其他精品第一次赋值
...@@ -496,8 +445,7 @@ export default { ...@@ -496,8 +445,7 @@ export default {
setTimeout(() => { setTimeout(() => {
this.changeTotalPrice() this.changeTotalPrice()
}, 0) }, 0)
} } else {
else {
if (_typeValue.key == 'city') { if (_typeValue.key == 'city') {
this.$set(this.orderObj, 'provinceText', chooseContent.province) this.$set(this.orderObj, 'provinceText', chooseContent.province)
this.$set(this.orderObj, 'cityText', chooseContent.city) this.$set(this.orderObj, 'cityText', chooseContent.city)
...@@ -513,7 +461,7 @@ export default { ...@@ -513,7 +461,7 @@ export default {
console.log(this.orderObj) console.log(this.orderObj)
}, },
// 输入框失去焦点事件 // 输入框失去焦点事件
inputBlur (e, val) { inputBlur(e, val) {
console.log(e, val) console.log(e, val)
if (val.value == 'price') { if (val.value == 'price') {
this.orderObj[val.value] = parseFloat(this.orderObj[val.value]) > 2000000 ? 2000000 : this.orderObj[val.value] this.orderObj[val.value] = parseFloat(this.orderObj[val.value]) > 2000000 ? 2000000 : this.orderObj[val.value]
...@@ -523,23 +471,25 @@ export default { ...@@ -523,23 +471,25 @@ export default {
// VIN车架号动态校验:车架号字段,动态转换为大写 // VIN车架号动态校验:车架号字段,动态转换为大写
if (val.value === 'carVin') this.validateVin() if (val.value === 'carVin') this.validateVin()
}, },
validateVin () { validateVin() {
let carVinVal = this.orderObj.carVin; let carVinVal = this.orderObj.carVin
if (carVinVal) { if (carVinVal) {
this.orderObj.carVin = formatVinInput(carVinVal) this.orderObj.carVin = formatVinInput(carVinVal)
validateVin(this.orderObj.carVin).then(result => { validateVin(this.orderObj.carVin)
console.log("validateVin", result); .then(result => {
let { valid } = result.data; console.log('validateVin', result)
this.validateState = valid let { valid } = result.data
// 校验成功,所有提示已在公共方法中处理 this.validateState = valid
console.log('车架号校验成功:', result) // 校验成功,所有提示已在公共方法中处理
}).catch(err => { console.log('车架号校验成功:', result)
console.log("validateVinErr", result); })
}) .catch(err => {
console.log('validateVinErr', result)
})
} }
}, },
// 校验必填等规则 // 校验必填等规则
checkRequired () { checkRequired() {
try { try {
const phoneRex = /^[1]([3-9])[0-9]{9}$/, const phoneRex = /^[1]([3-9])[0-9]{9}$/,
requiredArr = [], requiredArr = [],
...@@ -556,7 +506,7 @@ export default { ...@@ -556,7 +506,7 @@ export default {
}) })
// VIN车架号-动态校验 // VIN车架号-动态校验
const carVin = this.orderObj.carVin const carVin = this.orderObj.carVin
console.log("validateState", this.validateState); console.log('validateState', this.validateState)
if (carVin) { if (carVin) {
// 前置判断 // 前置判断
if (carVin.length !== 17) { if (carVin.length !== 17) {
...@@ -593,27 +543,25 @@ export default { ...@@ -593,27 +543,25 @@ export default {
if (orderObj.certificateNo && orderObj.certificateNo.length != 18) throw '请输入正确的18位证件号' if (orderObj.certificateNo && orderObj.certificateNo.length != 18) throw '请输入正确的18位证件号'
return true return true
} catch (error) { } catch (error) {
if (error) uni.showToast({ if (error)
title: error, uni.showToast({
icon: 'none' title: error,
}) icon: 'none'
})
return false return false
} }
}, },
// 提交 // 提交
async submit () { async submit() {
if (!this.checkRequired() || await this.checkDailyReport()) return if (!this.checkRequired() || (await this.checkDailyReport())) return
this.handleSecondConfirmCheck(true) this.handleSecondConfirmCheck(true)
}, },
async handleSecondConfirmCheck (check) { async handleSecondConfirmCheck(check) {
try { try {
let orderInfo = this.getInsurance(), let orderInfo = this.getInsurance(),
{ payType } = orderInfo { payType } = orderInfo
if (check && if (check && [2, 5, 6, 7].includes(+payType) && !(orderInfo.transactionNo && orderInfo.paymentDocList.length)) return (this.showUpload = true)
([2, 5, 6, 7].includes(+payType)) &&
!(orderInfo.transactionNo && orderInfo.paymentDocList.length)
) return this.showUpload = true
if (orderInfo.pay2Time && ![1, 3].includes(+payType)) orderInfo.pay2Time = dayjs(orderInfo.pay2Time).format('YYYY-MM-DD HH:mm:ss') if (orderInfo.pay2Time && ![1, 3].includes(+payType)) orderInfo.pay2Time = dayjs(orderInfo.pay2Time).format('YYYY-MM-DD HH:mm:ss')
else delete orderInfo.pay2Time else delete orderInfo.pay2Time
...@@ -646,7 +594,7 @@ export default { ...@@ -646,7 +594,7 @@ export default {
} }
}, },
createWithPay (id) { createWithPay(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let para = { let para = {
id, id,
...@@ -658,96 +606,72 @@ export default { ...@@ -658,96 +606,72 @@ export default {
}) })
}) })
}, },
getInsurance () { getInsurance() {
let { let { orderObj, userInfo } = this,
orderObj,
userInfo
} = this,
orderInfo = utils.deepClone(orderObj), orderInfo = utils.deepClone(orderObj),
{ { default4SStoreInfo } = userInfo,
default4SStoreInfo
} = userInfo,
params = { params = {
owner: { owner: {
...orderInfo.carInfo ...orderInfo.carInfo
} }
} }
if (orderInfo.id) params.id = orderInfo.id if (orderInfo.id) params.id = orderInfo.id
params.merchantId4s = default4SStoreInfo?.merchantId params.merchantId4s = default4SStoreInfo?.merchantId
params.merchantName4s = default4SStoreInfo?.merchantName params.merchantName4s = default4SStoreInfo?.merchantName
orderInfo.price = this.multipliedByHundred(orderInfo.price) orderInfo.price = this.multipliedByHundred(orderInfo.price)
params.insurancePrice = this.multipliedByHundred( params.insurancePrice = this.multipliedByHundred(orderInfo.insurancePrice)
orderInfo.insurancePrice params.quotedPriceUpdate = this.multipliedByHundred(orderInfo.quotedPriceUpdate)
) params.minEquityPrice = this.multipliedByHundred(orderInfo.minEquityPrice)
params.quotedPriceUpdate = this.multipliedByHundred( params.vdQuotationGoodsList = orderInfo.skuGoods.reduce((pre, item) => {
orderInfo.quotedPriceUpdate if (item.goods) {
) item = item.goods
params.minEquityPrice = this.multipliedByHundred( const obj = {
orderInfo.minEquityPrice goodsId: item.merchantGoodsId,
) goodsName: item.goodsName,
params.vdQuotationGoodsList = orderInfo.skuGoods.reduce( goodsNameAlias: item.goodsAlias || item.goodsNameAlias,
(pre, item) => { specificationsName: item.specificationNameSequence,
if (item.goods) { specificationsValue: item.specificationData ? item.specificationData.replace(/;~;/g, '/') : '',
item = item.goods goodsPrice: this.multipliedByHundred(item.sellPrice)
}
pre.push(obj)
}
if (item.packageGoods) {
item = item.packageGoods
item.goodsList.map(ele => {
let obj = {
packageId: item.packageCode,
packageName: item.packageName,
packageNameAlias: item.packageAlias || item.packageNameAlias,
goodsId: ele.merchantGoodsId || ele.upgradeGoodsId,
goodsName: ele.upgradeGoodsName || ele.goodsName,
goodsNameAlias: ele.goodsAlias || ele.goodsNameAlias,
specificationsName: ele.specificationNameSequence,
specificationsValue: ele.specificationData ? ele.specificationData.replace(/;~;/g, '/') : '',
// specificationsValue: item.specificationData ? item.specificationData.replace(reg, ' ') : '',
goodsPrice: this.multipliedByHundred(ele.sellPrice)
}
pre.push(obj)
})
}
if (item.multipleSpecificationsGoods) {
if (item.multipleSpecificationsGoods.goods) {
item = item.multipleSpecificationsGoods.goods
const obj = { const obj = {
goodsId: item.merchantGoodsId, goodsId: item.merchantGoodsId,
goodsName: item.goodsName, goodsName: item.upgradeGoodsName || item.goodsName,
goodsNameAlias: item.goodsAlias || item.goodsNameAlias, goodsNameAlias: item.goodsAlias || item.goodsNameAlias,
specificationsName: item.specificationNameSequence, specificationsName: item.specificationNameSequence,
specificationsValue: item.specificationData ? specificationsValue: item.specificationData ? item.specificationData.replace(/;~;/g, '/') : '',
item.specificationData.replace(/;~;/g, '/') : '',
goodsPrice: this.multipliedByHundred(item.sellPrice) goodsPrice: this.multipliedByHundred(item.sellPrice)
} }
pre.push(obj) pre.push(obj)
} }
}
if (item.packageGoods) { return pre
item = item.packageGoods }, [])
item.goodsList.map(ele => { let keyList = ['mode', 'payee', 'payType', 'referrerId', 'referrer', 'deliveryId', 'deliveryName', 'total', 'notes', 'tradeNo', 'transactionNo', 'paymentDocList', 'id', 'orderId', 'pay2Time'],
let obj = { customerKeyList = ['owner', 'phone', 'certificateNo', 'carVin', 'seat', 'price', 'ownerGender', 'city', 'ageRange', 'hobby', 'companion', 'carColor', 'salesType']
packageId: item.packageCode,
packageName: item.packageName,
packageNameAlias: item.packageAlias || item.packageNameAlias,
goodsId: ele.merchantGoodsId || ele.upgradeGoodsId,
goodsName: ele.upgradeGoodsName || ele.goodsName,
goodsNameAlias: ele.goodsAlias || ele.goodsNameAlias,
specificationsName: ele.specificationNameSequence,
specificationsValue: ele.specificationData ?
ele.specificationData.replace(/;~;/g, '/') : '',
// specificationsValue: item.specificationData ? item.specificationData.replace(reg, ' ') : '',
goodsPrice: this.multipliedByHundred(ele.sellPrice)
}
pre.push(obj)
})
}
if (item.multipleSpecificationsGoods) {
if (item.multipleSpecificationsGoods.goods) {
item = item.multipleSpecificationsGoods.goods
const obj = {
goodsId: item.merchantGoodsId,
goodsName: item.upgradeGoodsName || item.goodsName,
goodsNameAlias: item.goodsAlias || item.goodsNameAlias,
specificationsName: item.specificationNameSequence,
specificationsValue: item.specificationData ?
item.specificationData.replace(/;~;/g, '/') : '',
goodsPrice: this.multipliedByHundred(item.sellPrice)
}
pre.push(obj)
}
}
return pre
},
[]
)
let keyList = ['mode', 'payee', 'payType', 'referrerId', 'referrer',
'deliveryId', 'deliveryName', 'total', 'notes', 'tradeNo',
'transactionNo', 'paymentDocList', 'id', 'orderId', 'pay2Time'
],
customerKeyList = [
'owner', 'phone', 'certificateNo', 'carVin', 'seat', 'price',
'ownerGender', 'city', 'ageRange', 'hobby', 'companion', 'carColor', 'salesType'
]
keyList.map(key => { keyList.map(key => {
if (orderInfo[key] != null) params[key] = orderInfo[key] if (orderInfo[key] != null) params[key] = orderInfo[key]
}) })
...@@ -758,7 +682,7 @@ export default { ...@@ -758,7 +682,7 @@ export default {
return params return params
}, },
// 乘以100保留两位小数点 // 乘以100保留两位小数点
multipliedByHundred (str) { multipliedByHundred(str) {
let floatVal = parseFloat(str) let floatVal = parseFloat(str)
if (isNaN(floatVal)) { if (isNaN(floatVal)) {
return 0 return 0
...@@ -776,8 +700,12 @@ export default { ...@@ -776,8 +700,12 @@ export default {
return parseFloat(strVal) return parseFloat(strVal)
}, },
// 计算所有产品的总价 // 计算所有产品的总价
changeTotalPrice () { changeTotalPrice() {
let total = 0 let total = 0
const orderType = String(this.orderObj.orderTypeCode || '')
// 判断是否使用优惠后的价格:'2' 打折策略、'3' 买赠策略、'5' 组合付款使用优惠后的价格
const useFinalPrice = orderType === '2' || orderType === '3' || orderType === '5'
// 遍历所有商品 // 遍历所有商品
const productFields = ['skuGoods'] const productFields = ['skuGoods']
productFields.forEach(slotName => { productFields.forEach(slotName => {
...@@ -785,17 +713,43 @@ export default { ...@@ -785,17 +713,43 @@ export default {
if (Array.isArray(productList) && productList.length > 0) { if (Array.isArray(productList) && productList.length > 0) {
// 计算每个产品的价格 * 数量,并累加到总价 // 计算每个产品的价格 * 数量,并累加到总价
productList.forEach(item => { productList.forEach(item => {
// 单个商品(goodsFlag == 1)
if (item.goods && item.goods.sellPrice && item.goods.number) { if (item.goods && item.goods.sellPrice && item.goods.number) {
console.log(item.goods, '---单商品') console.log(item.goods, '---单商品')
total = NP.plus(total, NP.times(item.goods.sellPrice, item.goods.number)) if (useFinalPrice && item.goods.finalPrice !== undefined && item.goods.finalPrice !== null) {
} else if (item.packageGoods && item.packageGoods.totalPrice) { // 使用优惠后的价格(单位是分,需要转换为元)
total = NP.plus(total, item.goods.finalPrice / 100)
} else {
// 使用原始价格
total = NP.plus(total, NP.times(item.goods.sellPrice, item.goods.number))
}
}
// 套餐商品(goodsFlag == 3)
else if (item.packageGoods && item.packageGoods.goodsList) {
console.log(item.packageGoods, '套餐') console.log(item.packageGoods, '套餐')
item.packageGoods.goodsList.map(i => { const packageNumber = parseInt(item.packageGoods.number || 1)
total = NP.plus(total, i.sellPrice * i.number) item.packageGoods.goodsList.forEach(goods => {
if (useFinalPrice && goods.finalPrice !== undefined && goods.finalPrice !== null) {
// 使用优惠后的价格(单位是分,需要转换为元)
// finalPrice 已经是单价优惠后 × 套餐数量,所以直接使用
total = NP.plus(total, goods.finalPrice / 100)
} else {
// 使用原始价格
total = NP.plus(total, NP.times(goods.sellPrice, packageNumber))
}
}) })
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice) { }
// 多规格商品(goodsFlag == 2)
else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice) {
console.log(item.multipleSpecificationsGoods, '多规格') console.log(item.multipleSpecificationsGoods, '多规格')
total = NP.plus(total, NP.times(item.multipleSpecificationsGoods.goods.sellPrice, item.multipleSpecificationsGoods.number || 1)) const goods = item.multipleSpecificationsGoods.goods
if (useFinalPrice && goods.finalPrice !== undefined && goods.finalPrice !== null) {
// 使用优惠后的价格(单位是分,需要转换为元)
total = NP.plus(total, goods.finalPrice / 100)
} else {
// 使用原始价格
total = NP.plus(total, NP.times(goods.sellPrice, item.multipleSpecificationsGoods.number || 1))
}
} }
}) })
} }
...@@ -806,7 +760,7 @@ export default { ...@@ -806,7 +760,7 @@ export default {
}, },
// 获取园区店支付方式 // 获取园区店支付方式
async getConfig () { async getConfig() {
this.djPayList = [ this.djPayList = [
{ {
value: '1', value: '1',
...@@ -819,15 +773,17 @@ export default { ...@@ -819,15 +773,17 @@ export default {
{ {
name: '其它收款', name: '其它收款',
value: '7' value: '7'
}, }
]
this.merchantPayList = [
{
value: '2',
name: '门店收款'
}
] ]
this.merchantPayList = [{
value: '2',
name: '门店收款'
},]
this.changePayee() this.changePayee()
}, },
changePayee () { changePayee() {
const cell = this.formList[4].find(item => item.value === 'payType'), const cell = this.formList[4].find(item => item.value === 'payType'),
{ payType } = this.orderObj { payType } = this.orderObj
if (cell) { if (cell) {
...@@ -842,12 +798,13 @@ export default { ...@@ -842,12 +798,13 @@ export default {
} }
}, },
// 商品列表 // 商品列表
async getSelectOrderGoodsList () { async getSelectOrderGoodsList() {
const { userInfo, paramsData } = this const { userInfo, paramsData } = this
if (paramsData.id) uni.showLoading({ if (paramsData.id)
title: '加载中...', uni.showLoading({
mask: true title: '加载中...',
}) mask: true
})
const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({ const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({
merchantId: userInfo.shopMerchantId, merchantId: userInfo.shopMerchantId,
sceneType: userInfo.sceneType sceneType: userInfo.sceneType
...@@ -856,23 +813,21 @@ export default { ...@@ -856,23 +813,21 @@ export default {
this.changeTotalPrice() this.changeTotalPrice()
if (paramsData.id) this.getQuotationInfoById(paramsData.id) if (paramsData.id) this.getQuotationInfoById(paramsData.id)
}, },
handleSpecificationsEcho (item) { handleSpecificationsEcho(item) {
console.log('item', item) console.log('item', item)
let { let { goodsList: quotationGoodsList } = this,
goodsList: quotationGoodsList skuArr = [],
} = this, skuArr = [],
arr = item.specificationsValue.split('/'), arr = item.specificationsValue.split('/'),
str = arr.join(';~;'); str = arr.join(';~;')
quotationGoodsList.forEach(data => { quotationGoodsList.forEach(data => {
if (data.goodsFlag == 2) { if (data.goodsFlag == 2) {
let tempData = data.multipleSpecificationsGoods.specificationGoodsMap[str] let tempData = data.multipleSpecificationsGoods.specificationGoodsMap[str]
if (tempData) { if (tempData) {
tempData.forEach(temp => { tempData.forEach(temp => {
if (temp.merchantGoodsId == item.goodsId) { if (temp.merchantGoodsId == item.goodsId) {
let obj = { let obj = {
goodsFlag: 2, goodsFlag: 2,
goods: null, goods: null
} }
obj.multipleSpecificationsGoods = { obj.multipleSpecificationsGoods = {
...@@ -891,10 +846,7 @@ export default { ...@@ -891,10 +846,7 @@ export default {
}) })
return skuArr return skuArr
}, },
uploadConfirm ({ uploadConfirm({ payVoucherList, outTradeNo }) {
payVoucherList,
outTradeNo
}) {
let paymentDocList = [] let paymentDocList = []
payVoucherList.map(e => { payVoucherList.map(e => {
paymentDocList.push({ paymentDocList.push({
...@@ -907,7 +859,7 @@ export default { ...@@ -907,7 +859,7 @@ export default {
this.orderObj.paymentDocList = paymentDocList this.orderObj.paymentDocList = paymentDocList
this.submit() this.submit()
}, },
setCustomerInfo (customerInfo) { setCustomerInfo(customerInfo) {
const { orderObj } = this, const { orderObj } = this,
ownerGender = customerInfo.customerSex != 2 ? '男' : '女', ownerGender = customerInfo.customerSex != 2 ? '男' : '女',
salesType = customerInfo.salesType || '0', salesType = customerInfo.salesType || '0',
...@@ -924,7 +876,7 @@ export default { ...@@ -924,7 +876,7 @@ export default {
certificateNo: customerInfo.customerCertificateNo || '', certificateNo: customerInfo.customerCertificateNo || '',
salesType, salesType,
carVin: customerInfo.carVin || '', carVin: customerInfo.carVin || '',
carColor: customerInfo.carColor || '', carColor: customerInfo.carColor || ''
}) })
this.formList[1].map(e => { this.formList[1].map(e => {
if (e.value == 'salesType') e.current = salesType if (e.value == 'salesType') e.current = salesType
...@@ -953,7 +905,7 @@ export default { ...@@ -953,7 +905,7 @@ export default {
carChildsBrandId: customerInfo.carChildsBrandId, carChildsBrandId: customerInfo.carChildsBrandId,
carChildsBrandName: customerInfo.carChildsBrandName, carChildsBrandName: customerInfo.carChildsBrandName,
carSeriesId: customerInfo.carSeriesId, carSeriesId: customerInfo.carSeriesId,
carSeriesName: customerInfo.carSeriesName, carSeriesName: customerInfo.carSeriesName
} }
orderObj.carBrandText = `${customerInfo.carBrand}-${customerInfo.carChildsBrandName}-${customerInfo.carSeriesName}` orderObj.carBrandText = `${customerInfo.carBrand}-${customerInfo.carChildsBrandName}-${customerInfo.carSeriesName}`
} }
...@@ -962,13 +914,11 @@ export default { ...@@ -962,13 +914,11 @@ export default {
this.validateVin() this.validateVin()
console.log(this.orderObj) console.log(this.orderObj)
}, },
jumpSuccess (params) { jumpSuccess(params) {
this.$emit('jump', 'OrderDetail', params) this.$emit('jump', 'OrderDetail', params)
}, },
async handleEditSave () { async handleEditSave() {
let { let { saveStatus } = this
saveStatus
} = this
if (saveStatus) return false if (saveStatus) return false
this.saveStatus = true this.saveStatus = true
this.handleSecondConfirmCheck(false) this.handleSecondConfirmCheck(false)
...@@ -990,10 +940,10 @@ export default { ...@@ -990,10 +940,10 @@ export default {
} }
return parseFloat(strVal) return parseFloat(strVal)
}, },
closePopup () { closePopup() {
this.$emit('jump', 'OrderManagement') this.$emit('jump', 'OrderManagement')
}, },
clearPayMentDocList () { clearPayMentDocList() {
this.showUpload = false this.showUpload = false
this.orderObj.paymentDocList = [] this.orderObj.paymentDocList = []
this.orderObj.transactionNo = '' this.orderObj.transactionNo = ''
......
<template>
<view class="strategy-row">
<!-- 打折策略 -->
<view v-if="strategyType === 'discount'" class="strategy-left">
<view class="tab-group">
<view v-for="tab in discountTabs" :key="tab.value" class="tab-item" :class="{ 'tab-item--active': localState.mode === tab.value }" @click="onDiscountTabChange(tab.value)">
{{ tab.label }}
</view>
</view>
<view v-if="localState.mode === 'ratio' || localState.mode === 'amount'" class="input-box">
<!-- 折扣比例 -->
<view v-if="localState.mode === 'ratio'" class="ratio-input">
<input class="ratio-input-inner" type="digit" :placeholder="ratioPlaceholder" placeholder-class="placeholder" v-model="localState.discountRatio" @blur="onBlur('discountRatio')" />
<text class="unit">折</text>
</view>
<!-- 折扣金额 -->
<view v-else class="amount-input">
<view class="unit">¥</view>
<input class="input amount-input-inner" type="digit" placeholder="请输入" placeholder-class="placeholder" v-model="localState.discountAmount" @blur="onBlur('discountAmount')" />
</view>
</view>
</view>
<!-- 买赠策略 -->
<view v-else-if="strategyType === 'gift'" class="strategy-left flex">
<view class="label">是否为赠品</view>
<radio-group class="radio-group value" @change="onGiftRadioChange">
<label v-for="item in giftOptions" :key="item.value" class="uni-list-cell uni-list-cell-pd">
<radio style="transform: scale(0.65) translateY(-3px)" :value="item.value" :checked="item.value === localState.isGift" />
<view class="radio-name">{{ item.label }}</view>
</label>
</radio-group>
</view>
<!-- 组合付款 -->
<view v-else-if="strategyType === 'combined'" class="strategy-left">
<view class="tab-group">
<view v-for="tab in combinedTabs" :key="tab.value" class="tab-item" :class="{ 'tab-item--active': localState.mode === tab.value }" @click="onCombinedTabChange(tab.value)">
{{ tab.label }}
</view>
</view>
<view v-if="localState.mode === 'deduct'" class="input-box">
<view class="amount-input">
<view class="unit">¥</view>
<input class="input amount-input-inner" type="digit" placeholder="请输入" placeholder-class="placeholder" v-model="localState.deductAmount" @blur="onBlur('deductAmount')" />
</view>
</view>
</view>
<!-- 右侧价格展示 -->
<view v-if="showPrice" class="strategy-right">
<view class="price-label">价格</view>
<view class="price-value">{{ computedPrice }}</view>
</view>
</view>
</template>
<script>
export default {
name: 'OrderStrategy',
props: {
// discount(打折策略)/ gift(买赠策略)/ combined(组合付款)
strategyType: {
type: String,
default: 'discount'
},
// v-model 绑定的值
value: {
type: Object,
default() {
return {}
}
},
// 右侧价格展示文案(已废弃,改用计算值)
priceText: {
type: String,
default: '-'
},
// 基础价格(单价,不乘以数量)
basePrice: {
type: [Number, String],
default: 0
},
showPrice: {
type: Boolean,
default: true
}
},
data() {
return {
localState: {
// mode: ratio / amount / none / deduct
mode: 'none',
discountRatio: '',
discountAmount: '',
isGift: '0',
deductAmount: ''
},
discountTabs: [
{ label: '无折扣', value: 'none' },
{ label: '折扣比例', value: 'ratio' },
{ label: '折扣金额', value: 'amount' }
],
combinedTabs: [
{ label: '无抵扣', value: 'none' },
{ label: '抵扣金额', value: 'deduct' }
],
giftOptions: [
{ label: '是', value: '1' },
{ label: '否', value: '0' }
],
ratioPlaceholder: '请输入'
}
},
computed: {
// 计算最终价格
computedPrice() {
const basePrice = parseFloat(this.basePrice || 0)
if (!basePrice) return '-'
// 打折策略
if (this.strategyType === 'discount') {
if (this.localState.mode === 'ratio' && this.localState.discountRatio) {
const ratio = parseFloat(this.localState.discountRatio)
// 折扣比例:0.1-10,表示 0.1 折到 10 折(即 0.01 到 1.0)
if (ratio >= 0.1 && ratio <= 10) {
const finalPrice = basePrice * (ratio / 10)
return '¥' + (Math.round(finalPrice * 100) / 100).toFixed(2)
}
} else if (this.localState.mode === 'amount' && this.localState.discountAmount) {
const discountAmount = parseFloat(this.localState.discountAmount)
// 折扣金额:0.01 到不能大于基础价格
if (discountAmount >= 0.01 && discountAmount <= basePrice) {
const finalPrice = basePrice - discountAmount
return '¥' + (Math.round(finalPrice * 100) / 100).toFixed(2)
}
}
return '¥' + basePrice.toFixed(2)
}
// 买赠策略
if (this.strategyType === 'gift') {
if (this.localState.isGift === '1') {
return '¥0.00'
}
return '¥' + basePrice.toFixed(2)
}
// 组合付款
if (this.strategyType === 'combined') {
if (this.localState.mode === 'deduct' && this.localState.deductAmount) {
const deductAmount = parseFloat(this.localState.deductAmount)
// 抵扣金额:0.01 到不能大于基础价格
if (deductAmount >= 0.01 && deductAmount <= basePrice) {
const finalPrice = basePrice - deductAmount
return '¥' + (Math.round(finalPrice * 100) / 100).toFixed(2)
}
}
return '¥' + basePrice.toFixed(2)
}
return '¥' + basePrice.toFixed(2)
}
},
watch: {
// 外部 v-model -> 内部 state
value: {
handler(val) {
if (!val) return
Object.keys(this.localState).forEach(key => {
if (val[key] !== undefined) {
this.localState[key] = val[key]
}
})
},
deep: true,
immediate: true
},
// 内部 state 改变 -> 向外通知
localState: {
handler() {
this.$emit('input', { ...this.localState })
this.$emit('change', { ...this.localState })
// 价格变化时通知父组件
const basePrice = parseFloat(this.basePrice || 0)
if (basePrice) {
const finalPrice = this.calculateFinalPrice(basePrice)
this.$emit('priceChange', finalPrice)
}
},
deep: true
},
// 基础价格变化时重新计算
basePrice: {
handler() {
const basePrice = parseFloat(this.basePrice || 0)
if (basePrice) {
const finalPrice = this.calculateFinalPrice(basePrice)
this.$emit('priceChange', finalPrice)
}
},
immediate: true
}
},
methods: {
// 计算最终价格(内部方法)
calculateFinalPrice(basePrice) {
const bp = parseFloat(basePrice || 0)
if (!bp) return 0
// 打折策略
if (this.strategyType === 'discount') {
if (this.localState.mode === 'ratio' && this.localState.discountRatio) {
const ratio = parseFloat(this.localState.discountRatio)
if (ratio >= 0.1 && ratio <= 10) {
return Math.round(bp * (ratio / 10) * 100) / 100
}
} else if (this.localState.mode === 'amount' && this.localState.discountAmount) {
const discountAmount = parseFloat(this.localState.discountAmount)
if (discountAmount >= 0.01 && discountAmount <= bp) {
return Math.round((bp - discountAmount) * 100) / 100
}
}
return Math.round(bp * 100) / 100
}
// 买赠策略
if (this.strategyType === 'gift') {
if (this.localState.isGift === '1') {
return 0
}
return Math.round(bp * 100) / 100
}
// 组合付款
if (this.strategyType === 'combined') {
if (this.localState.mode === 'deduct' && this.localState.deductAmount) {
const deductAmount = parseFloat(this.localState.deductAmount)
if (deductAmount >= 0.01 && deductAmount <= bp) {
return Math.round((bp - deductAmount) * 100) / 100
}
}
return Math.round(bp * 100) / 100
}
return Math.round(bp * 100) / 100
},
// 失去焦点时格式化(跟价格输入框一样的逻辑)
onBlur(key) {
let v = this.localState[key]
if (key === 'discountAmount' || key === 'deductAmount') {
// 折扣金额/抵扣金额:限制 0.01 到商品原价(直接截断,不四舍五入)
if (!v || (typeof v === 'string' && v.trim() === '')) {
v = '0.01'
}
// 限制只能输入数字和小数点
v = String(v).replace(/[^\d.]/g, '')
// 限制只能有一个小数点
if (v.split('.').length > 2) {
v = v.slice(0, v.lastIndexOf('.')) + v.slice(v.lastIndexOf('.') + 1)
}
// 限制最多两位小数(直接截断,不四舍五入)
if (v.includes('.')) {
const parts = v.split('.')
if (parts[1] && parts[1].length > 2) {
parts[1] = parts[1].substring(0, 2)
v = parts.join('.')
}
}
const basePrice = parseFloat(this.basePrice || 0)
let amount = parseFloat(v)
// 限制最小值为 0.01
if (isNaN(amount) || amount < 0.01) {
v = '0.01'
}
// 限制最大值为基础价格
else if (basePrice > 0 && amount > basePrice) {
// 如果超过基础价格,限制为基础价格
v = basePrice.toFixed(2)
}
this.$set(this.localState, key, v)
} else if (key === 'discountRatio') {
// 折扣比例:限制在 0.1-10 之间,限制 1 位小数(直接截断,不四舍五入)
if (!v || (typeof v === 'string' && v.trim() === '')) {
v = ''
} else {
// 限制只能输入数字和小数点
v = String(v).replace(/[^\d.]/g, '')
// 限制只能有一个小数点
if (v.split('.').length > 2) {
v = v.slice(0, v.lastIndexOf('.')) + v.slice(v.lastIndexOf('.') + 1)
}
// 限制最多 1 位小数(直接截断,不四舍五入)
if (v.includes('.')) {
const parts = v.split('.')
if (parts[1] && parts[1].length > 1) {
parts[1] = parts[1].substring(0, 1)
v = parts.join('.')
}
}
const ratio = parseFloat(v)
if (!isNaN(ratio)) {
if (ratio < 0.1) {
v = '0.1'
} else if (ratio > 10) {
v = '10'
}
}
}
this.$set(this.localState, key, v)
}
},
// 买赠单选框 change,保持与收款方式一致的事件风格
onGiftRadioChange(e) {
this.onGiftChange(e.detail.value)
},
onDiscountTabChange(mode) {
this.localState.mode = mode
if (mode === 'none') {
this.localState.discountRatio = ''
this.localState.discountAmount = ''
}
},
onCombinedTabChange(mode) {
this.localState.mode = mode
if (mode === 'none') {
this.localState.deductAmount = ''
}
},
onGiftChange(val) {
this.localState.isGift = val
}
}
}
</script>
<style scoped lang="scss">
.strategy-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: toRpx(24) toRpx(24) 0 toRpx(24);
border-top: toRpx(2) dashed #ebedf0;
box-sizing: border-box;
}
.strategy-left {
display: flex;
align-items: center;
}
.tab-group {
display: flex;
background: #ededf2;
border-radius: toRpx(16);
overflow: hidden;
padding: toRpx(8);
box-sizing: border-box;
.tab-item {
padding: toRpx(8) toRpx(16);
font-size: toRpx(26);
color: #222222;
font-weight: 400;
}
.tab-item--active {
background-color: #ffffff;
border-radius: toRpx(6);
}
}
.input-box {
margin-left: toRpx(16);
}
.input {
width: toRpx(160);
height: toRpx(64);
padding: 0 toRpx(16);
border-radius: toRpx(12);
background-color: #ffffff;
box-sizing: border-box;
color: #333333;
}
.placeholder {
color: #b6b6b8;
font-size: toRpx(28);
}
.ratio-input {
display: flex;
align-items: center;
background-color: #ffffff;
border: toRpx(2) solid #eff0f2;
border-radius: toRpx(12);
padding: 0 toRpx(16);
height: toRpx(64);
width: toRpx(160);
font-size: toRpx(28);
line-height: toRpx(64);
box-sizing: border-box;
.ratio-input-inner {
flex: 1;
border: none;
padding: 0;
background: transparent;
height: 100%;
width: 100%;
color: #333333;
box-sizing: border-box;
}
.unit {
color: #333333;
margin-left: toRpx(8);
flex-shrink: 0;
line-height: toRpx(64);
display: inline-block;
}
}
.amount-input {
display: flex;
align-items: center;
background-color: #ffffff;
border-radius: toRpx(12);
padding-left: toRpx(24);
.unit {
font-size: toRpx(26);
color: #333;
flex-shrink: 0;
}
.amount-input-inner {
width: toRpx(140);
padding-left: toRpx(8);
text-align: right;
}
}
.label {
font-size: toRpx(28);
color: #222222;
margin-right: toRpx(24);
flex-shrink: 0;
line-height: 1; // 使用 line-height 而不是固定高度,确保与右侧文字基线对齐
}
.radio-group {
display: flex;
align-items: center;
&.value {
justify-content: flex-end;
width: 100%;
}
.uni-list-cell {
margin-left: toRpx(48);
&:first-child {
margin-left: 0;
}
}
.radio-name {
display: inline-block;
color: #292d33;
font-size: toRpx(28);
line-height: 1; // 确保与左侧 label 的 line-height 一致
}
}
.radio-item {
display: flex;
align-items: center;
margin-right: toRpx(24);
}
.radio-dot {
width: toRpx(28);
height: toRpx(28);
border-radius: 50%;
border: toRpx(2) solid #d1d5db;
margin-right: toRpx(8);
}
.radio-dot--active {
border-color: #2c66f7;
background-color: #2c66f7;
}
.radio-text {
font-size: toRpx(26);
color: #666;
}
.radio-item--active .radio-text {
color: #2c66f7;
}
.strategy-right {
display: flex;
align-items: center;
font-size: toRpx(28);
color: #333;
.price-label {
margin-right: toRpx(8);
color: #222222;
}
.price-value {
color: #ea6612;
}
}
</style>
<template> <template>
<view> <view>
<view class="shop-list"> <view class="shop-list">
<view <view class="shop-item" v-for="(item, index) in list" :key="index">
class="shop-item"
v-for="(item, index) in list"
:key="index"
>
<template v-if="item.goodsFlag == 3"> <template v-if="item.goodsFlag == 3">
<view class="package-box"> <view class="package-box">
<view class="shop-name flex"> <view class="shop-name flex">
<view <view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view>
class="sprite-icon icon-blue-delete"
@click="deleteGoods(index)"
></view>
<view class="name">{{ goodsName(item) }}</view> <view class="name">{{ goodsName(item) }}</view>
<view class="total-price">{{packageTotal(item)}}</view> <view class="total-price">{{ packageTotal(item) }}</view>
</view> </view>
<view class="line"></view> <view class="line"></view>
<view class="package-goods-list"> <view class="package-goods-list">
<template v-for="(i,ind) in item.packageGoods.goodsList"> <view class="package-item" v-for="(i, ind) in item.packageGoods.goodsList" :key="`package_${index}_${ind}`">
<view <view class="flex flex-1 pb-24">
class="package-item flex"
:key="`package_${index}_${ind}`"
>
<view class="package-icon"></view> <view class="package-icon"></view>
<view class="package-label">{{packageName(i,item)}}</view> <view class="package-label">{{ packageName(i, item) }}</view>
<view class="package-value flex"> <view class="package-value flex">
<template v-if="i.goodsPriceModify"> <template v-if="i.goodsPriceModify">
<view class="package-price">¥{{i.sellPrice}}</view> <view class="package-price">¥{{ i.sellPrice }}</view>
</template> </template>
<template v-else> <template v-else>
<view class="front-gear-input flex"> <view class="front-gear-input flex">
<view class="unit">¥</view> <view class="unit">¥</view>
<input <input class="uni-input" type="digit" maxlength="9" placeholder="请输入价格" placeholder-style="font-size: 14px" v-model="i.sellPrice" @blur="validatePrice($event, item, index, ind)" />
class="uni-input"
type="digit"
maxlength="9"
placeholder="请输入价格"
placeholder-style="font-size: 14px"
v-model="i.sellPrice"
@blur="validatePrice($event, item, index, ind)"
/>
</view> </view>
</template> </template>
<view class="number">x1</view> <view class="number">x1</view>
</view> </view>
</view> </view>
</template>
<!-- 折扣 / 买赠 / 组合付款策略组件 -->
<OrderStrategy v-if="getStrategyType(i)" :strategyType="getStrategyType(i)" :value="getStrategyConfig(i)" :basePrice="getBasePrice(i)" :displayPrice="getDisplayPrice(i)" @input="onStrategyConfigChange(i, $event)" @priceChange="onPriceChange(i, $event, item)" />
</view>
</view> </view>
</view> </view>
</template> </template>
<template v-else> <template v-else>
<view <view class="flex flex-1 pb-24">
class="sprite-icon icon-blue-delete" <view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view>
@click="deleteGoods(index)" <view :class="['right', { 'one-line': item.goodsFlag == 1 }]">
></view> <view :class="['shop-name', { 'name-top': item.goodsFlag == 2 }]">{{ goodsName(item) }}</view>
<view :class="['right',{'one-line':item.goodsFlag == 1}]"> <view class="alias" v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.goodsAlias">商品别名:{{ item.multipleSpecificationsGoods.goods.goodsAlias }}</view>
<view :class="['shop-name',{'name-top':item.goodsFlag == 2}]">{{ goodsName(item) }}</view> <view class="front-gear-box">
<view <view class="front-gear-input-box">
class="alias" <template v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.specificationStr">
v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.goodsAlias" <view class="front-gear-label">
>商品别名:{{ {{ item.multipleSpecificationsGoods.goods.specificationStr }}
item.multipleSpecificationsGoods.goods.goodsAlias }}</view> </view>
<view class="front-gear-box">
<view class="front-gear-input-box">
<template v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.specificationStr">
<view class="front-gear-label">
{{item.multipleSpecificationsGoods.goods.specificationStr}}
</view>
</template>
<view class="front-number-box flex">
<template v-if="item.goodsFlag == 1">
<template v-if="item.goods.goodsPriceModify">
¥{{item.goods.sellPrice}}
</template>
<template v-else>
<view class="front-gear-input">
<view class="unit">¥</view>
<input
class="uni-input"
type="digit"
maxlength="9"
placeholder="请输入价格"
placeholder-style="font-size: 14px"
v-model="item.goods.sellPrice"
@blur="validatePrice($event, item, index)"
/>
</view>
</template>
</template> </template>
<template v-else> <view class="front-number-box flex">
<template v-if="item.multipleSpecificationsGoods.goods.goodsPriceModify"> <template v-if="item.goodsFlag == 1">
¥{{item.multipleSpecificationsGoods.goods.sellPrice}} <template v-if="item.goods.goodsPriceModify">¥{{ item.goods.sellPrice }}</template>
<template v-else>
<view class="front-gear-input">
<view class="unit">¥</view>
<input class="uni-input" type="digit" maxlength="9" placeholder="请输入价格" placeholder-style="font-size: 14px" v-model="item.goods.sellPrice" @blur="validatePrice($event, item, index)" />
</view>
</template>
</template> </template>
<template v-else> <template v-else>
<view class="front-gear-input"> <template v-if="item.multipleSpecificationsGoods.goods.goodsPriceModify">¥{{ item.multipleSpecificationsGoods.goods.sellPrice }}</template>
<view class="unit">¥</view> <template v-else>
<input <view class="front-gear-input">
class="uni-input" <view class="unit">¥</view>
type="digit" <input class="uni-input" type="digit" maxlength="9" placeholder="请输入价格" placeholder-style="font-size: 14px" v-model="item.multipleSpecificationsGoods.goods.sellPrice" @blur="validatePrice($event, item, index)" />
maxlength="9" </view>
placeholder="请输入价格" </template>
placeholder-style="font-size: 14px"
v-model="item.multipleSpecificationsGoods.goods.sellPrice"
@blur="validatePrice($event, item, index)"
/>
</view>
</template> </template>
</template> <view class="number">x1</view>
<view class="number">
x1
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<!-- 折扣 / 买赠 / 组合付款策略组件 -->
<OrderStrategy v-if="getStrategyType(item)" :strategyType="getStrategyType(item)" :value="getStrategyConfig(item)" :basePrice="getBasePrice(item)" :displayPrice="getDisplayPrice(item)" @input="onStrategyConfigChange(item, $event)" @priceChange="onPriceChange(item, $event)" />
</template> </template>
</view> </view>
</view> </view>
...@@ -123,9 +83,13 @@ ...@@ -123,9 +83,13 @@
<script> <script>
import NP from 'number-precision' import NP from 'number-precision'
import OrderStrategy from './OrderStrategy.vue'
export default { export default {
name: 'SkuGoods', name: 'SkuGoods',
components: {
OrderStrategy
},
props: { props: {
list: { list: {
type: Array, type: Array,
...@@ -138,35 +102,43 @@ export default { ...@@ -138,35 +102,43 @@ export default {
baseConfigData: { baseConfigData: {
type: Object, type: Object,
default: {} default: {}
},
orderTypeCode: {
type: [String, Number],
default: ''
} }
}, },
created () { created() {
// 初始化商品数量 // 初始化商品数量
this.initProductNumbers() this.initProductNumbers()
}, },
mounted () { mounted() {
// 确保每次使用组件时都检查并设置number属性 // 确保每次使用组件时都检查并设置number属性
this.initProductNumbers() this.initProductNumbers()
}, },
updated () { updated() {
// 当组件数据更新时也检查number属性 // 当组件数据更新时也检查number属性
this.initProductNumbers() this.initProductNumbers()
}, },
computed: { watch: {
orderTypeCode: {
handler() {
this.initStrategyConfig()
},
immediate: true
}
}, },
computed: {},
methods: { methods: {
goodsName (item) { goodsName(item) {
let { goodsFlag } = item, let { goodsFlag } = item,
str = '' str = ''
if (goodsFlag == 3) str = item.packageGoods.packageAlias || item.packageGoods.packageName if (goodsFlag == 3) str = item.packageGoods.packageAlias || item.packageGoods.packageName
else str = item.multipleSpecificationsGoods ? else str = item.multipleSpecificationsGoods ? item.multipleSpecificationsGoods.baseGoodsName : item.goods.goodsAlias || item.goods.upgradeGoodsName || item.goods.goodsInfo.goodsName
item.multipleSpecificationsGoods.baseGoodsName : item.goods.goodsAlias || item.goods.upgradeGoodsName ||
item.goods.goodsInfo.goodsName
return str return str
}, },
// 初始化商品数量方法 // 初始化商品数量方法
initProductNumbers () { initProductNumbers() {
if (this.list && this.list.length > 0) { if (this.list && this.list.length > 0) {
this.list.forEach(item => { this.list.forEach(item => {
if (!item.multipleSpecificationsGoods) { if (!item.multipleSpecificationsGoods) {
...@@ -183,16 +155,16 @@ export default { ...@@ -183,16 +155,16 @@ export default {
}) })
} }
}, },
filterIncludes (item, arr) { filterIncludes(item, arr) {
return arr.indexOf(item) > -1 return arr.indexOf(item) > -1
}, },
// 格式化位置信息 // 格式化位置信息
formatPosition (item, positionTypeList) { formatPosition(item, positionTypeList) {
const filterData = positionTypeList.filter(v => v.positionValue == item) const filterData = positionTypeList.filter(v => v.positionValue == item)
return (filterData.length && filterData[0] && filterData[0].positionName) || '' return (filterData.length && filterData[0] && filterData[0].positionName) || ''
}, },
// 验证价格输入 // 验证价格输入
validatePrice (event, item, index, cindex) { validatePrice(event, item, index, cindex) {
let value = event.detail.value let value = event.detail.value
// 如果为空则设置为0 // 如果为空则设置为0
if (!value || value.trim() === '') { if (!value || value.trim() === '') {
...@@ -267,7 +239,7 @@ export default { ...@@ -267,7 +239,7 @@ export default {
this.$emit('changeTotalPrice') this.$emit('changeTotalPrice')
}, },
// 验证数量输入 // 验证数量输入
validateNumber (event, item) { validateNumber(event, item) {
let value = event.detail.value let value = event.detail.value
// 限制只能输入整数 // 限制只能输入整数
value = value.replace(/[^\d]/g, '') value = value.replace(/[^\d]/g, '')
...@@ -285,7 +257,7 @@ export default { ...@@ -285,7 +257,7 @@ export default {
this.$emit('changeTotalPrice') this.$emit('changeTotalPrice')
}, },
// 增加数量 // 增加数量
increaseNumber (item) { increaseNumber(item) {
if (!item.multipleSpecificationsGoods) { if (!item.multipleSpecificationsGoods) {
// 处理普通商品 // 处理普通商品
if (!item.goods.number) { if (!item.goods.number) {
...@@ -310,7 +282,7 @@ export default { ...@@ -310,7 +282,7 @@ export default {
this.$emit('changeTotalPrice') this.$emit('changeTotalPrice')
}, },
// 减少数量 // 减少数量
decreaseNumber (item) { decreaseNumber(item) {
if (!item.multipleSpecificationsGoods) { if (!item.multipleSpecificationsGoods) {
// 处理普通商品 // 处理普通商品
// 如果商品数量不存在或小于等于1,设置为1 // 如果商品数量不存在或小于等于1,设置为1
...@@ -337,28 +309,357 @@ export default { ...@@ -337,28 +309,357 @@ export default {
this.$emit('changeTotalPrice') this.$emit('changeTotalPrice')
}, },
// 删除商品 // 删除商品
deleteGoods (index) { deleteGoods(index) {
this.list.splice(index, 1) this.list.splice(index, 1)
this.$emit('changeTotalPrice') this.$emit('changeTotalPrice')
}, },
replaceItemText (value) { replaceItemText(value) {
let reg = getRegExp(';~;', 'g') let reg = getRegExp(';~;', 'g')
return value ? value.replace(reg, '/') : '' return value ? value.replace(reg, '/') : ''
}, },
packageName (item, parent) { packageName(item, parent) {
return item.goodsAlias return item.goodsAlias || item.goodsNameAlias || this.replaceItemText(item.upgradeGoodsName, parent.specificationData ? '/' + item.specificationData : '') || this.replaceItemText(item.goodsName, parent.specificationData ? '/' + item.specificationData : '')
|| item.goodsNameAlias
|| this.replaceItemText(item.upgradeGoodsName, (parent.specificationData ? '/' + item.specificationData : ''))
|| this.replaceItemText(item.goodsName, (parent.specificationData ? '/' + item.specificationData : ''))
}, },
packageTotal (item) { packageTotal(item) {
let total = 0 let total = 0
item.packageGoods.goodsList.map(i => { const orderType = String(this.orderTypeCode || '')
total = NP.plus(total, i.sellPrice * i.number) const packageNumber = parseInt(item.packageGoods.number || 1)
item.packageGoods.goodsList.forEach(goods => {
const sellPrice = parseFloat(goods.sellPrice || 0)
// 正常订单('1')和冲量订单('4'):使用原价
if (orderType === '1' || orderType === '4') {
total = NP.plus(total, NP.times(sellPrice, packageNumber))
}
// 其他类型(打折/买赠/组合付款):使用优惠后的价格
else {
const strategyConfig = goods.strategyConfig || {}
let finalPricePerUnit = sellPrice // 默认使用原价
// '2' 打折策略
if (orderType === '2') {
if (strategyConfig.mode === 'ratio' && strategyConfig.discountRatio) {
const ratio = parseFloat(strategyConfig.discountRatio)
if (ratio >= 0.1 && ratio <= 10) {
finalPricePerUnit = Math.round(sellPrice * (ratio / 10) * 100) / 100
}
} else if (strategyConfig.mode === 'amount' && strategyConfig.discountAmount) {
const discountAmount = parseFloat(strategyConfig.discountAmount)
if (discountAmount >= 0.01 && discountAmount <= sellPrice) {
finalPricePerUnit = Math.round((sellPrice - discountAmount) * 100) / 100
}
}
}
// '3' 买赠策略
if (orderType === '3') {
if (strategyConfig.isGift === '1') {
finalPricePerUnit = 0
}
}
// '5' 组合付款
if (orderType === '5') {
if (strategyConfig.mode === 'deduct' && strategyConfig.deductAmount) {
const deductAmount = parseFloat(strategyConfig.deductAmount)
if (deductAmount >= 0.01 && deductAmount <= sellPrice) {
finalPricePerUnit = Math.round((sellPrice - deductAmount) * 100) / 100
}
}
}
// 单价优惠后 × 套餐数量
total = NP.plus(total, NP.times(finalPricePerUnit, packageNumber))
}
}) })
item.packageGoods.totalPrice = total item.packageGoods.totalPrice = total
return total return total.toFixed(2)
},
// 根据订单类型获取策略类型
getStrategyType(item) {
// item 可能是套餐商品(goodsFlag == 3)或普通商品,也可能是套餐内的商品(直接是商品对象)
// 如果是套餐商品,不显示策略组件(策略组件应该显示在套餐内的商品上)
if (item && item.goodsFlag == 3) {
return null
}
const orderType = String(this.orderTypeCode || '')
// '1' 正常订单、'4' 冲量活动:不显示策略组件
if (orderType === '1' || orderType === '4') {
return null
}
// '2' 打折策略
if (orderType === '2') {
return 'discount'
}
// '3' 买赠策略
if (orderType === '3') {
return 'gift'
}
// '5' 组合付款
if (orderType === '5') {
return 'combined'
}
return null
},
// 获取策略配置对象
getStrategyConfig(item) {
// 如果是套餐内的商品(直接是商品对象,有 sellPrice 等属性)
if (item && item.sellPrice !== undefined && !item.goodsFlag) {
return item.strategyConfig || {}
}
// 如果是多规格商品
if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
return item.multipleSpecificationsGoods.goods.strategyConfig || {}
}
// 如果是普通商品
if (item.goods) {
return item.goods.strategyConfig || {}
}
return {}
},
// 策略配置变化回调
onStrategyConfigChange(item, config) {
// 如果是套餐内的商品(直接是商品对象)
if (item && item.sellPrice !== undefined && !item.goodsFlag) {
this.$set(item, 'strategyConfig', config)
}
// 如果是多规格商品
else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
this.$set(item.multipleSpecificationsGoods.goods, 'strategyConfig', config)
}
// 如果是普通商品
else if (item.goods) {
this.$set(item.goods, 'strategyConfig', config)
}
},
// 计算基础价格(单价,不乘以数量)
getBasePrice(item) {
let sellPrice = 0
// 如果是套餐内的商品(直接是商品对象)
if (item && item.sellPrice !== undefined && !item.goodsFlag) {
sellPrice = parseFloat(item.sellPrice || 0)
}
// 如果是多规格商品
else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
sellPrice = parseFloat(item.multipleSpecificationsGoods.goods.sellPrice || 0)
}
// 如果是普通商品
else if (item.goods) {
sellPrice = parseFloat(item.goods.sellPrice || 0)
}
// 四舍五入保留两位小数
return Math.round(sellPrice * 100) / 100
},
// 计算最终显示价格
getDisplayPrice(item) {
const basePrice = this.getBasePrice(item)
if (!basePrice) return '¥0.00'
const orderType = String(this.orderTypeCode || '')
const strategyConfig = this.getStrategyConfig(item)
// '2' 打折策略
if (orderType === '2') {
if (strategyConfig.mode === 'ratio' && strategyConfig.discountRatio) {
const ratio = parseFloat(strategyConfig.discountRatio)
if (ratio >= 0.1 && ratio <= 10) {
const finalPrice = basePrice * (ratio / 10)
return '¥' + (Math.round(finalPrice * 100) / 100).toFixed(2)
}
} else if (strategyConfig.mode === 'amount' && strategyConfig.discountAmount) {
const discountAmount = parseFloat(strategyConfig.discountAmount)
if (discountAmount >= 0.01 && discountAmount <= basePrice) {
const finalPrice = basePrice - discountAmount
return '¥' + (Math.round(finalPrice * 100) / 100).toFixed(2)
}
}
return '¥' + basePrice.toFixed(2)
}
// '3' 买赠策略
if (orderType === '3') {
if (strategyConfig.isGift === '1') {
return '¥0.00'
}
return '¥' + basePrice.toFixed(2)
}
// '5' 组合付款
if (orderType === '5') {
if (strategyConfig.mode === 'deduct' && strategyConfig.deductAmount) {
const deductAmount = parseFloat(strategyConfig.deductAmount)
if (deductAmount >= 0.01 && deductAmount <= basePrice) {
const finalPrice = basePrice - deductAmount
return '¥' + (Math.round(finalPrice * 100) / 100).toFixed(2)
}
}
return '¥' + basePrice.toFixed(2)
}
return '¥' + basePrice.toFixed(2)
},
// 价格变化回调(finalPrice 是单件商品优惠后的价格,需要乘以数量得到总价,并转换为分)
onPriceChange(item, finalPricePerUnit, packageItem) {
// 计算总价:单件优惠价 * 数量 * 100(转换为分)
// 如果是套餐内的商品,数量是套餐的数量;否则数量固定为 1
let number = 1
if (packageItem && packageItem.packageGoods && packageItem.packageGoods.number) {
number = parseInt(packageItem.packageGoods.number || 1)
}
const totalFinalPrice = Math.round(finalPricePerUnit * number * 100) / 100
const finalPriceInCents = Math.round(totalFinalPrice * 100) // 转换为分
// 如果是套餐内的商品(直接是商品对象,有 sellPrice 等属性)
if (item && item.sellPrice !== undefined && !item.goodsFlag) {
// 赠品传 0,无优惠传 null 或原价(单位分)
if (finalPriceInCents === 0) {
this.$set(item, 'finalPrice', 0)
} else {
const originalPriceInCents = Math.round(parseFloat(item.sellPrice || 0) * 100)
// 如果有优惠且不等于原价,传优惠后的价格;否则传 null
if (finalPriceInCents < originalPriceInCents) {
this.$set(item, 'finalPrice', finalPriceInCents)
} else {
this.$set(item, 'finalPrice', null)
}
}
this.$set(item, 'finalPricePerUnit', finalPricePerUnit)
}
// 如果是多规格商品
else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
// 赠品传 0,无优惠传 null 或原价(单位分)
if (finalPriceInCents === 0) {
this.$set(item.multipleSpecificationsGoods.goods, 'finalPrice', 0)
} else {
const originalPriceInCents = Math.round(parseFloat(item.multipleSpecificationsGoods.goods.sellPrice || 0) * 100)
// 如果有优惠且不等于原价,传优惠后的价格;否则传 null
if (finalPriceInCents < originalPriceInCents) {
this.$set(item.multipleSpecificationsGoods.goods, 'finalPrice', finalPriceInCents)
} else {
this.$set(item.multipleSpecificationsGoods.goods, 'finalPrice', null)
}
}
this.$set(item.multipleSpecificationsGoods.goods, 'finalPricePerUnit', finalPricePerUnit)
}
// 如果是普通商品
else if (item.goods) {
// 赠品传 0,无优惠传 null 或原价(单位分)
if (finalPriceInCents === 0) {
this.$set(item.goods, 'finalPrice', 0)
} else {
const originalPriceInCents = Math.round(parseFloat(item.goods.sellPrice || 0) * 100)
// 如果有优惠且不等于原价,传优惠后的价格;否则传 null
if (finalPriceInCents < originalPriceInCents) {
this.$set(item.goods, 'finalPrice', finalPriceInCents)
} else {
this.$set(item.goods, 'finalPrice', null)
}
}
this.$set(item.goods, 'finalPricePerUnit', finalPricePerUnit)
}
this.$emit('changeTotalPrice')
}, },
// 初始化策略配置
initStrategyConfig() {
if (!this.list || this.list.length === 0) return
const strategyType = this.getStrategyType({})
if (!strategyType) {
// 订单类型切换时,重置所有商品的策略配置
this.list.forEach(item => {
// 如果是套餐商品,需要重置套餐内所有商品的策略配置
if (item.goodsFlag == 3 && item.packageGoods && item.packageGoods.goodsList) {
item.packageGoods.goodsList.forEach(goods => {
if (goods.strategyConfig) {
goods.strategyConfig = {}
}
goods.discountType = null
goods.discountValue = null
goods.finalPrice = null
})
return
}
// 普通商品和多规格商品
let goods = null
if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
goods = item.multipleSpecificationsGoods.goods
} else if (item.goods) {
goods = item.goods
}
if (goods) {
// 重置策略配置和优惠相关字段
if (goods.strategyConfig) {
goods.strategyConfig = {}
}
goods.discountType = null
goods.discountValue = null
goods.finalPrice = null
}
})
return
}
this.list.forEach(item => {
// 如果是套餐商品,需要初始化套餐内所有商品的策略配置
if (item.goodsFlag == 3 && item.packageGoods && item.packageGoods.goodsList) {
item.packageGoods.goodsList.forEach(goods => {
if (!goods.strategyConfig) {
if (strategyType === 'discount') {
this.$set(goods, 'strategyConfig', {
mode: 'none',
discountRatio: '',
discountAmount: ''
})
} else if (strategyType === 'gift') {
this.$set(goods, 'strategyConfig', {
isGift: '0'
})
} else if (strategyType === 'combined') {
this.$set(goods, 'strategyConfig', {
mode: 'none',
deductAmount: ''
})
}
}
})
return
}
// 普通商品和多规格商品
let goods = null
if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
goods = item.multipleSpecificationsGoods.goods
} else if (item.goods) {
goods = item.goods
}
if (!goods) return
// 如果还没有 strategyConfig,初始化一个默认值
if (!goods.strategyConfig) {
if (strategyType === 'discount') {
this.$set(goods, 'strategyConfig', {
mode: 'none',
discountRatio: '',
discountAmount: ''
})
} else if (strategyType === 'gift') {
this.$set(goods, 'strategyConfig', {
isGift: '0'
})
} else if (strategyType === 'combined') {
this.$set(goods, 'strategyConfig', {
mode: 'none',
deductAmount: ''
})
}
}
})
}
} }
} }
</script> </script>
...@@ -368,8 +669,6 @@ export default { ...@@ -368,8 +669,6 @@ export default {
padding-right: toRpx(32); padding-right: toRpx(32);
.shop-item { .shop-item {
display: flex;
align-items: center;
background-color: #f5f7fa; background-color: #f5f7fa;
border-radius: toRpx(16); border-radius: toRpx(16);
margin-top: toRpx(16); margin-top: toRpx(16);
...@@ -426,6 +725,12 @@ export default { ...@@ -426,6 +725,12 @@ export default {
} }
.package-item { .package-item {
margin-top: toRpx(16); margin-top: toRpx(16);
border-bottom: toRpx(1.6) solid #dce1e6;
padding-bottom: toRpx(24);
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
} }
.sprite-icon { .sprite-icon {
margin-right: toRpx(24); margin-right: toRpx(24);
...@@ -442,7 +747,7 @@ export default { ...@@ -442,7 +747,7 @@ export default {
color: #292d33; color: #292d33;
font-size: toRpx(28); font-size: toRpx(28);
flex-shrink: 0; flex-shrink: 0;
max-width: 80%; max-width: 74%;
} }
.package-value { .package-value {
flex-shrink: 0; flex-shrink: 0;
...@@ -534,4 +839,4 @@ export default { ...@@ -534,4 +839,4 @@ export default {
} }
} }
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -135,6 +135,13 @@ const FORM_LIST = [ ...@@ -135,6 +135,13 @@ const FORM_LIST = [
], ],
[ [
{ {
label: '订单类型',
value: 'djOrderType',
type: 'select',
key: 'name',
required: true
},
{
label: '购买商品', label: '购买商品',
value: 'skuGoods', value: 'skuGoods',
type: 'select', type: 'select',
...@@ -395,6 +402,11 @@ const popupTypeEnum = { ...@@ -395,6 +402,11 @@ const popupTypeEnum = {
key: 'defeatEmployeeName', key: 'defeatEmployeeName',
targetIdKey: 'referrerId', targetIdKey: 'referrerId',
targetNameKey: 'referrer' targetNameKey: 'referrer'
},
28: {
// 订单类型弹窗(OrderTypePopup)
key: 'djOrderType',
list: ''
} }
} }
const titleList = [null, { addHtml: 'customer' }, { name: '车辆信息' }, { name: '增值车损险' }, { name: '其他信息' }] const titleList = [null, { addHtml: 'customer' }, { name: '车辆信息' }, { name: '增值车损险' }, { name: '其他信息' }]
...@@ -647,6 +659,11 @@ const EQUITY_POPUP_ENUM = { ...@@ -647,6 +659,11 @@ const EQUITY_POPUP_ENUM = {
}, },
25: { 25: {
key: 'carBrand' key: 'carBrand'
},
28: {
// 订单类型弹窗(OrderTypePopup)
key: 'djOrderType',
list: ''
} }
} }
...@@ -731,7 +748,7 @@ const EQUITY_FORM_RULE = { ...@@ -731,7 +748,7 @@ const EQUITY_FORM_RULE = {
{ required: true, message: '联系电话不能为空' }, { required: true, message: '联系电话不能为空' },
{ {
validator: (rule, value) => { validator: (rule, value) => {
const phoneRex = /^[1]([3-9])[0-9]{9}$/; const phoneRex = /^[1]([3-9])[0-9]{9}$/
return !phoneRex.test(value) ? { message: '请输入正确的手机号' } : null return !phoneRex.test(value) ? { message: '请输入正确的手机号' } : null
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!