Commit 29559c09 by Lin

feat(reception): 添加接待信息编辑页面及相关功能

- 新增接待信息编辑页面 FormReceptionListEdit,支持用户输入接待信息
- 更新接待中心列表,支持跳转到接待信息编辑页面
- 引入 buildPageUrlWithRecord 函数,优化页面跳转逻辑
- 修改接待记录数据结构,添加 orderFinishFlag 字段以支持接待结果的处理
1 parent 8321e0f5
...@@ -66,6 +66,13 @@ ...@@ -66,6 +66,13 @@
} }
}, },
{ {
"path": "pages/receptionCenter/FormReceptionListEdit",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "接待信息"
}
},
{
"path": "pages/receptionCenter/receptionDetail", "path": "pages/receptionCenter/receptionDetail",
"style": { "style": {
"navigationStyle": "custom", "navigationStyle": "custom",
......
<template>
<view class="form-add-root" :style="pageStyleVars">
<view class="reception-safe-top-spacer" :style="receptionSafeTopSpacerStyle"></view>
<un-navbar title="接待信息" @leftClick="handleClose" :titleStyle="formAddNavbarTitleStyle" />
<view class="reception-navbar-spacer"></view>
<view class="form-add-wrap">
<view class="form-add-body">
<un-form :model="formData" labelWidth="80" labelAlign="left" borderBottom>
<un-form-item prop="customerName" :customStyle="formAddFormItemCustomStyle">
<template #label>
<text class="form-add-label">车主姓名</text>
</template>
<un-input
v-model="formData['customerName']"
border="none"
inputAlign="right"
placeholder="请输入车主姓名"
:fontSize="formAddInputFontSize"
:placeholderStyle="formAddPlaceholderStyle"
:maxlength="50"
></un-input>
</un-form-item>
<un-form-item prop="phoneNumber" :customStyle="formAddFormItemCustomStyle">
<template #label>
<text class="form-add-label">车主电话</text>
</template>
<un-input
v-model="formData['phoneNumber']"
border="none"
type="tel"
inputAlign="right"
placeholder="请输入车主电话"
:fontSize="formAddInputFontSize"
:placeholderStyle="formAddPlaceholderStyle"
:maxlength="11"
></un-input>
</un-form-item>
<un-form-item prop="brandModel" :customStyle="formAddFormItemCustomStyle">
<template #label>
<text class="form-add-label">品牌车型</text>
</template>
<view class="form-add-link-cell" @click="brandCascaderShow = true">
<text
:class="[
'form-add-link-cell__value',
formData.brandModel !== '' ? 'form-add-link-cell__value--has' : 'form-add-link-cell__value--empty',
]"
>
{{ formData.brandModel !== '' ? formData.brandModel : '请选择品牌车型' }}
</text>
<un-icon name="arrow-right" color="#a1a1a1"></un-icon>
</view>
</un-form-item>
<un-form-item prop="receptionResult" :customStyle="formAddFormItemCustomStyle">
<template #label>
<text class="form-add-label">接待结果</text>
</template>
<view class="form-reception-result-wrap">
<radio-group class="reception-result-radio-group" @change="onReceptionResultRadioChange">
<view class="reception-result-radio-row">
<view class="reception-result-radio-item">
<radio value="0" :checked="receptionResultIndex === 0" color="#3b82f6" />
<text class="reception-result-radio-text">战败</text>
</view>
<view class="reception-result-radio-item reception-result-radio-item--spacing">
<radio value="1" :checked="receptionResultIndex === 1" color="#3b82f6" />
<text class="reception-result-radio-text">成交</text>
</view>
</view>
</radio-group>
</view>
</un-form-item>
<un-form-item prop="salesName" :customStyle="formAddFormItemCustomStyle">
<template #label>
<text class="form-add-label">销售姓名</text>
</template>
<view class="form-add-link-cell" @click="openEmployeeSelector">
<text
:class="[
'form-add-link-cell__value',
formData.salesName !== '' ? 'form-add-link-cell__value--has' : 'form-add-link-cell__value--empty',
]"
>
{{ formData.salesName !== '' ? formData.salesName : '请选择销售' }}
</text>
<un-icon name="arrow-right" color="#a1a1a1"></un-icon>
</view>
</un-form-item>
</un-form>
</view>
<view class="form-add-footer">
<view class="btn cancel-btn" @click="handleClose">
<text class="btn-text btn-text-cancel">取消</text>
</view>
<view class="btn submit-btn" @click="handleSubmit">
<text class="btn-text btn-text-submit">提交</text>
</view>
</view>
</view>
<CarBrands
ref="carBrandSelectRef"
@select="onCarBrandsSelect"
@close="onCarBrandClose"
/>
<Employee
ref="employeeBoxVisible"
:salesPropsUuid="formData.salesUuid"
@select="onEmployeeSelect"
/>
</view>
</template>
<script setup lang="uts">
import { ref, computed, onMounted, watch, nextTick, type Ref } from 'vue'
import { ComponentPublicInstance } from 'vue'
import CarBrands from '@/components/CarBrands.uvue'
import Employee from '@/components/Employee.uvue'
import { DBRecord } from '@/services/recorder/index.uts'
import { useScreenVars } from '@/services/adapter/hooks/index.uts'
import pageVars from './styles/index.vars.uts'
const phoneRex = /^1[3-9]\d{9}$/
const screenVarsHook = useScreenVars(pageVars as UTSJSONObject)
const pageStyleVars = computed((): Any => {
const sv = screenVarsHook.screenVars as Ref<UTSJSONObject>
return sv.value as Any
})
const formAddFormItemCustomStyle = {
height: 'var(--reception-form-add-item-height)',
paddingTop: 'var(--reception-form-add-item-padding-top)',
paddingBottom: 'var(--reception-form-add-item-padding-bottom)',
} as UTSJSONObject
const formAddNavbarTitleStyle = computed((): UTSJSONObject => {
return {
fontSize: 'var(--reception-form-add-navbar-title-font-size)',
} as UTSJSONObject
})
const formAddPlaceholderStyle = {
fontSize: 'var(--reception-form-add-placeholder-font-size)',
} as UTSJSONObject
const formAddInputFontSize = computed((): number => {
const v = (pageStyleVars.value as UTSJSONObject)['--reception-form-add-input-font-size'] as string | null
if (v == null || v == '') {
return 14
}
const n = parseInt(v.replace('px', ''), 10)
if (isNaN(n)) {
return 14
}
return n
})
type ReceptionEditForm = {
customerName: string
phoneNumber: string
/** 车型展示名(与 FormAdd.brandModel / 接口 name 一致) */
brandModel: string
carBrand: string
carBrandId: string
oneCarBrand: string
oneCarBrandId: string
carModelId: string
salesName: string
salesUuid: string
}
function getEmptyForm(): ReceptionEditForm {
return {
customerName: '',
phoneNumber: '',
brandModel: '',
carBrand: '',
carBrandId: '',
oneCarBrand: '',
oneCarBrandId: '',
carModelId: '',
salesName: '',
salesUuid: '',
}
}
const formData = ref<ReceptionEditForm>(getEmptyForm())
const brandCascaderShow = ref(false)
const carBrandSelectRef = ref<ComponentPublicInstance | null>(null)
const employeeBoxVisible = ref<ComponentPublicInstance | null>(null)
function toggleSelector(selectorRef: ComponentPublicInstance | null, show: boolean): void {
if (selectorRef == null) {
return
}
nextTick(() => {
nextTick(() => {
selectorRef.$callMethod(show ? 'open' : 'close')
})
})
}
watch(brandCascaderShow, (show: boolean) => {
toggleSelector(carBrandSelectRef.value, show)
})
/** 0=战败,1=成交,与列表 orderFinishFlag 一致 */
const receptionResultIndex = ref(0)
const recordId = ref('')
const submitLock = ref(false)
const receptionPageInsetTopPx = ref(0)
const receptionSafeTopSpacerStyle = computed((): UTSJSONObject => {
return {
height: `${receptionPageInsetTopPx.value}px`,
width: '100%',
} as UTSJSONObject
})
function syncReceptionSafeTopSpacer(): void {
const info = uni.getWindowInfo()
let topInset = 0
const insets = info.safeAreaInsets
if (insets?.top != null && insets.top > 0) {
topInset = Math.round(insets.top)
} else if (info.safeArea?.top != null && info.safeArea.top > 0) {
topInset = Math.round(info.safeArea.top)
} else if (info.statusBarHeight != null && info.statusBarHeight > 0) {
topInset = Math.round(info.statusBarHeight)
}
receptionPageInsetTopPx.value = topInset
}
function fieldStr(data: UTSJSONObject | null, key: string): string {
if (data == null || data[key] == null) {
return ''
}
return `${data[key]}`
}
function orderFinishToIndex(item: UTSJSONObject): number {
const v = item['orderFinishFlag']
if (v == null) {
return 0
}
if (typeof v === 'number') {
// 与 ListReception getOrderFinishFlagOutcome 一致:0 战败,非 0 成交(避免 UTS 对 >= 解析报错)
if (v == 0) {
return 0
}
return 1
}
if (typeof v === 'boolean') {
if (v == true) {
return 1
}
return 0
}
const s = `${v}`.trim().toLowerCase()
if (s == '1' || s == 'true') {
return 1
}
return 0
}
function applyFromItem(item: UTSJSONObject): void {
let idVal = fieldStr(item, 'batchId')
if (idVal == '') {
idVal = fieldStr(item, 'id')
}
recordId.value = idVal
const next = getEmptyForm()
next.customerName = fieldStr(item, 'customerName')
next.phoneNumber = fieldStr(item, 'phoneNumber')
next.brandModel = fieldStr(item, 'carModel')
if (next.brandModel === '') {
next.brandModel = fieldStr(item, 'carBrand')
}
next.carBrand = fieldStr(item, 'carBrand')
next.carBrandId = fieldStr(item, 'carBrandId')
next.oneCarBrand = fieldStr(item, 'oneCarBrand')
next.oneCarBrandId = fieldStr(item, 'oneCarBrandId')
next.carModelId = fieldStr(item, 'carModelId')
let salesVal = fieldStr(item, 'salesName')
if (salesVal == '') {
salesVal = fieldStr(item, 'staffName')
}
next.salesName = salesVal
next.salesUuid = fieldStr(item, 'salesUuid')
formData.value = next
receptionResultIndex.value = orderFinishToIndex(item)
}
function validateForm(): string | null {
const f = formData.value
if (f.customerName === '') {
return '请输入车主姓名'
}
if (f.phoneNumber === '') {
return '请输入车主电话'
}
if (!phoneRex.test(f.phoneNumber)) {
return '请输入正确的手机号码'
}
if (f.brandModel === '') {
return '请选择品牌车型'
}
if (f.salesName === '') {
return '请选择销售'
}
return null
}
function onCarBrandsSelect(payload: UTSJSONObject): void {
brandCascaderShow.value = false
const modelStr = fieldStr(payload, 'name')
const childName = fieldStr(payload, 'carChildsBrandName')
const childId = fieldStr(payload, 'carChildsBrandId')
const oneStr = fieldStr(payload, 'carBrand')
const oneId = fieldStr(payload, 'carBrandId')
const modelId = fieldStr(payload, 'id')
const f = formData.value
f.brandModel = modelStr
f.carBrand = childName
f.carBrandId = childId
f.oneCarBrand = oneStr
f.oneCarBrandId = oneId
f.carModelId = modelId
}
function onCarBrandClose(): void {
brandCascaderShow.value = false
}
function openEmployeeSelector(): void {
toggleSelector(employeeBoxVisible.value, true)
}
function onEmployeeSelect(payload: UTSJSONObject): void {
const itemObj = payload as UTSJSONObject
const f = formData.value
f.salesName = fieldStr(itemObj, 'staffName')
f.salesUuid = fieldStr(itemObj, 'uuid')
}
function handleClose(): void {
formData.value = getEmptyForm()
recordId.value = ''
brandCascaderShow.value = false
uni.navigateBack()
}
function onReceptionResultRadioChange(e: any): void {
const obj = e as UTSJSONObject
const detail = obj['detail'] as UTSJSONObject | null
const raw = detail != null ? detail['value'] : null
let idx = 0
if (typeof raw === 'number') {
if (raw > 0) {
idx = 1
} else {
idx = 0
}
} else {
const s = `${raw}`.trim()
if (s === '1') {
idx = 1
} else {
idx = 0
}
}
receptionResultIndex.value = idx
}
async function handleSubmit(): Promise<void> {
if (submitLock.value) {
return
}
const err = validateForm()
if (err != null) {
uni.showToast({ title: err, icon: 'none' })
return
}
const id = recordId.value
if (id === '') {
uni.showToast({ title: '缺少记录标识', icon: 'none' })
return
}
submitLock.value = true
uni.showLoading({ title: '提交中', mask: true })
try {
const db = DBRecord.getInstance()
await db.ensureColumns()
const f = formData.value
const setData = {
customerName: f.customerName,
phoneNumber: f.phoneNumber,
carModel: f.brandModel,
carBrand: f.carBrand,
carBrandId: f.carBrandId,
oneCarBrand: f.oneCarBrand,
oneCarBrandId: f.oneCarBrandId,
salesName: f.salesName,
salesUuid: f.salesUuid,
orderFinishFlag: receptionResultIndex.value,
} as UTSJSONObject
await db.updateRecord(setData, { id })
uni.showToast({ title: '提交成功', icon: 'success' })
uni.$emit('refresh-reception-list')
uni.navigateBack()
} catch (_e) {
uni.showToast({ title: '保存失败,请重试', icon: 'none' })
} finally {
uni.hideLoading()
submitLock.value = false
}
}
onMounted(() => {
syncReceptionSafeTopSpacer()
})
onLoad((options: UTSJSONObject) => {
const recordStr = options['record']
if (recordStr != null && typeof recordStr === 'string' && recordStr !== '') {
try {
const parsed = JSON.parse(recordStr)
if (parsed != null && typeof parsed === 'object') {
applyFromItem(parsed as UTSJSONObject)
}
} catch (e) {
console.error('FormReceptionListEdit: parse record failed', e)
}
}
})
</script>
<style lang="scss" scoped>
.form-add-root {
display: flex;
flex-direction: column;
width: 100%;
height: 100vh;
overflow: hidden;
box-sizing: border-box;
background-color: #ffffff;
}
.reception-safe-top-spacer {
width: 100%;
flex-shrink: 0;
}
.reception-navbar-spacer {
height: 44px;
flex-shrink: 0;
}
.form-add-wrap {
display: flex;
flex-direction: column;
flex: 1;
padding: 8px 24px 0;
padding-bottom: 24px;
box-sizing: border-box;
}
.form-add-body {
display: flex;
flex-direction: column;
width: 100%;
}
.form-reception-result-wrap {
display: flex;
flex: 1;
flex-direction: row;
align-items: center;
justify-content: flex-end;
min-width: 0;
}
.reception-result-radio-group {
flex: 1;
display: flex;
flex-direction: row;
justify-content: flex-end;
min-width: 0;
}
.reception-result-radio-row {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
}
.reception-result-radio-item {
display: flex;
flex-direction: row;
align-items: center;
}
.reception-result-radio-item--spacing {
margin-left: 28px;
}
.reception-result-radio-text {
margin-left: 6px;
font-size: var(--reception-form-add-input-font-size, 14px);
color: #1e293b;
}
.form-add-footer {
display: flex;
flex-direction: row;
margin: 24px;
padding-top: 16px;
flex-shrink: 0;
background-color: #ffffff;
padding-bottom: env(safe-area-inset-bottom);
position: fixed;
bottom: 0;
left: 0;
right: 0;
}
.btn {
flex: 1;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
height: 44px;
border-radius: 8px;
}
.cancel-btn {
background-color: #f1f5f9;
margin-right: 12px;
}
.submit-btn {
background-color: #3b82f6;
}
.btn-text {
font-size: var(--reception-form-add-btn-text-font-size, 16px);
font-weight: 700;
}
.cancel-btn .btn-text {
color: #64748b;
}
.submit-btn .btn-text {
color: #ffffff;
}
.form-add-label {
font-size: var(--reception-form-add-label-font-size, 14px);
}
.form-add-link-cell {
flex: 1;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
box-sizing: border-box;
}
.form-add-link-cell__value {
flex: 1;
font-size: var(--reception-form-add-cell-value-font-size, 14px);
text-align: right;
margin-right: 6px;
}
.form-add-link-cell__value--has {
color: #1e293b;
}
.form-add-link-cell__value--empty {
color: rgb(151, 150, 150);
}
</style>
...@@ -175,7 +175,7 @@ import ReceptionDetail from "./receptionDetail.uvue"; ...@@ -175,7 +175,7 @@ import ReceptionDetail from "./receptionDetail.uvue";
import pageVars from "./styles/index.vars"; import pageVars from "./styles/index.vars";
import ReceptionCustomerListTab from "./tabs/ReceptionCustomerListTab.uvue"; import ReceptionCustomerListTab from "./tabs/ReceptionCustomerListTab.uvue";
import ReceptionDashboardTab from "./tabs/ReceptionDashboardTab.uvue"; import ReceptionDashboardTab from "./tabs/ReceptionDashboardTab.uvue";
import { getCurrentMonthRange, getMockPerformanceData, getNum, getStr, getTodayDayRangeStrings, mergeByKey, resolveHasMore } from "./types/reception-center-helpers.uts"; import { buildPageUrlWithRecord, getCurrentMonthRange, getMockPerformanceData, getNum, getStr, getTodayDayRangeStrings, mergeByKey, resolveHasMore } from "./types/reception-center-helpers.uts";
import type { CompareRow, OutputSummary } from "./types/reception-output-types.uts"; import type { CompareRow, OutputSummary } from "./types/reception-output-types.uts";
const shellRef = ref(null); const shellRef = ref(null);
...@@ -419,7 +419,7 @@ onResize((_res: any) => { ...@@ -419,7 +419,7 @@ onResize((_res: any) => {
function toReceptionListRowFromLocalRecord(rec: RecordData): UTSJSONObject { function toReceptionListRowFromLocalRecord(rec: RecordData): UTSJSONObject {
// ListReception.uvue 使用 batchId 作为 key;本地记录只有 id,这里做一层兼容映射。 // ListReception.uvue 使用 batchId 作为 key;本地记录只有 id,这里做一层兼容映射。
// 未提交列表不展示“战败/成交”,因此 orderFinishFlag 置空让角标隐藏。 const of = rec.orderFinishFlag
return { return {
batchId: rec.id, batchId: rec.id,
customerName: rec.customerName ?? "", customerName: rec.customerName ?? "",
...@@ -430,7 +430,7 @@ function toReceptionListRowFromLocalRecord(rec: RecordData): UTSJSONObject { ...@@ -430,7 +430,7 @@ function toReceptionListRowFromLocalRecord(rec: RecordData): UTSJSONObject {
receptionStartTime: rec.receptionStartTime ?? "", receptionStartTime: rec.receptionStartTime ?? "",
receptionEndTime: rec.receptionEndTime ?? "", receptionEndTime: rec.receptionEndTime ?? "",
reviewFlag: 1, reviewFlag: 1,
orderFinishFlag: null, orderFinishFlag: of != null ? of : null,
submitted: 0, submitted: 0,
} as UTSJSONObject; } as UTSJSONObject;
} }
...@@ -542,7 +542,12 @@ function onReceptionCardClick(item: UTSJSONObject): void { ...@@ -542,7 +542,12 @@ function onReceptionCardClick(item: UTSJSONObject): void {
if (filterTabIndex.value == 0) { if (filterTabIndex.value == 0) {
// 与 FormAdd 打开方式一致:navigateTo + query record(JSON) // 与 FormAdd 打开方式一致:navigateTo + query record(JSON)
uni.navigateTo({ uni.navigateTo({
url: `/pages/receptionCenter/receptionDetail?record=${encodeURIComponent(JSON.stringify(item))}` url: buildPageUrlWithRecord("/pages/receptionCenter/receptionDetail", item)
});
} else if (filterTabIndex.value == 1 && unsubmittedPendingTabIndex.value == 1) {
// 未提交 · 待提交:本地临时记录,跳转补充/编辑表单
uni.navigateTo({
url: buildPageUrlWithRecord("/pages/receptionCenter/FormReceptionListEdit", item)
}); });
} else { } else {
uni.showToast({ title: "该接待尚不支持复盘", icon: "none" }); uni.showToast({ title: "该接待尚不支持复盘", icon: "none" });
...@@ -643,7 +648,7 @@ function onCustomerEntryClick(): void { ...@@ -643,7 +648,7 @@ function onCustomerEntryClick(): void {
function onListCustomerEntryEdit(item: UTSJSONObject): void { function onListCustomerEntryEdit(item: UTSJSONObject): void {
uni.navigateTo({ uni.navigateTo({
url: `/pages/receptionCenter/FormAdd?record=${encodeURIComponent(JSON.stringify(item))}` url: buildPageUrlWithRecord("/pages/receptionCenter/FormAdd", item)
}); });
} }
...@@ -660,7 +665,7 @@ function onReceptionRecordDetailClose(): void { ...@@ -660,7 +665,7 @@ function onReceptionRecordDetailClose(): void {
function onListCustomerEntryClick(item: UTSJSONObject): void { function onListCustomerEntryClick(item: UTSJSONObject): void {
// 与 FormAdd 打开方式一致:navigateTo + query record(JSON) // 与 FormAdd 打开方式一致:navigateTo + query record(JSON)
uni.navigateTo({ uni.navigateTo({
url: `/pages/receptionCenter/forms/FormDetail?record=${encodeURIComponent(JSON.stringify(item))}` url: buildPageUrlWithRecord("/pages/receptionCenter/forms/FormDetail", item)
}); });
} }
......
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
<view class="card-header-row"> <view class="card-header-row">
<view class="card-title-box"> <view class="card-title-box">
<text class="card-name">{{ getStr(item, 'customerName') }}</text> <text class="card-name">{{ getStr(item, 'customerName') }}</text>
<text class="card-car">{{ getStr(item, 'carBrand') }}</text> <text class="card-car">{{
getStr(item, 'carModel') != '' ? getStr(item, 'carModel') : getStr(item, 'carBrand')
}}</text>
</view> </view>
<view class="card-status-box"> <view class="card-status-box">
<view class="status-badge bg-slate-100"> <view class="status-badge bg-slate-100">
......
...@@ -148,3 +148,12 @@ export function isPerformanceDataEmpty(data: UTSJSONObject | null): boolean { ...@@ -148,3 +148,12 @@ export function isPerformanceDataEmpty(data: UTSJSONObject | null): boolean {
const hasRate = rate != null && `${rate}` != '' const hasRate = rate != null && `${rate}` != ''
return !(hasCount || hasRate) return !(hasCount || hasRate)
} }
/**
* 拼接带 record(JSON) 查询参数的页面 URL,供 uni.navigateTo 使用。
* 放在独立 .uts 中可避免 center.uvue 内对 url 表达式的路由校验误报。
*/
export function buildPageUrlWithRecord(path: string, item: UTSJSONObject): string {
const jsonStr = JSON.stringify(item)
return path + "?record=" + encodeURIComponent(jsonStr)
}
...@@ -89,6 +89,7 @@ export class DefaultRecorderStrategy implements IRecorderStrategy { ...@@ -89,6 +89,7 @@ export class DefaultRecorderStrategy implements IRecorderStrategy {
`carBrandId TEXT`, `carBrandId TEXT`,
`oneCarBrand TEXT`, `oneCarBrand TEXT`,
`oneCarBrandId TEXT`, `oneCarBrandId TEXT`,
`orderFinishFlag INTEGER`,
]; ];
} }
......
...@@ -19,6 +19,8 @@ export type RecordData = { ...@@ -19,6 +19,8 @@ export type RecordData = {
channelType?: null | number channelType?: null | number
customerName?: null | string customerName?: null | string
endReasonType?: null | number endReasonType?: null | number
/** 接待结果:0 战败,1 成交(本地补充) */
orderFinishFlag?: null | number
id: string id: string
loginPhone?: null | string loginPhone?: null | string
merchantId?: null | number merchantId?: null | number
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!