Commit f9ecc239 by 岑成威

fix: 新增客户档案信息

1 parent ce72508f
...@@ -116,16 +116,15 @@ module.exports = { ...@@ -116,16 +116,15 @@ module.exports = {
}, },
/**搜索订单(含套餐) */ /**搜索订单(含套餐) */
getWorkPackageGoodsList (data) { getWorkPackageGoodsList (data) {
let params = data || {}
params.sceneType = 1
return http.post( return http.post(
{ {
method: 'dj.api.smartcarlife.order.search.containPackageGoods', method: 'dj.api.smartcarlife.order.search.containPackageGoods',
projectName: 'boutique', projectName: 'boutique',
...data, pageSize: 20,
pageSize: 10, pageNum: 1,
pageSize: 999999, statusList: [1],
statusList: [1] sceneType: 1,
...data
}, },
false, false,
'dj', 'dj',
......
...@@ -45,21 +45,28 @@ export default { ...@@ -45,21 +45,28 @@ export default {
return return
} }
this.componentLoading(params) this.componentLoading(params)
const { shopMerchantId } = userInfo, const { shopMerchantId } = userInfo
apiParams = { const isOrderSearch = !params.defeat && userInfo.sceneType == 1
const useWorkPackageGoods = params.defeat || isOrderSearch
let apiTargetName = useWorkPackageGoods ? 'getWorkPackageGoodsList' : 'getQuotationCustomerList'
let apiParams = useWorkPackageGoods
? {
merchantId: shopMerchantId,
pageSize: 20,
pageNum: 1,
statusList: [1],
sceneType: 1,
keyword: searchValue || ''
}
: {
merchantId: shopMerchantId, merchantId: shopMerchantId,
pageSize: 999999, pageSize: 999999,
currentPage: 1, currentPage: 1,
search: searchValue search: searchValue
} }
let apiTargetName = !params.defeat ? 'getQuotationCustomerList' : 'getWorkPackageGoodsList'
console.log(apiTargetName, 'apiTargetName')
if (params.defeat) {
apiParams.keyword = searchValue
}
const { list } = await uni.$api.popupApi[apiTargetName](apiParams) const { list } = await uni.$api.popupApi[apiTargetName](apiParams)
let customerList = list let customerList = list
if (params.defeat) { if (useWorkPackageGoods) {
const listArray = list.map(item => { const listArray = list.map(item => {
if (item.customer && item.customer.carSeriesName) { if (item.customer && item.customer.carSeriesName) {
item.carType = `${item.customer.carBrand || ''}-${item.customer.carChildsBrandName || ''}-${item.customer.carSeriesName || ''}` item.carType = `${item.customer.carBrand || ''}-${item.customer.carChildsBrandName || ''}-${item.customer.carSeriesName || ''}`
...@@ -72,8 +79,9 @@ export default { ...@@ -72,8 +79,9 @@ export default {
this.updateParams(params, customerList || []) this.updateParams(params, customerList || [])
}, },
initData (list) { initData (list) {
const { params: { idKey, defeat }, data } = this const { params: { idKey, defeat }, data, userInfo } = this
let key = defeat ? 'id' : 'customerPhone' const isOrderSearch = !defeat && userInfo.sceneType == 1
let key = defeat || isOrderSearch ? 'id' : 'customerPhone'
console.log(data, idKey) console.log(data, idKey)
if (data[idKey]) { if (data[idKey]) {
this.currentId = data[idKey] this.currentId = data[idKey]
...@@ -88,14 +96,16 @@ export default { ...@@ -88,14 +96,16 @@ export default {
this.getList(searchValue, true) this.getList(searchValue, true)
}, },
choose (i) { choose (i) {
let { params } = this let { params, userInfo } = this
let key = params.defeat ? 'id' : 'customerPhone' const isOrderSearch = !params.defeat && userInfo.sceneType == 1
let key = params.defeat || isOrderSearch ? 'id' : 'customerPhone'
this.currentId = i[key] this.currentId = i[key]
this.$emit('choose', i) this.$emit('choose', i)
}, },
checkActive (i) { checkActive (i) {
let { currentId, data, params } = this let { currentId, data, params, userInfo } = this
let key = params.defeat ? 'id' : 'customerPhone' const isOrderSearch = !params.defeat && userInfo.sceneType == 1
let key = params.defeat || isOrderSearch ? 'id' : 'customerPhone'
return currentId ? (i[key] == currentId) : (i[key]) == data[params.idKey] return currentId ? (i[key] == currentId) : (i[key]) == data[params.idKey]
} }
} }
......
...@@ -4,7 +4,23 @@ ...@@ -4,7 +4,23 @@
<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" :titleList="titleList" @radioChange="radioChange" @inputBlur="inputBlur" @handleCell="handleCell">
<template slot="customer">
<view class="customer-title flex">
客户信息
<view
class="customer-file flex"
@click="
handleCell({
key: 'customer'
})
"
>
<view class="sprite-icon icon-customer-list"></view>
客户档案
</view>
</view>
</template>
<template slot="frontGear"> <template slot="frontGear">
<Product v-if="orderObj.frontGear" @changeTotalPrice="changeTotalPrice" @min-price-warning="handleMinPriceWarning" :list="orderObj.frontGear" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode" :show-marketing-icon="true"></Product> <Product v-if="orderObj.frontGear" @changeTotalPrice="changeTotalPrice" @min-price-warning="handleMinPriceWarning" :list="orderObj.frontGear" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode" :show-marketing-icon="true"></Product>
</template> </template>
...@@ -78,7 +94,7 @@ import GlCell from '../../../../components/Form/GlCell.vue' ...@@ -78,7 +94,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 { FORM_LIST, popupTypeEnum, payTypeList } from '../contant' import { FORM_LIST, popupTypeEnum, payTypeList, titleList } from '../contant'
import { interceptionMixin } from '@/mixin/index' import { interceptionMixin } from '@/mixin/index'
import { validateVin, formatVinInput } from '@/utils/vinVaildate' import { validateVin, formatVinInput } from '@/utils/vinVaildate'
import { getMarketingFlag, getActivityId, getSubmitMarketingFlag, getSubmitModifyFlag, getSubmitActivityId, snapshotOriginalPrice, snapshotOrderItemsOriginalPrice, snapshotActivityPriceFromCatalog } from '@/utils/marketingFlag' import { getMarketingFlag, getActivityId, getSubmitMarketingFlag, getSubmitModifyFlag, getSubmitActivityId, snapshotOriginalPrice, snapshotOrderItemsOriginalPrice, snapshotActivityPriceFromCatalog } from '@/utils/marketingFlag'
...@@ -134,96 +150,9 @@ export default { ...@@ -134,96 +150,9 @@ export default {
return return
} }
// 编辑和修改订单进入这里 // 编辑和修改订单进入这里
// 新增订单处理 const { paramsData } = newVal
const { this.applyOrderEchoFromRest(paramsData)
paramsData: { customer, customerCoupon, ...rest } this.subOrderList = this.prepareSubOrderListFromOrder(paramsData)
} = newVal
// 基础字段映射
const baseFields = ['id', 'orderCode', 'userId', 'employeeName', 'deliveryEmployeeName', 'deliveryUserId', 'subShopMerchantName', 'subShopMerchantId', 'sellerName', 'sellerUserId', 'sellerMerchantName', 'sellerMerchantId', 'merchantId', 'merchantName', 'customerCouponId', 'selectPayType']
Object.assign(this.orderObj, Object.fromEntries(baseFields.map(field => [field, rest[field]])))
// 场景名称回显:后端给 baseSceneCode(code) + baseSceneName(name)
this.$set(this.orderObj, 'baseSceneCode', rest.baseSceneName || '')
this.$set(this.orderObj, 'baseSceneCodeValue', rest.baseSceneCode || '')
const sceneCell = this.formList?.[0]?.find(item => item.value === 'baseSceneCode')
if (sceneCell) sceneCell.current = rest.baseSceneName || ''
// 回显订单类型
const orderTypeMap = {
1: '正常订单',
2: '打折策略',
3: '买赠策略',
4: '冲量活动',
5: '组合付款',
6: '内部结算'
}
if (rest.djOrderType !== undefined && rest.djOrderType !== null) {
this.orderObj.orderTypeCode = String(rest.djOrderType)
this.orderObj.djOrderType = orderTypeMap[this.orderObj.orderTypeCode] || ''
} else {
// 如果没有订单类型,默认设置为正常订单
this.orderObj.orderTypeCode = '1'
this.orderObj.djOrderType = orderTypeMap['1'] || '正常订单'
}
// 设置支付类型
this.orderObj.payeeType = rest.selectPayType == '2' ? '1' : '0'
// 客户信息映射
const customerFields = ['customerName', 'customerSex', 'customerPhone', 'salesType', 'standNo', 'plateNumber', 'experienceFlag']
Object.assign(this.orderObj, Object.fromEntries(customerFields.map(field => [field, customer[field]])))
// 优惠券信息
const { couponName, customerCouponCode } = customerCoupon
Object.assign(this.orderObj, {
couponName,
customerCouponCode,
couponInfo: couponName + customerCouponCode
})
// 车辆信息
this.orderObj.customer = {
carBrand: customer.carBrand,
carBrandId: customer.carBrandId,
carChildsBrandId: customer.carChildsBrandId,
carChildsBrandName: customer.carChildsBrandName,
carSeriesId: customer.carSeriesId,
carSeriesName: customer.carSeriesName,
customerPhone: customer.customerPhone,
standNo: customer.standNo,
plateNumber: customer.plateNumber,
customerSex: customer.customerSex,
experienceFlag: customer.experienceFlag,
salesType: customer.salesType,
customerName: customer.customerName
}
this.orderObj.carBrand = customer.carBrandId ? `${customer.carBrand}-${customer.carChildsBrandName}-${customer.carSeriesName}` : ''
// 更新表单状态
const updateFormCell = (formIndex, fieldName, value) => {
const cell = this.formList[formIndex].find(item => item.value === fieldName)
if (cell) cell.current = value
}
const formUpdates = [
[1, 'salesType', customer.salesType],
[1, 'customerSex', customer.customerSex],
[1, 'experienceFlag', customer.experienceFlag],
[2, 'selectPayType', this.orderObj.selectPayType],
[2, 'payeeType', this.orderObj.payeeType]
]
formUpdates.forEach(([index, field, value]) => updateFormCell(index, field, value))
// 更新订单类型字段显示
const orderTypeCell = this.formList[2].find(item => item.value === 'djOrderType')
if (orderTypeCell && this.orderObj.djOrderType) {
orderTypeCell.current = this.orderObj.djOrderType
}
// 商品回显,在获取商品列表之后
this.subOrderList = rest.subOrderList
} }
console.log(this.orderObj, 'orderObj') console.log(this.orderObj, 'orderObj')
handleTransactionData(newVal) handleTransactionData(newVal)
...@@ -256,6 +185,7 @@ export default { ...@@ -256,6 +185,7 @@ export default {
data() { data() {
return { return {
orderCreateType: 'createWithPay', // supplementOrder(补录订单) createWithPay(新增) orderCreateType: 'createWithPay', // supplementOrder(补录订单) createWithPay(新增)
titleList,
formList: utils.deepClone(FORM_LIST), formList: utils.deepClone(FORM_LIST),
userInfo: {}, userInfo: {},
baseConfigData: {}, baseConfigData: {},
...@@ -667,7 +597,10 @@ export default { ...@@ -667,7 +597,10 @@ export default {
// 选择行事件 // 选择行事件
async handleCell(val) { async handleCell(val) {
// 获取当前选中的popupType // 获取当前选中的popupType
const foundKey = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.value) let foundKey = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.value)
if (!foundKey && val.key) {
foundKey = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.key)
}
if (!foundKey) { if (!foundKey) {
console.error(`Popup type not found for value: ${val.value}`) console.error(`Popup type not found for value: ${val.value}`)
return return
...@@ -720,6 +653,8 @@ export default { ...@@ -720,6 +653,8 @@ export default {
// 根据popupTypeEnum优化处理 // 根据popupTypeEnum优化处理
const _typeValue = this.popupTypeEnum[popupTypeNum] const _typeValue = this.popupTypeEnum[popupTypeNum]
if (val.popupType == 19) return this.setCustomerInfo(chooseContent)
// 安全检查:如果_typeValue不存在,直接返回并关闭弹窗 // 安全检查:如果_typeValue不存在,直接返回并关闭弹窗
if (!_typeValue || !_typeValue.key) { if (!_typeValue || !_typeValue.key) {
console.error(`Invalid popupType: ${popupTypeNum}`) console.error(`Invalid popupType: ${popupTypeNum}`)
...@@ -1953,6 +1888,138 @@ export default { ...@@ -1953,6 +1888,138 @@ export default {
if (!this.useMinPriceApproval) return if (!this.useMinPriceApproval) return
this.minPriceApprovalPrice = price this.minPriceApprovalPrice = price
this.showMinPriceApprovalPopup = true this.showMinPriceApprovalPopup = true
},
applyOrderEchoFromRest(orderData, { skipOrderId = false } = {}) {
const customer = orderData.customer || {}
const customerCoupon = orderData.customerCoupon || {}
const rest = orderData
const baseFields = ['id', 'orderCode', 'userId', 'employeeName', 'deliveryEmployeeName', 'deliveryUserId', 'subShopMerchantName', 'subShopMerchantId', 'sellerName', 'sellerUserId', 'sellerMerchantName', 'sellerMerchantId', 'merchantId', 'merchantName', 'customerCouponId', 'selectPayType']
const fieldsToAssign = skipOrderId ? baseFields.filter(field => !['id', 'orderCode'].includes(field)) : baseFields
Object.assign(this.orderObj, Object.fromEntries(fieldsToAssign.map(field => [field, rest[field]])))
this.$set(this.orderObj, 'baseSceneCode', rest.baseSceneName || '')
this.$set(this.orderObj, 'baseSceneCodeValue', rest.baseSceneCode || '')
const sceneCell = this.formList?.[0]?.find(item => item.value === 'baseSceneCode')
if (sceneCell) sceneCell.current = rest.baseSceneName || ''
const orderTypeMap = {
1: '正常订单',
2: '打折策略',
3: '买赠策略',
4: '冲量活动',
5: '组合付款',
6: '内部结算'
}
if (rest.djOrderType !== undefined && rest.djOrderType !== null) {
this.orderObj.orderTypeCode = String(rest.djOrderType)
this.orderObj.djOrderType = orderTypeMap[this.orderObj.orderTypeCode] || ''
} else {
this.orderObj.orderTypeCode = '1'
this.orderObj.djOrderType = orderTypeMap['1'] || '正常订单'
}
this.orderObj.payeeType = rest.selectPayType == '2' ? '1' : '0'
const customerFields = ['customerName', 'customerSex', 'customerPhone', 'salesType', 'standNo', 'plateNumber', 'experienceFlag']
Object.assign(this.orderObj, Object.fromEntries(customerFields.map(field => [field, customer[field]])))
const { couponName, customerCouponCode } = customerCoupon
if (couponName || customerCouponCode) {
Object.assign(this.orderObj, {
couponName,
customerCouponCode,
couponInfo: `${couponName || ''}${customerCouponCode || ''}`
})
}
this.orderObj.customer = {
carBrand: customer.carBrand,
carBrandId: customer.carBrandId,
carChildsBrandId: customer.carChildsBrandId,
carChildsBrandName: customer.carChildsBrandName,
carSeriesId: customer.carSeriesId,
carSeriesName: customer.carSeriesName,
customerPhone: customer.customerPhone,
standNo: customer.standNo,
plateNumber: customer.plateNumber,
customerSex: customer.customerSex,
experienceFlag: customer.experienceFlag,
salesType: customer.salesType,
customerName: customer.customerName
}
this.orderObj.carBrand = customer.carBrandId ? `${customer.carBrand}-${customer.carChildsBrandName}-${customer.carSeriesName}` : ''
const updateFormCell = (formIndex, fieldName, value) => {
const cell = this.formList[formIndex].find(item => item.value === fieldName)
if (cell) cell.current = value
}
const formUpdates = [
[1, 'salesType', customer.salesType],
[1, 'customerSex', customer.customerSex],
[1, 'experienceFlag', customer.experienceFlag],
[2, 'selectPayType', this.orderObj.selectPayType],
[2, 'payeeType', this.orderObj.payeeType]
]
formUpdates.forEach(([index, field, value]) => updateFormCell(index, field, value))
const orderTypeCell = this.formList[2].find(item => item.value === 'djOrderType')
if (orderTypeCell && this.orderObj.djOrderType) {
orderTypeCell.current = this.orderObj.djOrderType
}
},
prepareSubOrderListFromOrder(orderData) {
let subOrderList = (orderData.subOrderList || []).filter(item => item.merchantGoodsId)
const packageGoodsList = orderData.packageGoodsList || []
if (packageGoodsList.length) {
packageGoodsList.forEach(item => {
item.goodsList = item.packageGoodsOrderList
item.price = item.goodsList.reduce((prev, cur) => {
return prev + Number(cur.finalPrice) / Number(cur.number)
}, 0)
item.count = item.goodsList.length ? item.goodsList[0].number : 1
const total = item.price * item.count
item.finalPrice = utils.decimal(total, 2)
})
subOrderList = subOrderList.concat(packageGoodsList)
}
return subOrderList
},
async setCustomerInfo(customerInfo) {
const productFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
productFields.forEach(field => {
this.$set(this.orderObj, field, null)
})
this.applyOrderEchoFromRest(customerInfo, { skipOrderId: true })
this.orderObj.customerId = customerInfo.id
this.subOrderList = this.prepareSubOrderListFromOrder(customerInfo)
this.updateSceneGate()
const echoedSelectPayType = this.orderObj.selectPayType
const echoedPayeeType = this.orderObj.payeeType
this.changePayee()
if (echoedSelectPayType != null && echoedSelectPayType !== '') {
this.$set(this.orderObj, 'selectPayType', echoedSelectPayType)
const payCell = this.formList[2].find(item => item.value === 'selectPayType')
if (payCell) payCell.current = echoedSelectPayType
}
if (echoedPayeeType != null && echoedPayeeType !== '') {
this.$set(this.orderObj, 'payeeType', echoedPayeeType)
const payeeCell = this.formList[2].find(item => item.value === 'payeeType')
if (payeeCell) payeeCell.current = echoedPayeeType
}
await this.getSelectOrderGoodsList()
if (this.orderObj.standNo) {
this.orderObj.standNo = formatVinInput(this.orderObj.standNo)
validateVin(this.orderObj.standNo)
.then(result => {
this.validateState = result.data.valid
})
.catch(() => {})
}
} }
} }
} }
...@@ -2059,4 +2126,14 @@ export default { ...@@ -2059,4 +2126,14 @@ export default {
text-align: center; text-align: center;
} }
} }
.customer-title {
.customer-file {
margin-left: toRpx(20);
color: #347bff;
font-size: toRpx(24);
.sprite-icon {
margin-right: toRpx(4);
}
}
}
</style> </style>
...@@ -654,7 +654,12 @@ const popupTypeEnum = { ...@@ -654,7 +654,12 @@ const popupTypeEnum = {
// 订单类型弹窗(OrderTypePopup) // 订单类型弹窗(OrderTypePopup)
key: 'djOrderType', key: 'djOrderType',
list: '' list: ''
},
19: {
key: 'customer'
} }
} }
export { FORM_LIST, popupTypeEnum, payTypeList, DEFEAT_FORM_LIST } const titleList = [null, { addHtml: 'customer' }]
export { FORM_LIST, popupTypeEnum, payTypeList, DEFEAT_FORM_LIST, titleList }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!