Commit ca7ad30a by Lin

feat(components): 添加接待中心新组件和功能

- 新增 CarBrandSelect、CardFlow、CardMonthValue、CardOutputValue 组件,增强接待中心的功能和用户体验
- 实现 findAllSence 和 findSenceTag API 调用,支持场景和标签的获取
- 移除不再使用的 CustomPopup 组件,优化代码结构
- 更新 ReceptionCenter 组件,整合新组件并调整布局
- 增强客户标签选择功能,支持多层级标签展示
1 parent 7d9aa08c
......@@ -43,7 +43,22 @@ export async function getCustomerFileList(params: UTSJSONObject): Promise<any> {
}
return await http.fetch("dj.api.smartcarlife.customervisits.customerInfoPage", data, true, "dj")
}
export async function findAllSence(params: UTSJSONObject): Promise<any> {
const data: UTSJSONObject = {
projectName: 'boutique',
...params
}
return await http.fetch("dj.api.smartcarlife.customervisits.findAllSence", data, true, "dj")
}
export async function findSenceTag(params: UTSJSONObject): Promise<any> {
const data: UTSJSONObject = {
projectName: 'boutique',
...params
}
return await http.fetch("dj.api.smartcarlife.customervisits.findSenceTag", data, true, "dj")
}
/**ҵ������ */
// getMerchantPerformance(data){
// return http.post({
......
<template>
<view
v-if="showMask"
class="custom-popup-mask"
:class="{ 'mask-visible': isAnimated }"
@click="handleMaskClick"
>
<view
class="custom-popup-content"
:class="[`popup-${positionClass}`, { 'content-visible': isAnimated }]"
@click.stop
>
<slot>
</slot>
</view>
</view>
</template>
<script setup lang="uts">
const props = defineProps({
visible: {
type: Boolean,
default: false
},
position: {
type: String,
default: "center"
},
maskClosable: {
type: Boolean,
default: true
},
duration: {
type: Number,
default: 300
}
})
const emit = defineEmits(['update:visible', 'close', 'mask-click', 'opened', 'closed'])
function close(): void {
emit('update:visible', false)
emit('close')
}
function open(): void {
emit('update:visible', true)
}
function handleMaskClick(): void {
emit('mask-click')
if (props.maskClosable) {
close()
}
}
const showMask = ref<boolean>(props.visible)
const isAnimated = ref<boolean>(false)
let closeTimer: any | null = null
let openTimer: any | null = null
const positionClass = computed<string>(() => {
const positionMap: UTSJSONObject = {
'top': 'top',
'center': 'center',
'bottom': 'bottom',
'left': 'left',
'right': 'right'
} as UTSJSONObject
const mappedValue = positionMap[props.position] as string | null
if (mappedValue == null) {
return 'center'
}
return mappedValue
})
watch(props.visible, (newVal: boolean) => {
if (newVal == true) {
// 打开流程
if (closeTimer != null) {
clearTimeout(closeTimer as number)
closeTimer = null
}
if (openTimer != null) {
clearTimeout(openTimer as number)
openTimer= null
}
showMask.value = true
isAnimated.value = false
// 等待 DOM 渲染后添加动画类
openTimer = setTimeout(() => {
isAnimated.value = true
}, 50)
// 动画完成后触发事件
setTimeout(() => {
emit('opened')
}, props.duration + 50)
} else {
// 关闭流程
if (openTimer != null) {
clearTimeout(openTimer as number)
openTimer = null
}
isAnimated.value = false
closeTimer= setTimeout(() => {
showMask.value = false
emit('closed')
}, props.duration)
}
}, { immediate: true })
defineExpose({ open, close })
</script>
<style scoped lang="scss">
.custom-popup-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.3);
z-index: 1000;
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.3s ease;
&.mask-visible {
opacity: 1;
}
}
.custom-popup-content {
position: absolute;
max-height: 90%;
opacity: 0;
transform: scale(0.95);
transition: opacity 0.3s ease, transform 0.3s ease;
&.content-visible {
opacity: 1;
transform: scale(1);
}
&.popup-top {
top: 0;
left: 50%;
transform: translateY(-100%) translateX(-50%);
width: 100%;
border-bottom-left-radius: 20rpx;
border-bottom-right-radius: 20rpx;
&.content-visible {
transform: translateY(0) translateX(-50%);
}
}
&.popup-center {
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0.95);
min-width: 600rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.15);
&.content-visible {
transform: translate(-50%, -50%) scale(1);
}
}
&.popup-bottom {
bottom: 0;
left: 50%;
transform: translateY(100%) translateX(-50%);
width: 100%;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
&.content-visible {
transform: translateY(0) translateX(-50%);
}
}
&.popup-left {
top: 50%;
left: 0;
transform: translateX(-100%) translateY(-50%);
height: 100%;
max-width: 80%;
border-top-right-radius: 20rpx;
border-bottom-right-radius: 20rpx;
&.content-visible {
transform: translateX(0) translateY(-50%);
}
}
&.popup-right {
top: 50%;
right: 0;
transform: translateX(100%) translateY(-50%);
height: 100%;
max-width: 80%;
border-top-left-radius: 20rpx;
border-bottom-left-radius: 20rpx;
&.content-visible {
transform: translateX(0) translateY(-50%);
}
}
}
</style>
\ No newline at end of file
<template>
<view class="glass-card funnel-card">
<view class="title-box">
<text class="title-text">门店客流情况</text>
</view>
<view class="funnel-container">
<text class="funnel-title">门店客流情况</text>
<view class="funnel-chart-box">
<view class="funnel-box">
<view class="funnel-bg-layer"></view>
<view class="funnel-content">
<text class="funnel-text-sm">累计交付数</text>
<text class="funnel-text-lg">{{ funnelCountDisplay1 }}</text>
<view class="funnel-divider"></view>
<text class="funnel-text-sm">实际触客数</text>
<text class="funnel-text-lg">{{ funnelCountDisplay2 }}</text>
</view>
</view>
<view class="funnel-bracket"></view>
<view class="funnel-side">
<text class="side-text-sm">实际触客率</text>
<text class="side-text-lg">{{ contactRateMasked }}%</text>
</view>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { computed } from 'vue'
/** 业绩看板聚合数据,与 center 中 performanceData 同源 */
const props = withDefaults(
defineProps<{
performanceData?: UTSJSONObject | null
/** 为 false 时隐藏客流数值 */
metricsVisible?: boolean
}>(),
{
performanceData: null,
metricsVisible: true
}
)
const performanceRef = computed((): UTSJSONObject => {
const pd = props.performanceData
return pd != null ? pd : ({} as UTSJSONObject)
})
function getNum(data: UTSJSONObject, key: string): number {
const v = data[key]
if (v == null) {
return 0
}
if (typeof v == 'number') {
return v
}
const n = parseFloat(`${v}`)
return isNaN(n) ? 0 : n
}
const cumulativeDeliveryCount = computed(() => getNum(performanceRef.value, 'cumulativeDeliveryCount'))
const actualContactCount = computed(() => getNum(performanceRef.value, 'actualContactCount'))
const funnelCountDisplay1 = computed((): string => {
if (props.metricsVisible == false) {
return '****'
}
return `${cumulativeDeliveryCount.value}`
})
const funnelCountDisplay2 = computed((): string => {
if (props.metricsVisible == false) {
return '****'
}
return `${actualContactCount.value}`
})
/** 触客率展示:接口可能返回 0.8(小数)或 80(百分比) */
const contactRateDisplay = computed(() => {
const v = getNum(performanceRef.value, 'contactRate')
if (v > 0 && v < 1) {
return (v * 100).toFixed(1)
}
return v.toFixed(1)
})
const contactRateMasked = computed((): string => {
if (props.metricsVisible == false) {
return '**'
}
return contactRateDisplay.value
})
</script>
<style scoped lang="scss">
.glass-card {
background-color: rgba(255, 255, 255, 0.7);
border: 1px solid rgba(255, 255, 255, 0.4);
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
border-radius: 32px;
flex-direction: column;
}
.funnel-card {
padding: 24px;
margin-bottom: 10px;
}
.title-box {
flex-direction: row;
align-items: center;
justify-content: flex-start;
}
.title-text {
color: #333333;
font-size: 14px;
font-weight: 500;
}
.funnel-container {
background-color: rgba(255, 255, 255, 0.4);
border-radius: 16px;
padding: 16px;
padding-right: 90px;
margin-top: 32px;
flex-direction: column;
align-items: center;
border: 1px solid rgba(255, 255, 255, 0.6);
overflow: visible;
}
.funnel-title {
font-size: 12px;
font-weight: bold;
color: #475569;
margin-bottom: 24px;
}
.funnel-chart-box {
width: 192px;
height: 128px;
flex-direction: row;
position: relative;
align-items: center;
justify-content: center;
overflow: visible;
}
.funnel-box {
width: 100%;
height: 100%;
position: relative;
border-radius: 8px;
flex-direction: column;
align-items: center;
justify-content: center;
overflow: hidden;
}
.funnel-bg-layer {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: #3b82f6;
background-image: linear-gradient(to bottom, #3b82f6, #60a5fa);
border-radius: 8px;
}
.funnel-content {
position: relative;
flex-direction: column;
align-items: center;
justify-content: center;
}
.funnel-text-sm {
font-size: 10px;
color: rgba(255, 255, 255, 0.8);
}
.funnel-text-lg {
font-size: 18px;
font-weight: bold;
color: #ffffff;
}
.funnel-divider {
width: 126px;
height: 1px;
background-color: rgba(255, 255, 255, 0.3);
margin-top: 8px;
margin-bottom: 8px;
}
.funnel-bracket {
position: absolute;
right: -40px;
top: 50%;
margin-top: -20px;
width: 32px;
height: 40px;
border-left-width: 2px;
border-left-style: solid;
border-left-color: #60a5fa;
border-bottom-width: 2px;
border-bottom-style: solid;
border-bottom-color: #60a5fa;
}
.funnel-side {
position: absolute;
right: -75px;
top: 50%;
margin-top: -20px;
flex-direction: column;
}
.side-text-sm {
font-size: 10px;
color: #2563eb;
}
.side-text-lg {
font-size: 14px;
font-weight: bold;
color: #2563eb;
}
</style>
<template>
<view class="glass-card output-value-card">
<view class="title-box">
<text class="title-text">本月产值</text>
</view>
<view class="output-summary">
<view class="summary-left">
<text class="summary-label">{{ summary.summaryLabel }}</text>
<view class="summary-value-box">
<text class="summary-value-num">{{ summaryNumDisplay }}</text>
<text class="summary-value-unit">{{ summaryUnitDisplay }}</text>
</view>
<view class="summary-personal">
<text class="personal-label">{{ summary.personalLabel }}</text>
<text class="personal-value">{{ personalValueDisplay }}</text>
</view>
</view>
<view class="summary-right">
<view class="ring-chart-wrap">
<view class="ring-bg"></view>
<view class="ring-progress-wrap">
<view class="ring-half ring-half-left">
<view class="ring-half-inner" :style="ringLeftStyle"></view>
</view>
<view class="ring-half ring-half-right">
<view class="ring-half-inner" :style="ringRightStyle"></view>
</view>
</view>
<view class="ring-center">
<text class="ring-percent">{{ ringPercentDisplay }}</text>
<text class="ring-label">{{ summary.ringLabel }}</text>
</view>
</view>
</view>
</view>
<view class="target-count-box">
<view class="left-count-box">
<text class="left-count-text">目标</text>
<text class="left-count-value">{{ targetValueDisplay }}</text>
</view>
<view class="target-count-divider"></view>
<view class="right-count-box">
<text class="right-count-text">达成比例</text>
<text class="right-count-value">{{ achievementValueDisplay }}</text>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { computed } from 'vue'
import type { OutputSummary } from './reception-output-types.uts'
const props = withDefaults(
defineProps<{
summary: OutputSummary
targetValueText: string
achievementValueText: string
/** 为 false 时隐藏产值与达成相关数值 */
metricsVisible?: boolean
}>(),
{
targetValueText: '122万',
achievementValueText: '20%',
metricsVisible: true
}
)
/** 环形图用百分比:隐藏时不展示进度弧 */
const ringPercentNumForChart = computed((): number => {
if (props.metricsVisible == false) {
return 0
}
return props.summary.ringPercentNum
})
const summaryNumDisplay = computed((): string => {
if (props.metricsVisible == false) {
return '****'
}
return props.summary.summaryValueNum
})
const summaryUnitDisplay = computed((): string => {
if (props.metricsVisible == false) {
return ''
}
return props.summary.summaryValueUnit
})
const personalValueDisplay = computed((): string => {
if (props.metricsVisible == false) {
return '****'
}
return props.summary.personalValue
})
const ringPercentDisplay = computed((): string => {
if (props.metricsVisible == false) {
return '**'
}
return props.summary.ringPercent
})
const targetValueDisplay = computed((): string => {
if (props.metricsVisible == false) {
return '****'
}
return props.targetValueText
})
const achievementValueDisplay = computed((): string => {
if (props.metricsVisible == false) {
return '**'
}
return props.achievementValueText
})
// 左半圆旋转:0-50% 时旋转 P*360°,50-100% 时固定 180°
const ringLeftStyle = computed(() => {
const p = ringPercentNumForChart.value
const p01 = p > 100 ? 1 : (p < 0 ? 0 : p / 100)
const deg = p01 <= 0.5 ? p01 * 360 : 180
return { transform: `rotate(${deg}deg)` }
})
// 右半圆旋转:>50% 时旋转 (P-0.5)*360°,形成连续弧
const ringRightStyle = computed(() => {
const p = ringPercentNumForChart.value
const p01 = p > 100 ? 1 : (p < 0 ? 0 : p / 100)
const deg = p01 > 0.5 ? (p01 - 0.5) * 360 : 0
return { transform: `rotate(${deg}deg)` }
})
</script>
<style scoped lang="scss">
.glass-card {
background-color: rgba(255, 255, 255, 0.7);
border: 1px solid rgba(255, 255, 255, 0.4);
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
border-radius: 32px;
flex-direction: column;
}
.output-value-card {
padding: 24px;
}
.title-box {
flex-direction: row;
align-items: center;
justify-content: flex-start;
}
.title-text {
color: #333333;
font-size: 14px;
font-weight: 500;
}
.output-summary {
flex-direction: row;
align-items: center;
justify-content: space-between;
margin-top: 40px;
}
.summary-left {
flex-direction: column;
}
.summary-label {
font-size: 12px;
color: #94a3b8;
margin-bottom: 4px;
}
.summary-value-box {
flex-direction: row;
align-items: flex-end;
}
.summary-value-num {
font-size: 24px;
font-weight: bold;
color: #2563eb;
}
.summary-value-unit {
font-size: 14px;
color: #2563eb;
}
.summary-personal {
flex-direction: row;
margin-top: 4px;
}
.personal-label {
font-size: 10px;
color: #94a3b8;
}
.personal-value {
font-size: 10px;
color: #3b82f6;
}
.summary-right {
position: relative;
flex-direction: column;
align-items: center;
}
.ring-chart-wrap {
position: relative;
width: 96px;
height: 96px;
}
.ring-bg {
position: absolute;
left: 0;
top: 0;
width: 96px;
height: 96px;
border-radius: 48px;
border-width: 8px;
border-style: solid;
border-color: #e2e8f0;
box-sizing: border-box;
}
.ring-progress-wrap {
position: absolute;
left: 0;
top: 0;
width: 96px;
height: 96px;
}
.ring-half {
position: absolute;
top: 0;
width: 48px;
height: 96px;
overflow: hidden;
}
.ring-half-left {
left: 0;
}
.ring-half-right {
left: 48px;
}
.ring-half-inner {
position: absolute;
width: 96px;
height: 96px;
border-radius: 48px;
border-width: 8px;
border-style: solid;
border-color: #3b82f6;
box-sizing: border-box;
transform-origin: 48px 48px;
}
.ring-half-left .ring-half-inner {
left: 0;
top: 0;
}
.ring-half-right .ring-half-inner {
left: -48px;
top: 0;
}
.ring-center {
position: absolute;
left: 0;
top: 0;
width: 96px;
height: 96px;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 2;
}
.ring-percent {
font-size: 12px;
font-weight: bold;
color: #1e293b;
}
.ring-label {
font-size: 8px;
color: #94a3b8;
}
.target-count-box {
flex-direction: row;
align-items: center;
width: 100%;
height: 29px;
border-radius: 225px;
opacity: 1;
background-color: #4673ff0d;
margin-top: 10px;
}
.left-count-text,
.right-count-text {
color: #333333;
}
.left-count-value,
.right-count-value {
color: #4673ff;
margin-left: 4px;
}
.left-count-text,
.left-count-value,
.right-count-text,
.right-count-value {
font-size: 12px;
font-weight: 700;
}
.left-count-box,
.right-count-box {
flex: 1;
flex-direction: row;
align-items: center;
justify-content: center;
min-width: 0;
height: 100%;
}
.target-count-divider {
width: 1px;
height: 14px;
flex-shrink: 0;
background-color: rgba(70, 115, 255, 0.2);
}
</style>
<template>
<view class="glass-card output-value-card">
<view class="tabs-box">
<un-segmented
shape="circle"
type="card"
:model-value="tabIndex"
@update:model-value="onSegmentedTabIndex"
>
<un-segmented-item text="本月交付转化率"></un-segmented-item>
<un-segmented-item text="本月交付客单价"></un-segmented-item>
</un-segmented>
</view>
<view class="compare-section">
<view
v-for="(row, idx) in compareRows"
:key="idx"
class="compare-row"
:class="{ 'compare-row-last': idx == compareRows.length - 1 }"
>
<text class="compare-label">{{ row.label }}</text>
<view class="compare-bar-bg">
<view
class="compare-bar-fill"
:class="row.barClass"
:style="{ width: row.barWidthPercent }"
></view>
</view>
<text class="compare-value">{{ metricsVisible ? row.value : '****' }}</text>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import type { CompareRow } from './reception-output-types.uts'
const props = withDefaults(
defineProps<{
/** 0=本月交付转化率,1=本月交付客单价 */
tabIndex: number
compareRows: CompareRow[]
/** 为 false 时隐藏对比数值 */
metricsVisible?: boolean
}>(),
{
tabIndex: 0,
compareRows: (): CompareRow[] => [],
metricsVisible: true
}
)
const emit = defineEmits<{
'update:tabIndex': [value: number]
}>()
/** UTS 下勿用 computed({ get, set }) 做 v-model 桥接,运行时会 ClassCastException */
const onSegmentedTabIndex = (v: number): void => {
emit('update:tabIndex', v)
}
</script>
<style scoped lang="scss">
.glass-card {
background-color: rgba(255, 255, 255, 0.7);
border: 1px solid rgba(255, 255, 255, 0.4);
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
border-radius: 32px;
flex-direction: column;
}
.output-value-card {
padding: 24px;
}
.tabs-box {
flex-direction: row;
justify-content: space-between;
margin-bottom: 32px;
}
.compare-section {
flex-direction: column;
}
.compare-row {
flex-direction: row;
align-items: center;
margin-bottom: 24px;
}
.compare-row-last {
margin-bottom: 0;
}
.compare-label {
font-size: 12px;
color: #64748b;
width: 75px;
}
.compare-bar-bg {
flex: 1;
height: 8px;
background-color: #f1f5f9;
border-radius: 999px;
margin-right: 16px;
overflow: hidden;
flex-direction: row;
}
.compare-bar-fill {
height: 100%;
border-radius: 999px;
}
.bg-blue-500 {
background-color: #3b82f6;
}
.bg-blue-400 {
background-color: #60a5fa;
}
.compare-value {
font-size: 12px;
font-weight: bold;
color: #1e293b;
width: 48px;
text-align: right;
}
</style>
......@@ -41,7 +41,7 @@
</view>
<view class="form-row">
<text class="form-label">接待场景</text>
<view class="form-input-wrap form-select-field" @click="receptionScenarioPickerShow = true">
<view class="form-input-wrap form-select-field" @click="sceneSelectShow = true">
<text class="form-select-text" :class="{ 'placeholder': formData.receptionScenario === '' }">
{{ formData.receptionScenario !== '' ? formData.receptionScenario : '请选择接待场景' }}
</text>
......@@ -59,8 +59,11 @@
</view>
<view class="form-row">
<text class="form-label">客户标签</text>
<view class="form-input-wrap">
<un-input v-model="formData.customerTags" border="none" placeholder="请输入客户标签"></un-input>
<view class="form-input-wrap form-select-field" @click="customerTagsSelectShow = true">
<text class="form-select-text" :class="{ 'placeholder': formData.customerTags === '' }">
{{ formData.customerTags !== '' ? formData.customerTags : '请选择客户标签' }}
</text>
<un-icon name="arrow-right" color="#2979ff" size="12"></un-icon>
</view>
</view>
</view>
......@@ -74,23 +77,27 @@
</view>
</view>
</view>
<!-- 品牌车型级联选择器 -->
<un-cascader-picker
:show="brandCascaderShow"
title="选择品牌车型"
:options="brandCascaderOptions"
:modelValue="brandCascaderValue"
@confirm="onBrandCascaderConfirm"
@cancel="brandCascaderShow = false"
@close="brandCascaderShow = false"
<!-- 品牌车型:CarBrandSelect 显隐由 brandCascaderShow 与 watch 同步 open/close -->
<CarBrandSelect
ref="carBrandSelectRef"
:echo-data="carBrandEchoData"
echo-child-brand-key="carBrand"
@confirm="onCarBrandConfirm"
@close="onCarBrandClose"
/>
<SenceSelect
ref="sceneSelectRef"
:echo-data="sceneEchoData"
echo-key="receptionScenario"
@confirm="onSceneConfirm"
@close="onSceneClose"
/>
<!-- 接待场景选择器 -->
<un-picker
:show="receptionScenarioPickerShow"
:columns="receptionScenarioColumns"
@confirm="onReceptionScenarioConfirm"
@cancel="receptionScenarioPickerShow = false"
@close="receptionScenarioPickerShow = false"
<CustomerTags
ref="customerTagsSelectRef"
:echo-data="customerTagsEchoData"
echo-key="customerTags"
@confirm="onCustomerTagsConfirm"
@close="onCustomerTagsClose"
/>
<!-- 到店日期选择器 -->
<un-datetime-picker
......@@ -107,9 +114,11 @@
</template>
<script setup lang="uts">
import { ref, onMounted } from 'vue'
import type { UnCascaderConfirmEvent, UnCascaderOption, UnPickerColumn, UnPickerColumnItem, UnPickerConfirmEvent } from '@/uni_modules/uview-unix'
import { saveRecCustomer } from '@/api/receiption.uts'
import { ref, onMounted, watch, nextTick, computed } from 'vue'
import { ComponentPublicInstance } from 'vue'
import CarBrandSelect from './CarBrandSelect.uvue'
import SenceSelect from './SenceSelect.uvue'
import CustomerTags from './CustomerTags.uvue'
// 使用窗口实际尺寸,避免 100% 导致溢出
type PopupSize = { w: string; h: string }
......@@ -179,78 +188,142 @@ function onDatePickerConfirm(): void {
datePickerShow.value = false
}
// 品牌车型级联选择器
// 品牌车型选择器:true 时打开 CarBrandSelect,false 时关闭(占位文案仍由 formData.brandModel 是否为空决定)
const brandCascaderShow = ref(false)
const brandCascaderValue = ref<Array<string | number>>([])
// 汽车品牌车型模拟数据(级联:品牌 -> 车型)
const brandCascaderOptions: UnCascaderOption[] = [
// {
// text: 'AITO 问界',
// value: 'aito',
// children: [
// { text: '问界 M9', value: 'aito-m9' },
// { text: '问界 M8', value: 'aito-m8' },
// { text: '问界 M7', value: 'aito-m7' },
// { text: '问界 M5', value: 'aito-m5' },
// { text: '问界 S9', value: 'aito-s9' }
// ]
// },
// {
// text: '比亚迪',
// value: 'byd',
// children: [
// { text: '汉', value: 'byd-han' },
// { text: '唐', value: 'byd-tang' },
// { text: '宋', value: 'byd-song' },
// { text: '秦', value: 'byd-qin' },
// { text: '海豹', value: 'byd-haibao' },
// { text: '海豚', value: 'byd-haitun' }
// ]
// },
// {
// text: '一汽-大众奥迪',
// value: 'audi',
// children: [
// { text: '奥迪 A7L', value: 'audi-a7l' },
// { text: '奥迪 Q5 e-tron', value: 'audi-q5-etron' },
// { text: '奥迪 Q6', value: 'audi-q6' },
// { text: '奥迪 A5L Sportback', value: 'audi-a5l' }
// ]
// }
]
// 接待场景选择器
const receptionScenarioPickerShow = ref(false)
const receptionScenarioColumns: UnPickerColumn[] = [
[
{ text: '新车交付', value: '新车交付' } as UnPickerColumnItem,
{ text: '售后场景', value: '售后场景' } as UnPickerColumnItem,
{ text: '二次转化', value: '二次转化' } as UnPickerColumnItem
] as UnPickerColumn
]
function onReceptionScenarioConfirm(e: UnPickerConfirmEvent): void {
receptionScenarioPickerShow.value = false
const items = e.value
if (items != null && items.length > 0) {
const first = items[0] as UnPickerColumnItem
formData.value.receptionScenario = first.text != null ? first.text : ''
const carBrandSelectRef = ref<ComponentPublicInstance | null>(null)
/** 与 CarBrandSelect 的 emit 字段一致(UTSJSONObject),供再次打开时高亮已选子品牌/车型;不可 as 强转为自定义 type(Android 会 ClassCastException) */
const carBrandSelectionEcho = ref<UTSJSONObject | null>(null)
const carBrandEchoData = computed((): UTSJSONObject => {
const p = carBrandSelectionEcho.value
if (p == null) {
return {} as UTSJSONObject
}
return p
})
watch(brandCascaderShow, (show: boolean) => {
// 双 nextTick:CarBrandSelect 在 un-popup 内,确保弹层渲染后再取 ref 调用 open
nextTick(() => {
nextTick(() => {
const r = carBrandSelectRef.value
const inst = r != null ? (r as ComponentPublicInstance) : null
if (inst == null) {
return
}
if (show) {
inst.$callMethod('open')
} else {
inst.$callMethod('close')
}
})
})
})
// 接待场景:与 CarBrandSelect 相同,通过 ref + watch 打开底部标签弹框
const sceneSelectShow = ref(false)
const sceneSelectRef = ref<ComponentPublicInstance | null>(null)
const sceneEchoData = computed((): UTSJSONObject => {
const o = {} as UTSJSONObject
o['receptionScenario'] = formData.value.receptionScenario
return o
})
watch(sceneSelectShow, (show: boolean) => {
nextTick(() => {
nextTick(() => {
const r = sceneSelectRef.value
const inst = r != null ? (r as ComponentPublicInstance) : null
if (inst == null) {
return
}
if (show) {
inst.$callMethod('open')
} else {
inst.$callMethod('close')
}
})
})
})
function onSceneConfirm(payload: UTSJSONObject): void {
sceneSelectShow.value = false
const label = payload['receptionScenario']
formData.value.receptionScenario = label != null ? `${label}` : ''
}
function onSceneClose(): void {
sceneSelectShow.value = false
}
const customerTagsSelectShow = ref(false)
const customerTagsSelectRef = ref<ComponentPublicInstance | null>(null)
const customerTagsEchoData = computed((): UTSJSONObject => {
const o = {} as UTSJSONObject
o['customerTags'] = formData.value.customerTags
return o
})
watch(customerTagsSelectShow, (show: boolean) => {
nextTick(() => {
nextTick(() => {
const r = customerTagsSelectRef.value
const inst = r != null ? (r as ComponentPublicInstance) : null
if (inst == null) {
return
}
if (show) {
inst.$callMethod('open')
} else {
inst.$callMethod('close')
}
})
})
})
function onCustomerTagsConfirm(payload: UTSJSONObject): void {
customerTagsSelectShow.value = false
const label = payload['customerTags']
formData.value.customerTags = label != null ? `${label}` : ''
}
function onBrandCascaderConfirm(e: UnCascaderConfirmEvent): void {
function onCustomerTagsClose(): void {
customerTagsSelectShow.value = false
}
function onCarBrandConfirm(payload: UTSJSONObject): void {
brandCascaderShow.value = false
const textArr = e.text
if (textArr != null && textArr.length > 0) {
formData.value.brandModel = textArr.join(' ')
const parts: string[] = []
const one = payload['oneCarBrand']
const child = payload['carBrand']
const model = payload['carModel']
if (one != null && `${one}` != '') {
parts.push(`${one}`)
}
if (child != null && `${child}` != '') {
parts.push(`${child}`)
}
if (model != null && `${model}` != '') {
parts.push(`${model}`)
}
formData.value.brandModel = parts.join(' ')
carBrandSelectionEcho.value = payload
}
function onCarBrandClose(): void {
brandCascaderShow.value = false
}
function resetForm(): void {
formData.value = getEmptyForm()
brandCascaderValue.value = []
brandCascaderShow.value = false
sceneSelectShow.value = false
customerTagsSelectShow.value = false
visitDateValue.value = ''
carBrandSelectionEcho.value = null
}
function handleClose(): void {
......
<template>
<view class="scene-select-root">
<MessageBox
ref="sheetRef"
position="bottom"
:isFooter="false"
title="选择接待场景"
@close="onSheetClose"
>
<scroll-view class="tag-scroll" scroll-y="true">
<view class="tag-box">
<template v-for="(item, index) in sceneList" :key="index">
<view
class="tag-item"
:class="{ checked: isRowChecked(item as UTSJSONObject) }"
@click="onTapRow(item as UTSJSONObject)"
>
<text class="tag-text">{{ (item as UTSJSONObject)['label'] }}</text>
</view>
</template>
</view>
</scroll-view>
</MessageBox>
</view>
</template>
<script setup lang="uts">
import MessageBox from '@/components/MessageBox.uvue'
import { findAllSence } from '@/api/receiption.uts'
import { ref, nextTick } from 'vue'
import { ComponentPublicInstance } from 'vue'
/** 接口失败或空列表时的兜底数据 */
function buildMockSceneList(): Array<UTSJSONObject> {
const out: Array<UTSJSONObject> = []
const o1 = {} as UTSJSONObject
o1['id'] = 'new_delivery'
o1['label'] = '新车交付'
out.push(o1)
const o2 = {} as UTSJSONObject
o2['id'] = 'after_sales'
o2['label'] = '售后场景'
out.push(o2)
const o3 = {} as UTSJSONObject
o3['id'] = 'second_conversion'
o3['label'] = '二次转化'
out.push(o3)
return out
}
/** 将接口项统一为 id / label,兼容常见字段名 */
function normalizeSceneRow(raw: UTSJSONObject): UTSJSONObject | null {
const idVal = raw['id'] != null ? raw['id'] : raw['sceneId']
const labelVal = raw['label'] != null ? raw['label'] : (raw['sceneName'] != null ? raw['sceneName'] : raw['name'])
if (labelVal == null) {
return null
}
const labelStr = `${labelVal}`
if (labelStr == '') {
return null
}
const out = {} as UTSJSONObject
out['id'] = idVal != null ? `${idVal}` : labelStr
out['label'] = labelStr
return out
}
/** 解析 findAllSence 返回:data 为数组,或 data.list 为数组 */
function parseSceneListFromResponse(res: any): Array<UTSJSONObject> {
const resObj = res as UTSJSONObject
const root = resObj['data']
let rawList: any[] | null = null
if (root != null && root instanceof Array) {
rawList = root as any[]
} else if (root != null) {
const dataObj = root as UTSJSONObject
const list = dataObj['list']
if (list != null && list instanceof Array) {
rawList = list as any[]
}
}
if (rawList == null) {
return []
}
const out: Array<UTSJSONObject> = []
let i = 0
while (i < rawList.length) {
const item = rawList[i] as UTSJSONObject
const row = normalizeSceneRow(item)
if (row != null) {
out.push(row)
}
i++
}
return out
}
const props = defineProps({
echoData: {
type: Object,
default: (): UTSJSONObject => ({} as UTSJSONObject)
},
echoKey: {
type: String,
default: 'receptionScenario'
},
/** 传给 findAllSence 的场景类型等业务参数 */
scene: {
type: Number,
default: 1
}
})
const emit = defineEmits(['close', 'confirm'])
const sheetRef = ref<ComponentPublicInstance | null>(null)
const sceneList = ref<Array<UTSJSONObject>>(buildMockSceneList())
async function loadSceneListFromApi(): Promise<void> {
try {
const params = { scene: 1 } as UTSJSONObject
const res = await findAllSence(params)
console.error('findAllSence 成功:', res)
const parsed = parseSceneListFromResponse(res)
if (parsed.length > 0) {
sceneList.value = parsed
return
}
} catch (e) {
console.error('findAllSence 失败:', e)
}
sceneList.value = buildMockSceneList()
}
function openSheet(): void {
const r = sheetRef.value
const inst = r != null ? (r as ComponentPublicInstance) : null
if (inst != null) {
inst.$callMethod('open')
}
}
function hideSheet(): void {
const r = sheetRef.value
const inst = r != null ? (r as ComponentPublicInstance) : null
if (inst != null) {
inst.$callMethod('hide')
}
}
function isRowChecked(row: UTSJSONObject): boolean {
const echo = props.echoData as UTSJSONObject
const key = props.echoKey
const v = echo[key]
const label = row['label']
if (v == null || label == null) {
return false
}
return `${v}` == `${label}`
}
function onTapRow(row: UTSJSONObject): void {
const label = row['label'] as string | null
const idVal = row['id']
if (label == null || label == '') {
return
}
const payload = {} as UTSJSONObject
payload['receptionScenario'] = label
payload['sceneId'] = idVal as string
hideSheet()
emit('confirm', payload)
}
function onSheetClose(): void {
emit('close')
}
async function open(): Promise<void> {
await loadSceneListFromApi()
nextTick(() => {
nextTick(() => {
openSheet()
})
})
}
function close(): void {
hideSheet()
}
defineExpose({
open,
close
})
</script>
<style scoped lang="scss">
.scene-select-root {
flex-direction: column;
}
.tag-scroll {
max-height: 400px;
margin-top: 8px;
margin-bottom: 16px;
}
.tag-box {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.tag-item {
padding-left: 16px;
padding-right: 16px;
padding-top: 8px;
padding-bottom: 8px;
margin-right: 12px;
margin-bottom: 12px;
border-width: 1px;
border-style: solid;
border-color: #dce0e6;
border-radius: 16px;
background-color: #ffffff;
flex-direction: row;
align-items: center;
justify-content: center;
}
.tag-item.checked {
border-color: #292d33;
background-color: #f5f6f7;
}
.tag-text {
font-size: 15px;
color: #333333;
text-align: center;
font-weight: 400;
}
</style>
/**
* 接待中心品牌/车型选择:纯 UTS 构造的模拟数据(避免 JSON.parse 在部分端上异常导致「获取品牌失败」)。
* CarBrandSelect 中 USE_MOCK_CAR_BRAND_LIST 为 true 时使用;改回 false 则走真实接口与登录校验。
*/
/** 与 flattenMerchantBrands 摊平后每行结构一致:子品牌行 + brandId、brandName */
export function getMockFlatCarBrandRows(): Array<any> {
const out: Array<any> = []
function pushRow(
brandId: number,
brandName: string,
childId: number,
childName: string
): void {
const row = {} as UTSJSONObject
row['id'] = childId
row['name'] = childName
row['brandId'] = brandId
row['brandName'] = brandName
out.push(row)
}
pushRow(2149, 'ARCFOX极狐', 2150, '北汽新能源')
pushRow(2978, '鸿蒙智行', 3454, 'AITO 问界')
pushRow(2978, '鸿蒙智行', 3458, 'LUXEED 智界')
pushRow(2978, '鸿蒙智行', 3502, 'MAEXTRO 尊界')
pushRow(2978, '鸿蒙智行', 3503, 'STELATO 享界')
pushRow(2978, '鸿蒙智行', 3574, 'SAIC 尚界')
return out
}
/** 第二步车型列表(替代 getCarBrandsListApi) */
export function getMockCarModelsList(): Array<any> {
const out: Array<any> = []
const m1 = {} as UTSJSONObject
m1['id'] = 90001
m1['name'] = '模拟车型 · 尊享版'
out.push(m1)
const m2 = {} as UTSJSONObject
m2['id'] = 90002
m2['name'] = '模拟车型 · 智驾版'
out.push(m2)
return out
}
/** 产值对比行:须在单文件定义,避免父子组件各写一份导致 Android ClassCastException */
export type CompareRow = {
label: string
barWidthPercent: string
barClass: string
value: string
}
/** 本月产值汇总区:与产值 Tab 共用,由父组件从业绩数据组装后传入 */
export type OutputSummary = {
summaryLabel: string
summaryValueNum: string
summaryValueUnit: string
personalLabel: string
personalValue: string
ringPercent: string
ringLabel: string
ringPercentNum: number
ringComparePercent: number
}
/** 品牌车型选择结果(与 CarBrands / 客户信息字段对齐) */
export type CarBrandSelectPayload = {
carBrand: string
carBrandId: number | string
oneCarBrand: string
oneCarBrandId: number | string
carModel: string
carModelId: number | string
}
/**
* getMerchantCarBrandList 返回的 res.data 为门店对象数组,每项含 carBrandList。
* 一级品牌:id、name、letter、logoUrl、childs(子品牌数组,元素 childs 可为 null)。
* 摊平到可选行后:在子项上挂载 brandId=一级 id、brandName=一级 name;
* 请求车型列表:getCarSeriesList 使用 brandId + childBrandId=子项 id。
*/
export type FlatCarBrandChildRow = {
id: number | string
name: string
brandId: number | string
brandName: string
}
......@@ -466,7 +466,6 @@ function onSend(): void {
.tabs-scroll {
width: 100%;
height: 48px;
white-space: nowrap;
}
.tabs-row {
......@@ -496,8 +495,9 @@ function onSend(): void {
.tab-text {
font-size: 14px;
font-weight: 500;
font-weight: 400;
color: #6B7280;
white-space: nowrap;
}
.tab-text-active {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!