Commit d549bd10 by liimin

feat(接待业务&tab导航): 优化tab栏配置,重构接待业务适配新接口

新增tabBar所需的4组图标资源,调整全局tab栏的路由顺序与激活索引配置
新增ConfirmDialog通用确认弹窗和ReceptionResultPopup接待结果选择弹窗,替换原生uni.showModal
重构接待中心的API调用与列表渲染逻辑,适配新后端接口的参数和返回格式
优化车辆信息显示逻辑,优先展示品牌与车系的拼接文本
优化日期格式化与解析工具,支持ISO格式时间字符串转换
修复门店选择页面未持久化存储storeId的问题
将RecordService的updateBusinessData方法改为异步版本并完善调用逻辑
优化最近接待列表的状态显示逻辑,调整默认状态文案为「战败」
为http请求添加调试日志,修复部分页面的字段渲染异常
修正多余的逗号语法问题
1 parent 958f19c0
...@@ -65,6 +65,7 @@ export function request( ...@@ -65,6 +65,7 @@ export function request(
dataType: "json", dataType: "json",
timeout: 30_000, timeout: 30_000,
success: (response) => { success: (response) => {
console.log("🚀 ~ request ~ response:", response)
const statusCode = response.statusCode; const statusCode = response.statusCode;
const resData = response.data; const resData = response.data;
......
<template>
<un-popup v-model:show="visible"
mode="center"
:mask-closeable="false"
round="16px"
:z-index="10080">
<view class="confirm-dialog">
<text class="confirm-dialog-title">{{ title }}</text>
<text class="confirm-dialog-content">{{ content }}</text>
<view class="confirm-dialog-footer">
<view class="confirm-dialog-btn confirm-dialog-btn--cancel" @click="handleCancel">
<text class="confirm-dialog-btn-text">{{ cancelText }}</text>
</view>
<view class="confirm-dialog-btn confirm-dialog-btn--confirm" @click="handleConfirm">
<text class="confirm-dialog-btn-text confirm-dialog-btn-text--confirm">{{ confirmText }}</text>
</view>
</view>
</view>
</un-popup>
</template>
<script setup lang="uts">
import { ref } from "vue";
type Props = {
title?: string
content?: string
cancelText?: string
confirmText?: string
}
const props = withDefaults(defineProps<Props>(), {
title: "提示",
content: "",
cancelText: "取消",
confirmText: "确认"
});
const emit = defineEmits(["confirm", "cancel"]);
const visible = ref<boolean>(false);
const open = (): void => {
visible.value = true;
};
const close = (): void => {
visible.value = false;
};
const handleCancel = (): void => {
close();
emit("cancel");
};
const handleConfirm = (): void => {
close();
emit("confirm");
};
defineExpose({ open, close });
</script>
<style scoped lang="scss">
.confirm-dialog {
width: 380px;
background: #ffffff;
border-radius: 16px;
padding: 24px 20px 16px;
box-sizing: border-box;
}
.confirm-dialog-title {
font-size: 17px;
font-weight: 600;
color: #1a1a1a;
text-align: center;
display: block;
}
.confirm-dialog-content {
font-size: 14px;
color: #666;
text-align: center;
margin-top: 10px;
line-height: 20px;
display: block;
}
.confirm-dialog-footer {
display: flex;
flex-direction: row;
margin-top: 20px;
}
.confirm-dialog-btn {
flex: 1;
height: 42px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
}
.confirm-dialog-btn--cancel {
background: #f2f3f5;
margin-right: 10px;
}
.confirm-dialog-btn--confirm {
background: #2c66f7;
}
.confirm-dialog-btn-text {
font-size: 15px;
font-weight: 500;
color: #333;
}
.confirm-dialog-btn-text--confirm {
color: #ffffff;
font-weight: 600;
}
</style>
...@@ -67,8 +67,8 @@ const loading = ref(true); ...@@ -67,8 +67,8 @@ const loading = ref(true);
function buildCardItem(row: UTSJSONObject): ReceptionCardItem { function buildCardItem(row: UTSJSONObject): ReceptionCardItem {
const status = row["status"]; const status = row["status"];
const statusName = getStr(row, 'statusName'); const statusName = getStr(row, 'result');
const resultText = statusName != '' ? statusName : '进行中'; const resultText = statusName != '' ? statusName : '战败';
// 新接口:brand + carSeries 拼接 // 新接口:brand + carSeries 拼接
const brand = getStr(row, 'brand'); const brand = getStr(row, 'brand');
const series = getStr(row, 'carSeries'); const series = getStr(row, 'carSeries');
......
<template>
<un-popup v-model:show="visible"
mode="center"
:mask-closeable="false"
:closeable="false"
round="16px"
:z-index="10075">
<view class="result-popup">
<view class="result-popup-header">
<text class="result-popup-title">接待结果</text>
<view class="result-popup-close" @click="handleCancel">
<un-icon name="close" size="18" color="#999"></un-icon>
</view>
</view>
<view class="result-popup-tip">
<uni-icons :size="16" type="info-circle" color="#2c66f7"></uni-icons>
<text class="result-popup-tip-text">请选择本次接待结果</text>
</view>
<view class="result-popup-choices">
<view class="result-choice"
:class="selected == '1' ? 'result-choice--success' : ''"
@click="onSelect('1')">
<un-icon name="checkmark-circle-fill"
:size="28"
:color="selected == '1' ? '#14cc68' : '#ccc'" />
<text class="result-choice-text"
:class="selected == '1' ? 'result-choice-text--success' : ''">成交了</text>
</view>
<view class="result-choice"
:class="selected == '0' ? 'result-choice--error' : ''"
@click="onSelect('0')">
<un-icon name="close-circle-fill"
:size="28"
:color="selected == '0' ? '#f24724' : '#ccc'" />
<text class="result-choice-text"
:class="selected == '0' ? 'result-choice-text--error' : ''">战败了</text>
</view>
</view>
<view class="result-popup-footer">
<view class="result-popup-btn result-popup-btn--cancel" @click="handleCancel">
<text class="result-popup-btn-text">取消</text>
</view>
<view class="result-popup-btn result-popup-btn--confirm" @click="handleConfirm">
<text class="result-popup-btn-text result-popup-btn-text--confirm">确认</text>
</view>
</view>
</view>
</un-popup>
</template>
<script setup lang="uts">
import { ref } from "vue";
const emit = defineEmits(["confirm", "cancel", "select"]);
const visible = ref<boolean>(false);
const selected = ref<string>("");
const open = (): void => {
selected.value = "";
visible.value = true;
};
const onSelect = (val: string): void => {
selected.value = val;
emit("select", val);
};
const close = (): void => {
visible.value = false;
};
const handleCancel = (): void => {
close();
emit("cancel");
};
const handleConfirm = (): void => {
if (selected.value === "") {
uni.showToast({ title: "请选择接待结果", icon: "none" });
return;
}
close();
emit("confirm", selected.value);
};
defineExpose({ open, close });
</script>
<style scoped lang="scss">
.result-popup {
width: 360px;
background: #ffffff;
border-radius: 16px;
overflow: hidden;
}
.result-popup-header {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 16px 16px 0;
}
.result-popup-title {
font-size: 17px;
font-weight: 600;
color: #1a1a1a;
}
.result-popup-close {
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
}
.result-popup-tip {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
margin: 14px 16px 0;
padding: 10px 14px;
background: #f0f4ff;
border-radius: 8px;
}
.result-popup-tip-text {
font-size: 13px;
color: #2c66f7;
font-weight: 500;
margin-left: 6px;
}
.result-popup-choices {
display: flex;
flex-direction: column;
padding: 20px 16px 8px;
}
.result-choice {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
height: 60px;
border-radius: 12px;
background: #f7f8fa;
border: 2px solid transparent;
margin-bottom: 12px;
transition: all 0.2s ease;
}
.result-choice--success {
background: #f0fbf5;
border-color: #14cc68;
}
.result-choice--error {
background: #fff4f2;
border-color: #f24724;
}
.result-choice-text {
font-size: 16px;
font-weight: 500;
color: #666;
margin-left: 10px;
}
.result-choice-text--success {
color: #14cc68;
font-weight: 600;
}
.result-choice-text--error {
color: #f24724;
font-weight: 600;
}
.result-popup-footer {
display: flex;
flex-direction: row;
padding: 8px 16px 16px;
}
.result-popup-btn {
flex: 1;
height: 44px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
}
.result-popup-btn--cancel {
background: #f2f3f5;
margin-right: 10px;
}
.result-popup-btn--confirm {
background: #2c66f7;
}
.result-popup-btn-text {
font-size: 15px;
font-weight: 500;
color: #333;
}
.result-popup-btn-text--confirm {
color: #ffffff;
font-weight: 600;
}
</style>
...@@ -38,7 +38,7 @@ export type TabItem = { ...@@ -38,7 +38,7 @@ export type TabItem = {
iconSrcInactive: string; iconSrcInactive: string;
}; };
/** 与 pages.json tabBar 一致:首页 | 我的 */ /** 与 pages.json tabBar 一致:首页 | 任务 | 录单 | 报表 | 我的 */
export const HOME_FRAME_TABS: TabItem[] = [ export const HOME_FRAME_TABS: TabItem[] = [
{ {
label: "首页", label: "首页",
...@@ -48,33 +48,33 @@ export const HOME_FRAME_TABS: TabItem[] = [ ...@@ -48,33 +48,33 @@ export const HOME_FRAME_TABS: TabItem[] = [
iconSrcInactive: "/static/images/tabbar/home.png" iconSrcInactive: "/static/images/tabbar/home.png"
}, },
{ {
label: "我的",
icon: "my",
name: "MyCenter",
iconSrcActive: "/static/images/tabbar/study-active.png",
iconSrcInactive: "/static/images/tabbar/study.png"
},
{
label: "任务", label: "任务",
icon: "home", icon: "tasks",
name: "Tasks", name: "Tasks",
iconSrcActive: "/static/images/tabbar/home-active.png", iconSrcActive: "/static/images/tabbar/tasks-active.png",
iconSrcInactive: "/static/images/tabbar/home.png" iconSrcInactive: "/static/images/tabbar/tasks.png"
}, },
{ {
label: "录单", label: "录单",
icon: "tasks", icon: "record",
name: "orderEntry", name: "orderEntry",
iconSrcActive: "/static/images/tabbar/tasks-active.png", iconSrcActive: "/static/images/tabbar/record-active.png",
iconSrcInactive: "/static/images/tabbar/tasks.png" iconSrcInactive: "/static/images/tabbar/record.png"
}, },
{ {
label: "报表", label: "报表",
icon: "home", icon: "reports",
name: "Reports", name: "Reports",
iconSrcActive: "/static/images/tabbar/home-active.png", iconSrcActive: "/static/images/tabbar/reports-active.png",
iconSrcInactive: "/static/images/tabbar/home.png" iconSrcInactive: "/static/images/tabbar/reports.png"
} },
{
label: "我的",
icon: "my",
name: "MyCenter",
iconSrcActive: "/static/images/tabbar/study-active.png",
iconSrcInactive: "/static/images/tabbar/study.png"
}
]; ];
function reLaunchPage(pagesJsonPath: string): void { function reLaunchPage(pagesJsonPath: string): void {
...@@ -111,20 +111,21 @@ export function navigateToTab(index: number, currentTabIndex: number): void { ...@@ -111,20 +111,21 @@ export function navigateToTab(index: number, currentTabIndex: number): void {
switchTabPage("pages/index/index"); switchTabPage("pages/index/index");
return; return;
} }
if (index == 1) { if (index == 1) {
switchTabPage("pages/person/myCenter"); switchTabPage("pages/tasks/tasks");
return; return;
} }
if (index == 2) { if (index == 2) {
switchTabPage("pages/tasks/tasks"); uni.navigateTo({ url: "/pages/common/orderEntry/index" });
return; return;
} }
if (index == 3) { if (index == 3) {
uni.navigateTo({ url: "/pages/common/orderEntry/index" }); switchTabPage("pages/reports/reports");
return; return;
} }
if (index == 4) { if (index == 4) {
switchTabPage("pages/reports/reports"); switchTabPage("pages/person/myCenter");
return; return;
} }
} }
......
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
"text": "报表", "text": "报表",
"iconPath": "static/images/tabbar/home.png", "iconPath": "static/images/tabbar/home.png",
"selectedIconPath": "static/images/tabbar/home-active.png" "selectedIconPath": "static/images/tabbar/home-active.png"
}, }
] ]
}, },
"uniIdRouter": {} "uniIdRouter": {}
......
...@@ -221,6 +221,8 @@ function completeStoreSelection(): void { ...@@ -221,6 +221,8 @@ function completeStoreSelection(): void {
storeName: storeName, storeName: storeName,
storeCode: storeCode storeCode: storeCode
} as UTSJSONObject, 0); } as UTSJSONObject, 0);
// 独立存储 storeId,方便其他页面直接读取
storage.set("storeId", storeId, 0);
// 补全 userInfo 的商户字段 // 补全 userInfo 的商户字段
const profile = storage.parse("userInfo"); const profile = storage.parse("userInfo");
......
...@@ -142,23 +142,44 @@ ...@@ -142,23 +142,44 @@
</view> </view>
<un-popup v-model:show="previewPopupShow" <un-popup v-model:show="previewPopupShow"
mode="center" mode="center"
:mask-closeable="true" :mask-closeable="true"
round="20px"> round="20px">
<view class="reception-preview-popup"> <view class="reception-preview-popup">
<text class="reception-preview-title">{{ previewTitle }}</text> <text class="reception-preview-title">{{ previewTitle }}</text>
<image class="reception-preview-image" <image class="reception-preview-image"
:src="previewImageUrl" :src="previewImageUrl"
mode="widthFix" /> mode="widthFix" />
</view> </view>
</un-popup> </un-popup>
<ReceptionResultPopup ref="resultPopup"
@select="onResultSelect"
@confirm="onResultConfirm"
@cancel="onResultCancel" />
<ConfirmDialog ref="finishDialog"
title="结束接待"
content="确认结束本次接待?录音及客户资料将保存。"
cancelText="继续接待"
confirmText="结束接待"
@confirm="onFinishConfirm" />
<ConfirmDialog ref="backDialog"
title="退出接待"
content="退出后将停止本次接待录音,接待记录不会保存。"
cancelText="继续接待"
confirmText="退出"
@confirm="onBackConfirm" />
</view> </view>
</layout-root> </layout-root>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { computed, ref, watch, onUnmounted, type Ref } from "vue"; import { computed, ref, watch, onUnmounted, type Ref, type ComponentPublicInstance } from "vue";
import ProductIntroGrid from "@/components/ProductIntroGrid.uvue"; import ProductIntroGrid from "@/components/ProductIntroGrid.uvue";
import ReceptionResultPopup from "@/components/ReceptionResultPopup.uvue";
import ConfirmDialog from "@/components/ConfirmDialog.uvue";
import { useOrientation } from "@/services/adapter/hooks/index.uts"; import { useOrientation } from "@/services/adapter/hooks/index.uts";
import { recordService } from "@/services/recorder/index.uts"; import { recordService } from "@/services/recorder/index.uts";
import { useReceptionStore, type CustomerInfo } from "@/store/modules/reception.uts"; import { useReceptionStore, type CustomerInfo } from "@/store/modules/reception.uts";
...@@ -226,6 +247,9 @@ const formData = ref<CustomerReceptionForm>(createEmptyReceptionForm()); ...@@ -226,6 +247,9 @@ const formData = ref<CustomerReceptionForm>(createEmptyReceptionForm());
const previewPopupShow = ref<boolean>(false); const previewPopupShow = ref<boolean>(false);
const previewTitle = ref<string>(""); const previewTitle = ref<string>("");
const previewImageUrl = ref<string>(""); const previewImageUrl = ref<string>("");
const resultPopup = ref<ComponentPublicInstance | null>(null);
const finishDialog = ref<ComponentPublicInstance | null>(null);
const backDialog = ref<ComponentPublicInstance | null>(null);
let hasClosed = false; let hasClosed = false;
...@@ -283,33 +307,31 @@ function closeReception(isNotSave: boolean): void { ...@@ -283,33 +307,31 @@ function closeReception(isNotSave: boolean): void {
} }
function handleFinishReception(): void { function handleFinishReception(): void {
uni.showModal({ (finishDialog.value as ComponentPublicInstance).$callMethod("open");
title: "结束接待", }
content: "确认结束本次接待?录音及客户资料将保存。",
cancelText: "继续接待", function onFinishConfirm(): void {
confirmText: "结束接待", (resultPopup.value as ComponentPublicInstance).$callMethod("open");
confirmColor: "#2c66f7", }
success: (res) => {
if (res.confirm) { function onResultSelect(result: string): void {
closeReception(false); recordService.updateBusinessData({ result: result == "1" ? "成交" : "战败" } as RecordData);
} }
}
}); function onResultConfirm(): void {
closeReception(false);
}
function onResultCancel(): void {
// 取消时不做任何操作,继续接待
} }
function handleBack(): void { function handleBack(): void {
uni.showModal({ (backDialog.value as ComponentPublicInstance).$callMethod("open");
title: "退出接待", }
content: "退出后将停止本次接待录音,接待记录不会保存。",
cancelText: "继续接待", function onBackConfirm(): void {
confirmText: "退出", closeReception(true);
confirmColor: "#ff4d4f",
success: (res) => {
if (res.confirm) {
closeReception(true);
}
}
});
} }
function onMaterialTap(index: number): void { function onMaterialTap(index: number): void {
......
<template> <template>
<TabBarShell ref="shellRef" <TabBarShell ref="shellRef"
:active-tab-index="1"> :active-tab-index="4">
<!-- ✅ 修复空指针:骨架屏和真实内容同时渲染 --> <!-- ✅ 修复空指针:骨架屏和真实内容同时渲染 -->
<PersonSkeleton v-if="!userInfoLoaded" /> <PersonSkeleton v-if="!userInfoLoaded" />
<MyCenterMain @loaded="onMyCenterLoaded" /> <MyCenterMain @loaded="onMyCenterLoaded" />
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<script setup lang="uts"> <script setup lang="uts">
import { type Ref, computed, onMounted, onShow, ref } from "vue"; import { type Ref, computed, onMounted, onShow, ref } from "vue";
import { getList } from "@/api/receiption.uts"; import { getReceptions } from "@/api/modules/receptions.uts";
import { useOrientation } from "@/services/adapter/hooks/index.uts"; import { useOrientation } from "@/services/adapter/hooks/index.uts";
import { DBRecord, recordService, type RecordData } from "@/services/recorder/index.uts"; import { DBRecord, recordService, type RecordData } from "@/services/recorder/index.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
...@@ -170,23 +170,29 @@ function initGetReceptionRecordListImpl(): void { ...@@ -170,23 +170,29 @@ function initGetReceptionRecordListImpl(): void {
if (!append) { if (!append) {
receptionPageNum.value = 1; receptionPageNum.value = 1;
} }
// 新API: status 1=进行中, 2=已结束, 3=已取消
// submittedResultTabIndex: 0=进行中, 1=已结束
const status = submittedResultTabIndex.value == 0 ? 1 : 2;
const storeId = storage.get("storeId") as string | null;
const params = { const params = {
pageNum: receptionPageNum.value, pageNum: receptionPageNum.value,
pageSize: RECEPTION_PAGE_SIZE, status: status
orderFinishFlag: submittedResultTabIndex.value == 1 ? "1" : "0"
} as UTSJSONObject; } as UTSJSONObject;
if (storeId != null && storeId !== "") {
params["storeId"] = 1//parseInt(storeId);
}
try { try {
const resp = await getList(params); const resp = await getReceptions(params);
const respObj = resp as UTSJSONObject; // request() 已提取 obj.data,resp 直接就是 [Reception] 数组
const rows = (respObj.data as UTSJSONObject)?.rows as UTSJSONObject[] | null; const items = resp as UTSJSONObject[] | null;
if (rows != null) { if (items != null) {
if (append) { if (append) {
receptionRecordList.value = receptionRecordList.value.concat(rows); receptionRecordList.value = receptionRecordList.value.concat(items);
} else { } else {
receptionRecordList.value = rows; receptionRecordList.value = items;
} }
const total = (respObj.data as UTSJSONObject)?.total as number | null; // 新API返回数组,通过判断返回数量判断是否还有更多
receptionListHasMore.value = total != null && receptionRecordList.value.length < total; receptionListHasMore.value = items.length >= RECEPTION_PAGE_SIZE;
} else { } else {
if (!append) { if (!append) {
receptionRecordList.value = []; receptionRecordList.value = [];
......
...@@ -41,18 +41,14 @@ ...@@ -41,18 +41,14 @@
<view class="card-header-row"> <view class="card-header-row">
<view class="card-title-box"> <view class="card-title-box">
<text class="card-name">{{ getCustomerName(item) }}</text> <text class="card-name">{{ getCustomerName(item) }}</text>
<text class="card-car">{{ getCarType(item) }}</text> <text v-if="getCarSeriesDisplay(item) != ''" class="card-car">{{ getCarSeriesDisplay(item) }}</text>
</view> </view>
<view class="card-status-box"> <view class="card-status-box">
<view
v-if="hasResult(item)"
:class="['status-badge', getResultBadgeBgClass(item)]"
>
<text :class="['status-text', getResultBadgeTextClass(item)]">{{ <text :class="['status-text', getResultBadgeTextClass(item)]">{{
getResult(item) getResult(item)
}}</text> }}</text>
</view>
</view> </view>
</view>
</view> </view>
<view class="card-info-list"> <view class="card-info-list">
<view class="info-row"><text class="info-label">客户类型</text><text class="info-value">{{ getCustomerType(item) }}</text></view> <view class="info-row"><text class="info-label">客户类型</text><text class="info-value">{{ getCustomerType(item) }}</text></view>
...@@ -81,18 +77,32 @@ function getCustomerName(item: UTSJSONObject): string { ...@@ -81,18 +77,32 @@ function getCustomerName(item: UTSJSONObject): string {
return textOrDash(getStr(item, 'customerName')) return textOrDash(getStr(item, 'customerName'))
} }
function getCarType(item: UTSJSONObject): string { function getCarSeriesDisplay(item: UTSJSONObject): string {
const brand = getStr(item, 'brand')
const carSeries = getStr(item, 'carSeries')
if (brand != '' && carSeries != '') {
return `${brand} ${carSeries}`
}
if (carSeries != '') { return carSeries }
if (brand != '') { return brand }
const s = getStr(item, 'seriesName') const s = getStr(item, 'seriesName')
if (s != '') { return textOrDash(s) } if (s != '') { return s }
return textOrDash(getStr(item, 'carType')) return getStr(item, 'carType')
} }
function getResult(item: UTSJSONObject): string { function getResult(item: UTSJSONObject): string {
return getStr(item, 'result') // 新API: statusName(进行中/已结束/已取消),旧API: result(成交/战败)
const statusName = getStr(item, 'statusName')
if (statusName != '') { return statusName }
const result = getStr(item, 'result')
if (result != '') { return result }
// 默认显示战败
return '战败'
} }
function hasResult(item: UTSJSONObject): boolean { function hasResult(item: UTSJSONObject): boolean {
return !isBlankDisplayText(getStr(item, 'result')) // 始终显示徽章(默认显示战败)
return true
} }
function getResultBadgeBgClass(item: UTSJSONObject): string { function getResultBadgeBgClass(item: UTSJSONObject): string {
......
...@@ -9,8 +9,8 @@ import { getStr, getTs } from '../types/reception-center-helpers.uts' ...@@ -9,8 +9,8 @@ import { getStr, getTs } from '../types/reception-center-helpers.uts'
import { parseIntValue, parseNumberValue } from '../receptionDetail.helper.uts' import { parseIntValue, parseNumberValue } from '../receptionDetail.helper.uts'
/** /**
* 解析到店日期字段为时间戳 * 解析日期字段为时间戳
* 支持多种格式:数字时间戳、纯数字字符串、yyyy-MM-dd 格式字符串 * 支持多种格式:数字时间戳、纯数字字符串、yyyy-MM-dd、ISO格式 yyyy-MM-ddTHH:mm:ss
*/ */
function parseArrivalDateFieldToTs(v: any | null): number | null { function parseArrivalDateFieldToTs(v: any | null): number | null {
if (v == null) { if (v == null) {
...@@ -42,6 +42,26 @@ function parseArrivalDateFieldToTs(v: any | null): number | null { ...@@ -42,6 +42,26 @@ function parseArrivalDateFieldToTs(v: any | null): number | null {
return n return n
} }
} }
// ISO格式: yyyy-MM-ddTHH:mm:ss
if (s.length >= 19 && s.indexOf('T') > 0) {
const dtParts = s.split('T')
if (dtParts.length == 2) {
const ymd = dtParts[0].split('-')
const hms = dtParts[1].split(':')
if (ymd.length == 3 && hms.length >= 2) {
const y = parseInt(ymd[0], 10)
const mo = parseInt(ymd[1], 10) - 1
const d = parseInt(ymd[2], 10)
const h = parseInt(hms[0], 10)
const min = parseInt(hms[1], 10)
const sec = hms.length >= 3 ? parseInt(hms[2], 10) : 0
if (!isNaN(y) && !isNaN(mo) && !isNaN(d) && !isNaN(h) && !isNaN(min)) {
return new Date(y, mo, d, h, min, sec).getTime()
}
}
}
}
// yyyy-MM-dd 格式
const head = s.length >= 10 ? s.substring(0, 10) : '' const head = s.length >= 10 ? s.substring(0, 10) : ''
if (head.length == 10) { if (head.length == 10) {
const parts = head.split('-') const parts = head.split('-')
...@@ -58,10 +78,14 @@ function parseArrivalDateFieldToTs(v: any | null): number | null { ...@@ -58,10 +78,14 @@ function parseArrivalDateFieldToTs(v: any | null): number | null {
} }
/** /**
* 获取客户档案的到店时间戳 * 获取接待记录的时间戳(新API优先 startTime,兼容旧字段 arrivalDate/arrivalTime)
* 优先从 arrivalDate 字段获取,其次从 arrivalTime 字段获取
*/ */
export function getArrivalTsForEntry(item: UTSJSONObject): number | null { export function getArrivalTsForEntry(item: UTSJSONObject): number | null {
// 新API: startTime (ISO格式: "2026-07-29T13:58:14")
const fromStart = parseArrivalDateFieldToTs(item['startTime'])
if (fromStart != null && fromStart > 0) {
return fromStart
}
const fromAd = parseArrivalDateFieldToTs(item['arrivalDate']) const fromAd = parseArrivalDateFieldToTs(item['arrivalDate'])
if (fromAd != null && fromAd > 0) { if (fromAd != null && fromAd > 0) {
return fromAd return fromAd
...@@ -70,17 +94,17 @@ export function getArrivalTsForEntry(item: UTSJSONObject): number | null { ...@@ -70,17 +94,17 @@ export function getArrivalTsForEntry(item: UTSJSONObject): number | null {
} }
/** /**
* 获取客户电话(优先 customerMobile,兼容旧字段 customerPhone 和 phoneNumber) * 获取客户电话(新API优先 customerPhone,兼容旧字段 customerMobile 和 phoneNumber)
*/ */
export function getCustomerPhone(item: UTSJSONObject): string { export function getCustomerPhone(item: UTSJSONObject): string {
const m = getStr(item, 'customerMobile')
if (!isBlankDisplayText(m)) {
return m
}
const p = getStr(item, 'customerPhone') const p = getStr(item, 'customerPhone')
if (!isBlankDisplayText(p)) { if (!isBlankDisplayText(p)) {
return p return p
} }
const m = getStr(item, 'customerMobile')
if (!isBlankDisplayText(m)) {
return m
}
return getStr(item, 'phoneNumber') return getStr(item, 'phoneNumber')
} }
...@@ -172,17 +196,31 @@ function resolveReceptionBoundaryMs(item: UTSJSONObject, primaryKey: string, fal ...@@ -172,17 +196,31 @@ function resolveReceptionBoundaryMs(item: UTSJSONObject, primaryKey: string, fal
} }
/** /**
* 格式化接待时长字符串 * 格式化接待时长字符串(新API优先 durationSec,兼容旧字段 duration/durationStr)
*/ */
export function getDurationStr(item: UTSJSONObject): string { export function getDurationStr(item: UTSJSONObject): string {
// 新API: durationSec(秒数)
const secAny = item['durationSec']
if (secAny != null) {
const secNum = typeof secAny == 'number' ? secAny : parseFloat(`${secAny}`)
if (!isNaN(secNum) && secNum >= 0) {
const diffSec = Math.floor(secNum)
if (diffSec == 0) {
return '--'
}
const min = Math.floor(diffSec / 60)
const sec = diffSec % 60
return `${min}分${sec}秒`
}
}
const d = getStr(item, 'durationStr') const d = getStr(item, 'durationStr')
if (d != '' && !isBlankDisplayText(d)) { if (d != '' && !isBlankDisplayText(d)) {
return d return d
} }
// 兼容后端仅给 duration(秒) // 兼容旧API: duration(秒)
const secAny = item['duration'] const oldSecAny = item['duration']
if (secAny != null) { if (oldSecAny != null) {
const secNum = typeof secAny == 'number' ? secAny : parseFloat(`${secAny}`) const secNum = typeof oldSecAny == 'number' ? oldSecAny : parseFloat(`${oldSecAny}`)
if (!isNaN(secNum) && secNum >= 0) { if (!isNaN(secNum) && secNum >= 0) {
const diffSec = Math.floor(secNum) const diffSec = Math.floor(secNum)
const min = Math.floor(diffSec / 60) const min = Math.floor(diffSec / 60)
...@@ -190,7 +228,7 @@ export function getDurationStr(item: UTSJSONObject): string { ...@@ -190,7 +228,7 @@ export function getDurationStr(item: UTSJSONObject): string {
return `${min}分${sec}秒` return `${min}分${sec}秒`
} }
} }
// 无 duration 时:用开始/结束时间推算(与 formatReceptionDateTime 字段优先级一致) // 无 duration 时:用开始/结束时间推算
const startMs = resolveReceptionBoundaryMs(item, 'startTime', 'receptionStartTime') const startMs = resolveReceptionBoundaryMs(item, 'startTime', 'receptionStartTime')
const endMs = resolveReceptionBoundaryMs(item, 'endTime', 'receptionEndTime') const endMs = resolveReceptionBoundaryMs(item, 'endTime', 'receptionEndTime')
if (startMs != null && endMs != null && startMs > 0 && endMs > 0) { if (startMs != null && endMs != null && startMs > 0 && endMs > 0) {
...@@ -205,13 +243,13 @@ export function getDurationStr(item: UTSJSONObject): string { ...@@ -205,13 +243,13 @@ export function getDurationStr(item: UTSJSONObject): string {
} }
/** /**
* 获取接待结果徽章背景类名 * 获取接待结果徽章背景类名(新API: statusName 进行中/已结束/已取消,旧API: result 成交/战败)
*/ */
export function getReceptionResultBadgeBgClass(result: string): string { export function getReceptionResultBadgeBgClass(statusOrResult: string): string {
if (result == '战败') { if (statusOrResult == '战败' || statusOrResult == '已结束') {
return 'bg-result-defeat' return 'bg-result-defeat'
} }
if (result == '成交') { if (statusOrResult == '成交' || statusOrResult == '进行中') {
return 'bg-result-deal' return 'bg-result-deal'
} }
return 'bg-slate-100' return 'bg-slate-100'
...@@ -220,11 +258,11 @@ export function getReceptionResultBadgeBgClass(result: string): string { ...@@ -220,11 +258,11 @@ export function getReceptionResultBadgeBgClass(result: string): string {
/** /**
* 获取接待结果徽章文字类名 * 获取接待结果徽章文字类名
*/ */
export function getReceptionResultBadgeTextClass(result: string): string { export function getReceptionResultBadgeTextClass(statusOrResult: string): string {
if (result == '战败') { if (statusOrResult == '战败' || statusOrResult == '已结束') {
return 'text-result-defeat' return 'text-result-defeat'
} }
if (result == '成交') { if (statusOrResult == '成交' || statusOrResult == '进行中') {
return 'text-result-deal' return 'text-result-deal'
} }
return 'text-slate-400' return 'text-slate-400'
......
<template> <template>
<TabBarShell ref="shellRef" <TabBarShell ref="shellRef"
:active-tab-index="4" :active-tab-index="3"
:page-vars="reportPageVars as UTSJSONObject"> :page-vars="reportPageVars as UTSJSONObject">
<view class="reports-page"> <view class="reports-page">
<view class="reports-layout"> <view class="reports-layout">
......
<template> <template>
<TabBarShell ref="shellRef" <TabBarShell ref="shellRef"
:active-tab-index="2" :active-tab-index="1"
:page-vars="taskPageVars as UTSJSONObject"> :page-vars="taskPageVars as UTSJSONObject">
<view class="tasks-page"> <view class="tasks-page">
<view class="tasks-layout"> <view class="tasks-layout">
......
...@@ -253,28 +253,23 @@ export class RecordService { ...@@ -253,28 +253,23 @@ export class RecordService {
} }
/** /**
* 通用业务数据更新入口 * 通用业务数据更新入口(异步,可 await 等待写入完成)
* @param data 数据载荷,会自动根据字段判断是缓存还是直接持久化 * @param data 数据载荷,会自动根据字段判断是缓存还是直接持久化
*/ */
updateBusinessData(data: RecordData) { async updateBusinessData(data: RecordData): Promise<void> {
// if (!this.isReceptioning()) return; const currentRecord = this.record?.currentRecord;
// 委托给 Handler 处理,传入 recordId 以便策略自行决定缓存还是持久化 let recordId: string = "";
const currentRecord = this.record?.currentRecord; if (currentRecord !== null && currentRecord.id != null) {
// ✅ 安全获取 recordId recordId = currentRecord.id;
let recordId: string = ""; }
if (currentRecord !== null && currentRecord.id != null) { if (isEmptyStr(recordId)) {
recordId = currentRecord.id; logger.warn("【录音服务 RecordService】 == recordId 为空", "RecordService");
} return;
if (isEmptyStr(recordId)) { }
logger.warn("【录音服务 RecordService】 == recordId 为空", "RecordService"); const result = this.businessHandler?.processBusinessData(data, recordId);
return; if (result === null) return;
} await this.record?.updatePreRecords(result);
const result = this.businessHandler?.processBusinessData(data, recordId); }
// 如果策略返回 null,说明已经由策略自行处理(如缓存)或无需处理
if (result === null) return;
// 如果策略返回了数据对象,则交由 Service 进行预记录持久化 (updatePreRecords)
this.record?.updatePreRecords(result);
}
/** /**
* 初始化录音服务(懒加载) * 初始化录音服务(懒加载)
*/ */
......
...@@ -90,6 +90,11 @@ export function formatDateTimeLike(value: any | null): string { ...@@ -90,6 +90,11 @@ export function formatDateTimeLike(value: any | null): string {
if (isBlankDisplayText(value)) { if (isBlankDisplayText(value)) {
return '' return ''
} }
// ISO格式: "2026-07-29T13:58:14" → "2026-07-29 13:58:14"
const tIndex = value.indexOf('T')
if (tIndex > 0) {
return value.substring(0, tIndex) + ' ' + value.substring(tIndex + 1)
}
return value return value
} }
if (typeof value == 'number') { if (typeof value == 'number') {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!