Commit 5aaa9842 by 岑成威

fiix: 回显场景

1 parent d59d9149
...@@ -27,17 +27,6 @@ const SCENE_TYPE_TAG_MAP = { ...@@ -27,17 +27,6 @@ const SCENE_TYPE_TAG_MAP = {
4: { label: '其他', bg: '#ff9d2e1a', color: '#ff9d2e' } 4: { label: '其他', bg: '#ff9d2e1a', color: '#ff9d2e' }
} }
const MOCK_SCENE_LIST = [
{ uuid: '100101', name: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', name: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', name: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', name: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', name: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', name: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', name: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', name: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
export default { export default {
mixins: [popupmixin], mixins: [popupmixin],
name: 'SceneList', name: 'SceneList',
...@@ -61,6 +50,9 @@ export default { ...@@ -61,6 +50,9 @@ export default {
mounted () { mounted () {
}, },
methods: { methods: {
getSceneId (item = {}) {
return item.baseSceneCode || item.uuid
},
async getList (searchValue, search) { async getList (searchValue, search) {
const { userInfo, params } = this, const { userInfo, params } = this,
{ cacheData } = params { cacheData } = params
...@@ -76,14 +68,14 @@ export default { ...@@ -76,14 +68,14 @@ export default {
sceneType: String(userInfo.sceneType), sceneType: String(userInfo.sceneType),
phone: userInfo.phone phone: userInfo.phone
}) })
const list = (data && data.length) ? data : MOCK_SCENE_LIST const list = (data && data.length) ? data : []
this.updateParams(params, list || []) this.updateParams(params, list)
}, },
initData (list) { initData (list) {
const { idKey, data } = this const { idKey, data } = this
if (data[idKey]) { if (data[idKey]) {
this.currentId = data[idKey] this.currentId = data[idKey]
let item = list.find(i => i.uuid == this.currentId) let item = list.find(i => this.getSceneId(i) == this.currentId)
console.log(item) console.log(item)
this.$emit('choose', item) this.$emit('choose', item)
} }
...@@ -130,12 +122,13 @@ export default { ...@@ -130,12 +122,13 @@ export default {
icon: 'none', icon: 'none',
mask: true mask: true
}) })
this.currentId = i.uuid this.currentId = this.getSceneId(i)
this.$emit('choose', i) this.$emit('choose', i)
}, },
checkActive (i) { checkActive (i) {
let { currentId, idKey, data } = this let { currentId, idKey, data } = this
return currentId ? i.uuid == currentId : i.uuid == data[idKey] const id = this.getSceneId(i)
return currentId ? id == currentId : id == data[idKey]
} }
} }
} }
......
<template> <template>
<view class="employee-list"> <view class="employee-list">
<view @click="currentIds = []" :class="['item flex', { active: !currentIds.length }]"> <view @click="currentId = ''" :class="['item flex', { active: !currentId }]">
<view class="sprite-icon icon-tag-checked"></view> <view class="sprite-icon icon-tag-checked"></view>
全部 全部
</view> </view>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
data () { data () {
return { return {
list: [], list: [],
currentIds: [] currentId: ''
} }
}, },
props: { props: {
...@@ -26,15 +26,15 @@ ...@@ -26,15 +26,15 @@
data: [Array, Object], data: [Array, Object],
}, },
watch: { watch: {
currentIds: { currentId: {
handler (val) { handler (val) {
let { params: { idKey } } = this let { params: { idKey } } = this
this.$emit('choose', { this.$emit('choose', {
key: idKey, key: idKey,
value: val.length ? val : null // 兼容历史筛选参数:baseSceneCode 始终用 string(空字符串表示“全部”)
value: val ? String(val) : ''
}) })
}, },
deep: true
} }
}, },
mounted () { mounted () {
...@@ -77,28 +77,21 @@ ...@@ -77,28 +77,21 @@
let { data, params: {idKey} } = this let { data, params: {idKey} } = this
this.list = list this.list = list
let paramsData = idKey ? data[idKey] : data let paramsData = idKey ? data[idKey] : data
if (paramsData && paramsData.length) paramsData.map(e => { this.currentId = paramsData || ''
this.currentIds.push(e)
})
this.$emit('onComplete') this.$emit('onComplete')
}, },
choose (i) { choose (i) {
if (i) { if (!i) return
const sceneId = this.getSceneId(i) const sceneId = this.getSceneId(i)
if (!sceneId) return if (!sceneId) return
let // 场景名称在列表筛选里为单选:点击已选项不取消
{ currentIds } = this, if (this.currentId === sceneId) return
index = currentIds.indexOf(sceneId) this.currentId = sceneId
if (index == -1) this.currentIds.push(sceneId)
else this.currentIds.splice(index, 1)
}
}, },
checkActive (i) { checkActive (i) {
let { currentIds } = this, let { currentId } = this
active = false return currentId ? currentId === this.getSceneId(i) : false
if (currentIds.length) active = currentIds.includes(this.getSceneId(i)) // return this.currentId === i.uuid
return active
// return this.currentIds.includes(i.uuid)
}, },
} }
} }
......
<template> <template>
<view class="employee-list"> <view class="employee-list">
<view @click="currentIds = []" :class="['item flex', { active: !currentIds.length }]"> <view @click="currentId = ''" :class="['item flex', { active: !currentId }]">
<view class="sprite-icon icon-tag-checked"></view> <view class="sprite-icon icon-tag-checked"></view>
全部 全部
</view> </view>
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
export default { export default {
name: 'EmployeeList', name: 'SceneList',
inject: ['userInfo'], inject: ['userInfo'],
data () { data () {
return { return {
list: [], list: [],
currentIds: [] currentId: ''
} }
}, },
props: { props: {
...@@ -26,15 +26,15 @@ ...@@ -26,15 +26,15 @@
data: [Array, Object], data: [Array, Object],
}, },
watch: { watch: {
currentIds: { currentId: {
handler (val) { handler (val) {
let { params: { idKey } } = this let { params: { idKey } } = this
this.$emit('choose', { this.$emit('choose', {
key: idKey, key: idKey,
value: val.length ? val : null // 场景名称单选:baseSceneCode 始终为 string(空字符串表示“全部”)
value: val ? String(val) : ''
}) })
}, },
deep: true
} }
}, },
mounted () { mounted () {
...@@ -74,29 +74,24 @@ ...@@ -74,29 +74,24 @@
initList (list) { initList (list) {
let { data, params: {idKey} } = this let { data, params: {idKey} } = this
this.list = list this.list = list
let paramsData = idKey ? data[idKey] : data const paramsData = idKey ? data?.[idKey] : data
if (paramsData && paramsData.length) paramsData.map(e => { // 兼容历史值:如果传进来是数组,取第一个;否则按 string 处理
this.currentIds.push(e) if (Array.isArray(paramsData)) this.currentId = paramsData[0] ? String(paramsData[0]) : ''
}) else this.currentId = paramsData ? String(paramsData) : ''
this.$emit('onComplete') this.$emit('onComplete')
}, },
choose (i) { choose (i) {
if (i) { if (!i) return
const sceneId = this.getSceneId(i) const sceneId = this.getSceneId(i)
if (!sceneId) return if (!sceneId) return
let // 单选:点击已选项不取消
{ currentIds } = this, if (String(this.currentId) === String(sceneId)) return
index = currentIds.indexOf(sceneId) this.currentId = String(sceneId)
if (index == -1) this.currentIds.push(sceneId)
else this.currentIds.splice(index, 1)
}
}, },
checkActive (i) { checkActive (i) {
let { currentIds } = this, const id = this.getSceneId(i)
active = false if (!id) return false
if (currentIds.length) active = currentIds.includes(this.getSceneId(i)) return this.currentId ? String(this.currentId) === String(id) : false
return active
// return this.currentIds.includes(i.uuid)
}, },
} }
} }
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
<template v-if="lockReason == '1'"> <template v-if="lockReason == '1'">
到学习中心-我的任务,完成长课程学习任务后,即可解锁开单权限。 到学习中心-我的任务,完成长课程学习任务后,即可解锁开单权限。
</template> </template>
<template v-if="lockReason == '2'">
到服务中心-短课程,完成短课程学习任务后,即可解锁开单权限。
</template>
</view> </view>
<!-- 第三段描述 --> <!-- 第三段描述 -->
......
const target = ['ip', 'dev', 'uat', 'prod', 'beta'] const target = ['ip', 'dev', 'uat', 'prod', 'beta']
const index = 1 const index = 2
/** /**
* *
0本地 0本地
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</template> </template>
</GlCell> </GlCell>
</view> </view>
<view v-if="orderObj.baseSceneCodeValue || orderObj.baseSceneCode" @click="submit" class="btn">直接下单</view> <view v-if="orderObj.baseSceneCodeValue" @click="submit" class="btn">直接下单</view>
</scroll-view> </scroll-view>
</view> </view>
<!-- 弹窗 --> <!-- 弹窗 -->
...@@ -314,28 +314,21 @@ export default { ...@@ -314,28 +314,21 @@ export default {
const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid
if (!recentBaseSceneCode) return if (!recentBaseSceneCode) return
const MOCK_SCENE_LIST = [ // getSceneListWithOrder 有 Promise 缓存,不会重复发请求
{ uuid: '100101', name: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', name: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', name: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', name: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', name: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', name: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', name: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', name: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
// getSceneListWithOrder 有 Promise 缓存,不会重复发请求;接口无数据时 fallback 到 mock
const rawList = await uni.$api.equityApi.getSceneListWithOrder({ const rawList = await uni.$api.equityApi.getSceneListWithOrder({
phone, phone,
sceneType: String(userSceneType) sceneType: String(userSceneType)
}) })
const listData = (Array.isArray(rawList) && rawList.length) ? rawList : MOCK_SCENE_LIST const listData = Array.isArray(rawList) ? rawList : []
const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode)) const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode))
if (!item) return if (!item) return
this.$set(this.orderObj, 'baseSceneCode', item.name || item.staffName) this.$set(this.orderObj, 'baseSceneCode', item.name || item.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid) this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid)
this.$set(this.orderObj, 'sceneType', item.sceneType) this.$set(this.orderObj, 'sceneType', item.sceneType)
// 同步表单展示(GlCell 某些字段依赖 current)
const sceneCell = this.formList?.[0]?.find(v => v && v.value === 'baseSceneCode')
if (sceneCell) sceneCell.current = item.name || item.staffName || ''
} catch (e) {} } catch (e) {}
}, },
// 计算单个商品的最终价格(与页面展示保持一致:先算单件优惠价,再乘数量,均向上取整两位) // 计算单个商品的最终价格(与页面展示保持一致:先算单件优惠价,再乘数量,均向上取整两位)
...@@ -616,8 +609,10 @@ export default { ...@@ -616,8 +609,10 @@ export default {
} }
} }
// 新增页:先回显最近场景;未选场景时不展示/不请求下方表单与接口 // 新增页:先回显最近场景;未选场景时不展示/不请求下方表单与接口
if (this.orderCreateType === 'createWithPay' && !this.orderObj.id) { // 补录订单也需要回显最近场景(否则首屏场景名称为空,无法继续)
await this.initRecentSceneEcho() if (!this.orderObj.id && (this.orderCreateType === 'createWithPay' || this.orderCreateType === 'supplementOrder')) {
const hasScene = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
if (!hasScene) await this.initRecentSceneEcho()
} }
const hasScene = this.updateSceneGate() const hasScene = this.updateSceneGate()
if (!hasScene) return if (!hasScene) return
...@@ -741,7 +736,7 @@ export default { ...@@ -741,7 +736,7 @@ export default {
} else if (_typeValue.key === 'baseSceneCode') { } else if (_typeValue.key === 'baseSceneCode') {
// 场景名称:页面显示名称;提交时使用 code // 场景名称:页面显示名称;提交时使用 code
this.$set(this.orderObj, 'baseSceneCode', chooseContent.name || chooseContent.staffName) this.$set(this.orderObj, 'baseSceneCode', chooseContent.name || chooseContent.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.uuid) this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.baseSceneCode || chooseContent.uuid)
this.$set(this.orderObj, 'sceneType', chooseContent.sceneType) this.$set(this.orderObj, 'sceneType', chooseContent.sceneType)
// 选择后保存最近选中场景(sceneType 用登录场景) // 选择后保存最近选中场景(sceneType 用登录场景)
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {}) const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
...@@ -1371,7 +1366,7 @@ export default { ...@@ -1371,7 +1366,7 @@ export default {
const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({ const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({
merchantId: userInfo.shopMerchantId, merchantId: userInfo.shopMerchantId,
sceneType: userInfo.sceneType, sceneType: userInfo.sceneType,
baseSceneCode: this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode baseSceneCode: this.orderObj.baseSceneCodeValue
}) })
this.goodsList = res this.goodsList = res
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
</GlCell> </GlCell>
</view> </view>
<view <view
v-if="orderObj.baseSceneCodeValue || orderObj.baseSceneCode" v-if="orderObj.baseSceneCodeValue"
@click.stop="submit" @click.stop="submit"
class="btn" class="btn"
>战败下单</view> >战败下单</view>
...@@ -174,6 +174,20 @@ export default { ...@@ -174,6 +174,20 @@ export default {
const baseFields = ['id', 'orderCode', 'userId', 'employeeName', 'deliveryEmployeeName', 'deliveryUserId', 'subShopMerchantName', 'subShopMerchantId', 'sellerName', 'sellerUserId', 'sellerMerchantName', 'sellerMerchantId', 'merchantId', 'merchantName', 'customerCouponId'] 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]])))
// 场景回显:列表进入会带 baseSceneName/baseSceneCode
const sceneName = rest.baseSceneName || rest.sceneName || ''
const sceneCode = rest.baseSceneCode || rest.baseSceneId || ''
if (sceneName || sceneCode) {
this.$set(this.orderObj, 'baseSceneCode', sceneName)
this.$set(this.orderObj, 'baseSceneCodeValue', sceneCode)
const sceneCell = this.formList?.[0]?.find(item => item.value === 'baseSceneCode')
if (sceneCell) sceneCell.current = sceneName
}
// 二级流量方回显(列表进入会直接带 subShopMerchantName/subShopMerchantId)
const subShopCell = this.formList?.[0]?.find(item => item.value === 'subShopMerchantName')
if (subShopCell && this.orderObj.subShopMerchantName) subShopCell.current = this.orderObj.subShopMerchantName
// 客户信息映射 // 客户信息映射
const customerFields = ['customerName', 'customerSex', 'customerPhone', '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]])))
...@@ -291,6 +305,21 @@ export default { ...@@ -291,6 +305,21 @@ export default {
this.initData() this.initData()
}, },
methods: { methods: {
async tryEchoSubShopMerchantFromDetail (orderCode) {
try {
if (!orderCode) return
// 订单列表接口可能不返回二级流量方,详情接口通常会返回
const detail = await uni.$api.boutiqueApi.getPackageGoodsDetail({ orderCode })
const name = detail?.subShopMerchantName
const id = detail?.subShopMerchantId
if (name || id) {
this.$set(this.orderObj, 'subShopMerchantId', id)
this.$set(this.orderObj, 'subShopMerchantName', name)
const subShopCell = this.formList?.[0]?.find(item => item.value === 'subShopMerchantName')
if (subShopCell) subShopCell.current = name
}
} catch (e) {}
},
updateSceneGate () { updateSceneGate () {
const selected = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode)) const selected = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
const list = this.formList || [] const list = this.formList || []
...@@ -323,28 +352,21 @@ export default { ...@@ -323,28 +352,21 @@ export default {
const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid
if (!recentBaseSceneCode) return if (!recentBaseSceneCode) return
const MOCK_SCENE_LIST = [ // getSceneListWithOrder 有 Promise 缓存,不会重复发请求
{ uuid: '100101', name: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', name: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', name: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', name: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', name: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', name: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', name: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', name: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
// getSceneListWithOrder 有 Promise 缓存,不会重复发请求;接口无数据时 fallback 到 mock
const rawList = await uni.$api.equityApi.getSceneListWithOrder({ const rawList = await uni.$api.equityApi.getSceneListWithOrder({
phone, phone,
sceneType: String(userSceneType) sceneType: String(userSceneType)
}) })
const listData = (Array.isArray(rawList) && rawList.length) ? rawList : MOCK_SCENE_LIST const listData = Array.isArray(rawList) ? rawList : []
const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode)) const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode))
if (!item) return if (!item) return
this.$set(this.orderObj, 'baseSceneCode', item.name || item.staffName) this.$set(this.orderObj, 'baseSceneCode', item.name || item.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid) this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid)
this.$set(this.orderObj, 'sceneType', item.sceneType) this.$set(this.orderObj, 'sceneType', item.sceneType)
// 同步表单展示(GlCell 某些字段依赖 current)
const sceneCell = this.formList?.[0]?.find(v => v && v.value === 'baseSceneCode')
if (sceneCell) sceneCell.current = item.name || item.staffName || ''
} catch (e) {} } catch (e) {}
}, },
async initData () { async initData () {
...@@ -368,6 +390,11 @@ export default { ...@@ -368,6 +390,11 @@ export default {
this.getSubShopMerchantList(userInfo.shopMerchantId) this.getSubShopMerchantList(userInfo.shopMerchantId)
this.getSetting() this.getSetting()
// 列表进入(带 id/orderCode)但未返回二级流量方时,走详情兜底回显
if (this.orderObj.id && this.orderObj.orderCode && !this.orderObj.subShopMerchantName && !this.orderObj.subShopMerchantId) {
await this.tryEchoSubShopMerchantFromDetail(this.orderObj.orderCode)
}
// 进页面先回显最近场景;未选场景时不展示/不请求下方表单与接口 // 进页面先回显最近场景;未选场景时不展示/不请求下方表单与接口
if (!this.orderObj.id) await this.initRecentSceneEcho() if (!this.orderObj.id) await this.initRecentSceneEcho()
const hasScene = this.updateSceneGate() const hasScene = this.updateSceneGate()
...@@ -468,7 +495,7 @@ export default { ...@@ -468,7 +495,7 @@ export default {
} else if (_typeValue.key === 'baseSceneCode') { } else if (_typeValue.key === 'baseSceneCode') {
// 场景名称:页面显示名称;接口参数使用 code // 场景名称:页面显示名称;接口参数使用 code
this.$set(this.orderObj, 'baseSceneCode', chooseContent.name || chooseContent.staffName) this.$set(this.orderObj, 'baseSceneCode', chooseContent.name || chooseContent.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.uuid) this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.baseSceneCode || chooseContent.uuid)
this.$set(this.orderObj, 'sceneType', chooseContent.sceneType) this.$set(this.orderObj, 'sceneType', chooseContent.sceneType)
// 选择后保存最近选中场景(sceneType 用登录场景) // 选择后保存最近选中场景(sceneType 用登录场景)
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {}) const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
...@@ -789,6 +816,16 @@ export default { ...@@ -789,6 +816,16 @@ export default {
const hasScene = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode)) const hasScene = Boolean(this.orderObj && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode))
cell.hidden = !hasScene cell.hidden = !hasScene
} }
// 列表进入时后端可能不返回 subShopMerchantName/subShopMerchantId;
// 若仅有一个可选项且当前未选择,则默认回填,避免“空白不可操作”的体验
if (!this.orderObj.subShopMerchantId && !this.orderObj.subShopMerchantName && res.length === 1) {
const only = res[0] || {}
this.$set(this.orderObj, 'subShopMerchantId', only.subMerchantId)
this.$set(this.orderObj, 'subShopMerchantName', only.subMerchantName)
const subShopCell = this.formList?.[0]?.find(item => item.value === 'subShopMerchantName')
if (subShopCell) subShopCell.current = only.subMerchantName
}
} }
}, },
// 动态获取 车型 车架 车牌 是否必填 // 动态获取 车型 车架 车牌 是否必填
...@@ -910,7 +947,7 @@ export default { ...@@ -910,7 +947,7 @@ export default {
merchantId: userInfo.shopMerchantId, merchantId: userInfo.shopMerchantId,
upradeFlag: 'N', upradeFlag: 'N',
sceneType: this.orderObj.sceneType != null ? this.orderObj.sceneType : userInfo.sceneType, sceneType: this.orderObj.sceneType != null ? this.orderObj.sceneType : userInfo.sceneType,
baseSceneCode: this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode baseSceneCode: this.orderObj.baseSceneCodeValue
}) })
// 分类映射 // 分类映射
......
...@@ -57,7 +57,7 @@ const FORM_LIST = [ ...@@ -57,7 +57,7 @@ const FORM_LIST = [
radioList: [ radioList: [
{ {
value: '0', value: '0',
name: '存储门店引流-售前' name: '门店引流-售前'
}, },
{ {
value: '1', value: '1',
...@@ -329,7 +329,7 @@ const DEFEAT_FORM_LIST = [ ...@@ -329,7 +329,7 @@ const DEFEAT_FORM_LIST = [
radioList: [ radioList: [
{ {
value: '0', value: '0',
name: '存储门店引流-售前' name: '门店引流-售前'
}, },
{ {
value: '1', value: '1',
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</template> </template>
</GlCell> </GlCell>
</view> </view>
<view class="btns flex" v-if="orderObj.baseSceneCodeValue || orderObj.baseSceneCode"> <view class="btns flex" v-if="orderObj.baseSceneCodeValue">
<view class="btn save" @click="handleEditSave">存草稿</view> <view class="btn save" @click="handleEditSave">存草稿</view>
<view @click="submit" class="btn">{{ confirmText }}</view> <view @click="submit" class="btn">{{ confirmText }}</view>
</view> </view>
...@@ -216,28 +216,21 @@ export default { ...@@ -216,28 +216,21 @@ export default {
const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid
if (!recentBaseSceneCode) return if (!recentBaseSceneCode) return
const MOCK_SCENE_LIST = [ // getSceneListWithOrder 有 Promise 缓存,不会重复发请求
{ uuid: '100101', name: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', name: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', name: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', name: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', name: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', name: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', name: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', name: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
// getSceneListWithOrder 有 Promise 缓存,不会重复发请求;接口无数据时 fallback 到 mock
const rawList = await uni.$api.equityApi.getSceneListWithOrder({ const rawList = await uni.$api.equityApi.getSceneListWithOrder({
phone, phone,
sceneType: String(userSceneType) sceneType: String(userSceneType)
}) })
const listData = (Array.isArray(rawList) && rawList.length) ? rawList : MOCK_SCENE_LIST const listData = Array.isArray(rawList) ? rawList : []
const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode)) const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode))
if (!item) return if (!item) return
this.$set(this.orderObj, 'baseSceneCode', item.name || item.staffName) this.$set(this.orderObj, 'baseSceneCode', item.name || item.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid) this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid)
this.$set(this.orderObj, 'sceneType', item.sceneType) this.$set(this.orderObj, 'sceneType', item.sceneType)
// 同步表单展示(GlCell 部分字段依赖 current)
const sceneCell = this.formList?.[0]?.find(v => v && v.value === 'baseSceneCode')
if (sceneCell) sceneCell.current = item.name || item.staffName || ''
} catch (e) {} } catch (e) {}
}, },
async getQuotationInfoById(id) { async getQuotationInfoById(id) {
...@@ -471,6 +464,18 @@ export default { ...@@ -471,6 +464,18 @@ export default {
// 埋点 // 埋点
// uni.$track.add({ eventCode: 'app_create_order' }) // uni.$track.add({ eventCode: 'app_create_order' })
const { paramsData } = this const { paramsData } = this
// 去报价/编辑进入(带 id)时,优先用入参回显业务场景名称
// 这里不走 recent 覆盖,避免把用户正在编辑的单子场景冲掉
if (paramsData && paramsData.id) {
const sceneName = paramsData.baseSceneName || paramsData.sceneName || ''
const sceneCode = paramsData.baseSceneCode || paramsData.baseSceneId || ''
if (sceneName || sceneCode) {
this.$set(this.orderObj, 'baseSceneCode', sceneName)
this.$set(this.orderObj, 'baseSceneCodeValue', sceneCode)
const sceneCell = this.formList?.[0]?.find(v => v && v.value === 'baseSceneCode')
if (sceneCell) sceneCell.current = sceneName
}
}
// 设置订单类型表单显示(新建订单时) // 设置订单类型表单显示(新建订单时)
if (!paramsData.id && this.orderObj.djOrderType) { if (!paramsData.id && this.orderObj.djOrderType) {
const orderTypeCell = this.formList[3]?.find(item => item.value === 'djOrderType') const orderTypeCell = this.formList[3]?.find(item => item.value === 'djOrderType')
...@@ -648,7 +653,7 @@ export default { ...@@ -648,7 +653,7 @@ export default {
} else if (_typeValue.key === 'baseSceneCode') { } else if (_typeValue.key === 'baseSceneCode') {
// 场景名称:界面显示名称;提交时使用 code // 场景名称:界面显示名称;提交时使用 code
this.$set(this.orderObj, 'baseSceneCode', chooseContent.name || chooseContent.staffName) this.$set(this.orderObj, 'baseSceneCode', chooseContent.name || chooseContent.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.uuid) this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.baseSceneCode || chooseContent.uuid)
this.$set(this.orderObj, 'sceneType', chooseContent.sceneType) this.$set(this.orderObj, 'sceneType', chooseContent.sceneType)
// 选择后保存最近选中场景(sceneType 用登录场景) // 选择后保存最近选中场景(sceneType 用登录场景)
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {}) const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
...@@ -1312,7 +1317,7 @@ export default { ...@@ -1312,7 +1317,7 @@ export default {
const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({ const res = await uni.$api.boutiqueApi.getSelectOrderGoodsList({
merchantId: userInfo.shopMerchantId, merchantId: userInfo.shopMerchantId,
sceneType: userInfo.sceneType, sceneType: userInfo.sceneType,
baseSceneCode: this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode baseSceneCode: this.orderObj.baseSceneCodeValue
}) })
this.goodsList = res this.goodsList = res
this.changeTotalPrice() this.changeTotalPrice()
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</GlCell> </GlCell>
</view> </view>
</scroll-view> </scroll-view>
<view class="btns flex" v-if="orderObj.baseSceneCodeValue || orderObj.baseSceneCode"> <view class="btns flex" v-if="orderObj.baseSceneCodeValue">
<view @click.stop="submit('reload')" class="btn save">提交后继续添加</view> <view @click.stop="submit('reload')" class="btn save">提交后继续添加</view>
<view @click.stop="submit" class="btn">战败下单</view> <view @click.stop="submit" class="btn">战败下单</view>
</view> </view>
...@@ -80,6 +80,16 @@ export default { ...@@ -80,6 +80,16 @@ export default {
const baseFields = ['id', 'orderCode', 'userId', 'employeeName', 'defeatEmployeeName', 'deliveryUserId', 'subShopMerchantName', 'subShopMerchantId', 'sellerName', 'sellerUserId', 'sellerMerchantName', 'sellerMerchantId', 'merchantId', 'merchantName', 'customerCouponId'] const baseFields = ['id', 'orderCode', 'userId', 'employeeName', 'defeatEmployeeName', '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]])))
// 场景回显:列表进入会带 baseSceneName/baseSceneCode
const sceneName = rest.baseSceneName || rest.sceneName || ''
const sceneCode = rest.baseSceneCode || rest.baseSceneId || ''
if (sceneName || sceneCode) {
this.$set(this.orderObj, 'baseSceneCode', sceneName)
this.$set(this.orderObj, 'baseSceneCodeValue', sceneCode)
const sceneCell = this.formList?.[0]?.find(item => item.value === 'baseSceneCode')
if (sceneCell) sceneCell.current = sceneName
}
this.orderObj.carBrand = `${customer.carBrand}-${customer.carChildsBrandName}-${customer.carSeriesName}` this.orderObj.carBrand = `${customer.carBrand}-${customer.carChildsBrandName}-${customer.carSeriesName}`
const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'] const weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
this.$set(this.orderObj, 'todayShow', dayjs(this.orderObj.createDate).format('YYYY-MM-DD') + ' ' + weeks[dayjs(this.orderObj.createDate).day()]) this.$set(this.orderObj, 'todayShow', dayjs(this.orderObj.createDate).format('YYYY-MM-DD') + ' ' + weeks[dayjs(this.orderObj.createDate).day()])
...@@ -208,28 +218,21 @@ export default { ...@@ -208,28 +218,21 @@ export default {
const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid const recentBaseSceneCode = recent?.baseSceneCode || recent?.uuid
if (!recentBaseSceneCode) return if (!recentBaseSceneCode) return
const MOCK_SCENE_LIST = [ // getSceneListWithOrder 有 Promise 缓存,不会重复发请求
{ uuid: '100101', name: '精品升级', baseSceneCode: '100101', sceneType: 1, businessType: null },
{ uuid: '100102', name: '交新车干配', baseSceneCode: '100102', sceneType: 2, businessType: null },
{ uuid: '100103', name: '售后众筹', baseSceneCode: '100103', sceneType: 3, businessType: null },
{ uuid: '110101', name: '售前会员权益升级', baseSceneCode: '110101', sceneType: 0, businessType: 1 },
{ uuid: '110102', name: '售后会员权益升级', baseSceneCode: '110102', sceneType: 0, businessType: 1 },
{ uuid: '110201', name: '售前延保', baseSceneCode: '110201', sceneType: 0, businessType: 2 },
{ uuid: '110202', name: '售后延保', baseSceneCode: '110202', sceneType: 0, businessType: 2 },
{ uuid: '120101', name: '二手车收车', baseSceneCode: '120101', sceneType: 7, businessType: null }
]
// getSceneListWithOrder 有 Promise 缓存,不会重复发请求;接口无数据时 fallback 到 mock
const rawList = await uni.$api.equityApi.getSceneListWithOrder({ const rawList = await uni.$api.equityApi.getSceneListWithOrder({
phone, phone,
sceneType: String(userSceneType) sceneType: String(userSceneType)
}) })
const listData = (Array.isArray(rawList) && rawList.length) ? rawList : MOCK_SCENE_LIST const listData = Array.isArray(rawList) ? rawList : []
const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode)) const item = listData.find(i => String(i.baseSceneCode || i.uuid) === String(recentBaseSceneCode))
if (!item) return if (!item) return
this.$set(this.orderObj, 'baseSceneCode', item.name || item.staffName) this.$set(this.orderObj, 'baseSceneCode', item.name || item.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid) this.$set(this.orderObj, 'baseSceneCodeValue', item.baseSceneCode || item.uuid)
this.$set(this.orderObj, 'sceneType', item.sceneType) this.$set(this.orderObj, 'sceneType', item.sceneType)
// 同步表单展示(GlCell 某些字段依赖 current)
const sceneCell = this.formList?.[0]?.find(v => v && v.value === 'baseSceneCode')
if (sceneCell) sceneCell.current = item.name || item.staffName || ''
} catch (e) {} } catch (e) {}
}, },
resetParams() { resetParams() {
...@@ -370,7 +373,7 @@ export default { ...@@ -370,7 +373,7 @@ export default {
} else if (_typeValue.key === 'baseSceneCode') { } else if (_typeValue.key === 'baseSceneCode') {
// 场景名称:页面显示名称;后续接口参数使用 sceneType/code // 场景名称:页面显示名称;后续接口参数使用 sceneType/code
this.$set(this.orderObj, 'baseSceneCode', chooseContent.name || chooseContent.staffName) this.$set(this.orderObj, 'baseSceneCode', chooseContent.name || chooseContent.staffName)
this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.uuid) this.$set(this.orderObj, 'baseSceneCodeValue', chooseContent.baseSceneCode || chooseContent.uuid)
this.$set(this.orderObj, 'sceneType', chooseContent.sceneType) this.$set(this.orderObj, 'sceneType', chooseContent.sceneType)
// 选择后保存最近选中场景(sceneType 用登录场景) // 选择后保存最近选中场景(sceneType 用登录场景)
const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {}) const userInfo = this.userInfo || (uni.$storage.get('userInfo') || {})
......
...@@ -200,6 +200,8 @@ export default { ...@@ -200,6 +200,8 @@ export default {
merchantIds: [localUserInfo.shopMerchantId], merchantIds: [localUserInfo.shopMerchantId],
...this.searchObj ...this.searchObj
} }
// 兼容筛选入参:baseSceneCode 为空字符串表示“全部”,请求时不下发该字段
if (params.baseSceneCode === '') delete params.baseSceneCode
uni.$api.equityApi uni.$api.equityApi
.orderStatistics(params) .orderStatistics(params)
.then(result => { .then(result => {
...@@ -265,6 +267,8 @@ export default { ...@@ -265,6 +267,8 @@ export default {
merchantIds: [localUserInfo.shopMerchantId], merchantIds: [localUserInfo.shopMerchantId],
...this.searchObj ...this.searchObj
} }
// 兼容筛选入参:baseSceneCode 为空字符串表示“全部”,请求时不下发该字段
if (params.baseSceneCode === '') delete params.baseSceneCode
if (params?.zyPayStatus == '1') params.orderStatus = 7 if (params?.zyPayStatus == '1') params.orderStatus = 7
// if (staffUuid) { // if (staffUuid) {
// params.transferIds = [staffUuid] // params.transferIds = [staffUuid]
......
...@@ -46,7 +46,7 @@ const FORM_LIST = [ ...@@ -46,7 +46,7 @@ const FORM_LIST = [
radioList: [ radioList: [
{ {
value: '0', value: '0',
name: '存储门店引流-售前' name: '门店引流-售前'
}, },
{ {
value: '1', value: '1',
...@@ -272,7 +272,7 @@ const DEFEAT_FORM_LIST = [ ...@@ -272,7 +272,7 @@ const DEFEAT_FORM_LIST = [
radioList: [ radioList: [
{ {
value: '0', value: '0',
name: '存储门店引流-售前' name: '门店引流-售前'
}, },
{ {
value: '1', value: '1',
...@@ -462,7 +462,7 @@ const UpdateOrderInfo = [ ...@@ -462,7 +462,7 @@ const UpdateOrderInfo = [
radioList: [ radioList: [
{ {
value: '0', value: '0',
name: '存储门店引流-售前' name: '门店引流-售前'
}, },
{ {
value: '1', value: '1',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!