회사코드 입력, 작성자 입력가능하게 수정완료

This commit is contained in:
leeheejin
2025-11-03 16:26:32 +09:00
parent 4dba7c0a16
commit 94e5a5de0b
7 changed files with 86 additions and 25 deletions

View File

@@ -284,7 +284,7 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
// 컬럼 라벨 가져오기
// ========================================
const fetchColumnLabels = async () => {
const fetchColumnLabels = useCallback(async () => {
if (!tableConfig.selectedTable) return;
try {
@@ -339,13 +339,13 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
} catch (error) {
console.error("컬럼 라벨 가져오기 실패:", error);
}
};
}, [tableConfig.selectedTable]);
// ========================================
// 테이블 라벨 가져오기
// ========================================
const fetchTableLabel = async () => {
const fetchTableLabel = useCallback(async () => {
if (!tableConfig.selectedTable) return;
try {
@@ -374,7 +374,7 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
} catch (error) {
console.error("테이블 라벨 가져오기 실패:", error);
}
};
}, [tableConfig.selectedTable]);
// ========================================
// 데이터 가져오기
@@ -930,7 +930,7 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
useEffect(() => {
fetchColumnLabels();
fetchTableLabel();
}, [tableConfig.selectedTable]);
}, [tableConfig.selectedTable, fetchColumnLabels, fetchTableLabel]);
useEffect(() => {
if (!isDesignMode && tableConfig.selectedTable) {
@@ -945,6 +945,7 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
searchTerm,
refreshKey,
isDesignMode,
fetchTableDataDebounced,
]);
useEffect(() => {

View File

@@ -203,15 +203,29 @@ export class ButtonActionExecutor {
// INSERT 처리
// 🆕 자동으로 작성자 정보 추가
const writerValue = context.userId || context.userName || "unknown";
if (!context.userId) {
throw new Error("사용자 정보를 불러올 수 없습니다. 다시 로그인해주세요.");
}
const writerValue = context.userId;
const companyCodeValue = context.companyCode || "";
console.log("👤 [buttonActions] 사용자 정보:", {
userId: context.userId,
userName: context.userName,
companyCode: context.companyCode, // ✅ 회사 코드
formDataWriter: formData.writer, // ✅ 폼에서 입력한 writer 값
formDataCompanyCode: formData.company_code, // ✅ 폼에서 입력한 company_code 값
defaultWriterValue: writerValue,
companyCodeValue, // ✅ 최종 회사 코드 값
});
const dataWithUserInfo = {
...formData,
writer: writerValue,
created_by: writerValue,
updated_by: writerValue,
company_code: companyCodeValue,
writer: formData.writer || writerValue, // ✅ 입력값 우선, 없으면 userId
created_by: writerValue, // created_by는 항상 로그인한 사람
updated_by: writerValue, // updated_by는 항상 로그인한 사람
company_code: formData.company_code || companyCodeValue, // ✅ 입력값 우선, 없으면 user.companyCode
};
saveResult = await DynamicFormApi.saveFormData({