Commit f5c584e8 by 岑成威

feat: 新增场景

1 parent a3d2f44a
import http from '../request/http'
// 轻量去重:同参数短时间内复用同一个 Promise,避免页面/弹窗多次触发
const __sceneListPromiseCache = new Map()
module.exports = {
/**查询存在订单数据的场景列表 */
getSceneListWithOrder(data) {
const key = `getSceneListWithOrder:${JSON.stringify(data || {})}`
if (__sceneListPromiseCache.has(key)) return __sceneListPromiseCache.get(key)
const p = http.post({
method: 'dj.api.smartcarlife.scene.config.getUserScene',
projectName: 'boutique',
...data
}).finally(() => {
// 释放缓存,避免长期持有
__sceneListPromiseCache.delete(key)
})
__sceneListPromiseCache.set(key, p)
return p
},
/**保存用户最近选中的场景值 */
saveUserRecentScene(data) {
return http.post({
method: 'dj.api.smartcarlife.scene.recent.saveUserScene',
projectName: 'boutique',
...data
})
},
/**查询用户最近选中的场景值 */
getUserRecentScene(data) {
return http.post({
method: 'dj.api.smartcarlife.scene.recent.getUserScene',
projectName: 'boutique',
...data
})
},
/**新建车损报价单 */
quotationAdd(data) {
return http.post({
......
......@@ -7,7 +7,7 @@
>
<view
class="cell-box"
v-if="items.length"
v-if="items.some(i => !i.hidden)"
:style="cellBoxStyle"
>
<template v-if="titleList.length">
......
......@@ -85,7 +85,11 @@ export default {
apiParams = {
merchantId: shopMerchantId
}
isDefeatOrder ? apiParams.upradeFlag = 'N' : apiParams.sceneType = sceneType
apiParams.sceneType = sceneType
apiParams.baseSceneCode = this.data.baseSceneCodeValue || this.data.baseSceneCode
if (isDefeatOrder) {
apiParams.upradeFlag = 'N'
}
const data = await uni.$api.popupApi[apiName](apiParams)
this.updateParams(params, data || [])
},
......
......@@ -28,6 +28,7 @@ export default {
// 默认支持所有订单类型
let data = [
{ name: '正常订单', value: '1' },
{ name: '内部结算', value: '6' },
{ name: '打折策略', value: '2' },
{ name: '买赠策略', value: '3' },
{ name: '冲量活动', value: '4' },
......@@ -82,7 +83,8 @@ export default {
// 3)有 flag 且不为 1 时,只允许“正常订单”
if (flag !== null && flag !== '1') {
data = [{ name: '正常订单', value: '1' }]
// 内部结算与正常订单同逻辑,也一并允许
data = [{ name: '正常订单', value: '1' }, { name: '内部结算', value: '6' }]
}
} catch (e) {
// 读取失败时不影响默认行为
......
......@@ -24,10 +24,21 @@ const SCENE_TYPE_TAG_MAP = {
0: { label: '轻改', bg: '#5575f51a', color: '#5575f5' },
1: { label: '权益', bg: '#4bc8fe1a', color: '#4bc8fe' },
2: { label: '保险', bg: '#00baad1a', color: '#00baad' },
3: { label: '二手车', bg: '#fe624b1a', color: '#fe624b' },
7: { label: '二手车', bg: '#fe624b1a', color: '#fe624b' },
4: { label: '其他', bg: '#ff9d2e1a', color: '#ff9d2e' }
}
const MOCK_SCENE_LIST = [
{ uuid: '100101', staffName: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', staffName: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', staffName: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', staffName: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', staffName: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', staffName: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', staffName: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', staffName: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
export default {
mixins: [popupmixin],
name: 'SceneList',
......@@ -61,15 +72,13 @@ export default {
return
}
this.componentLoading(params)
const { shopMerchantId, sceneType, merchantId } = userInfo,
apiTargetName = sceneType == 1 || params.defeat ? 'getEmployeeList' : 'getOrderScreenEmployeeList',
apiParams = {
merchantId: params.idKey == 'sellerUserId' ? merchantId : shopMerchantId,
sceneList: params.idKey == 'sellerUserId' ? '' : [sceneType],
}
if (searchValue) apiParams.name = searchValue
const data = await uni.$api.popupApi[apiTargetName](apiParams)
this.updateParams(params, data || [])
// 和 OrderScreen 的 SceneList 保持一致:走 getSceneListWithOrder
const data = await uni.$api.equityApi.getSceneListWithOrder({
sceneType: String(userInfo.sceneType),
phone: userInfo.phone
})
const list = (data && data.length) ? data : MOCK_SCENE_LIST
this.updateParams(params, list || [])
},
initData (list) {
const { idKey, data } = this
......
......@@ -197,7 +197,11 @@ export default {
let apiParams = {
merchantId: shopMerchantId
}
isDefeatOrder ? apiParams.upradeFlag = 'N' : apiParams.sceneType = sceneType
apiParams.sceneType = sceneType
apiParams.baseSceneCode = this.data.baseSceneCodeValue || this.data.baseSceneCode
if (isDefeatOrder) {
apiParams.upradeFlag = 'N'
}
const data = await uni.$api.popupApi[apiName](apiParams)
if (isDefeatOrder) {
let newArray = []
......
......@@ -395,7 +395,8 @@ const componentConfig = {
name: 'SceneList',
title: '场景名称',
hideSearch: true,
idKey: 'senceCode',
// 选择场景后存 code 字段,用于回显选中
idKey: 'baseSceneCodeValue',
cacheData: [],
loadComplete: false,
searchValue: '',
......
......@@ -169,9 +169,20 @@ export default {
componentRef () {
return this.$refs.componentRef
},
// 场景切换后清空依赖 sceneType 的弹窗缓存,下次打开时强制重新请求
clearCacheByTypes (types) {
(types || []).forEach(type => {
if (this.componentObject[type]) {
this.componentObject[type].cacheData = []
}
})
},
open () {
this.$refs.popup.open()
this.initPopupData()
// 等待当前 tick 的响应式 watcher(如 externalData → cacheData)执行完再初始化
this.$nextTick(() => {
this.initPopupData()
})
},
cancel () {
this.$refs.popup.close()
......
<template>
<view class="employee-list">
<view @click="currentIds = []" :class="['item flex', { active: !currentIds.length }]">
<view class="sprite-icon icon-tag-checked"></view>
全部
</view>
<template v-for="(i, index) in list">
<view :key="index" @click="choose(i)" :class="['item flex', { active: checkActive(i) }]">
<view class="sprite-icon icon-tag-checked"></view>
{{ i.staffName }}
</view>
</template>
</view>
</template>
<script type="text/ecmascript-6">
export default {
name: 'SceneList',
inject: ['userInfo'],
data () {
return {
list: [],
currentIds: []
}
},
props: {
params: Object,
data: [Array, Object],
},
watch: {
currentIds: {
handler (val) {
let { params: { idKey } } = this
this.$emit('choose', {
key: idKey,
value: val.length ? val : null
})
},
deep: true
}
},
mounted () {
this.getList()
},
methods: {
async getList () {
const { userInfo, params } = this,
{ cacheData } = params
if (cacheData && cacheData.length) {
this.initList(cacheData)
return
}
const data = await uni.$api.equityApi.getSceneListWithOrder({
sceneType: String(userInfo.sceneType),
phone: userInfo.phone
})
const list = (data && data.length)
? data
: [
// 接口暂无数据时的临时模拟返回(来自 scene 表)
{ uuid: '100101', staffName: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', staffName: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', staffName: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', staffName: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', staffName: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', staffName: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', staffName: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', staffName: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
this.initList(list)
params.cacheData = list
this.$emit('update:params', params)
},
initList (list) {
let { data, params: {idKey} } = this
this.list = list
let paramsData = idKey ? data[idKey] : data
if (paramsData && paramsData.length) paramsData.map(e => {
this.currentIds.push(e)
})
this.$emit('onComplete')
},
choose (i) {
if (i) {
let { uuid } = i,
{ currentIds } = this,
index = currentIds.indexOf(uuid)
if (index == -1) this.currentIds.push(uuid)
else this.currentIds.splice(index, 1)
}
},
checkActive (i) {
let { currentIds } = this,
active = false
if (currentIds.length) active = currentIds.includes(i.uuid)
return active
// return this.currentIds.includes(i.uuid)
},
}
}
</script>
<style scoped lang="scss">
.employee-list {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: toRpx(32);
margin: 0 toRpx(48);
.item {
justify-content: center;
height: toRpx(72);
border-radius: toRpx(8);
border: toRpx(2) solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: toRpx(32);
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
\ No newline at end of file
const screenList = [
{
title: '场景名称',
componentName: 'SceneList',
params: {
cacheData: [],
idKey: 'baseSceneCode'
},
hasToggle: true,
toggle: false
},
{
title: '转化人员',
suffix: 'merchantName',
componentName: 'EmployeeList',
......
......@@ -74,6 +74,7 @@ import OrderStatusList from './components/OrderStatusList.vue'
import PayList from './components/PayList.vue'
import CourseOptionList from './components/CourseOptionList.vue'
import ErrorOrderList from './components/ErrorOrderList.vue'
import SceneList from './components/SceneList.vue'
export default {
components: {
Popup,
......@@ -82,7 +83,8 @@ export default {
OrderStatusList,
PayList,
CourseOptionList,
ErrorOrderList
ErrorOrderList,
SceneList
},
name: 'OrderScreen',
props: {
......
......@@ -50,16 +50,25 @@
this.initList(cacheData)
return
}
const { shopMerchantId, sceneType, merchantId } = userInfo,
data = await uni.$api.popupApi.getOrderScreenEmployeeList({
merchantId: params.idKey == 'transferIds' ? merchantId : shopMerchantId,
sceneList: params.idKey == 'transferIds' ? '' : [sceneType]
})
if (data && data.length) {
this.initList(data)
params.cacheData = data
this.$emit('update:params', params)
}
const data = await uni.$api.equityApi.getSceneListWithOrder({
sceneType: String(userInfo.sceneType),
phone: userInfo.phone
})
const list = (data && data.length)
? data
: [
{ uuid: '100101', staffName: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', staffName: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', staffName: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', staffName: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', staffName: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', staffName: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', staffName: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', staffName: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
this.initList(list)
params.cacheData = list
this.$emit('update:params', params)
},
initList (list) {
let { data, params: {idKey} } = this
......
......@@ -4,7 +4,7 @@ const screenList = [
componentName: 'SceneList',
params: {
cacheData: [],
idKey: 'senceCode'
idKey: 'baseSceneCode'
},
hasToggle: true,
toggle: false
......
const target = ['ip', 'dev', 'uat', 'prod', 'beta']
const index = 2
const index = 1
/**
*
0本地
......@@ -39,7 +39,7 @@ const secretKey = {
const domain = {
// ip: 'http://192.168.2.94:8558',
// ip: 'http://192.168.2.3:8315',
ip: 'http://192.168.1.76:8292',
ip: 'http://192.168.1.104:8292',
/**登录: 192.168.2.3:8315
商城: 192.168.2.3:8558 */
dev: 'https://scrm.dev.glsx.com.cn',
......@@ -50,7 +50,7 @@ const domain = {
const djDomain = {
// ip: 'http://dj.dev.glsx.com.cn',
ip: 'http://192.168.1.76:8292',
ip: 'http://192.168.1.104:8292',
dev: 'http://dj.dev.glsx.com.cn',
beta: 'https://dj.beta.glsx.com.cn', //预发布 appid: wx9f91c1ec493eb425
uat: 'https://dj.test.glsx.com.cn', //测试 appid: wxe10067a63c1856ac
......
......@@ -35,7 +35,7 @@
</template>
</GlCell>
</view>
<view @click="submit" class="btn">直接下单</view>
<view v-if="orderObj.baseSceneCodeValue || orderObj.baseSceneCode" @click="submit" class="btn">直接下单</view>
</scroll-view>
</view>
<!-- 弹窗 -->
......@@ -104,13 +104,20 @@ export default {
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: '组合付款'
5: '组合付款',
6: '内部结算'
}
if (rest.djOrderType !== undefined && rest.djOrderType !== null) {
this.orderObj.orderTypeCode = String(rest.djOrderType)
......@@ -268,6 +275,62 @@ export default {
this.initData()
},
methods: {
updateSceneGate () {
const selected = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
const list = this.formList || []
list.forEach(group => {
;(group || []).forEach(item => {
if (!item) return
if (item._originHidden === undefined) item._originHidden = Boolean(item.hidden)
if (!selected) {
item.hidden = item.value !== 'baseSceneCode'
} else {
item.hidden = item._originHidden
}
})
})
this.formList = list
return selected
},
async initRecentSceneEcho () {
try {
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
const phone = userInfo.phone
const userSceneType = userInfo.sceneType
if (!phone || userSceneType === undefined || userSceneType === null) return
const recent = await uni.$api.equityApi.getUserRecentScene({
phone,
sceneType: userSceneType
})
// HTTP 层已将 data.data 解包,recent 直接是 { baseSceneCode: '...' }
const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid
if (!recentBaseSceneCode) return
const MOCK_SCENE_LIST = [
{ uuid: '100101', staffName: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', staffName: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', staffName: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', staffName: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', staffName: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', staffName: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', staffName: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', staffName: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
// getSceneListWithOrder 有 Promise 缓存,不会重复发请求;接口无数据时 fallback 到 mock
const rawList = await uni.$api.equityApi.getSceneListWithOrder({
phone,
sceneType: String(userSceneType)
})
const listData = (Array.isArray(rawList) && rawList.length) ? rawList : MOCK_SCENE_LIST
const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode))
if (!item) return
this.$set(this.orderObj, 'baseSceneCode', item.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid)
this.$set(this.orderObj, 'sceneType', item.sceneType)
} catch (e) {}
},
// 计算单个商品的最终价格(与页面展示保持一致:先算单件优惠价,再乘数量,均向上取整两位)
calculateFinalPrice(goods, sellPrice, number, orderTypeCode) {
const price = parseFloat(sellPrice || 0)
......@@ -474,6 +537,7 @@ export default {
}
}
// '1' 正常订单 或 '4' 冲量活动
// '6' 内部结算:与正常订单同逻辑
else {
result.discountType = 3
result.discountAmount = 0
......@@ -481,7 +545,7 @@ export default {
return result
},
initData() {
async initData() {
console.log('initData', this.orderCreateType, this.orderObj.id)
// 埋点
if (this.orderCreateType == 'createWithPay' && !this.orderObj.id) {
......@@ -544,6 +608,13 @@ export default {
orderTypeCell.current = this.orderObj.djOrderType
}
}
// 新增页:先回显最近场景;未选场景时不展示/不请求下方表单与接口
if (this.orderCreateType === 'createWithPay' && !this.orderObj.id) {
await this.initRecentSceneEcho()
}
const hasScene = this.updateSceneGate()
if (!hasScene) return
// this.getEmployeeList()
this.getSelectOrderGoodsList()
this.getPositionList()
......@@ -660,6 +731,25 @@ export default {
setTimeout(() => {
this.changeTotalPrice()
}, 0)
} else if (_typeValue.key === 'baseSceneCode') {
// 场景名称:页面显示名称;提交时使用 code
this.$set(this.orderObj, 'baseSceneCode', chooseContent.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.uuid)
this.$set(this.orderObj, 'sceneType', chooseContent.sceneType)
// 选择后保存最近选中场景(sceneType 用登录场景)
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
if (userInfo.phone) {
uni.$api.equityApi.saveUserRecentScene({
phone: userInfo.phone,
sceneType: userInfo.sceneType,
baseSceneCode: chooseContent.baseSceneCode || chooseContent.uuid
})
}
// 选中场景后,放开下方表单并触发依赖接口
this.$refs.orderPopup && this.$refs.orderPopup.clearCacheByTypes([0, 1, 3, 6, 7, 8, 9, 10, 11, 12])
this.updateSceneGate()
this.getSelectOrderGoodsList()
this.getPositionList()
} else if (_typeValue.key) {
this.orderObj[_typeValue.targetIdKey] = chooseContent[_typeValue.sourceIdKey]
this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey])
......@@ -931,6 +1021,9 @@ export default {
const { orderCreateType } = this
const obj = utils.deepClone(this.orderObj)
// 场景名称:界面展示用 name;提交入参需要 code
if (obj.baseSceneCodeValue) obj.baseSceneCode = obj.baseSceneCodeValue
delete obj.baseSceneCodeValue
const otherCustomer = ['standNo', 'plateNumber', 'customerSex', 'experienceFlag', 'salesType']
obj.customer = {
...obj.customer,
......@@ -1059,7 +1152,7 @@ export default {
const orderTypeCode = this.orderObj.orderTypeCode
const orderType = String(orderTypeCode || '')
// 判断是否使用优惠后的价格(不是正常订单和冲量活动的,都要用优惠后的价格)
const useFinalPrice = orderType !== '1' && orderType !== '4'
const useFinalPrice = orderType !== '1' && orderType !== '4' && orderType !== '6'
// 遍历所有商品
const productFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
......@@ -1130,7 +1223,11 @@ export default {
if (employeeCell) employeeCell.label = '销售顾问/录单员'
const deliveryCell = this.formList[0].find(item => item.label === '交付专员')
if (deliveryCell) {
deliveryCell.hidden = false
// 告知 updateSceneGate 选中场景后该字段应展示
deliveryCell._originHidden = false
// 当前有无场景决定是否立即展示(避免无场景时提前出现)
const hasScene = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
deliveryCell.hidden = !hasScene
}
}
// 订单类型配置:createAllGoodsFlag = 1 显示全部类型;0 仅正常订单
......@@ -1145,7 +1242,9 @@ export default {
this.subShopMerchantList = res
const cell = this.formList[0].find(item => item.label === '二级流量方')
if (cell) {
cell.hidden = false
cell._originHidden = false
const hasScene = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
cell.hidden = !hasScene
}
}
},
......@@ -1245,7 +1344,9 @@ export default {
const { shopMerchantId, sceneType, merchantId } = userInfo,
data = await uni.$api.popupApi.getEmployeeList({
merchantId: orderObj.idKey == 'sellerUserId' ? merchantId : shopMerchantId,
sceneList: orderObj.idKey == 'sellerUserId' ? '' : [sceneType]
sceneList: orderObj.idKey == 'sellerUserId'
? ''
: [this.orderObj.sceneType != null ? this.orderObj.sceneType : sceneType]
})
if (data && data.length) {
this.employeeList = data
......@@ -1262,7 +1363,8 @@ export default {
const { userInfo } = this
const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({
merchantId: userInfo.shopMerchantId,
sceneType: userInfo.sceneType
sceneType: userInfo.sceneType,
baseSceneCode: this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode
})
this.goodsList = res
......
......@@ -111,6 +111,7 @@
</GlCell>
</view>
<view
v-if="orderObj.baseSceneCodeValue || orderObj.baseSceneCode"
@click.stop="submit"
class="btn"
>战败下单</view>
......@@ -290,7 +291,63 @@ export default {
this.initData()
},
methods: {
initData () {
updateSceneGate () {
const selected = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
const list = this.formList || []
list.forEach(group => {
;(group || []).forEach(item => {
if (!item) return
if (item._originHidden === undefined) item._originHidden = Boolean(item.hidden)
if (!selected) {
item.hidden = item.value !== 'baseSceneCode'
} else {
item.hidden = item._originHidden
}
})
})
this.formList = list
return selected
},
async initRecentSceneEcho () {
try {
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
const phone = userInfo.phone
const userSceneType = userInfo.sceneType
if (!phone || userSceneType === undefined || userSceneType === null) return
const recent = await uni.$api.equityApi.getUserRecentScene({
phone,
sceneType: userSceneType
})
// HTTP 层已将 data.data 解包,recent 直接是 { baseSceneCode: '...' }
const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid
if (!recentBaseSceneCode) return
const MOCK_SCENE_LIST = [
{ uuid: '100101', staffName: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', staffName: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', staffName: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', staffName: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', staffName: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', staffName: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', staffName: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', staffName: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
// getSceneListWithOrder 有 Promise 缓存,不会重复发请求;接口无数据时 fallback 到 mock
const rawList = await uni.$api.equityApi.getSceneListWithOrder({
phone,
sceneType: String(userSceneType)
})
const listData = (Array.isArray(rawList) && rawList.length) ? rawList : MOCK_SCENE_LIST
const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode))
if (!item) return
this.$set(this.orderObj, 'baseSceneCode', item.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid)
this.$set(this.orderObj, 'sceneType', item.sceneType)
} catch (e) {}
},
async initData () {
const { userInfo } = this
if (!this.orderObj.id) {
const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
......@@ -311,6 +368,11 @@ export default {
this.getSubShopMerchantList(userInfo.shopMerchantId)
this.getSetting()
// 进页面先回显最近场景;未选场景时不展示/不请求下方表单与接口
if (!this.orderObj.id) await this.initRecentSceneEcho()
const hasScene = this.updateSceneGate()
if (!hasScene) return
this.getConfig()
this.getConfigList()
// this.getEmployeeList()
......@@ -403,6 +465,27 @@ export default {
const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
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'))
} else if (_typeValue.key === 'baseSceneCode') {
// 场景名称:页面显示名称;接口参数使用 code
this.$set(this.orderObj, 'baseSceneCode', chooseContent.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.uuid)
this.$set(this.orderObj, 'sceneType', chooseContent.sceneType)
// 选择后保存最近选中场景(sceneType 用登录场景)
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
if (userInfo.phone) {
uni.$api.equityApi.saveUserRecentScene({
phone: userInfo.phone,
sceneType: userInfo.sceneType,
baseSceneCode: chooseContent.baseSceneCode || chooseContent.uuid
})
}
// 选中场景后,放开下方表单并触发依赖接口
this.$refs.orderPopup && this.$refs.orderPopup.clearCacheByTypes([0, 1, 3, 6, 7, 8, 9, 10, 11, 12])
this.updateSceneGate()
this.getConfig()
this.getConfigList()
// 场景变化后重新拉取商品列表
this.getSelectOrderGoodsList()
} else if (_typeValue.key) {
this.orderObj[_typeValue.targetIdKey] = chooseContent[_typeValue.sourceIdKey]
this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey])
......@@ -531,6 +614,9 @@ export default {
if (!this.checkRequired()) return
const { orderCreateType } = this
const obj = utils.deepClone(this.orderObj)
// 场景名称:界面展示用 name;提交入参需要 code
if (obj.baseSceneCodeValue) obj.baseSceneCode = obj.baseSceneCodeValue
delete obj.baseSceneCodeValue
const otherCustomer = ['customerSex', 'experienceFlag']
obj.customer = {
...obj.customer,
......@@ -699,7 +785,9 @@ export default {
this.subShopMerchantList = res
const cell = this.formList[0].find(item => item.label === '二级流量方')
if (cell) {
cell.hidden = false
cell._originHidden = false
const hasScene = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
cell.hidden = !hasScene
}
}
},
......@@ -801,7 +889,9 @@ export default {
const { shopMerchantId, sceneType, merchantId } = userInfo,
data = await uni.$api.popupApi.getEmployeeList({
merchantId: orderObj.idKey == 'sellerUserId' ? merchantId : shopMerchantId,
sceneList: orderObj.idKey == 'sellerUserId' ? '' : [sceneType]
sceneList: orderObj.idKey == 'sellerUserId'
? ''
: [this.orderObj.sceneType != null ? this.orderObj.sceneType : sceneType]
})
if (data && data.length) {
this.employeeList = data
......@@ -818,7 +908,9 @@ export default {
const { userInfo } = this
const res = await uni.$api.boutiqueApi.getOrderBaseGoodsList({
merchantId: userInfo.shopMerchantId,
upradeFlag: 'N'
upradeFlag: 'N',
sceneType: this.orderObj.sceneType != null ? this.orderObj.sceneType : userInfo.sceneType,
baseSceneCode: this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode
})
// 分类映射
......
const FORM_LIST = [
[
{
label: '场景名称',
value: 'baseSceneCode',
type: 'select',
key: 'baseSceneCode',
required: true
},
{
label: '销售顾问',
value: 'employeeName',
type: 'select',
......@@ -50,11 +57,15 @@ const FORM_LIST = [
radioList: [
{
value: '0',
name: '售前'
name: '存储门店引流-售前'
},
{
value: '1',
name: '售后'
name: '门店引流-售后'
},
{
value: '2',
name: '自然到店'
}
],
required: true
......@@ -255,6 +266,13 @@ const FORM_LIST = [
const DEFEAT_FORM_LIST = [
[
{
label: '场景名称',
value: 'baseSceneCode',
type: 'select',
key: 'baseSceneCode',
required: true
},
{
label: '战败日期',
value: 'todayShow',
type: 'select',
......@@ -311,11 +329,15 @@ const DEFEAT_FORM_LIST = [
radioList: [
{
value: '0',
name: '售前'
name: '存储门店引流-售前'
},
{
value: '1',
name: '售后'
name: '门店引流-售后'
},
{
value: '2',
name: '自然到店'
}
],
required: true,
......@@ -547,6 +569,11 @@ const payTypeList = [
]
const popupTypeEnum = {
29: {
// 场景名称弹窗(SceneList)
key: 'baseSceneCode',
list: ''
},
0: {
key: 'employeeName',
list: 'employeeList',
......
......@@ -38,7 +38,7 @@
</template>
</GlCell>
</view>
<view class="btns flex">
<view class="btns flex" v-if="orderObj.baseSceneCodeValue || orderObj.baseSceneCode">
<view class="btn save" @click="handleEditSave">存草稿</view>
<view @click="submit" class="btn">{{ confirmText }}</view>
</view>
......@@ -184,6 +184,62 @@ export default {
this.initData()
},
methods: {
updateSceneGate () {
const selected = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
const list = this.formList || []
list.forEach(group => {
;(group || []).forEach(item => {
if (!item) return
if (item._originHidden === undefined) item._originHidden = Boolean(item.hidden)
if (!selected) {
item.hidden = item.value !== 'baseSceneCode'
} else {
item.hidden = item._originHidden
}
})
})
this.formList = list
return selected
},
async initRecentSceneEcho () {
try {
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
const phone = userInfo.phone
const userSceneType = userInfo.sceneType
if (!phone || userSceneType === undefined || userSceneType === null) return
const recent = await uni.$api.equityApi.getUserRecentScene({
phone,
sceneType: userSceneType
})
// HTTP 层已将 data.data 解包,recent 直接是 { baseSceneCode: '...' }
const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid
if (!recentBaseSceneCode) return
const MOCK_SCENE_LIST = [
{ uuid: '100101', staffName: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', staffName: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', staffName: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', staffName: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', staffName: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', staffName: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', staffName: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', staffName: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
// getSceneListWithOrder 有 Promise 缓存,不会重复发请求;接口无数据时 fallback 到 mock
const rawList = await uni.$api.equityApi.getSceneListWithOrder({
phone,
sceneType: String(userSceneType)
})
const listData = (Array.isArray(rawList) && rawList.length) ? rawList : MOCK_SCENE_LIST
const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode))
if (!item) return
this.$set(this.orderObj, 'baseSceneCode', item.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid)
this.$set(this.orderObj, 'sceneType', item.sceneType)
} catch (e) {}
},
async getQuotationInfoById(id) {
try {
let { goodsList: quotationGoodsList } = this,
......@@ -422,7 +478,19 @@ export default {
orderTypeCell.current = this.orderObj.djOrderType
}
}
this.getSelectOrderGoodsList()
// 新增页:先回显最近场景;未选场景时不展示/不请求下方表单与接口
const p = this.paramsData || {}
if (!p.id) {
this.initRecentSceneEcho().finally(() => {
const hasScene = this.updateSceneGate()
if (!hasScene) return
this.getSelectOrderGoodsList()
})
} else {
// 编辑页不做 recent 覆盖
this.updateSceneGate()
this.getSelectOrderGoodsList()
}
if (!paramsData.id) this.getConfig()
this.getShopMerchantPointConfig()
......@@ -577,6 +645,26 @@ export default {
this.$set(this.orderObj, 'provinceText', chooseContent.province)
this.$set(this.orderObj, 'cityText', chooseContent.city)
this.$set(this.orderObj, 'city', chooseContent.city == chooseContent.province ? chooseContent.city : `${chooseContent.province}-${chooseContent.city}`)
} else if (_typeValue.key === 'baseSceneCode') {
// 场景名称:界面显示名称;提交时使用 code
this.$set(this.orderObj, 'baseSceneCode', chooseContent.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.uuid)
this.$set(this.orderObj, 'sceneType', chooseContent.sceneType)
// 选择后保存最近选中场景(sceneType 用登录场景)
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
if (userInfo.phone) {
uni.$api.equityApi.saveUserRecentScene({
phone: userInfo.phone,
sceneType: userInfo.sceneType,
baseSceneCode: chooseContent.baseSceneCode || chooseContent.uuid
})
}
// 选中场景后,放开下方表单并触发依赖接口
// 立即清空 goodsList,确保弹窗打开时 externalData 为空,迫使 SkuGoodsList 重新调接口
this.goodsList = []
this.$refs.orderPopup && this.$refs.orderPopup.clearCacheByTypes([0, 1, 3, 6, 7, 8, 9, 10, 11, 12])
this.updateSceneGate()
this.getSelectOrderGoodsList()
} else if (_typeValue.key == 'todayShow') {
this.$set(this.orderObj, 'pay2Time', chooseContent)
} else if (_typeValue.list == 'employeeList') {
......@@ -985,6 +1073,9 @@ export default {
}
}
if (orderInfo.id) params.id = orderInfo.id
// 场景 code(用于后端入参)
if (orderInfo.baseSceneCodeValue) params.baseSceneCode = orderInfo.baseSceneCodeValue
else if (orderInfo.baseSceneCode) params.baseSceneCode = orderInfo.baseSceneCode
params.merchantId4s = default4SStoreInfo?.merchantId
params.merchantName4s = default4SStoreInfo?.merchantName
orderInfo.price = this.multipliedByHundred(orderInfo.price)
......@@ -1220,7 +1311,8 @@ export default {
})
const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({
merchantId: userInfo.shopMerchantId,
sceneType: userInfo.sceneType
sceneType: userInfo.sceneType,
baseSceneCode: this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode
})
this.goodsList = res
this.changeTotalPrice()
......
......@@ -31,7 +31,7 @@
</GlCell>
</view>
</scroll-view>
<view class="btns flex">
<view class="btns flex" v-if="orderObj.baseSceneCodeValue || orderObj.baseSceneCode">
<view @click.stop="submit('reload')" class="btn save">提交后继续添加</view>
<view @click.stop="submit" class="btn">战败下单</view>
</view>
......@@ -176,6 +176,62 @@ export default {
this.initData()
},
methods: {
updateSceneGate () {
const selected = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
const list = this.formList || []
list.forEach(group => {
;(group || []).forEach(item => {
if (!item) return
if (item._originHidden === undefined) item._originHidden = Boolean(item.hidden)
if (!selected) {
item.hidden = item.value !== 'baseSceneCode'
} else {
item.hidden = item._originHidden
}
})
})
this.formList = list
return selected
},
async initRecentSceneEcho () {
try {
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
const phone = userInfo.phone
const userSceneType = userInfo.sceneType
if (!phone || userSceneType === undefined || userSceneType === null) return
const recent = await uni.$api.equityApi.getUserRecentScene({
phone,
sceneType: userSceneType
})
// HTTP 层已将 data.data 解包,recent 直接是 { baseSceneCode: '...' }
const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid
if (!recentBaseSceneCode) return
const MOCK_SCENE_LIST = [
{ uuid: '100101', staffName: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', staffName: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', staffName: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', staffName: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', staffName: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', staffName: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', staffName: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', staffName: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
// getSceneListWithOrder 有 Promise 缓存,不会重复发请求;接口无数据时 fallback 到 mock
const rawList = await uni.$api.equityApi.getSceneListWithOrder({
phone,
sceneType: String(userSceneType)
})
const listData = (Array.isArray(rawList) && rawList.length) ? rawList : MOCK_SCENE_LIST
const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode))
if (!item) return
this.$set(this.orderObj, 'baseSceneCode', item.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid)
this.$set(this.orderObj, 'sceneType', item.sceneType)
} catch (e) {}
},
resetParams() {
// 重置表单数据
this.orderObj = {
......@@ -206,6 +262,10 @@ export default {
merchantName: userInfo.shopMerchantName
})
}
// 进页面回显最近一次选中的场景
if (!this.orderObj.id) await this.initRecentSceneEcho()
const hasScene = this.updateSceneGate()
if (!hasScene) return
await this.getEmployeeList()
this.getLastUserOrderInfo()
this.getGoodsProduct()
......@@ -248,7 +308,9 @@ export default {
const { shopMerchantId, sceneType, merchantId } = userInfo,
data = await uni.$api.popupApi.getEmployeeList({
merchantId: orderObj.idKey == 'sellerUserId' ? merchantId : shopMerchantId,
sceneList: orderObj.idKey == 'sellerUserId' ? '' : [sceneType]
sceneList: orderObj.idKey == 'sellerUserId'
? ''
: [this.orderObj.sceneType != null ? this.orderObj.sceneType : sceneType]
})
if (data && data.length) {
this.employeeList = data
......@@ -305,6 +367,24 @@ export default {
const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
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'))
} else if (_typeValue.key === 'baseSceneCode') {
// 场景名称:页面显示名称;后续接口参数使用 sceneType/code
this.$set(this.orderObj, 'baseSceneCode', chooseContent.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.uuid)
this.$set(this.orderObj, 'sceneType', chooseContent.sceneType)
// 选择后保存最近选中场景(sceneType 用登录场景)
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
if (userInfo.phone) {
uni.$api.equityApi.saveUserRecentScene({
phone: userInfo.phone,
sceneType: userInfo.sceneType,
baseSceneCode: chooseContent.baseSceneCode || chooseContent.uuid
})
}
// 选中场景后,放开下方表单并触发依赖接口
this.$refs.orderPopup && this.$refs.orderPopup.clearCacheByTypes([0, 1, 3, 6, 7, 8, 9, 10, 11, 12])
this.updateSceneGate()
this.getEmployeeList()
}
// 定义产品相关字段数组
if (val.popupType == 20) {
......
......@@ -2,9 +2,9 @@ const FORM_LIST = [
[
{
label: '场景名称',
value: 'senceCode',
value: 'baseSceneCode',
type: 'select',
key: 'senceCode',
key: 'baseSceneCode',
required: true
},
{
......@@ -46,11 +46,15 @@ const FORM_LIST = [
radioList: [
{
value: '0',
name: '售前'
name: '存储门店引流-售前'
},
{
value: '1',
name: '售后'
name: '门店引流-售后'
},
{
value: '2',
name: '自然到店'
}
],
required: true
......@@ -261,11 +265,15 @@ const DEFEAT_FORM_LIST = [
radioList: [
{
value: '0',
name: '售前'
name: '存储门店引流-售前'
},
{
value: '1',
name: '售后'
name: '门店引流-售后'
},
{
value: '2',
name: '自然到店'
}
],
required: true
......@@ -417,8 +425,8 @@ const popupTypeEnum = {
},
29: {
// 场景名称弹窗(SceneList)
key: 'senceCode',
list: 'sceneList'
key: 'baseSceneCode',
list: ''
}
}
const titleList = [null, { addHtml: 'customer' }, { name: '车辆信息' }, { name: '增值车损险' }, { name: '其他信息' }]
......@@ -447,11 +455,15 @@ const UpdateOrderInfo = [
radioList: [
{
value: '0',
name: '售前'
name: '存储门店引流-售前'
},
{
value: '1',
name: '售后'
name: '门店引流-售后'
},
{
value: '2',
name: '自然到店'
}
]
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!