견적서 담당자/연락처 자동 채움 (wace estimateTemplate1.jsp ready 1:1)
신규 작성 시 useAuth로 로그인 사용자 정보 자동 채움:
- 담당자 = "{deptName} {userName}" (wace: connectUserDeptName + connectUserName)
- 연락처 = user.tel (wace: cell_phone || tel)
조건: templateObjid 없는 신규 작성 + 사용자가 아직 입력하지 않은 빈 값에만 채움.
기존 견적서 수정 모드는 DB 값 우선 (manager_name/manager_contact).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useParams, useSearchParams, useRouter } from "next/navigation";
|
||||
import { salesEstimateApi, EstimateTemplateItemRow } from "@/lib/api/salesEstimate";
|
||||
import { CustomerSelect } from "@/components/common/CustomerSelect";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
|
||||
// ─── 포맷 헬퍼 (wace addComma / getCurrencySymbol 1:1) ────────
|
||||
function addComma(num: number | string): string {
|
||||
@@ -67,6 +68,7 @@ export default function EstimateTemplate1Page() {
|
||||
const params = useParams<{ contractObjid: string }>();
|
||||
const searchParams = useSearchParams();
|
||||
const router = useRouter();
|
||||
const { user } = useAuth();
|
||||
|
||||
const contractObjidParam = params?.contractObjid ?? "";
|
||||
const templateObjidParam = searchParams?.get("templateObjid") ?? "";
|
||||
@@ -233,6 +235,15 @@ export default function EstimateTemplate1Page() {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [contractObjidParam, templateObjidParam]);
|
||||
|
||||
// 로그인 사용자 정보로 담당자/연락처 자동 채움 (wace estimateTemplate1.jsp:321-322)
|
||||
// — 신규 작성 시에만, 그리고 사용자가 아직 직접 입력하지 않은 경우(빈값)에만 채움
|
||||
useEffect(() => {
|
||||
if (!user) return;
|
||||
if (templateObjidParam) return; // 기존 견적서 수정 모드는 건드리지 않음
|
||||
setManagerName(prev => prev || `${user.deptName ?? ""} ${user.userName ?? ""}`.trim());
|
||||
setManagerContact(prev => prev || user.tel ?? "");
|
||||
}, [user, templateObjidParam]);
|
||||
|
||||
// ─── 저장 (wace fn_save 1:1) ─────────────────────────────────
|
||||
async function handleSave() {
|
||||
if (!contractObjid) {
|
||||
|
||||
Reference in New Issue
Block a user