메일발송기능 데이터 모달로 전달
This commit is contained in:
parent
ece7f21bd3
commit
1506389757
|
|
@ -60,6 +60,9 @@ export interface ButtonPrimaryComponentProps extends ComponentRendererProps {
|
|||
|
||||
// 🆕 같은 화면의 모든 컴포넌트 (TableList 자동 감지용)
|
||||
allComponents?: any[];
|
||||
|
||||
// 🆕 부모창에서 전달된 그룹 데이터 (모달에서 부모 데이터 접근용)
|
||||
groupedData?: Record<string, any>[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -98,6 +101,7 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
|||
flowSelectedData,
|
||||
flowSelectedStepId,
|
||||
allComponents, // 🆕 같은 화면의 모든 컴포넌트
|
||||
groupedData, // 🆕 부모창에서 전달된 그룹 데이터
|
||||
...props
|
||||
}) => {
|
||||
const { isPreviewMode } = useScreenPreview(); // 프리뷰 모드 확인
|
||||
|
|
@ -807,9 +811,23 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
|||
return;
|
||||
}
|
||||
|
||||
// 🆕 modalDataStore에서 선택된 데이터 가져오기 (분할 패널 등에서 선택한 데이터)
|
||||
// 🆕 선택된 데이터 우선순위:
|
||||
// 1. selectedRowsData (테이블에서 직접 선택)
|
||||
// 2. groupedData (부모창에서 모달로 전달된 데이터)
|
||||
// 3. modalDataStore (분할 패널 등에서 선택한 데이터)
|
||||
let effectiveSelectedRowsData = selectedRowsData;
|
||||
if ((!selectedRowsData || selectedRowsData.length === 0) && effectiveTableName) {
|
||||
|
||||
// groupedData가 있으면 우선 사용 (모달에서 부모 데이터 접근)
|
||||
if ((!effectiveSelectedRowsData || effectiveSelectedRowsData.length === 0) && groupedData && groupedData.length > 0) {
|
||||
effectiveSelectedRowsData = groupedData;
|
||||
console.log("🔗 [ButtonPrimaryComponent] groupedData에서 부모창 데이터 가져옴:", {
|
||||
count: groupedData.length,
|
||||
data: groupedData,
|
||||
});
|
||||
}
|
||||
|
||||
// modalDataStore에서 선택된 데이터 가져오기 (분할 패널 등에서 선택한 데이터)
|
||||
if ((!effectiveSelectedRowsData || effectiveSelectedRowsData.length === 0) && effectiveTableName) {
|
||||
try {
|
||||
const { useModalDataStore } = await import("@/stores/modalDataStore");
|
||||
const dataRegistry = useModalDataStore.getState().dataRegistry;
|
||||
|
|
|
|||
|
|
@ -2460,18 +2460,22 @@ export class ButtonActionExecutor {
|
|||
break;
|
||||
|
||||
case "both":
|
||||
// 폼 + 테이블 선택
|
||||
sourceData = [];
|
||||
if (context.formData && Object.keys(context.formData).length > 0) {
|
||||
sourceData.push(context.formData);
|
||||
}
|
||||
// 폼 + 테이블 선택 (데이터 병합)
|
||||
// 🔥 각 selectedRowsData 항목에 formData를 병합하여 전달
|
||||
// 이렇게 해야 메일 발송 시 부모 데이터(상품명 등)와 폼 데이터(수신자 등)가 모두 변수로 사용 가능
|
||||
if (context.selectedRowsData && context.selectedRowsData.length > 0) {
|
||||
sourceData.push(...context.selectedRowsData);
|
||||
sourceData = context.selectedRowsData.map((row: any) => ({
|
||||
...row,
|
||||
...(context.formData || {}),
|
||||
}));
|
||||
console.log("🔀 폼 + 테이블 선택 데이터 병합:", {
|
||||
dataCount: sourceData.length,
|
||||
sourceData,
|
||||
});
|
||||
} else if (context.formData && Object.keys(context.formData).length > 0) {
|
||||
sourceData = [context.formData];
|
||||
console.log("🔀 폼 데이터만 사용 (선택된 행 없음):", sourceData);
|
||||
}
|
||||
console.log("🔀 폼 + 테이블 선택 데이터 사용:", {
|
||||
dataCount: sourceData.length,
|
||||
sourceData,
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -2481,9 +2485,23 @@ export class ButtonActionExecutor {
|
|||
dataSourceType = "flow-selection";
|
||||
console.log("🌊 [자동] 플로우 선택 데이터 사용");
|
||||
} else if (context.selectedRowsData && context.selectedRowsData.length > 0) {
|
||||
sourceData = context.selectedRowsData;
|
||||
dataSourceType = "table-selection";
|
||||
console.log("📊 [자동] 테이블 선택 데이터 사용");
|
||||
// 🔥 selectedRowsData가 있으면 formData도 함께 병합
|
||||
// 모달에서 부모 데이터(selectedRowsData)와 폼 입력(formData)을 모두 사용할 수 있도록
|
||||
if (context.formData && Object.keys(context.formData).length > 0) {
|
||||
sourceData = context.selectedRowsData.map((row: any) => ({
|
||||
...row,
|
||||
...context.formData,
|
||||
}));
|
||||
dataSourceType = "both";
|
||||
console.log("📊 [자동] 테이블 선택 + 폼 데이터 병합 사용:", {
|
||||
rowCount: context.selectedRowsData.length,
|
||||
formDataKeys: Object.keys(context.formData),
|
||||
});
|
||||
} else {
|
||||
sourceData = context.selectedRowsData;
|
||||
dataSourceType = "table-selection";
|
||||
console.log("📊 [자동] 테이블 선택 데이터 사용");
|
||||
}
|
||||
} else if (context.formData && Object.keys(context.formData).length > 0) {
|
||||
sourceData = [context.formData];
|
||||
dataSourceType = "form";
|
||||
|
|
|
|||
Loading…
Reference in New Issue