Commit 425265c0 by 胡悦

fix(CreateOrder): 修复订单创建逻辑并添加拦截混入

refactor(sprite): 优化图标样式文件结构并移除无用图标
1 parent 0f5a5a93

2.61 MB | W: | H:

2.61 MB | W: | H:

assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -46,8 +46,10 @@ import Product from './Product.vue' ...@@ -46,8 +46,10 @@ 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 { FORM_LIST, popupTypeEnum, payTypeList } from '../contant' import { FORM_LIST, popupTypeEnum, payTypeList } from '../contant'
import { interceptionMixin } from '@/mixin/index'
export default { export default {
name: 'CreateOrder', name: 'CreateOrder',
mixins: [interceptionMixin],
components: { components: {
GlCell, GlCell,
OrderPopup, OrderPopup,
...@@ -82,7 +84,7 @@ export default { ...@@ -82,7 +84,7 @@ export default {
}) })
return return
} }
// 编辑和修改订单进入这里
// 新增订单处理 // 新增订单处理
const { paramsData: { customer, customerCoupon, ...rest } } = newVal const { paramsData: { customer, customerCoupon, ...rest } } = newVal
...@@ -94,7 +96,7 @@ export default { ...@@ -94,7 +96,7 @@ export default {
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',
...@@ -143,10 +145,10 @@ export default { ...@@ -143,10 +145,10 @@ export default {
] ]
formUpdates.forEach(([index, field, value]) => updateFormCell(index, field, value)) formUpdates.forEach(([index, field, value]) => updateFormCell(index, field, value))
// 商品回显,在获取商品列表之后
this.goodsList = rest.subOrderList this.goodsList = rest.subOrderList
} }
console.log(this.orderObj, 'orderObj')
handleTransactionData(newVal) handleTransactionData(newVal)
} }
}, },
...@@ -155,7 +157,7 @@ export default { ...@@ -155,7 +157,7 @@ export default {
}, },
data() { data() {
return { return {
orderCreateType: 'createWithPay', // supplementOrder(补录订单) createWithPay(新增) editWithPay(编辑、修改) orderCreateType: 'createWithPay', // supplementOrder(补录订单) createWithPay(新增)
formList: utils.deepClone(FORM_LIST), formList: utils.deepClone(FORM_LIST),
userInfo: {}, userInfo: {},
baseConfigData: {}, baseConfigData: {},
...@@ -208,8 +210,6 @@ export default { ...@@ -208,8 +210,6 @@ export default {
console.log('mounted', this.orderCreateType) console.log('mounted', this.orderCreateType)
this.userInfo = uni.$storage.get('userInfo') || {} this.userInfo = uni.$storage.get('userInfo') || {}
this.baseConfigData = uni.$storage.get('mock_data') || {} this.baseConfigData = uni.$storage.get('mock_data') || {}
const { userInfo } = this
this.initData() this.initData()
}, },
methods: { methods: {
...@@ -412,81 +412,83 @@ export default { ...@@ -412,81 +412,83 @@ export default {
async submit() { async submit() {
console.log(this.orderObj) console.log(this.orderObj)
if (!this.checkRequired()) return if (!this.checkRequired()) return
const { orderCreateType } = this if (!await this.checkDailyReport()) {
const obj = utils.deepClone(this.orderObj) const { orderCreateType } = this
const otherCustomer = ['standNo', 'plateNumber', 'customerSex', 'experienceFlag', 'salesType'] const obj = utils.deepClone(this.orderObj)
obj.customer = { const otherCustomer = ['standNo', 'plateNumber', 'customerSex', 'experienceFlag', 'salesType']
...obj.customer, obj.customer = {
...otherCustomer.reduce((acc, key) => { ...obj.customer,
if (obj[key] !== undefined) { ...otherCustomer.reduce((acc, key) => {
acc[key] = obj[key] if (obj[key] !== undefined) {
delete obj[key] acc[key] = obj[key]
} delete obj[key]
return acc }
}, {}) return acc
} }, {})
// 将 frontGear、frontWindow、rearGear、rearWindow、sunRoof 字段合并到 goodsList 中
const labelFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
let goodsList = []
let subGoodsList = []
labelFields.forEach(field => {
if (Array.isArray(obj[field]) && obj[field].length > 0) {
goodsList = goodsList.concat(obj[field])
} }
delete obj[field] // 将 frontGear、frontWindow、rearGear、rearWindow、sunRoof 字段合并到 goodsList 中
}) const labelFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
if (goodsList.length > 0) { let goodsList = []
goodsList.map(e => { let subGoodsList = []
if (e.goodsFlag == 1) { labelFields.forEach(field => {
// 单商品 if (Array.isArray(obj[field]) && obj[field].length > 0) {
subGoodsList.push({ goodsList = goodsList.concat(obj[field])
totalPrice: e.goods.sellPrice,
number: e.goods.number,
merchantGoodsId: e.goods.merchantGoodsId
})
} }
// 套餐 delete obj[field]
if (e.goodsFlag == 3) { })
e.packageGoods.goodsList.forEach(g => { if (goodsList.length > 0) {
goodsList.map(e => {
if (e.goodsFlag == 1) {
// 单商品
subGoodsList.push({ subGoodsList.push({
packageCode: e.packageGoods.packageCode, totalPrice: e.goods.sellPrice,
packageName: e.packageGoods.packageName, number: e.goods.number,
totalPrice: g.sellPrice, merchantGoodsId: e.goods.merchantGoodsId
number: e.packageGoods.number,
merchantGoodsId: g.merchantGoodsId,
upgradePrice: g.oldPrice
}) })
}) }
} // 套餐
// 多规格 if (e.goodsFlag == 3) {
if (e.goodsFlag == 2) { e.packageGoods.goodsList.forEach(g => {
subGoodsList.push({ subGoodsList.push({
baseGoodsId: e.multipleSpecificationsGoods.goods.baseGoodsId, packageCode: e.packageGoods.packageCode,
totalPrice: Number(e.multipleSpecificationsGoods.goods.sellPrice), packageName: e.packageGoods.packageName,
number: e.multipleSpecificationsGoods.number, totalPrice: g.sellPrice,
merchantGoodsId: e.multipleSpecificationsGoods.goods.id || e.multipleSpecificationsGoods.goods.merchantGoodsId number: e.packageGoods.number,
}) merchantGoodsId: g.merchantGoodsId,
} upgradePrice: g.oldPrice
}) })
obj.subOrderList = subGoodsList })
} }
delete obj.carBrand // 多规格
delete obj.couponInfo if (e.goodsFlag == 2) {
console.log(obj, 'rucan') subGoodsList.push({
baseGoodsId: e.multipleSpecificationsGoods.goods.baseGoodsId,
totalPrice: Number(e.multipleSpecificationsGoods.goods.sellPrice),
number: e.multipleSpecificationsGoods.number,
merchantGoodsId: e.multipleSpecificationsGoods.goods.id || e.multipleSpecificationsGoods.goods.merchantGoodsId
})
}
})
obj.subOrderList = subGoodsList
}
delete obj.carBrand
delete obj.couponInfo
console.log(obj, 'rucan')
uni.showLoading({ uni.showLoading({
title: '提交中...', title: '提交中...',
mask: true mask: true
})
const res = await uni.$api.boutiqueApi[orderCreateType](obj).finally(() => {
uni.hideLoading()
})
if (res) {
uni.showToast({
title: '保存成功',
icon: 'success'
}) })
this.$emit('jump', orderCreateType == 'supplementOrder' ? 'OrderDetail' : 'ConfirmOrder', res) const res = await uni.$api.boutiqueApi[orderCreateType](obj).finally(() => {
uni.hideLoading()
})
if (res) {
uni.showToast({
title: '保存成功',
icon: 'success'
})
this.$emit('jump', orderCreateType == 'supplementOrder' ? 'OrderDetail' : 'ConfirmOrder', res)
}
} }
}, },
// 计算所有产品的总价 // 计算所有产品的总价
...@@ -500,6 +502,7 @@ export default { ...@@ -500,6 +502,7 @@ export default {
// 计算每个产品的价格 * 数量,并累加到总价 // 计算每个产品的价格 * 数量,并累加到总价
productList.forEach(item => { productList.forEach(item => {
if (item.goods && item.goods.sellPrice && item.goods.number) { if (item.goods && item.goods.sellPrice && item.goods.number) {
console.log(item.goods, '---单商品')
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) { } else if (item.packageGoods && item.packageGoods.upgradePrice && item.packageGoods.number) {
console.log(item.packageGoods, '套餐') console.log(item.packageGoods, '套餐')
...@@ -511,8 +514,9 @@ export default { ...@@ -511,8 +514,9 @@ export default {
item.packageGoods.goodsList.forEach(i => { item.packageGoods.goodsList.forEach(i => {
total += parseFloat(i.sellPrice) * parseInt(item.packageGoods.number) total += parseFloat(i.sellPrice) * parseInt(item.packageGoods.number)
}) })
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice && item.multipleSpecificationsGoods.number) { } else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice) {
total += parseFloat(item.multipleSpecificationsGoods.goods.sellPrice) * parseInt(item.multipleSpecificationsGoods.number) console.log(item.multipleSpecificationsGoods, '多规格')
total += parseFloat(item.multipleSpecificationsGoods.goods.sellPrice) * parseInt(item.multipleSpecificationsGoods.number||1)
} }
}) })
} }
...@@ -527,9 +531,14 @@ export default { ...@@ -527,9 +531,14 @@ export default {
const res = await uni.$api.boutiqueApi.getLastUserOrderInfo({ const res = await uni.$api.boutiqueApi.getLastUserOrderInfo({
sellerUserId: this.userInfo.subLoginUser.uuid sellerUserId: this.userInfo.subLoginUser.uuid
}) })
this.$set(this.orderObj, 'employeeName', res.employeeName) console.log(this.orderObj.merchantId)
this.orderObj.userId = res.userId if (this.orderObj.merchantId == res.merchantId) {
console.log(res, '上一个订单的销售顾问信息') this.$set(this.orderObj, 'employeeName', res.employeeName)
this.orderObj.userId = res.userId
console.log(res, '上一个订单的销售顾问信息')
} else {
this.getEmployeeList()
}
}, },
async getShopMerchantPointConfig(merchantId) { async getShopMerchantPointConfig(merchantId) {
const res = await uni.$api.boutiqueApi.getShopMerchantPointConfig({ merchantId }) const res = await uni.$api.boutiqueApi.getShopMerchantPointConfig({ merchantId })
...@@ -631,8 +640,8 @@ export default { ...@@ -631,8 +640,8 @@ export default {
}) })
if (data && data.length) { if (data && data.length) {
this.employeeList = data this.employeeList = data
// this.$set(this.orderObj, 'employeeName', data[0].staffName) this.$set(this.orderObj, 'employeeName', data[0].staffName)
// this.orderObj.userId = data[0].uuid this.orderObj.userId = data[0].uuid
} }
}, },
async getPositionList() { async getPositionList() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!