|
@@ -1,5 +1,6 @@
|
|
|
import {
|
|
import {
|
|
|
alcoholAnalysisReport,
|
|
alcoholAnalysisReport,
|
|
|
|
|
+ back,
|
|
|
edge,
|
|
edge,
|
|
|
end,
|
|
end,
|
|
|
healthAnalysis,
|
|
healthAnalysis,
|
|
@@ -8,6 +9,7 @@ import {
|
|
|
ID_Analysis_Health,
|
|
ID_Analysis_Health,
|
|
|
ID_Analysis_Pulse,
|
|
ID_Analysis_Pulse,
|
|
|
ID_Analysis_TongueAndFace,
|
|
ID_Analysis_TongueAndFace,
|
|
|
|
|
+ ID_Back,
|
|
|
ID_End,
|
|
ID_End,
|
|
|
ID_Register,
|
|
ID_Register,
|
|
|
ID_Report_Alcohol,
|
|
ID_Report_Alcohol,
|
|
@@ -33,24 +35,24 @@ const nodeRef = {
|
|
|
[ID_Analysis_TongueAndFace]: /*拍照页*/ 'tongueface_upload',
|
|
[ID_Analysis_TongueAndFace]: /*拍照页*/ 'tongueface_upload',
|
|
|
[ID_Analysis_Health]: /* 问诊页 */ 'tongueface_analysis',
|
|
[ID_Analysis_Health]: /* 问诊页 */ 'tongueface_analysis',
|
|
|
[ID_Report_Pulse]: /* 脉诊结果页 */ 'pulse_upload_result',
|
|
[ID_Report_Pulse]: /* 脉诊结果页 */ 'pulse_upload_result',
|
|
|
- [ID_Report_TongueAndFace]: /* 舌面想分析报告页 */'tongueface_analysis_result',
|
|
|
|
|
|
|
+ [ID_Report_TongueAndFace]: /* 舌面诊分析报告页 */'tongueface_analysis_result',
|
|
|
[ID_Report_Health]: /* 健康报告页 */ 'health_analysis',
|
|
[ID_Report_Health]: /* 健康报告页 */ 'health_analysis',
|
|
|
[ID_Scheme_Health]: /* 调理方案页 */ 'health_analysis_scheme',
|
|
[ID_Scheme_Health]: /* 调理方案页 */ 'health_analysis_scheme',
|
|
|
[ID_Report_Alcohol]: /* 酒精结果页 */ 'alcohol_upload_result',
|
|
[ID_Report_Alcohol]: /* 酒精结果页 */ 'alcohol_upload_result',
|
|
|
} as const;
|
|
} as const;
|
|
|
|
|
|
|
|
export type NodeId = keyof typeof nodeRef;
|
|
export type NodeId = keyof typeof nodeRef;
|
|
|
-export type Gather = { level: number; sourceNodeId: NodeId; targetNodeId: NodeId; edgeId?: string }[];
|
|
|
|
|
|
|
+export type Gather = { level: number; sourceNodeId: NodeId; targetNodeId: NodeId | typeof ID_Back; edgeId: string }[];
|
|
|
|
|
|
|
|
const refNode = ((ref) => Object.keys(ref).reduce((record, key) => ((record[ref[<NodeId>key]] = <NodeId>key), record), {} as Record<string, NodeId>))(nodeRef);
|
|
const refNode = ((ref) => Object.keys(ref).reduce((record, key) => ((record[ref[<NodeId>key]] = <NodeId>key), record), {} as Record<string, NodeId>))(nodeRef);
|
|
|
|
|
|
|
|
export function toFlowRequestData(gather: Gather, data: Record<string, any>) {
|
|
export function toFlowRequestData(gather: Gather, data: Record<string, any>) {
|
|
|
const value: string[] = [];
|
|
const value: string[] = [];
|
|
|
- const _gather = [...gather].sort((g1, g2) => g1.level - g2.level || +(g1.targetNodeId === ID_End) - +(g2.targetNodeId === ID_End));
|
|
|
|
|
- for (const { targetNodeId } of _gather) {
|
|
|
|
|
- if (targetNodeId === ID_End) {
|
|
|
|
|
|
|
+ for (let i = 0; i < gather.length; i++) {
|
|
|
|
|
+ const { targetNodeId } = gather[i];
|
|
|
|
|
+ if (targetNodeId === ID_Back && i !== gather.length - 1) {
|
|
|
value.push(value.pop()!.replace(/\?*$/, '?'));
|
|
value.push(value.pop()!.replace(/\?*$/, '?'));
|
|
|
- } else value.push(nodeRef[targetNodeId]);
|
|
|
|
|
|
|
+ } else if (targetNodeId !== ID_Back && targetNodeId !== ID_End) value.push(nodeRef[targetNodeId]);
|
|
|
}
|
|
}
|
|
|
const getReportRequestData = (key: string) => data[key]?.elements ?? [];
|
|
const getReportRequestData = (key: string) => data[key]?.elements ?? [];
|
|
|
return {
|
|
return {
|
|
@@ -90,6 +92,7 @@ export function fromFlowRequestData(data?: FlowRequestData) {
|
|
|
healthAnalysisReport({ requestData: getReportRequestData('health_analysis_report_page') }),
|
|
healthAnalysisReport({ requestData: getReportRequestData('health_analysis_report_page') }),
|
|
|
healthAnalysisScheme({ requestData: getReportRequestData('health_analysis_scheme_page') }),
|
|
healthAnalysisScheme({ requestData: getReportRequestData('health_analysis_scheme_page') }),
|
|
|
],
|
|
],
|
|
|
|
|
+ [back()],
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
const nodes = new Set<string>([ID_Start, ID_End]);
|
|
const nodes = new Set<string>([ID_Start, ID_End]);
|
|
@@ -98,6 +101,7 @@ export function fromFlowRequestData(data?: FlowRequestData) {
|
|
|
if (flow.length && flow[0] === nodeRef[ID_Start]) flow.shift();
|
|
if (flow.length && flow[0] === nodeRef[ID_Start]) flow.shift();
|
|
|
if (flow.length && flow[flow.length - 1] === nodeRef[ID_End]) flow.pop();
|
|
if (flow.length && flow[flow.length - 1] === nodeRef[ID_End]) flow.pop();
|
|
|
flow.unshift(ID_Start);
|
|
flow.unshift(ID_Start);
|
|
|
|
|
+ flow.push(ID_End);
|
|
|
for (let i = 1; i < flow.length; i++) {
|
|
for (let i = 1; i < flow.length; i++) {
|
|
|
const [source] = flow[i - 1].split(/[?:]/).filter(Boolean);
|
|
const [source] = flow[i - 1].split(/[?:]/).filter(Boolean);
|
|
|
const [target, title, countDown] = flow[i].split(/[?:]/).filter(Boolean);
|
|
const [target, title, countDown] = flow[i].split(/[?:]/).filter(Boolean);
|