Commit 2d8e13eb by Lin

feat(reception): 添加接待中心表单和详情页面导航功能

- 在接待中心页面中新增表单详情和接待详情的路由配置
- 更新接待记录和客户表单点击事件,使用 navigateTo 方法传递记录数据
- 实现页面模式,通过 query 传递 JSON 字符串以支持动态数据加载
1 parent 32b97ed9
...@@ -81,6 +81,20 @@ ...@@ -81,6 +81,20 @@
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarTitleText": "客户档案" "navigationBarTitleText": "客户档案"
} }
},
{
"path": "pages/receptionCenter/forms/FormDetail",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "客户档案"
}
},
{
"path": "pages/receptionCenter/receptionDetail",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "接待详情"
}
} }
], ],
......
...@@ -691,9 +691,10 @@ function onReceptionRecordDetailClose(): void { ...@@ -691,9 +691,10 @@ function onReceptionRecordDetailClose(): void {
} }
function onListCustomerEntryClick(item: UTSJSONObject): void { function onListCustomerEntryClick(item: UTSJSONObject): void {
customerFormDetailItem.value = item // 与 FormAdd 打开方式一致:navigateTo + query record(JSON)
showCustomerFormDetail.value = true uni.navigateTo({
showReceptionRecordDetail.value = false url: `/pages/receptionCenter/forms/FormDetail?record=${encodeURIComponent(JSON.stringify(item))}`
})
} }
function onListCustomerEntryDelete(item: UTSJSONObject): void { function onListCustomerEntryDelete(item: UTSJSONObject): void {
...@@ -713,9 +714,10 @@ function onListCustomerEntryDelete(item: UTSJSONObject): void { ...@@ -713,9 +714,10 @@ function onListCustomerEntryDelete(item: UTSJSONObject): void {
function onReceptionCardClick(item: UTSJSONObject): void { function onReceptionCardClick(item: UTSJSONObject): void {
if (filterTabIndex.value == 0) { if (filterTabIndex.value == 0) {
receptionRecordItem.value = item // 与 FormAdd 打开方式一致:navigateTo + query record(JSON)
showReceptionRecordDetail.value = true uni.navigateTo({
showCustomerFormDetail.value = false url: `/pages/receptionCenter/receptionDetail?record=${encodeURIComponent(JSON.stringify(item))}`
})
} else { } else {
uni.showToast({ title: '该接待尚不支持复盘', icon: 'none' }) uni.showToast({ title: '该接待尚不支持复盘', icon: 'none' })
} }
......
...@@ -313,8 +313,10 @@ function switchEntryFilterTab(index: number): void { ...@@ -313,8 +313,10 @@ function switchEntryFilterTab(index: number): void {
// ========== 事件处理 ========== // ========== 事件处理 ==========
function onListCustomerEntryClick(item: UTSJSONObject): void { function onListCustomerEntryClick(item: UTSJSONObject): void {
receptionDetailItem.value = item // 与 FormAdd 打开方式一致:navigateTo + query record(JSON)
showReceptionDetail.value = true uni.navigateTo({
url: `/pages/receptionCenter/forms/FormDetail?record=${encodeURIComponent(JSON.stringify(item))}`
})
} }
function onListCustomerEntryEdit(item: UTSJSONObject): void { function onListCustomerEntryEdit(item: UTSJSONObject): void {
......
...@@ -664,9 +664,10 @@ const receptionRecordItem = ref<UTSJSONObject>({}) ...@@ -664,9 +664,10 @@ const receptionRecordItem = ref<UTSJSONObject>({})
function onReceptionCardClick(item: UTSJSONObject): void { function onReceptionCardClick(item: UTSJSONObject): void {
if (filterTabIndex.value == 0) { if (filterTabIndex.value == 0) {
receptionRecordItem.value = item // 与 FormAdd 打开方式一致:navigateTo + query record(JSON)
showReceptionRecordDetail.value = true uni.navigateTo({
showCustomerFormDetail.value = false url: `/pages/receptionCenter/receptionDetail?record=${encodeURIComponent(JSON.stringify(item))}`
})
} else { } else {
uni.showToast({ title: '该接待尚不支持复盘', icon: 'none' }) uni.showToast({ title: '该接待尚不支持复盘', icon: 'none' })
} }
...@@ -784,9 +785,10 @@ function onReceptionRecordDetailClose(): void { ...@@ -784,9 +785,10 @@ function onReceptionRecordDetailClose(): void {
} }
function onListCustomerEntryClick(item: UTSJSONObject): void { function onListCustomerEntryClick(item: UTSJSONObject): void {
customerFormDetailItem.value = item // 与 FormAdd 打开方式一致:navigateTo + query record(JSON)
showCustomerFormDetail.value = true uni.navigateTo({
showReceptionRecordDetail.value = false url: `/pages/receptionCenter/forms/FormDetail?record=${encodeURIComponent(JSON.stringify(item))}`
})
} }
function onListCustomerEntryDelete(item: UTSJSONObject): void { function onListCustomerEntryDelete(item: UTSJSONObject): void {
......
...@@ -198,6 +198,16 @@ const props = withDefaults( ...@@ -198,6 +198,16 @@ const props = withDefaults(
{ show: false, detail: null } { show: false, detail: null }
) )
/** 页面模式:通过 uni.navigateTo 打开时为 true(同 FormAdd 用 query record 传参) */
const pageMode = ref(false)
const openFlag = computed((): boolean => {
if (pageMode.value) {
return true
}
return props.show === true
})
function syncReceptionSafeTopSpacer(): void { function syncReceptionSafeTopSpacer(): void {
const info = uni.getWindowInfo() const info = uni.getWindowInfo()
receptionPageInsetTopPx.value = calcReceptionSafeTopInsetPx(info) receptionPageInsetTopPx.value = calcReceptionSafeTopInsetPx(info)
...@@ -329,7 +339,7 @@ async function loadDetailFromApiIfNeeded(row: UTSJSONObject): Promise<void> { ...@@ -329,7 +339,7 @@ async function loadDetailFromApiIfNeeded(row: UTSJSONObject): Promise<void> {
} }
watch( watch(
(): boolean => props.show, (): boolean => openFlag.value,
(open: boolean): void => { (open: boolean): void => {
if (!open) { if (!open) {
resolvedDetail.value = null resolvedDetail.value = null
...@@ -341,6 +351,10 @@ watch( ...@@ -341,6 +351,10 @@ watch(
nextTick(() => { nextTick(() => {
syncReceptionSafeTopSpacer() syncReceptionSafeTopSpacer()
}) })
// pageMode 下 resolvedDetail 由 onLoad 设定;这里仅处理“组件弹层”场景
if (pageMode.value) {
return
}
const r = props.detail const r = props.detail
if (r == null) { if (r == null) {
resolvedDetail.value = null resolvedDetail.value = null
...@@ -543,13 +557,13 @@ async function loadMaterialResponsePageForDetail(d: UTSJSONObject | null): Promi ...@@ -543,13 +557,13 @@ async function loadMaterialResponsePageForDetail(d: UTSJSONObject | null): Promi
/** 详情(含列表行或 findVisitsInfo 结果)变化时拉取素材分页,填充商品套餐区 */ /** 详情(含列表行或 findVisitsInfo 结果)变化时拉取素材分页,填充商品套餐区 */
watch( watch(
(): UTSJSONObject | null => { (): UTSJSONObject | null => {
if (props.show !== true) { if (openFlag.value !== true) {
return null return null
} }
return resolvedDetail.value return resolvedDetail.value
}, },
(d: UTSJSONObject | null): void => { (d: UTSJSONObject | null): void => {
if (props.show !== true) { if (openFlag.value !== true) {
return return
} }
void loadMaterialResponsePageForDetail(d) void loadMaterialResponsePageForDetail(d)
...@@ -744,8 +758,40 @@ function goodsRowKey(row: GoodsCardItem[]): string { ...@@ -744,8 +758,40 @@ function goodsRowKey(row: GoodsCardItem[]): string {
} }
function handleClose(): void { function handleClose(): void {
if (pageMode.value) {
uni.navigateBack()
} else {
emit('close') emit('close')
}
} }
/**
* 页面打开:与 FormAdd 同样通过 query record 传递 JSON 字符串
* url: /pages/receptionCenter/forms/FormDetail?record=${encodeURIComponent(JSON.stringify(item))}
*/
onLoad((options: UTSJSONObject | null) => {
// 只要走到 onLoad 就视为页面模式(组件弹层不会触发 onLoad)
pageMode.value = true
syncReceptionSafeTopSpacer()
if (options == null) {
resolvedDetail.value = null
return
}
const recordStr = options['record']
if (recordStr != null && typeof recordStr === 'string' && recordStr !== '') {
try {
const parsed = JSON.parse(recordStr)
if (parsed != null && typeof parsed === 'object') {
const row = parsed as UTSJSONObject
resolvedDetail.value = row
void loadDetailFromApiIfNeeded(row)
}
} catch (e) {
console.error('Failed to parse record query', e)
}
}
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -215,6 +215,11 @@ const portraitRecvDetailText = computed((): ReceptionPortraitReceptionDetailText ...@@ -215,6 +215,11 @@ const portraitRecvDetailText = computed((): ReceptionPortraitReceptionDetailText
return getReceptionPortraitReceptionDetailTextConfig(cssClassRef.value); return getReceptionPortraitReceptionDetailTextConfig(cssClassRef.value);
}); });
/** 页面模式:通过 uni.navigateTo 打开时为 true(同 FormAdd/FormDetail 用 query record 传参) */
const pageMode = ref(false);
/** 页面模式下,从 query 解析出来的接待列表项 */
const pageItem = ref<UTSJSONObject | null>(null);
function recvDetailTextPick(mapper: (c: ReceptionPortraitReceptionDetailTextConfig) => UTSJSONObject): UTSJSONObject { function recvDetailTextPick(mapper: (c: ReceptionPortraitReceptionDetailTextConfig) => UTSJSONObject): UTSJSONObject {
const c = portraitRecvDetailText.value; const c = portraitRecvDetailText.value;
if (c == null) { if (c == null) {
...@@ -301,8 +306,16 @@ const props = withDefaults( ...@@ -301,8 +306,16 @@ const props = withDefaults(
} }
); );
function getItemRaw(key: string): any | null { const effectiveItem = computed((): UTSJSONObject | null => {
if (pageMode.value) {
return pageItem.value;
}
const it = props.item; const it = props.item;
return it != null ? (it as UTSJSONObject) : null;
});
function getItemRaw(key: string): any | null {
const it = effectiveItem.value;
if (it == null) { if (it == null) {
return null; return null;
} }
...@@ -400,7 +413,11 @@ const emit = defineEmits<{ ...@@ -400,7 +413,11 @@ const emit = defineEmits<{
}>(); }>();
function onBack(): void { function onBack(): void {
if (pageMode.value) {
uni.navigateBack();
} else {
emit("close"); emit("close");
}
} }
function getItemBatchIdValue(): number | string | null { function getItemBatchIdValue(): number | string | null {
...@@ -1390,6 +1407,30 @@ function syncReceptionSafeTopSpacer(): void { ...@@ -1390,6 +1407,30 @@ function syncReceptionSafeTopSpacer(): void {
} }
} }
/**
* 页面打开:与 FormAdd/FormDetail 同样通过 query record 传递 JSON 字符串
* url: /pages/receptionCenter/receptionDetail?record=${encodeURIComponent(JSON.stringify(item))}
*/
onLoad((options: UTSJSONObject | null) => {
pageMode.value = true;
syncReceptionSafeTopSpacer();
if (options == null) {
pageItem.value = null;
return;
}
const recordStr = options["record"];
if (recordStr != null && typeof recordStr === "string" && recordStr !== "") {
try {
const parsed = JSON.parse(recordStr);
if (parsed != null && typeof parsed === "object") {
pageItem.value = parsed as UTSJSONObject;
}
} catch (e) {
console.error("Failed to parse record query", e);
}
}
});
const RECEPTION_DETAIL_LAYOUT_POLL_MS = 400; const RECEPTION_DETAIL_LAYOUT_POLL_MS = 400;
let receptionDetailLayoutPollId: number | null = null; let receptionDetailLayoutPollId: number | null = null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!