Commit ad2b8ca0 by cen

fix: 战败回显

1 parent 5693c008
...@@ -188,6 +188,14 @@ module.exports = { ...@@ -188,6 +188,14 @@ module.exports = {
...data ...data
}) })
}, },
/**战败商品列表- upradeFlag(N为基础,Y为升级) */
getOrderBaseGoodsList(data) {
return http.post({
method: 'dj.api.smartcarlife.orderUpgradeGoods.listByMerchantId',
projectName: 'boutique',
...data
})
},
/** 选择支付方式下单 */ /** 选择支付方式下单 */
createWithPay(data) { createWithPay(data) {
console.log(data) console.log(data)
......
...@@ -5,11 +5,7 @@ ...@@ -5,11 +5,7 @@
<template v-for="(item, idx) in items"> <template v-for="(item, idx) in items">
<view v-if="!item.hidden"> <view v-if="!item.hidden">
<view class="cell-row" :key="idx"> <view class="cell-row" :key="idx">
<view class="cell" @click="onCellClick(item)" :class="[ <view class="cell" @click="onCellClick(item)" :class="[item.noBorder ? '' : 'border', item.onlyLabel ? 'small-height' : '', item.class]">
item.noBorder ? '' : 'border',
item.onlyLabel ? 'small-height' : '',
item.class
]">
<view :class="['cell-label', { 'only-label': item.onlyLabel }]"> <view :class="['cell-label', { 'only-label': item.onlyLabel }]">
<view v-if="item.labellIcon" :class="['sprite-icon', `icon-${item.labellIcon}`]"></view> <view v-if="item.labellIcon" :class="['sprite-icon', `icon-${item.labellIcon}`]"></view>
{{ item.label }} {{ item.label }}
...@@ -19,12 +15,8 @@ ...@@ -19,12 +15,8 @@
<!-- 输入框 --> <!-- 输入框 -->
<template v-if="item.type === 'input'"> <template v-if="item.type === 'input'">
<view class="input-box"> <view class="input-box">
<input class="input-value" v-model="formData[item.value]" :type="item.inputType || 'text'" <input class="input-value" v-model="formData[item.value]" :type="item.inputType || 'text'" @blur="handleBlur($event, item)" :placeholder="item.placeholder || '请输入'" :maxlength="item.inputType === 'number' ? false : item.maxlength || -1" @input="item.inputType === 'number' && item.maxlength ? (formData[item.value] = String($event.target.value).slice(0, item.maxlength)) : null" />
@blur="handleBlur($event, item)" :placeholder="item.placeholder || '请输入'" <view v-if="item.valueIcon" :class="['sprite-icon', `icon-${item.valueIcon}`]" @click="onValueClick(item)"></view>
:maxlength="item.inputType === 'number' ? false : (item.maxlength || -1)"
@input="item.inputType === 'number' && item.maxlength ? (formData[item.value] = String($event.target.value).slice(0, item.maxlength)) : null" />
<view v-if="item.valueIcon" :class="['sprite-icon', `icon-${item.valueIcon}`]"
@click="onValueClick(item)"></view>
</view> </view>
</template> </template>
<!-- 下拉选择 --> <!-- 下拉选择 -->
...@@ -32,7 +24,8 @@ ...@@ -32,7 +24,8 @@
<view class="value"> <view class="value">
<template v-if="!item.addHtml && formData[item.value] && formData[item.value]"> <template v-if="!item.addHtml && formData[item.value] && formData[item.value]">
<template v-if="item.showText && userInfo && userInfo[item.showText]"> <template v-if="item.showText && userInfo && userInfo[item.showText]">
{{ userInfo[item.showText] }}<text>|</text> {{ userInfo[item.showText] }}
<text>|</text>
</template> </template>
{{ formData[item.value] }} {{ formData[item.value] }}
</template> </template>
...@@ -45,19 +38,15 @@ ...@@ -45,19 +38,15 @@
<!-- 单选框 --> <!-- 单选框 -->
<template v-else-if="item.type === 'radio'"> <template v-else-if="item.type === 'radio'">
<radio-group class="radio-group value" @change="onRadioChange($event, item)"> <radio-group class="radio-group value" @change="onRadioChange($event, item)">
<label class="uni-list-cell uni-list-cell-pd" v-for="radio in item.radioList" <label class="uni-list-cell uni-list-cell-pd" v-for="radio in item.radioList" :key="radio.value + item.value">
:key="radio.value + item.value"> <radio style="transform: scale(0.7)" :value="radio.value" :disabled="item.disabled || radio.disabled" :checked="radio.value == item.current" />
<radio style="transform:scale(0.7)" :value="radio.value" :disabled="item.disabled || radio.disabled"
:checked="radio.value == item.current" />
<view class="radio-name">{{ radio.name }}</view> <view class="radio-name">{{ radio.name }}</view>
</label> </label>
</radio-group> </radio-group>
</template> </template>
<!-- 多行文本 --> <!-- 多行文本 -->
<template v-else-if="item.type === 'textarea'"> <template v-else-if="item.type === 'textarea'">
<textarea class="textarea" v-model="formData[item.value]" :placeholder="item.placeholder || '请输入'" <textarea class="textarea" v-model="formData[item.value]" :placeholder="item.placeholder || '请输入'" placeholder-class="textarea-placeholder" confirm-type="done" auto-height :maxlength="item.maxlength"></textarea>
placeholder-class="textarea-placeholder" confirm-type="done" auto-height
:maxlength="item.maxlength"></textarea>
</template> </template>
</view> </view>
</view> </view>
...@@ -72,7 +61,7 @@ ...@@ -72,7 +61,7 @@
<script> <script>
export default { export default {
name: "GlCell", name: 'GlCell',
props: { props: {
/** /**
* noBorder:默认false:有下边框,true:无下边框 * noBorder:默认false:有下边框,true:无下边框
...@@ -106,11 +95,11 @@ export default { ...@@ -106,11 +95,11 @@ export default {
methods: { methods: {
onCellClick(item) { onCellClick(item) {
if (item.type === 'select') { if (item.type === 'select') {
this.$emit('handleCell', item); this.$emit('handleCell', item)
} }
}, },
onRadioChange(e, item) { onRadioChange(e, item) {
this.$emit('radioChange', e, item); this.$emit('radioChange', e, item)
}, },
onValueClick(item) { onValueClick(item) {
this.$emit('handleValue', item) this.$emit('handleValue', item)
...@@ -119,7 +108,7 @@ export default { ...@@ -119,7 +108,7 @@ export default {
this.$emit('inputBlur', e, item) this.$emit('inputBlur', e, item)
} }
} }
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -168,7 +157,7 @@ export default { ...@@ -168,7 +157,7 @@ export default {
.required { .required {
display: inline-block; display: inline-block;
margin-left: toRpx(8); margin-left: toRpx(8);
color: #F24724; color: #f24724;
} }
&.only-label { &.only-label {
...@@ -248,8 +237,6 @@ export default { ...@@ -248,8 +237,6 @@ export default {
display: inline-block; display: inline-block;
} }
.textarea { .textarea {
width: 100%; width: 100%;
border-radius: toRpx(16); border-radius: toRpx(16);
......
<template> <template>
<view :class="['goods-list',{'is-defeat-order':isDefeatOrder}]"> <view :class="['goods-list', { 'is-defeat-order': isDefeatOrder }]">
<template v-if="params.loadComplete"> <template v-if="params.loadComplete">
<template v-if="listData.length"> <template v-if="listData.length">
<template v-for="(i, index) in listData"> <template v-for="(i, index) in listData">
<template v-if="isDefeatOrder"> <template v-if="isDefeatOrder">
<view <view class="item-box" :key="index">
class="item-box" <view class="goods-title flex">{{ i.goodsTypeName }}|建议价</view>
:key="index"
>
<view class="goods-title flex">{{i.goodsTypeName}}|建议价</view>
<view class="defeat-goods-list"> <view class="defeat-goods-list">
<template v-for="(item,ind) in i.upgradeGoodsList"> <template v-for="(item, ind) in i.upgradeGoodsList">
<view <view :class="['item flex', { active: checkActive(item) }]" :key="`${index}_${ind}`" @click="choose(item)">
:class="['item flex',{active:checkActive(item)}]"
:key="`${index}_${ind}`"
@click="choose(item)"
>
<view class="sprite-icon icon-tag-checked"></view> <view class="sprite-icon icon-tag-checked"></view>
<text class="goods-name text-hide"> <text class="goods-name text-hide">
{{replaceItemText(item, 'upgradeGoodsAlias') ||replaceItemText(item,'upgradeGoodsName') || replaceItemText(item.goodsInfo, 'goodsName')}} {{ replaceItemText(item, 'upgradeGoodsAlias') || replaceItemText(item, 'upgradeGoodsName') || replaceItemText(item.goodsInfo, 'goodsName') }}
</text> </text>
<template v-if="item.merchantGoodsPosition && (item.goodsInfo.goodsType == 1 || item.goodsInfo.goodsType == baseConfigData.selfBuildFilmType)"> <template v-if="item.merchantGoodsPosition && (item.goodsInfo.goodsType == 1 || item.goodsInfo.goodsType == baseConfigData.selfBuildFilmType)">
<text>「{{ item.positionStr}}」</text> <text>「{{ item.positionStr }}」</text>
</template> </template>
<template v-if="!item.merchantGoodsPosition && (item.goodsInfo.goodsType == 1 || item.goodsInfo.goodsType == baseConfigData.selfBuildFilmType)"> <template v-if="!item.merchantGoodsPosition && (item.goodsInfo.goodsType == 1 || item.goodsInfo.goodsType == baseConfigData.selfBuildFilmType)">
<view class="no-postion">无部位</view> <view class="no-postion">无部位</view>
</template> </template>
<text class="price">¥{{item.upgradePrice}}</text> <text class="price">¥{{ item.upgradePrice }}</text>
</view> </view>
</template> </template>
</view> </view>
</view> </view>
</template> </template>
<template v-else> <template v-else>
<view <view :key="index" @click="choose(i)" :class="['item flex', { active: checkActive(i) }]">
:key="index"
@click="choose(i)"
:class="['item flex',{active: checkActive(i)}]"
>
<view class="sprite-icon icon-tag-checked"></view> <view class="sprite-icon icon-tag-checked"></view>
<text class="goods-name text-hide"> <text class="goods-name text-hide">
{{replaceItemText(i.goods,'goodsAlias') ||replaceItemText(i.goods,'upgradeGoodsName') || replaceItemText(i.goodsInfo,'goodsName')}} {{ replaceItemText(i.goods, 'goodsAlias') || replaceItemText(i.goods, 'upgradeGoodsName') || replaceItemText(i.goodsInfo, 'goodsName') }}
</text> </text>
<template v-if="i.goods.merchantGoodsPosition && (i.goods.goodsInfo.goodsType == 1 || i.goods.goodsInfo.goodsType == baseConfigData.selfBuildFilmType)"> <template v-if="i.goods.merchantGoodsPosition && (i.goods.goodsInfo.goodsType == 1 || i.goods.goodsInfo.goodsType == baseConfigData.selfBuildFilmType)">
<text>「{{ i.goods.positionStr}}」</text> <text>「{{ i.goods.positionStr }}」</text>
</template> </template>
<text class="price">¥{{i.goods.price}}</text> <text class="price">¥{{ i.goods.price }}</text>
</view> </view>
</template> </template>
</template> </template>
...@@ -54,7 +43,7 @@ ...@@ -54,7 +43,7 @@
</view> </view>
</template> </template>
<script type='text/ecmascript-6'> <script type="text/ecmascript-6">
import popupmixin from './popupmixin' import popupmixin from './popupmixin'
export default { export default {
mixins: [popupmixin], mixins: [popupmixin],
...@@ -158,6 +147,7 @@ export default { ...@@ -158,6 +147,7 @@ export default {
this.list = arr this.list = arr
}, },
choose (i) { choose (i) {
let { currentIds, isDefeatOrder } = this, let { currentIds, isDefeatOrder } = this,
id = '' id = ''
if (isDefeatOrder) id = i.id if (isDefeatOrder) id = i.id
...@@ -190,7 +180,7 @@ export default { ...@@ -190,7 +180,7 @@ export default {
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang="scss">
.goods-list { .goods-list {
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(2, 1fr);
...@@ -282,4 +272,4 @@ export default { ...@@ -282,4 +272,4 @@ export default {
} }
} }
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -4,21 +4,16 @@ ...@@ -4,21 +4,16 @@
<view class="box"> <view class="box">
<scroll-view class="scroll-view" scroll-y="true"> <scroll-view class="scroll-view" scroll-y="true">
<view class="box-content"> <view class="box-content">
<GlCell :formList="formList" :formData="orderObj" @radioChange="radioChange" @inputBlur="inputBlur" <GlCell :formList="formList" :formData="orderObj" @radioChange="radioChange" @inputBlur="inputBlur" @handleCell="handleCell">
@handleCell="handleCell">
<!-- 使用v-for循环渲染产品组件,减少重复代码 --> <!-- 使用v-for循环渲染产品组件,减少重复代码 -->
<template v-for="(_, slotName) in productSlots" :slot="slotName"> <template v-for="(_, slotName) in productSlots" :slot="slotName">
<Product :key="slotName" v-if="orderObj[slotName] && orderObj[slotName].length" <Product :key="slotName" v-if="orderObj[slotName] && orderObj[slotName].length" @changeTotalPrice="changeTotalPrice" :list="orderObj[slotName]" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData"></Product>
@changeTotalPrice="changeTotalPrice" :list="orderObj[slotName]" :positionTypeList="positionTypeList"
:baseConfigData="baseConfigData"></Product>
</template> </template>
<template slot="package"> <template slot="package">
<Package v-if="orderObj.package" @changeTotalPrice="changeTotalPrice" :list="orderObj.package" <Package v-if="orderObj.package" @changeTotalPrice="changeTotalPrice" :list="orderObj.package" :positionTypeList="positionTypeList"></Package>
:positionTypeList="positionTypeList"></Package>
</template> </template>
<template slot="skuGoods"> <template slot="skuGoods">
<SkuGoods v-if="orderObj.skuGoods" :list="orderObj.skuGoods" @changeTotalPrice="changeTotalPrice" <SkuGoods v-if="orderObj.skuGoods" :list="orderObj.skuGoods" @changeTotalPrice="changeTotalPrice" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData"></SkuGoods>
:positionTypeList="positionTypeList" :baseConfigData="baseConfigData"></SkuGoods>
<view class="total" v-if="totalPrice > 0"> <view class="total" v-if="totalPrice > 0">
<view class="total-left">总价</view> <view class="total-left">总价</view>
<view class="total-right">¥{{ totalPrice }}</view> <view class="total-right">¥{{ totalPrice }}</view>
...@@ -33,8 +28,7 @@ ...@@ -33,8 +28,7 @@
</scroll-view> </scroll-view>
</view> </view>
<!-- 弹窗 --> <!-- 弹窗 -->
<order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" @onConfirm="onConfirm" <order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" />
:externalData="externalData" :popupType="popupType" />
</view> </view>
</template> </template>
...@@ -68,15 +62,18 @@ export default { ...@@ -68,15 +62,18 @@ export default {
handler(newVal) { handler(newVal) {
if (newVal) { if (newVal) {
// 处理交易数据 // 处理交易数据
const handleTransactionData = (newVal) => { const handleTransactionData = newVal => {
this.orderCreateType = newVal.type this.orderCreateType = newVal.type
if (this.orderCreateType === 'supplementOrder') { if (this.orderCreateType === 'supplementOrder') {
// 补录订单处理 // 补录订单处理
const { outTradeNo, tradeNo } = newVal.selectedItems.reduce((acc, item) => ({ const { outTradeNo, tradeNo } = newVal.selectedItems.reduce(
outTradeNo: [...(acc.outTradeNo || []), item.outTradeNo], (acc, item) => ({
tradeNo: [...(acc.tradeNo || []), item.tradeNo] outTradeNo: [...(acc.outTradeNo || []), item.outTradeNo],
}), {}) tradeNo: [...(acc.tradeNo || []), item.tradeNo]
}),
{}
)
Object.assign(this.orderObj, { Object.assign(this.orderObj, {
outTradeNo: outTradeNo.join(','), outTradeNo: outTradeNo.join(','),
...@@ -86,21 +83,19 @@ export default { ...@@ -86,21 +83,19 @@ export default {
} }
// 编辑和修改订单进入这里 // 编辑和修改订单进入这里
// 新增订单处理 // 新增订单处理
const { paramsData: { customer, customerCoupon, ...rest } } = newVal const {
paramsData: { customer, customerCoupon, ...rest }
} = newVal
// 基础字段映射 // 基础字段映射
const baseFields = ['id','orderCode', 'userId', 'employeeName', 'deliveryEmployeeName', 'deliveryUserId', const baseFields = ['id', 'orderCode', 'userId', 'employeeName', 'deliveryEmployeeName', 'deliveryUserId', 'subShopMerchantName', 'subShopMerchantId', 'sellerName', 'sellerUserId', 'sellerMerchantName', 'sellerMerchantId', 'merchantId', 'merchantName', 'customerCouponId', 'selectPayType']
'subShopMerchantName', 'subShopMerchantId', 'sellerName', 'sellerUserId',
'sellerMerchantName', 'sellerMerchantId', 'merchantId', 'merchantName',
'customerCouponId', 'selectPayType']
Object.assign(this.orderObj, Object.fromEntries(baseFields.map(field => [field, rest[field]]))) Object.assign(this.orderObj, Object.fromEntries(baseFields.map(field => [field, rest[field]])))
// 设置支付类型 // 设置支付类型
this.orderObj.payeeType = rest.selectPayType == '2' ? '1' : '0' this.orderObj.payeeType = rest.selectPayType == '2' ? '1' : '0'
// 客户信息映射 // 客户信息映射
const customerFields = ['customerName', 'customerSex', 'customerPhone', 'salesType', const customerFields = ['customerName', 'customerSex', 'customerPhone', 'salesType', 'standNo', 'plateNumber', 'experienceFlag']
'standNo', 'plateNumber', 'experienceFlag']
Object.assign(this.orderObj, Object.fromEntries(customerFields.map(field => [field, customer[field]]))) Object.assign(this.orderObj, Object.fromEntries(customerFields.map(field => [field, customer[field]])))
// 优惠券信息 // 优惠券信息
...@@ -157,7 +152,7 @@ export default { ...@@ -157,7 +152,7 @@ export default {
}, },
data() { data() {
return { return {
orderCreateType: 'createWithPay', // supplementOrder(补录订单) createWithPay(新增) orderCreateType: 'createWithPay', // supplementOrder(补录订单) createWithPay(新增)
formList: utils.deepClone(FORM_LIST), formList: utils.deepClone(FORM_LIST),
userInfo: {}, userInfo: {},
baseConfigData: {}, baseConfigData: {},
...@@ -168,13 +163,13 @@ export default { ...@@ -168,13 +163,13 @@ export default {
experienceFlag: 'Y', experienceFlag: 'Y',
payeeType: 1, payeeType: 1,
salesType: '0', salesType: '0',
frontGear: null, // 1 ,回显upgradeGoodsPosition == 1 frontGear: null, // 1 ,回显upgradeGoodsPosition == 1
frontWindow: null, // 2 frontWindow: null, // 2
rearWindow: null, // 3 rearWindow: null, // 3
rearGear: null, // 4 rearGear: null, // 4
sunRoof: null, // 5, 6,7 sunRoof: null, // 5, 6,7
package: null, package: null,
skuGoods: null // upgradeGoodsPosition 为空,则是其他精品单商品 skuGoods: null // upgradeGoodsPosition 为空,则是其他精品单商品
}, // 弹窗传入的数据}, }, // 弹窗传入的数据},
popupType: 0, popupType: 0,
popupTypeEnum, popupTypeEnum,
...@@ -325,6 +320,7 @@ export default { ...@@ -325,6 +320,7 @@ export default {
} }
} else { } else {
this.$set(this.orderObj, _typeValue.key, chooseContent) this.$set(this.orderObj, _typeValue.key, chooseContent)
console.log(this.orderObj, 'this.orderObj')
} }
// 商品类,需计算总价 // 商品类,需计算总价
setTimeout(() => { setTimeout(() => {
...@@ -412,7 +408,7 @@ export default { ...@@ -412,7 +408,7 @@ export default {
async submit() { async submit() {
console.log(this.orderObj) console.log(this.orderObj)
if (!this.checkRequired()) return if (!this.checkRequired()) return
if (!await this.checkDailyReport()) { if (!(await this.checkDailyReport())) {
const { orderCreateType } = this const { orderCreateType } = this
const obj = utils.deepClone(this.orderObj) const obj = utils.deepClone(this.orderObj)
const otherCustomer = ['standNo', 'plateNumber', 'customerSex', 'experienceFlag', 'salesType'] const otherCustomer = ['standNo', 'plateNumber', 'customerSex', 'experienceFlag', 'salesType']
...@@ -516,7 +512,7 @@ export default { ...@@ -516,7 +512,7 @@ export default {
}) })
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice) { } else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice) {
console.log(item.multipleSpecificationsGoods, '多规格') console.log(item.multipleSpecificationsGoods, '多规格')
total += parseFloat(item.multipleSpecificationsGoods.goods.sellPrice) * parseInt(item.multipleSpecificationsGoods.number||1) total += parseFloat(item.multipleSpecificationsGoods.goods.sellPrice) * parseInt(item.multipleSpecificationsGoods.number || 1)
} }
}) })
} }
...@@ -700,7 +696,7 @@ export default { ...@@ -700,7 +696,7 @@ export default {
this.otherProduct.push(val) this.otherProduct.push(val)
} }
}) })
console.log(arrMap, 'arrMap')
// 批量设置 hidden 属性 // 批量设置 hidden 属性
Object.keys(arrMap).forEach(key => { Object.keys(arrMap).forEach(key => {
const cell = this.formList[2].find(item => item.value === key) const cell = this.formList[2].find(item => item.value === key)
...@@ -708,23 +704,24 @@ export default { ...@@ -708,23 +704,24 @@ export default {
}) })
const subOrderList = this.goodsList || [] const subOrderList = this.goodsList || []
let chooseList = []; console.log('subOrderList', subOrderList)
let chooseList = []
subOrderList.map(e => { subOrderList.map(e => {
// 普通商品 // 普通商品
if (e && !e.packageName) { if (e && !e.packageName) {
if (e.specificationData.indexOf(';~;') == -1) { if (e.specificationData.indexOf(';~;') == -1) {
// 修复取值字段名字错误问题 // 修复取值字段名字错误问题
if (!e.price) { if (!e.price) {
e.price = utils.decimal(Number(e.totalPrice / e.number), 2); e.price = utils.decimal(Number(e.totalPrice / e.number), 2)
//最低价 //最低价
} }
e.sellPrice = e.price e.sellPrice = e.price
e.goodsId = e.merchantGoodsId e.goodsId = e.merchantGoodsId
if (!e.minSellPrice) e.minSellPrice = e.upgradeShopMinPrice; if (!e.minSellPrice) e.minSellPrice = e.upgradeShopMinPrice
e.goodsInfo = { e.goodsInfo = {
goodsName: e.upgradeGoodsAlias || e.upgradeGoodsName, goodsName: e.upgradeGoodsAlias || e.upgradeGoodsName
}; }
e.merchantGoodsId = e.merchantGoodsId || e.id; e.merchantGoodsId = e.merchantGoodsId || e.id
chooseList.push({ chooseList.push({
goodsFlag: 1, goodsFlag: 1,
goods: e, goods: e,
...@@ -736,17 +733,17 @@ export default { ...@@ -736,17 +733,17 @@ export default {
if (e.specificationData.indexOf(';~;') > -1) { if (e.specificationData.indexOf(';~;') > -1) {
// 修复取值字段名字错误问题 // 修复取值字段名字错误问题
if (!e.price) { if (!e.price) {
e.price = utils.decimal(Number(e.totalPrice / e.number), 2); e.price = utils.decimal(Number(e.totalPrice / e.number), 2)
//最低价 //最低价
e.sellPrice = e.price e.sellPrice = e.price
} }
e.goodsId = e.merchantGoodsId e.goodsId = e.merchantGoodsId
if (!e.minSellPrice) e.minSellPrice = e.upgradeShopMinPrice; if (!e.minSellPrice) e.minSellPrice = e.upgradeShopMinPrice
e.goodsInfo = { e.goodsInfo = {
goodsName: e.upgradeGoodsAlias || e.upgradeGoodsName, goodsName: e.upgradeGoodsAlias || e.upgradeGoodsName
}; }
e.count = e.number; e.count = e.number
e.merchantGoodsId = e.merchantGoodsId || e.id; e.merchantGoodsId = e.merchantGoodsId || e.id
let specificdata = this.handleSpecificationsEcho(e) let specificdata = this.handleSpecificationsEcho(e)
console.log(specificdata, 'specificdata') console.log(specificdata, 'specificdata')
chooseList = chooseList.concat(specificdata) chooseList = chooseList.concat(specificdata)
...@@ -754,24 +751,22 @@ export default { ...@@ -754,24 +751,22 @@ export default {
} }
// 套餐 // 套餐
if (e && e.packageName) { if (e && e.packageName) {
e.packageGoodsOrderList.forEach((g) => { e.packageGoodsOrderList.forEach(g => {
g.oldPrice = g.sellPrice || g.upgradePrice g.oldPrice = g.sellPrice || g.upgradePrice
// g.sellPrice = g.sellPrice || g.upgradePrice; // g.sellPrice = g.sellPrice || g.upgradePrice;
g.price = g.totalPrice ? g.price = g.totalPrice ? Number(g.totalPrice) / Number(g.number) : g.sellPrice
Number(g.totalPrice) / Number(g.number) :
g.sellPrice;
g.sellPrice = g.price g.sellPrice = g.price
}); })
e.goodsList = e.packageGoodsOrderList e.goodsList = e.packageGoodsOrderList
e.upgradePrice = e.goodsList.reduce((prev, cur) => { e.upgradePrice = e.goodsList.reduce((prev, cur) => {
console.log(prev, cur) console.log(prev, cur)
return prev + cur.sellPrice; return prev + cur.sellPrice
}, 0); }, 0)
e.number = e.goodsList.length ? e.goodsList[0].number : 1; e.number = e.goodsList.length ? e.goodsList[0].number : 1
e.price = e.goodsList.reduce((prev, cur) => { e.price = e.goodsList.reduce((prev, cur) => {
return prev + Number(cur.totalPrice) / Number(cur.number); return prev + Number(cur.totalPrice) / Number(cur.number)
}, 0); }, 0)
chooseList.push({ chooseList.push({
isType: 'meal', isType: 'meal',
...@@ -787,17 +782,38 @@ export default { ...@@ -787,17 +782,38 @@ export default {
const _singleGoods = chooseList.filter(item => item.goodsFlag == 1) const _singleGoods = chooseList.filter(item => item.goodsFlag == 1)
const _packageGoods = chooseList.filter(item => item.goodsFlag == 3) const _packageGoods = chooseList.filter(item => item.goodsFlag == 3)
const _skuGoods = chooseList.filter(item => item.goodsFlag == 2) || [] const _skuGoods = chooseList.filter(item => item.goodsFlag == 2) || []
console.log(_singleGoods, 'singleGoods')
if (_singleGoods) { if (_singleGoods) {
// 回显upgradeGoodsPosition 1:前挡 2:前窗 3:后窗 4:后挡 5、6、7:天窗。 为空则是其他精品 // 回显upgradeGoodsPosition 1:前挡 2:前窗 3:后窗 4:后挡 5、6、7:天窗。 为空则是其他精品
this.$set(this.orderObj, 'frontGear', _singleGoods.filter(item => item.goods.upgradeGoodsPosition == 1)) this.$set(
this.$set(this.orderObj, 'frontWindow', _singleGoods.filter(item => item.goods.upgradeGoodsPosition == 2)) this.orderObj,
this.$set(this.orderObj, 'rearWindow', _singleGoods.filter(item => item.goods.upgradeGoodsPosition == 3)) 'frontGear',
this.$set(this.orderObj, 'rearGear', _singleGoods.filter(item => item.goods.upgradeGoodsPosition == 4)) _singleGoods.filter(item => item.goods.upgradeGoodsPosition == 1)
this.$set(this.orderObj, 'sunRoof', _singleGoods.filter(item => item.goods.upgradeGoodsPosition == 5 || item.goods.upgradeGoodsPosition == 6 || item.goods.upgradeGoodsPosition == 7)) )
this.$set(
this.orderObj,
'frontWindow',
_singleGoods.filter(item => item.goods.upgradeGoodsPosition == 2)
)
this.$set(
this.orderObj,
'rearWindow',
_singleGoods.filter(item => item.goods.upgradeGoodsPosition == 3)
)
this.$set(
this.orderObj,
'rearGear',
_singleGoods.filter(item => item.goods.upgradeGoodsPosition == 4)
)
this.$set(
this.orderObj,
'sunRoof',
_singleGoods.filter(item => item.goods.upgradeGoodsPosition == 5 || item.goods.upgradeGoodsPosition == 6 || item.goods.upgradeGoodsPosition == 7)
)
// 将没有upgradeGoodsPosition的商品添加到_skuGoods中 // 将没有upgradeGoodsPosition的商品添加到_skuGoods中
const noPositionGoods = _singleGoods.filter(item => !item.goods.upgradeGoodsPosition); const noPositionGoods = _singleGoods.filter(item => !item.goods.upgradeGoodsPosition)
if (noPositionGoods.length > 0) { if (noPositionGoods.length > 0) {
_skuGoods.push(...noPositionGoods); _skuGoods.push(...noPositionGoods)
} }
} }
if (_packageGoods) { if (_packageGoods) {
...@@ -807,10 +823,11 @@ export default { ...@@ -807,10 +823,11 @@ export default {
if (_skuGoods && _skuGoods.length) { if (_skuGoods && _skuGoods.length) {
this.$set(this.orderObj, 'skuGoods', _skuGoods) this.$set(this.orderObj, 'skuGoods', _skuGoods)
} }
console.log(this.orderObj, 'this.orderObj')
this.changeTotalPrice() this.changeTotalPrice()
}, },
handleSpecificationsEcho(item) { handleSpecificationsEcho(item) {
let skuArr = []; let skuArr = []
const { otherProduct } = this, const { otherProduct } = this,
arr = item.specificationData.split('/'), arr = item.specificationData.split('/'),
str = arr.join(';~;'), str = arr.join(';~;'),
...@@ -820,7 +837,7 @@ export default { ...@@ -820,7 +837,7 @@ export default {
goods: null, goods: null,
active: true, active: true,
isFlag: true //初始化进来不显示标识 isFlag: true //初始化进来不显示标识
}; }
otherProduct.forEach(data => { otherProduct.forEach(data => {
if (data.goodsFlag == 2) { if (data.goodsFlag == 2) {
let tempData = data.multipleSpecificationsGoods.specificationGoodsMap[str] let tempData = data.multipleSpecificationsGoods.specificationGoodsMap[str]
...@@ -841,15 +858,12 @@ export default { ...@@ -841,15 +858,12 @@ export default {
skuArr.push(obj) skuArr.push(obj)
} }
}) })
} }
} }
}) })
console.log(skuArr) console.log(skuArr)
return skuArr return skuArr
}, }
} }
} }
</script> </script>
......
<template> <template>
<view class="defeat-order"> <view class="defeat-order">
<view class="common-title">战败录单</view> <view class="common-title">战败下单</view>
<view class="box"> <view class="box">
<scroll-view class="scroll-view" scroll-y="true"> <scroll-view class="scroll-view" scroll-y="true">
<view class="box-content"> <view class="box-content">
<GlCell :formList="formList" :formData="orderObj" @radioChange="radioChange" @inputBlur="inputBlur" @handleCell="handleCell"> <GlCell :formList="formList" :formData="orderObj" @radioChange="radioChange" @inputBlur="inputBlur" @handleCell="handleCell">
<!-- 使用v-for循环渲染产品组件,减少重复代码 --> <!-- 使用v-for循环渲染产品组件,减少重复代码 -->
<template v-for="(_, slotName) in productSlots" :slot="slotName"> <template v-for="(_, slotName) in productSlots" :slot="slotName">
<Product :key="slotName" v-if="orderObj[slotName] && orderObj[slotName].length" @changeTotalPrice="changeTotalPrice" :list="orderObj[slotName]" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData"></Product> <Product :key="slotName" :isDisabled="true" v-if="orderObj[slotName] && orderObj[slotName].length" @changeTotalPrice="changeTotalPrice" :list="orderObj[slotName]" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData"></Product>
</template> </template>
<template slot="package"> <template slot="package">
<Package v-if="orderObj.package" @changeTotalPrice="changeTotalPrice" :list="orderObj.package" :positionTypeList="positionTypeList"></Package> <Package v-if="orderObj.package" @changeTotalPrice="changeTotalPrice" :list="orderObj.package" :positionTypeList="positionTypeList"></Package>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</scroll-view> </scroll-view>
</view> </view>
<!-- 弹窗 --> <!-- 弹窗 -->
<order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" /> <order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" :isDefeatOrder="true" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" />
</view> </view>
</template> </template>
...@@ -47,6 +47,7 @@ import GlCell from '../../../../components/Form/GlCell.vue' ...@@ -47,6 +47,7 @@ import GlCell from '../../../../components/Form/GlCell.vue'
import Product from './Product.vue' import Product from './Product.vue'
import Package from './Package.vue' import Package from './Package.vue'
import SkuGoods from './SkuGoods.vue' import SkuGoods from './SkuGoods.vue'
import { checkDailyReport, showNextModal } from '@/utils/modalUtils'
import { DEFEAT_FORM_LIST, popupTypeEnum, payTypeList } from '../contant' import { DEFEAT_FORM_LIST, popupTypeEnum, payTypeList } from '../contant'
export default { export default {
name: 'DefeatOrder', name: 'DefeatOrder',
...@@ -77,14 +78,11 @@ export default { ...@@ -77,14 +78,11 @@ export default {
} = newVal } = newVal
// 基础字段映射 // 基础字段映射
const baseFields = ['id', 'orderCode', 'userId', 'employeeName', 'deliveryEmployeeName', 'deliveryUserId', 'subShopMerchantName', 'subShopMerchantId', 'sellerName', 'sellerUserId', 'sellerMerchantName', 'sellerMerchantId', 'merchantId', 'merchantName', 'customerCouponId', 'selectPayType'] const baseFields = ['id', 'orderCode', 'userId', 'employeeName', 'deliveryEmployeeName', 'deliveryUserId', 'subShopMerchantName', 'subShopMerchantId', 'sellerName', 'sellerUserId', 'sellerMerchantName', 'sellerMerchantId', 'merchantId', 'merchantName', 'customerCouponId']
Object.assign(this.orderObj, Object.fromEntries(baseFields.map(field => [field, rest[field]]))) Object.assign(this.orderObj, Object.fromEntries(baseFields.map(field => [field, rest[field]])))
// 设置支付类型
this.orderObj.payeeType = rest.selectPayType === '2' ? '1' : '0'
// 客户信息映射 // 客户信息映射
const customerFields = ['customerName', 'customerSex', 'customerPhone', 'salesType', 'standNo', 'plateNumber', 'experienceFlag'] const customerFields = ['customerName', 'customerSex', 'customerPhone', 'standNo', 'plateNumber', 'experienceFlag']
Object.assign(this.orderObj, Object.fromEntries(customerFields.map(field => [field, customer[field]]))) Object.assign(this.orderObj, Object.fromEntries(customerFields.map(field => [field, customer[field]])))
// 优惠券信息 // 优惠券信息
...@@ -108,11 +106,12 @@ export default { ...@@ -108,11 +106,12 @@ export default {
plateNumber: customer.plateNumber, plateNumber: customer.plateNumber,
customerSex: customer.customerSex, customerSex: customer.customerSex,
experienceFlag: customer.experienceFlag, experienceFlag: customer.experienceFlag,
salesType: customer.salesType,
customerName: customer.customerName customerName: customer.customerName
} }
this.orderObj.carBrand = `${customer.carBrand}-${customer.carChildsBrandName}-${customer.carSeriesName}` this.orderObj.carBrand = `${customer.carBrand}-${customer.carChildsBrandName}-${customer.carSeriesName}`
const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
this.$set(this.orderObj, 'todayShow', dayjs(this.orderObj.createDate).format('YYYY-MM-DD') + ' ' + weeks[dayjs(this.orderObj.createDate).day()])
// 更新表单状态 // 更新表单状态
const updateFormCell = (formIndex, fieldName, value) => { const updateFormCell = (formIndex, fieldName, value) => {
...@@ -121,10 +120,8 @@ export default { ...@@ -121,10 +120,8 @@ export default {
} }
const formUpdates = [ const formUpdates = [
[1, 'salesType', customer.salesType],
[1, 'customerSex', customer.customerSex], [1, 'customerSex', customer.customerSex],
[1, 'experienceFlag', customer.experienceFlag], [1, 'experienceFlag', customer.experienceFlag],
[2, 'selectPayType', this.orderObj.selectPayType],
[2, 'payeeType', this.orderObj.payeeType] [2, 'payeeType', this.orderObj.payeeType]
] ]
...@@ -150,7 +147,6 @@ export default { ...@@ -150,7 +147,6 @@ export default {
customerSex: '1', customerSex: '1',
experienceFlag: 'Y', experienceFlag: 'Y',
payeeType: 1, payeeType: 1,
salesType: '0',
frontGear: null, // 1 ,回显upgradeGoodsPosition == 1 frontGear: null, // 1 ,回显upgradeGoodsPosition == 1
frontWindow: null, // 2 frontWindow: null, // 2
rearWindow: null, // 3 rearWindow: null, // 3
...@@ -169,6 +165,7 @@ export default { ...@@ -169,6 +165,7 @@ export default {
configPayTypeList: [], // 园区店配置支持的支付方式 configPayTypeList: [], // 园区店配置支持的支付方式
payTypeList, payTypeList,
goodsList: [], goodsList: [],
otherProduct: [],
positionTypeList: [], positionTypeList: [],
valueKey: '', valueKey: '',
totalPrice: 0, totalPrice: 0,
...@@ -202,6 +199,9 @@ export default { ...@@ -202,6 +199,9 @@ export default {
initData() { initData() {
const { userInfo } = this const { userInfo } = this
if (!this.orderObj.id) { if (!this.orderObj.id) {
const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
this.$set(this.orderObj, 'todayShow', dayjs().format('YYYY-MM-DD') + ' ' + weeks[dayjs().day()])
this.$set(this.orderObj, 'createDate', dayjs().format('YYYY-MM-DD'))
// 在原有的 orderObj 对象上新增这些属性 // 在原有的 orderObj 对象上新增这些属性
Object.assign(this.orderObj, { Object.assign(this.orderObj, {
sellerMerchantName: userInfo.merchantName, sellerMerchantName: userInfo.merchantName,
...@@ -212,6 +212,7 @@ export default { ...@@ -212,6 +212,7 @@ export default {
merchantName: userInfo.shopMerchantName merchantName: userInfo.shopMerchantName
}) })
} }
this.getShopMerchantPointConfig(userInfo.shopMerchantId) this.getShopMerchantPointConfig(userInfo.shopMerchantId)
this.getSubShopMerchantList(userInfo.shopMerchantId) this.getSubShopMerchantList(userInfo.shopMerchantId)
this.getSetting() this.getSetting()
...@@ -265,7 +266,9 @@ export default { ...@@ -265,7 +266,9 @@ export default {
this.$set(this.orderObj, _typeValue.key, `${chooseContent.carBrand}-${chooseContent.carChildsBrandName}-${chooseContent.carSeriesName}`) this.$set(this.orderObj, _typeValue.key, `${chooseContent.carBrand}-${chooseContent.carChildsBrandName}-${chooseContent.carSeriesName}`)
this.orderObj.customer = { this.orderObj.customer = {
...(this.orderObj.customer || {}), ...(this.orderObj.customer || {}),
...chooseContent ...chooseContent,
standNo: '',
plateNumber: ''
} }
} else if (_typeValue.key == 'couponInfo') { } else if (_typeValue.key == 'couponInfo') {
// 礼券 // 礼券
...@@ -277,18 +280,35 @@ export default { ...@@ -277,18 +280,35 @@ export default {
}) })
this.$set(this.orderObj, 'couponInfo', couponName + customerCouponCode) this.$set(this.orderObj, 'couponInfo', couponName + customerCouponCode)
} else if (productFields.includes(_typeValue.key)) { } else if (productFields.includes(_typeValue.key)) {
if (_typeValue.key == 'skuGoods') {
if (!this.orderObj[_typeValue.key]) {
this.$set(this.orderObj, _typeValue.key, chooseContent)
} else {
// 过滤出已选的goodFlag为2的对象
const selectedGoods = this.orderObj[_typeValue.key].filter(item => item.goodsFlag === 2)
const singleGoods = chooseContent.filter(item => item.goodsFlag === 1)
const moreGoods = chooseContent
.filter(item => item.goodsFlag === 2)
.filter(item => {
return !selectedGoods.some(selectedItem => selectedItem.multipleSpecificationsGoods.id === item.multipleSpecificationsGoods.id)
})
// 合并已选的goodFlag为2的对象
this.orderObj[_typeValue.key] = [...singleGoods, ...moreGoods, ...selectedGoods]
}
} else {
// 手动拼装和新增工单一样的结构
console.log(this.orderObj)
this.$set(this.orderObj, _typeValue.key, Array.isArray(chooseContent) ? chooseContent.map(item => ({ goodsFlag: 1, goods: { ...item, sellPrice: item.price } })) : [{ goodsFlag: 1, goods: chooseContent }])
}
// 商品类,需计算总价 // 商品类,需计算总价
this.$set(this.orderObj, _typeValue.key, val.chooseContent) setTimeout(() => {
this.$nextTick(() => {
// 确保数据更新后再计算总价
this.changeTotalPrice() this.changeTotalPrice()
}) }, 0)
} else if (_typeValue.key == 'todayShow') { } else if (_typeValue.key == 'todayShow') {
const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'] const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
this.$set(this.orderObj, 'todayShow', dayjs(chooseContent).format('YYYY-MM-DD') + ' ' + weeks[dayjs(chooseContent).day()]) this.$set(this.orderObj, 'todayShow', dayjs(chooseContent).format('YYYY-MM-DD') + ' ' + weeks[dayjs(chooseContent).day()])
this.$set(this.orderObj, 'createDate', dayjs(chooseContent).format('YYYY-MM-DD')) this.$set(this.orderObj, 'createDate', dayjs(chooseContent).format('YYYY-MM-DD'))
} else if (_typeValue.key) { } else if (_typeValue.key) {
console.log(_typeValue)
this.orderObj[_typeValue.targetIdKey] = chooseContent[_typeValue.sourceIdKey] this.orderObj[_typeValue.targetIdKey] = chooseContent[_typeValue.sourceIdKey]
this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey]) this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey])
} }
...@@ -348,7 +368,7 @@ export default { ...@@ -348,7 +368,7 @@ export default {
// 处理onlyLabel为true的特殊校验 // 处理onlyLabel为true的特殊校验
if (onlyLabelItem.length > 0) { if (onlyLabelItem.length > 0) {
// 检查frontGear、frontWindow、rearGear、rearWindow、sunRoof和couponInfo字段中是否至少有一个不为空 // 检查frontGear、frontWindow、rearGear、rearWindow、sunRoof和couponInfo字段中是否至少有一个不为空
const labelFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof'] const labelFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
const hasValue = labelFields.some(field => { const hasValue = labelFields.some(field => {
console.log(field, this.orderObj[field]) console.log(field, this.orderObj[field])
const value = this.orderObj[field] const value = this.orderObj[field]
...@@ -357,7 +377,7 @@ export default { ...@@ -357,7 +377,7 @@ export default {
console.log(hasValue, hasValue) console.log(hasValue, hasValue)
if (!hasValue) { if (!hasValue) {
uni.showToast({ uni.showToast({
title: '请至少选择一个产品', title: '商品不能为空',
icon: 'none' icon: 'none'
}) })
return false return false
...@@ -369,11 +389,13 @@ export default { ...@@ -369,11 +389,13 @@ export default {
// 提交 // 提交
async submit() { async submit() {
console.log(this.orderObj) // 校验是否填写昨日日报
let staffCheck = await checkDailyReport()
if (staffCheck) return false
if (!this.checkRequired()) return if (!this.checkRequired()) return
const { orderCreateType } = this const { orderCreateType } = this
const obj = utils.deepClone(this.orderObj) const obj = utils.deepClone(this.orderObj)
const otherCustomer = ['standNo', 'plateNumber', 'customerSex', 'experienceFlag', 'salesType'] const otherCustomer = ['customerSex', 'experienceFlag']
obj.customer = { obj.customer = {
...obj.customer, ...obj.customer,
...otherCustomer.reduce((acc, key) => { ...otherCustomer.reduce((acc, key) => {
...@@ -398,11 +420,12 @@ export default { ...@@ -398,11 +420,12 @@ export default {
return { return {
totalPrice: item.goods.sellPrice, totalPrice: item.goods.sellPrice,
number: item.goods.number, number: item.goods.number,
merchantGoodsId: item.goods.merchantGoodsId merchantGoodsId: item.goods.merchantGoodsId || item.goods.id,
baseGoodsId: item.goods.baseGoodsId
} }
}) })
} }
obj.notUpgradeOrderList = [{ customer: obj.customer, subOrderList: obj.subOrderList }] obj.notUpgradeOrderList = [{ customer: obj.customer, subOrderList: obj.subOrderList, confirmIndex: false, isTouchMove: false, txtStyle: 'left:0' }]
delete obj.carBrand delete obj.carBrand
delete obj.couponInfo delete obj.couponInfo
...@@ -413,6 +436,8 @@ export default { ...@@ -413,6 +436,8 @@ export default {
delete obj.package delete obj.package
delete obj.payeeType delete obj.payeeType
delete obj.skuGoods delete obj.skuGoods
delete obj.customerName
delete obj.customerPhone
console.log(obj, 'rucan') console.log(obj, 'rucan')
const res = await uni.$api.boutiqueApi.notUpgradeOrder({ json: JSON.stringify(obj) }) const res = await uni.$api.boutiqueApi.notUpgradeOrder({ json: JSON.stringify(obj) })
...@@ -428,14 +453,27 @@ export default { ...@@ -428,14 +453,27 @@ export default {
// 计算所有产品的总价 // 计算所有产品的总价
changeTotalPrice() { changeTotalPrice() {
let total = 0 let total = 0
// 遍历所有产品槽位 // 遍历所有商品
Object.keys(this.productSlots).forEach(slotName => { const productFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
productFields.forEach(slotName => {
const productList = this.orderObj[slotName] const productList = this.orderObj[slotName]
if (Array.isArray(productList) && productList.length > 0) { if (Array.isArray(productList) && productList.length > 0) {
// 计算每个产品的价格 * 数量,并累加到总价 // 计算每个产品的价格 * 数量,并累加到总价
productList.forEach(item => { productList.forEach(item => {
if (item.goods && item.goods.sellPrice && item.goods.number) { if (item.goods && item.goods.sellPrice && item.goods.number) {
total += parseFloat(item.goods.sellPrice) * parseInt(item.goods.number) total += parseFloat(item.goods.sellPrice) * parseInt(item.goods.number)
} else if (item.packageGoods && item.packageGoods.upgradePrice && item.packageGoods.number) {
console.log(item.packageGoods, '套餐')
// if (item.packageGoods.price) {
// total += parseFloat(item.packageGoods.price) * parseInt(item.packageGoods.number)
// } else {
// total += parseFloat(item.packageGoods.upgradePrice) * parseInt(item.packageGoods.number)
// }
item.packageGoods.goodsList.forEach(i => {
total += parseFloat(i.sellPrice) * parseInt(item.packageGoods.number)
})
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice && item.multipleSpecificationsGoods.number) {
total += parseFloat(item.multipleSpecificationsGoods.goods.sellPrice) * parseInt(item.multipleSpecificationsGoods.number)
} }
}) })
} }
...@@ -461,10 +499,10 @@ export default { ...@@ -461,10 +499,10 @@ export default {
const employeeCell = this.formList[0].find(item => item.label === '销售顾问') const employeeCell = this.formList[0].find(item => item.label === '销售顾问')
if (employeeCell) employeeCell.label = '销售顾问/录单员' if (employeeCell) employeeCell.label = '销售顾问/录单员'
// 找到formList中label为"交付专员"的对象,添加hidden: true // 找到formList中label为"交付专员"的对象,添加hidden: true
const deliveryCell = this.formList[0].find(item => item.label === '交付专员') // const deliveryCell = this.formList[0].find(item => item.label === '交付专员')
if (deliveryCell) { // if (deliveryCell) {
deliveryCell.hidden = false // deliveryCell.hidden = false
} // }
} }
}, },
// 判断二级流量方 // 判断二级流量方
...@@ -543,7 +581,7 @@ export default { ...@@ -543,7 +581,7 @@ export default {
cell.radioList = this.orderObj.payeeType == 1 ? this.merchantPayList : this.djPayList cell.radioList = this.orderObj.payeeType == 1 ? this.merchantPayList : this.djPayList
if (cell.radioList && cell.radioList.length > 0) { if (cell.radioList && cell.radioList.length > 0) {
cell.current = cell.radioList[0].value cell.current = cell.radioList[0].value
this.orderObj.selectPayType = cell.radioList[0].value // this.orderObj.selectPayType = cell.radioList[0].value
} }
} }
}, },
...@@ -568,11 +606,10 @@ export default { ...@@ -568,11 +606,10 @@ export default {
// 商品列表 // 商品列表
async getSelectOrderGoodsList() { async getSelectOrderGoodsList() {
const { userInfo } = this const { userInfo } = this
const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({ const res = await uni.$api.boutiqueApi.getOrderBaseGoodsList({
merchantId: userInfo.shopMerchantId, merchantId: userInfo.shopMerchantId,
sceneType: userInfo.sceneType upradeFlag: 'N'
}) })
console.log(res, '=====getSelectOrderGoodsList')
// 分类映射 // 分类映射
const posMap = { const posMap = {
...@@ -590,28 +627,151 @@ export default { ...@@ -590,28 +627,151 @@ export default {
rearWindow: [], rearWindow: [],
sunRoof: [] sunRoof: []
} }
// 目前战败下单,只能选取 太阳膜这个类别的商品
const dataList = res.filter(val => val.goodsType === 1).flatMap(val => val.upgradeGoodsList)
console.log(dataList)
dataList.forEach(subVal => {
subVal.positionStr = subVal.position
subVal.upgradePrice = subVal.sellPrice
subVal.price = subVal.sellPrice
subVal.goodsId = subVal.merchantGoodsId
res.forEach(val => { Object.keys(posMap).forEach(key => {
if (val.goodsFlag == 1) { if (posMap[key].includes(subVal.merchantGoodsPosition)) {
let subVal = val.goods arrMap[key].push({ goodsFlag: 1, goods: subVal })
subVal.positionStr = subVal.position }
subVal.upgradePrice = subVal.sellPrice })
subVal.price = subVal.sellPrice
subVal.goodsId = subVal.merchantGoodsId
Object.keys(posMap).forEach(key => {
if (posMap[key].includes(subVal.merchantGoodsPosition)) {
arrMap[key].push(val)
}
})
}
}) })
console.log('arrMap', arrMap)
// 批量设置 hidden 属性 // 批量设置 hidden 属性
Object.keys(arrMap).forEach(key => { Object.keys(arrMap).forEach(key => {
const cell = this.formList[2].find(item => item.value === key) const cell = this.formList[2].find(item => item.value === key)
if (cell) cell.hidden = arrMap[key].length === 0 if (cell) cell.hidden = arrMap[key].length === 0
}) })
const subOrderList = this.goodsList || []
let chooseList = []
console.log('subOrderList', subOrderList)
subOrderList.map(e => {
// 普通商品
if (e && !e.packageName) {
if (e.specificationData.indexOf(';~;') == -1) {
// 修复取值字段名字错误问题
if (!e.price) {
e.price = utils.decimal(Number(e.totalPrice / e.number), 2)
//最低价
}
e.sellPrice = e.price
e.goodsId = e.merchantGoodsId
if (!e.minSellPrice) e.minSellPrice = e.upgradeShopMinPrice
e.goodsInfo = {
goodsName: e.upgradeGoodsAlias || e.upgradeGoodsName
}
e.merchantGoodsId = e.merchantGoodsId || e.id
chooseList.push({
goodsFlag: 1,
goods: e,
number: e.number,
active: true
})
}
// 多规格商品
// if (e.specificationData.indexOf(';~;') > -1) {
// // 修复取值字段名字错误问题
// if (!e.price) {
// e.price = utils.decimal(Number(e.totalPrice / e.number), 2)
// //最低价
// e.sellPrice = e.price
// }
// e.goodsId = e.merchantGoodsId
// if (!e.minSellPrice) e.minSellPrice = e.upgradeShopMinPrice
// e.goodsInfo = {
// goodsName: e.upgradeGoodsAlias || e.upgradeGoodsName
// }
// e.count = e.number
// e.merchantGoodsId = e.merchantGoodsId || e.id
// let specificdata = this.handleSpecificationsEcho(e)
// console.log(specificdata, 'specificdata')
// chooseList = chooseList.concat(specificdata)
// }
}
// 套餐
// if (e && e.packageName) {
// e.packageGoodsOrderList.forEach(g => {
// g.oldPrice = g.sellPrice || g.upgradePrice
// // g.sellPrice = g.sellPrice || g.upgradePrice;
// g.price = g.totalPrice ? Number(g.totalPrice) / Number(g.number) : g.sellPrice
// g.sellPrice = g.price
// })
// e.goodsList = e.packageGoodsOrderList
// e.upgradePrice = e.goodsList.reduce((prev, cur) => {
// console.log(prev, cur)
// return prev + cur.sellPrice
// }, 0)
// e.number = e.goodsList.length ? e.goodsList[0].number : 1
// e.price = e.goodsList.reduce((prev, cur) => {
// return prev + Number(cur.totalPrice) / Number(cur.number)
// }, 0)
// chooseList.push({
// isType: 'meal',
// active: true,
// goodsFlag: 3,
// packageGoods: e,
// number: e.number,
// totalPrice: e.price
// })
// }
})
console.log(chooseList, 'chooseList')
const _singleGoods = chooseList
// const _packageGoods = chooseList.filter(item => item.goodsFlag == 3)
// const _skuGoods = chooseList.filter(item => item.goodsFlag == 2) || []
console.log(_singleGoods, 'singleGoods')
if (_singleGoods) {
// 回显upgradeGoodsPosition 1:前挡 2:前窗 3:后窗 4:后挡 5、6、7:天窗。 为空则是其他精品
this.$set(
this.orderObj,
'frontGear',
_singleGoods.filter(item => item.goods.upgradeGoodsPosition == 1)
)
this.$set(
this.orderObj,
'frontWindow',
_singleGoods.filter(item => item.goods.upgradeGoodsPosition == 2)
)
this.$set(
this.orderObj,
'rearWindow',
_singleGoods.filter(item => item.goods.upgradeGoodsPosition == 3)
)
this.$set(
this.orderObj,
'rearGear',
_singleGoods.filter(item => item.goods.upgradeGoodsPosition == 4)
)
this.$set(
this.orderObj,
'sunRoof',
_singleGoods.filter(item => item.goods.upgradeGoodsPosition == 5 || item.goods.upgradeGoodsPosition == 6 || item.goods.upgradeGoodsPosition == 7)
)
// 将没有upgradeGoodsPosition的商品添加到_skuGoods中
// const noPositionGoods = _singleGoods.filter(item => !item.goods.upgradeGoodsPosition)
// if (noPositionGoods.length > 0) {
// _skuGoods.push(...noPositionGoods)
// }
}
// if (_packageGoods) {
// this.$set(this.orderObj, 'package', _packageGoods)
// }
// console.log(_skuGoods, '_skuGoods')
// if (_skuGoods && _skuGoods.length) {
// this.$set(this.orderObj, 'skuGoods', _skuGoods)
// }
console.log(this.orderObj, 'this.orderObj')
this.changeTotalPrice()
}, },
// 获取不升级常用字符列表 // 获取不升级常用字符列表
getConfigList() { getConfigList() {
...@@ -629,6 +789,44 @@ export default { ...@@ -629,6 +789,44 @@ export default {
this.$set(this.orderObj, 'refusalReason', (this.orderObj?.refusalReason || '') + text) this.$set(this.orderObj, 'refusalReason', (this.orderObj?.refusalReason || '') + text)
this.orderObj.customer.refusalReason = (this.orderObj.customer.refusalReason || '') + text this.orderObj.customer.refusalReason = (this.orderObj.customer.refusalReason || '') + text
console.log(this.orderObj.customer?.refusalReason) console.log(this.orderObj.customer?.refusalReason)
},
handleSpecificationsEcho(item) {
let skuArr = []
const { otherProduct } = this,
arr = item.specificationData.split('/'),
str = arr.join(';~;'),
obj = {
count: item.count,
goodsFlag: 2,
goods: null,
active: true,
isFlag: true //初始化进来不显示标识
}
otherProduct.forEach(data => {
if (data.goodsFlag == 2) {
let tempData = data.multipleSpecificationsGoods.specificationGoodsMap[str]
if (tempData) {
tempData.forEach(temp => {
if (temp.merchantGoodsId == item.goodsId) {
obj.multipleSpecificationsGoods = {
...data.multipleSpecificationsGoods,
baseGoodsName: item.goodsName || item.upgradeGoodsName,
goods: {
...temp,
price: item.price,
sellPrice: item.price,
goodsId: item.goodsId,
specificationStr: item.specificationData.replace(/;~;/g, '/')
}
}
skuArr.push(obj)
}
})
}
}
})
console.log(skuArr)
return skuArr
} }
} }
} }
......
...@@ -5,24 +5,24 @@ ...@@ -5,24 +5,24 @@
<view class="header"> <view class="header">
<view class="header-left"> <view class="header-left">
<view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view> <view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view>
<view class="name">{{item.packageGoods.packageAlias||item.packageGoods.packageName}}</view> <view class="name">{{ item.packageGoods.packageAlias || item.packageGoods.packageName }}</view>
<view class="control"> <view class="control">
<view class="minus" @click="decreaseNumber(item)">-</view> <view class="minus" @click="decreaseNumber(item)">-</view>
<input class="uni-input control-input" type="number" maxlength="3" v-model="item.packageGoods.number" @blur="validateNumber($event, item)" /> <input class="uni-input control-input" type="number" maxlength="3" v-model="item.packageGoods.number" @blur="validateNumber($event, item)" />
<view class="add" @click="increaseNumber(item)">+</view> <view class="add" @click="increaseNumber(item)">+</view>
</view> </view>
</view> </view>
<view class="price">¥{{changeTotal(item)}}</view> <view class="price">¥{{ changeTotal(item) }}</view>
</view> </view>
<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">
<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">
<view class="unit">¥</view> <view class="unit">¥</view>
<input class="uni-input" type="digit" maxlength="9" placeholder="请输入价格" placeholder-style="font-size: 14px" v-model="goods.sellPrice" @blur="validatePrice($event, goods, ind, index)" /> <input class="uni-input" type="digit" maxlength="9" placeholder="请输入价格" placeholder-style="font-size: 14px" v-model="goods.sellPrice" @blur="validatePrice($event, goods, ind, index)" />
</view> </view>
</view> </view>
</view> </view>
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
</view> </view>
</template> </template>
<script> <script>
export default { export default {
name: 'Package', name: 'Package',
props: { props: {
...@@ -43,7 +42,7 @@ export default { ...@@ -43,7 +42,7 @@ export default {
positionTypeList: { positionTypeList: {
type: Array, type: Array,
default: [] default: []
}, }
}, },
created() { created() {
// 初始化商品数量 // 初始化商品数量
...@@ -57,7 +56,7 @@ export default { ...@@ -57,7 +56,7 @@ export default {
updated() { updated() {
// 当组件数据更新时也检查number属性 // 当组件数据更新时也检查number属性
this.initProductNumbers() this.initProductNumbers()
console.log(this.list, 'Package-list') console.log(this.list, 'Package-list2')
}, },
methods: { methods: {
// 初始化商品数量方法 // 初始化商品数量方法
...@@ -70,7 +69,7 @@ export default { ...@@ -70,7 +69,7 @@ export default {
// 存储旧值 // 存储旧值
item.packageGoods.goodsList.forEach(goods => { item.packageGoods.goodsList.forEach(goods => {
if (!goods.price) { if (!goods.price) {
goods.oldPrice = goods.sellPrice goods.oldPrice = goods.sellPrice
} }
}) })
}) })
...@@ -121,7 +120,6 @@ export default { ...@@ -121,7 +120,6 @@ export default {
}, },
validatePrice(event, goods, ind, index) { validatePrice(event, goods, ind, index) {
let value = event.detail.value let value = event.detail.value
console.log('value', value)
// 如果为空则设置为0 // 如果为空则设置为0
if (!value || value.trim() === '') { if (!value || value.trim() === '') {
value = '0' value = '0'
...@@ -269,7 +267,7 @@ export default { ...@@ -269,7 +267,7 @@ export default {
align-items: center; align-items: center;
border-bottom: toRpx(1.6) solid #dce1e6; border-bottom: toRpx(1.6) solid #dce1e6;
padding: toRpx(24); padding: toRpx(24);
&-left { &-left {
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -307,5 +305,4 @@ export default { ...@@ -307,5 +305,4 @@ export default {
} }
} }
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
<template> <template>
<view> <view>
<view class="shop-list"> <view class="shop-list">
<view class="shop-item" v-for="(item, index) in list" :key="item.goods.goodsId"> <view class="shop-item" v-for="(item, index) in list" :key="item.goods.goodsId || item.goods.id">
<view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view> <view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view>
<view class="right"> <view class="right">
<view class="shop-name">商品名称:{{ item.goods.goodsAlias || item.goods.upgradeGoodsName || <view class="shop-name">商品名称:{{ item.goods.goodsAlias || item.goods.upgradeGoodsName || item.goods.goodsInfo.goodsName }}</view>
item.goods.goodsInfo.goodsName }}</view>
<!-- <view class="alias">商品别名:{{ item.goods.goodsAlias }}</view> --> <!-- <view class="alias">商品别名:{{ item.goods.goodsAlias }}</view> -->
<view class="front-gear-box"> <view class="front-gear-box">
<view class="front-gear-input-box"> <view class="front-gear-input-box">
<view class="front-gear-label" <view class="front-gear-label" 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)">
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)"> {{ formatPosition(item.goods.merchantGoodsPosition || item.goods.upgradeGoodsPosition, positionTypeList) }}
{{ formatPosition((item.goods.merchantGoodsPosition || item.goods.upgradeGoodsPosition), </view>
positionTypeList)}}</view>
<view class="front-gear-input"> <view class="front-gear-input">
<view class="unit">¥</view> <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)" /> <input class="uni-input" :disabled="isDisabled" type="digit" maxlength="9" placeholder="请输入价格" placeholder-style="font-size: 14px" v-model="item.goods.sellPrice" @blur="validatePrice($event, item, index)" />
</view> </view>
</view> </view>
<view class="control"> <view class="control">
...@@ -45,6 +43,10 @@ export default { ...@@ -45,6 +43,10 @@ export default {
baseConfigData: { baseConfigData: {
type: Object, type: Object,
default: {} default: {}
},
isDisabled: {
type: Boolean,
default: false
} }
}, },
created() { created() {
...@@ -72,13 +74,13 @@ export default { ...@@ -72,13 +74,13 @@ export default {
}, },
circulation(data, str) { circulation(data, str) {
let arr = str.split('.'), let arr = str.split('.'),
result; result
if (arr.length) { if (arr.length) {
result = arr.reduce((pre, key) => { result = arr.reduce((pre, key) => {
return pre[key] return pre[key]
}, data) }, data)
} }
return result; return result
}, },
// 格式化位置信息 // 格式化位置信息
formatPosition(item, positionTypeList) { formatPosition(item, positionTypeList) {
...@@ -88,7 +90,6 @@ export default { ...@@ -88,7 +90,6 @@ export default {
// 验证价格输入 // 验证价格输入
validatePrice(event, item, index) { validatePrice(event, item, index) {
let value = event.detail.value let value = event.detail.value
console.log('value', value)
// 如果为空则设置为0 // 如果为空则设置为0
if (!value || value.trim() === '') { if (!value || value.trim() === '') {
value = '0' value = '0'
...@@ -280,4 +281,4 @@ export default { ...@@ -280,4 +281,4 @@ export default {
} }
} }
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!