Merge pull request 'hjjeong' (#6) from hjjeong into main
Reviewed-on: https://g.wace.me/chpark/vexplor_rps/pulls/6
This commit is contained in:
@@ -376,6 +376,8 @@ export class AuthController {
|
||||
userType: userInfo.userType || dbUserInfo.userType || "USER", // JWT 토큰 우선
|
||||
userTypeName: dbUserInfo.userTypeName || "일반사용자",
|
||||
email: dbUserInfo.email || "",
|
||||
tel: dbUserInfo.tel || "",
|
||||
cellPhone: dbUserInfo.cellPhone || "",
|
||||
photo: dbUserInfo.photo,
|
||||
locale: dbUserInfo.locale || "KR", // locale 정보 추가
|
||||
deptCode: dbUserInfo.deptCode, // 추가 필드
|
||||
|
||||
@@ -96,3 +96,52 @@ export async function sendMail(req: AuthenticatedRequest, res: Response) {
|
||||
return res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
// G5 견적작성 — estimate_template
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
|
||||
export async function saveTemplate1(req: AuthenticatedRequest, res: Response) {
|
||||
try {
|
||||
const userId = req.user!.userId;
|
||||
const data = await salesEstimateService.saveEstimateTemplate1(userId, req.body);
|
||||
return res.json({ success: true, data, message: "견적서가 저장되었습니다." });
|
||||
} catch (error: any) {
|
||||
logger.error("견적작성(일반) 저장 실패", { error: error.message });
|
||||
return res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveTemplate2(req: AuthenticatedRequest, res: Response) {
|
||||
try {
|
||||
const userId = req.user!.userId;
|
||||
const data = await salesEstimateService.saveEstimateTemplate2(userId, req.body);
|
||||
return res.json({ success: true, data, message: "견적서가 저장되었습니다." });
|
||||
} catch (error: any) {
|
||||
logger.error("견적작성(장비) 저장 실패", { error: error.message });
|
||||
return res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTemplate(req: AuthenticatedRequest, res: Response) {
|
||||
try {
|
||||
const { templateObjid } = req.params;
|
||||
const data = await salesEstimateService.getTemplateById(templateObjid);
|
||||
if (!data) return res.status(404).json({ success: false, message: "견적서를 찾을 수 없습니다." });
|
||||
return res.json({ success: true, data });
|
||||
} catch (error: any) {
|
||||
logger.error("견적작성 단건 조회 실패", { error: error.message });
|
||||
return res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
export async function listTemplates(req: AuthenticatedRequest, res: Response) {
|
||||
try {
|
||||
const { contractObjid } = req.params;
|
||||
const data = await salesEstimateService.listTemplatesByContract(contractObjid);
|
||||
return res.json({ success: true, data });
|
||||
} catch (error: any) {
|
||||
logger.error("견적 차수 리스트 조회 실패", { error: error.message });
|
||||
return res.status(500).json({ success: false, message: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,13 @@ router.use(authenticateToken);
|
||||
router.get("/list", salesEstimateController.getList);
|
||||
router.get("/generate-number", salesEstimateController.generateNumber);
|
||||
router.post("/mail", salesEstimateController.sendMail);
|
||||
|
||||
// G5 견적작성 (estimate_template) — /:id 라우트보다 위에
|
||||
router.post("/template1", salesEstimateController.saveTemplate1);
|
||||
router.post("/template2", salesEstimateController.saveTemplate2);
|
||||
router.get("/template/:templateObjid", salesEstimateController.getTemplate);
|
||||
router.get("/templates/:contractObjid", salesEstimateController.listTemplates);
|
||||
|
||||
router.get("/:id", salesEstimateController.getById);
|
||||
router.post("/", salesEstimateController.create);
|
||||
router.put("/:id", salesEstimateController.update);
|
||||
|
||||
@@ -626,3 +626,326 @@ export async function remove(objid: string) {
|
||||
client.release();
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// G5 견적작성 (estimate_template / estimate_template_item)
|
||||
// ============================================================
|
||||
// wace contractMgmt.xml#insertEstimateTemplate/updateEstimateTemplate (template1=일반)
|
||||
// contractMgmt.xml#insertEstimateTemplate2/updateEstimateTemplate2 (template2=장비)
|
||||
// contractMgmt.xml#deleteEstimateTemplateItems/insertEstimateTemplateItems
|
||||
// ContractMgmtServiceImpl#saveEstimateTemplate/2 (line 1501/1591)
|
||||
//
|
||||
// 한 contract_mgmt → N estimate_template (template_objid 명시 없으면 항상 신규 차수)
|
||||
// 라인 처리: 매 저장마다 DELETE + 전체 재INSERT (wace 패턴 그대로).
|
||||
|
||||
export interface EstimateTemplateItem {
|
||||
seq?: number;
|
||||
category?: string;
|
||||
part_objid?: string;
|
||||
description?: string;
|
||||
specification?: string;
|
||||
quantity?: string;
|
||||
unit?: string;
|
||||
unit_price?: string;
|
||||
amount?: string;
|
||||
note?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
// Template1 (일반 견적서)
|
||||
export interface EstimateTemplate1Body {
|
||||
contract_objid: string;
|
||||
template_objid?: string; // 명시되고 존재하면 수정, 아니면 항상 신규 차수
|
||||
executor?: string;
|
||||
recipient?: string;
|
||||
estimate_no?: string;
|
||||
contact_person?: string;
|
||||
greeting_text?: string;
|
||||
model_name?: string;
|
||||
model_code?: string;
|
||||
executor_date?: string;
|
||||
note1?: string;
|
||||
note2?: string;
|
||||
note3?: string;
|
||||
note4?: string;
|
||||
note_remarks?: string;
|
||||
total_amount?: string;
|
||||
total_amount_krw?: string;
|
||||
manager_name?: string;
|
||||
manager_contact?: string;
|
||||
show_total_row?: "Y" | "N";
|
||||
items: EstimateTemplateItem[];
|
||||
}
|
||||
|
||||
// Template2 (장비 견적서) — categories_json 1개 + items 자동 1행
|
||||
export interface EstimateTemplate2Body {
|
||||
contract_objid: string;
|
||||
template_objid?: string;
|
||||
executor_date?: string;
|
||||
recipient?: string;
|
||||
part_name?: string;
|
||||
part_objid?: string;
|
||||
notes_content?: string;
|
||||
validity_period?: string;
|
||||
categories_json: string;
|
||||
group1_subtotal?: string;
|
||||
total_amount?: string;
|
||||
total_amount_krw?: string;
|
||||
}
|
||||
|
||||
// 라인 재구축 헬퍼 (wace deleteEstimateTemplateItems + insertEstimateTemplateItems)
|
||||
async function rebuildTemplateItems(client: any, templateObjid: string, items: EstimateTemplateItem[]) {
|
||||
await client.query(`DELETE FROM estimate_template_item WHERE template_objid=$1`, [templateObjid]);
|
||||
let seq = 1;
|
||||
for (const item of items ?? []) {
|
||||
const desc = (item.description ?? "").trim();
|
||||
if (desc === "") continue; // wace: WHERE COALESCE(item->>'description','') != ''
|
||||
await client.query(
|
||||
`INSERT INTO estimate_template_item (
|
||||
template_objid, seq, category, part_objid,
|
||||
description, specification, quantity, unit, unit_price, amount,
|
||||
note, remark
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)`,
|
||||
[
|
||||
templateObjid,
|
||||
item.seq ?? seq++,
|
||||
item.category ?? null,
|
||||
item.part_objid ?? null,
|
||||
desc,
|
||||
item.specification ?? null,
|
||||
item.quantity ?? null,
|
||||
item.unit ?? null,
|
||||
item.unit_price ?? null,
|
||||
item.amount ?? null,
|
||||
item.note ?? null,
|
||||
item.remark ?? null,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function existsTemplate(client: any, templateObjid: string): Promise<boolean> {
|
||||
const r = await client.query(`SELECT 1 FROM estimate_template WHERE objid=$1 LIMIT 1`, [templateObjid]);
|
||||
return (r.rowCount ?? 0) > 0;
|
||||
}
|
||||
|
||||
// 일반 견적서 저장 (wace saveEstimateTemplate)
|
||||
export async function saveEstimateTemplate1(userId: string, body: EstimateTemplate1Body) {
|
||||
if (!body.contract_objid) throw new Error("contract_objid is required");
|
||||
const pool = getPool();
|
||||
const client = await pool.connect();
|
||||
try {
|
||||
await client.query("BEGIN");
|
||||
|
||||
let templateObjid = body.template_objid ?? "";
|
||||
const isUpdate = templateObjid !== "" && templateObjid !== "-1" && (await existsTemplate(client, templateObjid));
|
||||
|
||||
if (isUpdate) {
|
||||
await client.query(
|
||||
`UPDATE estimate_template SET
|
||||
executor=$2, recipient=$3, estimate_no=$4, contact_person=$5,
|
||||
greeting_text=$6, model_name=$7, model_code=$8, executor_date=$9,
|
||||
note1=$10, note2=$11, note3=$12, note4=$13, note_remarks=$14,
|
||||
total_amount=$15, total_amount_krw=$16,
|
||||
manager_name=$17, manager_contact=$18, show_total_row=$19,
|
||||
chg_user_id=$20, chgdate=NOW()
|
||||
WHERE objid=$1`,
|
||||
[
|
||||
templateObjid,
|
||||
body.executor ?? null, body.recipient ?? null, body.estimate_no ?? null, body.contact_person ?? null,
|
||||
body.greeting_text ?? null, body.model_name ?? null, body.model_code ?? null, body.executor_date ?? null,
|
||||
body.note1 ?? null, body.note2 ?? null, body.note3 ?? null, body.note4 ?? null, body.note_remarks ?? null,
|
||||
body.total_amount ?? null, body.total_amount_krw ?? null,
|
||||
body.manager_name ?? null, body.manager_contact ?? null, body.show_total_row ?? "Y",
|
||||
userId,
|
||||
],
|
||||
);
|
||||
} else {
|
||||
templateObjid = genVarcharObjid("ET");
|
||||
await client.query(
|
||||
`INSERT INTO estimate_template (
|
||||
objid, contract_objid, template_type,
|
||||
executor, recipient, estimate_no, contact_person, greeting_text,
|
||||
model_name, model_code, executor_date,
|
||||
note1, note2, note3, note4, note_remarks,
|
||||
total_amount, total_amount_krw,
|
||||
manager_name, manager_contact, show_total_row,
|
||||
writer, regdate, chg_user_id, chgdate
|
||||
) VALUES (
|
||||
$1, $2, '1',
|
||||
$3, $4, $5, $6, $7,
|
||||
$8, $9, $10,
|
||||
$11, $12, $13, $14, $15,
|
||||
$16, $17,
|
||||
$18, $19, $20,
|
||||
$21, NOW(), $21, NOW()
|
||||
)`,
|
||||
[
|
||||
templateObjid, body.contract_objid,
|
||||
body.executor ?? null, body.recipient ?? null, body.estimate_no ?? null, body.contact_person ?? null, body.greeting_text ?? null,
|
||||
body.model_name ?? null, body.model_code ?? null, body.executor_date ?? null,
|
||||
body.note1 ?? null, body.note2 ?? null, body.note3 ?? null, body.note4 ?? null, body.note_remarks ?? null,
|
||||
body.total_amount ?? null, body.total_amount_krw ?? null,
|
||||
body.manager_name ?? null, body.manager_contact ?? null, body.show_total_row ?? "Y",
|
||||
userId,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
await rebuildTemplateItems(client, templateObjid, body.items ?? []);
|
||||
|
||||
await client.query("COMMIT");
|
||||
logger.info("견적작성(일반) 저장", { templateObjid, contractObjid: body.contract_objid, isUpdate, items: (body.items ?? []).length });
|
||||
return { templateObjid, isUpdate };
|
||||
} catch (error) {
|
||||
await client.query("ROLLBACK");
|
||||
throw error;
|
||||
} finally {
|
||||
client.release();
|
||||
}
|
||||
}
|
||||
|
||||
// 장비 견적서 저장 (wace saveEstimateTemplate2)
|
||||
// 헤더 + categories_json + 장비 1행 자동 라인 INSERT (cnc_machine 수량 추출은 클라이언트 책임)
|
||||
export async function saveEstimateTemplate2(userId: string, body: EstimateTemplate2Body) {
|
||||
if (!body.contract_objid && !body.template_objid) throw new Error("contract_objid or template_objid is required");
|
||||
const pool = getPool();
|
||||
const client = await pool.connect();
|
||||
try {
|
||||
await client.query("BEGIN");
|
||||
|
||||
let templateObjid = body.template_objid ?? "";
|
||||
let contractObjid = body.contract_objid;
|
||||
const isUpdate = templateObjid !== "" && templateObjid !== "-1" && (await existsTemplate(client, templateObjid));
|
||||
|
||||
if (isUpdate) {
|
||||
if (!contractObjid) {
|
||||
const r = await client.query(`SELECT contract_objid FROM estimate_template WHERE objid=$1`, [templateObjid]);
|
||||
contractObjid = r.rows[0]?.contract_objid;
|
||||
}
|
||||
await client.query(
|
||||
`UPDATE estimate_template SET
|
||||
executor_date=$2, recipient=$3, part_name=$4, part_objid=$5,
|
||||
notes_content=$6, validity_period=$7, categories_json=$8,
|
||||
group1_subtotal=$9, total_amount=$10, total_amount_krw=$11,
|
||||
chg_user_id=$12, chgdate=NOW()
|
||||
WHERE objid=$1`,
|
||||
[
|
||||
templateObjid,
|
||||
body.executor_date ?? null, body.recipient ?? null, body.part_name ?? null, body.part_objid ?? null,
|
||||
body.notes_content ?? null, body.validity_period ?? null, body.categories_json ?? null,
|
||||
body.group1_subtotal ?? null, body.total_amount ?? null, body.total_amount_krw ?? null,
|
||||
userId,
|
||||
],
|
||||
);
|
||||
} else {
|
||||
templateObjid = genVarcharObjid("ET");
|
||||
await client.query(
|
||||
`INSERT INTO estimate_template (
|
||||
objid, contract_objid, template_type,
|
||||
executor_date, recipient, part_name, part_objid,
|
||||
notes_content, validity_period, categories_json,
|
||||
group1_subtotal, total_amount, total_amount_krw,
|
||||
writer, regdate, chg_user_id, chgdate
|
||||
) VALUES (
|
||||
$1, $2, '2',
|
||||
$3, $4, $5, $6,
|
||||
$7, $8, $9,
|
||||
$10, $11, $12,
|
||||
$13, NOW(), $13, NOW()
|
||||
)`,
|
||||
[
|
||||
templateObjid, contractObjid,
|
||||
body.executor_date ?? null, body.recipient ?? null, body.part_name ?? null, body.part_objid ?? null,
|
||||
body.notes_content ?? null, body.validity_period ?? null, body.categories_json ?? null,
|
||||
body.group1_subtotal ?? null, body.total_amount ?? null, body.total_amount_krw ?? null,
|
||||
userId,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 장비 견적서는 part_name + total_amount + categories_json의 cnc_machine 수량으로 1행 라인 생성
|
||||
// (wace saveEstimateTemplate2 line 1647~)
|
||||
await client.query(`DELETE FROM estimate_template_item WHERE template_objid=$1`, [templateObjid]);
|
||||
const partName = (body.part_name ?? "").trim();
|
||||
const amountStr = (body.total_amount ?? "").toString().replace(/[^0-9.]/g, "");
|
||||
if (partName !== "" && amountStr !== "") {
|
||||
let qty = 1;
|
||||
if (body.categories_json) {
|
||||
try {
|
||||
const cats = JSON.parse(body.categories_json) as Array<any>;
|
||||
const cnc = cats.find(c => c?.category === "cnc_machine");
|
||||
const firstItem = cnc?.items?.[0];
|
||||
const qtyRaw = firstItem?.quantity;
|
||||
if (qtyRaw != null) {
|
||||
const numOnly = String(qtyRaw).split("\n")[0].replace(/[^0-9]/g, "");
|
||||
if (numOnly) qty = parseInt(numOnly, 10);
|
||||
}
|
||||
} catch {
|
||||
// categories_json 파싱 실패 시 수량 1로 폴백
|
||||
}
|
||||
}
|
||||
await client.query(
|
||||
`INSERT INTO estimate_template_item (
|
||||
template_objid, seq, category, part_objid,
|
||||
description, specification, quantity, unit, unit_price, amount,
|
||||
note, remark
|
||||
) VALUES ($1, 1, 'cnc_machine', $2, $3, NULL, $4, NULL, NULL, $5, NULL, NULL)`,
|
||||
[templateObjid, body.part_objid ?? null, partName, String(qty), amountStr],
|
||||
);
|
||||
}
|
||||
|
||||
await client.query("COMMIT");
|
||||
logger.info("견적작성(장비) 저장", { templateObjid, contractObjid, isUpdate });
|
||||
return { templateObjid, isUpdate };
|
||||
} catch (error) {
|
||||
await client.query("ROLLBACK");
|
||||
throw error;
|
||||
} finally {
|
||||
client.release();
|
||||
}
|
||||
}
|
||||
|
||||
// 단건 조회 (wace getEstimateTemplateByObjId + getEstimateTemplateItemsByTemplateObjId)
|
||||
export async function getTemplateById(templateObjid: string) {
|
||||
const pool = getPool();
|
||||
const headerRes = await pool.query(
|
||||
`SELECT ET.*,
|
||||
TO_CHAR(ET.regdate, 'YYYY-MM-DD HH24:MI') AS regdate_str,
|
||||
TO_CHAR(ET.chgdate, 'YYYY-MM-DD HH24:MI') AS chgdate_str,
|
||||
CM.exchange_rate,
|
||||
CM.contract_currency,
|
||||
CC_CUR.code_name AS contract_currency_name
|
||||
FROM estimate_template ET
|
||||
LEFT JOIN contract_mgmt CM ON CM.objid = ET.contract_objid
|
||||
LEFT JOIN comm_code CC_CUR ON CC_CUR.code_id = CM.contract_currency AND CC_CUR.status='active'
|
||||
WHERE ET.objid=$1`,
|
||||
[templateObjid],
|
||||
);
|
||||
if (headerRes.rowCount === 0) return null;
|
||||
const header = headerRes.rows[0];
|
||||
|
||||
const itemsRes = await pool.query(
|
||||
`SELECT * FROM estimate_template_item WHERE template_objid=$1 ORDER BY seq`,
|
||||
[templateObjid],
|
||||
);
|
||||
|
||||
return { ...header, items: itemsRes.rows };
|
||||
}
|
||||
|
||||
// 견적 차수 리스트 (wace estimateList.jsp fn_showEstimateList — contract_objid별 차수들)
|
||||
export async function listTemplatesByContract(contractObjid: string) {
|
||||
const pool = getPool();
|
||||
const res = await pool.query(
|
||||
`SELECT objid, template_type, estimate_no,
|
||||
recipient, total_amount, total_amount_krw,
|
||||
writer,
|
||||
TO_CHAR(regdate, 'YYYY-MM-DD HH24:MI') AS regdate,
|
||||
TO_CHAR(chgdate, 'YYYY-MM-DD HH24:MI') AS chgdate
|
||||
FROM estimate_template
|
||||
WHERE contract_objid=$1
|
||||
ORDER BY regdate DESC`,
|
||||
[contractObjid],
|
||||
);
|
||||
return res.rows;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ export interface OrderItem {
|
||||
}
|
||||
|
||||
export interface OrderBody {
|
||||
// contract_mgmt 헤더
|
||||
// contract_mgmt 헤더 (wace estimateAndOrderRegistFormPopup 직접등록 통합폼 — G2)
|
||||
objid?: string; // 신규면 자동 생성
|
||||
contract_no?: string;
|
||||
category_cd?: string;
|
||||
@@ -57,15 +57,17 @@ export interface OrderBody {
|
||||
paid_type?: string;
|
||||
contract_currency?: string;
|
||||
exchange_rate?: string;
|
||||
receipt_date?: string;
|
||||
contract_date?: string; // 발주일
|
||||
receipt_date?: string; // 접수일 *
|
||||
order_date?: string; // 발주일 * (wace G2 필수)
|
||||
req_del_date?: string; // 요청납기
|
||||
po_no?: string; // 발주번호
|
||||
contract_result?: string; // 수주상태 (예: WAITING/CONFIRMED/CANCELLED)
|
||||
contract_result?: string; // 수주상태
|
||||
approval_required?: string; // 결재여부 'Y'|'N'
|
||||
pm_user_id?: string;
|
||||
customer_request?: string;
|
||||
shipping_method?: string;
|
||||
incoterms?: string;
|
||||
is_direct_order?: string; // 'Y'면 직접등록 (견적관리 노출 X, 주문관리만 노출)
|
||||
// 라인
|
||||
items: OrderItem[];
|
||||
}
|
||||
@@ -182,6 +184,7 @@ export async function getList(filter: OrderListFilter) {
|
||||
,NULL::text AS ORDER_APPR_STATUS
|
||||
,NULL::text AS AMARANTH_STATUS
|
||||
,0 AS CU01_CNT
|
||||
,T.IS_DIRECT_ORDER AS IS_DIRECT_ORDER
|
||||
FROM contract_mgmt T
|
||||
LEFT JOIN customer_mng C
|
||||
ON C.customer_code = CASE WHEN T.CUSTOMER_OBJID LIKE 'C_%' THEN substring(T.CUSTOMER_OBJID, 3) ELSE T.CUSTOMER_OBJID END
|
||||
@@ -435,25 +438,29 @@ export async function create(userId: string, body: OrderBody) {
|
||||
return s + (isNaN(v) ? 0 : v);
|
||||
}, 0);
|
||||
|
||||
// wace G2 패턴: 주문관리 등록은 직접등록 통합폼 — is_direct_order='Y' (견적관리에 노출 X)
|
||||
const isDirectOrder = body.is_direct_order || "Y";
|
||||
|
||||
await client.query(
|
||||
`INSERT INTO contract_mgmt (
|
||||
objid, contract_no, category_cd, customer_objid, product, area_cd, paid_type,
|
||||
contract_currency, exchange_rate, receipt_date, contract_date, req_del_date,
|
||||
po_no, contract_result, pm_user_id, customer_request, shipping_method, incoterms,
|
||||
contract_currency, exchange_rate, receipt_date, order_date, req_del_date,
|
||||
po_no, contract_result, approval_required, pm_user_id, customer_request,
|
||||
shipping_method, incoterms, is_direct_order,
|
||||
order_supply_price, order_vat, order_total_amount,
|
||||
writer, regdate
|
||||
) VALUES (
|
||||
$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,
|
||||
$19,$20,$21,$22,NOW()
|
||||
$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,
|
||||
$21,$22,$23,$24,NOW()
|
||||
)`,
|
||||
[
|
||||
objid, contractNo, body.category_cd || null, body.customer_objid || null,
|
||||
body.product || null, body.area_cd || null, body.paid_type || null,
|
||||
body.contract_currency || null, body.exchange_rate || null,
|
||||
body.receipt_date || null, body.contract_date || null, body.req_del_date || null,
|
||||
body.po_no || null, body.contract_result || null,
|
||||
body.receipt_date || null, body.order_date || null, body.req_del_date || null,
|
||||
body.po_no || null, body.contract_result || null, body.approval_required || "N",
|
||||
body.pm_user_id || null, body.customer_request || null,
|
||||
body.shipping_method || null, body.incoterms || null,
|
||||
body.shipping_method || null, body.incoterms || null, isDirectOrder,
|
||||
String(sum("order_supply_price")), String(sum("order_vat")), String(sum("order_total_amount")),
|
||||
userId,
|
||||
],
|
||||
@@ -484,18 +491,18 @@ export async function update(userId: string, objid: string, body: OrderBody) {
|
||||
await client.query(
|
||||
`UPDATE contract_mgmt SET
|
||||
category_cd=$2, customer_objid=$3, product=$4, area_cd=$5, paid_type=$6,
|
||||
contract_currency=$7, exchange_rate=$8, receipt_date=$9, contract_date=$10,
|
||||
req_del_date=$11, po_no=$12, contract_result=$13, pm_user_id=$14,
|
||||
customer_request=$15, shipping_method=$16, incoterms=$17,
|
||||
order_supply_price=$18, order_vat=$19, order_total_amount=$20,
|
||||
chg_user_id=$21
|
||||
contract_currency=$7, exchange_rate=$8, receipt_date=$9, order_date=$10,
|
||||
req_del_date=$11, po_no=$12, contract_result=$13, approval_required=$14, pm_user_id=$15,
|
||||
customer_request=$16, shipping_method=$17, incoterms=$18,
|
||||
order_supply_price=$19, order_vat=$20, order_total_amount=$21,
|
||||
chg_user_id=$22
|
||||
WHERE objid=$1`,
|
||||
[
|
||||
objid, body.category_cd || null, body.customer_objid || null,
|
||||
body.product || null, body.area_cd || null, body.paid_type || null,
|
||||
body.contract_currency || null, body.exchange_rate || null,
|
||||
body.receipt_date || null, body.contract_date || null, body.req_del_date || null,
|
||||
body.po_no || null, body.contract_result || null,
|
||||
body.receipt_date || null, body.order_date || null, body.req_del_date || null,
|
||||
body.po_no || null, body.contract_result || null, body.approval_required || "N",
|
||||
body.pm_user_id || null, body.customer_request || null,
|
||||
body.shipping_method || null, body.incoterms || null,
|
||||
String(sum("order_supply_price")), String(sum("order_vat")), String(sum("order_total_amount")),
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# 05. PR-B G2 — 주문관리 직접등록 통합폼 (`is_direct_order='Y'`)
|
||||
|
||||
> 작성: 2026-05-11
|
||||
> 원본: `wace_plm/WebContent/WEB-INF/view/contractMgmt/estimateAndOrderRegistFormPopup.jsp` + `ContractMgmtService.saveEstimateAndOrderInfo` (라인 2664~)
|
||||
> 대상: `app/(main)/COMPANY_16/sales/order/page.tsx` "수주입력" 다이얼로그 + `POST /api/sales/order-mgmt`
|
||||
|
||||
## 1. wace 패턴
|
||||
|
||||
견적 없이 주문을 바로 등록하는 통합폼. 핵심 차이:
|
||||
- `contract_mgmt.is_direct_order = 'Y'` 강제 (견적관리 그리드 노출 X — 견적관리 SQL이 `IS_DIRECT_ORDER != 'Y'` 필터)
|
||||
- 주문관리 그리드엔 노출
|
||||
- 헤더에 발주일(`order_date`) / 발주번호(`po_no`) 추가
|
||||
- 라인에 `ORDER_*` 컬럼 (수주수량/단가/공급가액/부가세/총액) 입력
|
||||
- 라인의 `quantity = order_quantity` 미러링 (wace 통합폼은 견적수량 별도 입력 X)
|
||||
|
||||
## 2. 운영 데이터 검증
|
||||
|
||||
```
|
||||
contract_mgmt 90건 중 is_direct_order='Y' = 74건 (82%)
|
||||
```
|
||||
|
||||
→ 운영 주문은 절대다수가 직접등록 통합폼으로 작성. G2가 주문 신규 등록의 기본 흐름.
|
||||
|
||||
## 3. RPS 변경
|
||||
|
||||
### 백엔드 [salesOrderMgmtService.ts]
|
||||
- `OrderBody` 타입: `order_date` / `approval_required` / `is_direct_order` 추가, `contract_date` 폐지 (운영 컬럼은 `order_date`)
|
||||
- `create()`: INSERT에 `is_direct_order` (default 'Y') / `order_date` / `approval_required` 추가
|
||||
- `update()`: 동일 컬럼 UPDATE
|
||||
- `upsertItems`: 기존 `ORDER_*` 처리 그대로 (이미 G2 호환)
|
||||
|
||||
### 프론트 [order/page.tsx] + [salesOrderMgmt.ts]
|
||||
- `OrderBody`: `order_date`/`approval_required`/`is_direct_order` 보강, `contract_date` 폐지
|
||||
- `openCreate()`: `order_date = today` + `is_direct_order = 'Y'` 기본값
|
||||
- `openEdit()`: `order_date`/`approval_required`/`is_direct_order` detail에서 복원
|
||||
- 폼 다이얼로그: "발주일" 입력을 `order_date` 바인딩 (이전 `contract_date` 잘못 바인딩 정정)
|
||||
|
||||
## 4. 자동 검증 결과 (BEGIN/ROLLBACK)
|
||||
|
||||
| 항목 | 결과 |
|
||||
|---|---|
|
||||
| `is_direct_order='Y'` INSERT | ✅ |
|
||||
| `order_date` 컬럼에 저장 | ✅ (`2026-05-11`) |
|
||||
| `ORDER_*` 라인 컬럼 (qty/unit_price/total_amount) | ✅ |
|
||||
| 견적관리 노출 차단 (필터 `is_direct_order != 'Y'`) | ✅ (0 rows) |
|
||||
| 주문관리 노출 | ✅ (1 row) |
|
||||
|
||||
## 5. 결론
|
||||
|
||||
기존 RPS `create/update`가 거의 G2 호환이라 신규 endpoint 없이 컬럼 보강(is_direct_order/order_date/approval_required)으로 처리. 분리 endpoint 불필요.
|
||||
|
||||
다음 단계: G5 견적작성 PDF 또는 G4 결재 모듈.
|
||||
@@ -142,6 +142,44 @@ export default function SalesEstimatePage() {
|
||||
});
|
||||
|
||||
// 첨부파일 다이얼로그 (추가견적 클립 컬럼 클릭 시)
|
||||
// G5 견적작성 — 일반/장비 선택 다이얼로그
|
||||
const [templateChoiceOpen, setTemplateChoiceOpen] = useState(false);
|
||||
// 견적 차수 리스트 다이얼로그 (est_status folder 클릭)
|
||||
const [templateListOpen, setTemplateListOpen] = useState(false);
|
||||
const [templateList, setTemplateList] = useState<any[]>([]);
|
||||
|
||||
function openTemplateChoice() {
|
||||
if (!selected) { toast.warning("견적을 선택하세요."); return; }
|
||||
setTemplateChoiceOpen(true);
|
||||
}
|
||||
|
||||
function pickTemplate(templateType: "1" | "2") {
|
||||
if (!selected) return;
|
||||
setTemplateChoiceOpen(false);
|
||||
const url = `/COMPANY_16/sales/estimate/template${templateType}/pop/${encodeURIComponent(selected.objid)}`;
|
||||
window.open(url, `estimateTemplate_${selected.objid}_${templateType}`,
|
||||
"width=1280,height=900,menubar=no,scrollbars=yes,resizable=yes");
|
||||
}
|
||||
|
||||
async function openTemplateList(contractObjid: string) {
|
||||
try {
|
||||
const list = await salesEstimateApi.listTemplates(contractObjid);
|
||||
setTemplateList(list);
|
||||
setTemplateListOpen(true);
|
||||
} catch (e: any) {
|
||||
toast.error("견적 차수 리스트 조회 실패: " + (e?.message ?? ""));
|
||||
}
|
||||
}
|
||||
|
||||
function openExistingTemplate(templateObjid: string, templateType: string) {
|
||||
const t = templateType === "2" ? "2" : "1";
|
||||
const contractObjid = selected?.objid ?? "";
|
||||
const url = `/COMPANY_16/sales/estimate/template${t}/pop/${encodeURIComponent(contractObjid)}?templateObjid=${encodeURIComponent(templateObjid)}`;
|
||||
window.open(url, `estimateTemplate_${templateObjid}`,
|
||||
"width=1280,height=900,menubar=no,scrollbars=yes,resizable=yes");
|
||||
setTemplateListOpen(false);
|
||||
}
|
||||
|
||||
const [attachDialogOpen, setAttachDialogOpen] = useState(false);
|
||||
const [attachContext, setAttachContext] = useState<{
|
||||
targetObjid: string;
|
||||
@@ -169,6 +207,17 @@ export default function SalesEstimatePage() {
|
||||
},
|
||||
};
|
||||
}
|
||||
// G5: 견적현황(폴더 아이콘) 클릭 시 차수 리스트 다이얼로그 (wace fn_showEstimateList)
|
||||
if (col.key === "est_status") {
|
||||
return {
|
||||
...col,
|
||||
onClick: (row) => {
|
||||
if (!row.est_status || Number(row.est_status) === 0) return;
|
||||
setSelected(row as EstimateRow);
|
||||
openTemplateList(String(row.objid));
|
||||
},
|
||||
};
|
||||
}
|
||||
return col;
|
||||
}),
|
||||
[]
|
||||
@@ -460,7 +509,7 @@ export default function SalesEstimatePage() {
|
||||
{selected ? <Pencil className="w-4 h-4 mr-1" /> : <Plus className="w-4 h-4 mr-1" />}
|
||||
{selected ? "견적요청수정" : "견적요청등록"}
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={openEdit} disabled={!selected}>
|
||||
<Button size="sm" variant="outline" onClick={openTemplateChoice} disabled={!selected}>
|
||||
<Pencil className="w-4 h-4 mr-1" />견적작성
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" disabled={!selected}
|
||||
@@ -567,7 +616,10 @@ export default function SalesEstimatePage() {
|
||||
|
||||
{/* 등록/수정 Dialog */}
|
||||
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||
<DialogContent className="!max-w-[95vw] w-[95vw] max-h-[92vh] overflow-y-auto">
|
||||
<DialogContent
|
||||
className="!max-w-[95vw] w-[95vw] max-h-[92vh] overflow-y-auto"
|
||||
onInteractOutside={(e) => e.preventDefault()} /* 자식 S/N·연속번호 Dialog 닫힐 때 부모까지 닫히는 현상 차단 */
|
||||
>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{dialogMode === "create" ? "견적 등록" : "견적 수정"}</DialogTitle>
|
||||
<DialogDescription>
|
||||
@@ -835,6 +887,60 @@ export default function SalesEstimatePage() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* G5: 견적작성 — 일반/장비 선택 (wace estimateList_new.jsp Swal 105~106) */}
|
||||
<Dialog open={templateChoiceOpen} onOpenChange={setTemplateChoiceOpen}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>견적서 작성</DialogTitle>
|
||||
<DialogDescription>작성할 견적서 종류를 선택하세요.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="flex gap-3 justify-center py-4">
|
||||
<Button variant="default" size="lg" onClick={() => pickTemplate("1")}>일반 견적서</Button>
|
||||
<Button size="lg" onClick={() => pickTemplate("2")} style={{ backgroundColor: "#28a745" }}>장비 견적서</Button>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* G5: 견적 차수 리스트 (wace fn_showEstimateList) */}
|
||||
<Dialog open={templateListOpen} onOpenChange={setTemplateListOpen}>
|
||||
<DialogContent className="sm:max-w-2xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>견적 차수 리스트 — {selected?.contract_no ?? ""}</DialogTitle>
|
||||
<DialogDescription>차수를 선택하면 해당 견적서를 새 창으로 엽니다.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="max-h-[60vh] overflow-y-auto">
|
||||
<table className="w-full text-sm border-collapse">
|
||||
<thead>
|
||||
<tr className="bg-muted">
|
||||
<th className="border px-2 py-1.5 text-center w-[60px]">차수</th>
|
||||
<th className="border px-2 py-1.5 text-center w-[80px]">종류</th>
|
||||
<th className="border px-2 py-1.5">견적번호</th>
|
||||
<th className="border px-2 py-1.5 text-right w-[120px]">공급가액</th>
|
||||
<th className="border px-2 py-1.5 text-center w-[140px]">작성일시</th>
|
||||
<th className="border px-2 py-1.5 text-center w-[80px]">작성자</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{templateList.length === 0 ? (
|
||||
<tr><td colSpan={6} className="text-center py-6 text-muted-foreground">등록된 견적서가 없습니다.</td></tr>
|
||||
) : templateList.map((t, i) => (
|
||||
<tr key={t.objid}
|
||||
className="cursor-pointer hover:bg-accent"
|
||||
onClick={() => openExistingTemplate(t.objid, t.template_type)}>
|
||||
<td className="border px-2 py-1.5 text-center">{templateList.length - i}차</td>
|
||||
<td className="border px-2 py-1.5 text-center">{t.template_type === "2" ? "장비" : "일반"}</td>
|
||||
<td className="border px-2 py-1.5">{t.estimate_no ?? ""}</td>
|
||||
<td className="border px-2 py-1.5 text-right">{t.total_amount ? Number(String(t.total_amount).replace(/,/g, "")).toLocaleString() : ""}</td>
|
||||
<td className="border px-2 py-1.5 text-center">{t.regdate ?? ""}</td>
|
||||
<td className="border px-2 py-1.5 text-center">{t.writer ?? ""}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* 품목 검색 — 라인 클릭 시 해당 라인에 part_objid/part_no/part_name 채움 (단일 선택) */}
|
||||
<ItemSearchDialog
|
||||
open={itemDialogOpen}
|
||||
@@ -873,7 +979,7 @@ export default function SalesEstimatePage() {
|
||||
|
||||
{/* S/N 관리 — wace fn_openItemSnPopup (테이블 + 연속번호생성) */}
|
||||
<Dialog open={serialDialogOpen} onOpenChange={setSerialDialogOpen}>
|
||||
<DialogContent className="max-w-2xl">
|
||||
<DialogContent className="max-w-2xl" onInteractOutside={(e) => e.preventDefault()}>
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-center">S/N 관리</DialogTitle>
|
||||
<DialogDescription className="sr-only">시리얼 번호 추가/삭제 및 연속번호 생성</DialogDescription>
|
||||
@@ -922,7 +1028,7 @@ export default function SalesEstimatePage() {
|
||||
|
||||
{/* 연속번호 생성 — wace fn_openItemSequentialSnPopup */}
|
||||
<Dialog open={seqDialogOpen} onOpenChange={setSeqDialogOpen}>
|
||||
<DialogContent className="max-w-sm">
|
||||
<DialogContent className="max-w-sm" onInteractOutside={(e) => e.preventDefault()}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>연속번호 생성</DialogTitle>
|
||||
<DialogDescription className="sr-only">시작번호와 생성개수로 연속 S/N 일괄 추가</DialogDescription>
|
||||
|
||||
@@ -0,0 +1,760 @@
|
||||
"use client";
|
||||
|
||||
// ============================================================
|
||||
// 영업관리 > 견적관리 > 견적작성(일반)
|
||||
// wace estimateTemplate1.jsp 1:1 이식 (template_type='1')
|
||||
// 진입: 견적관리 그리드 행 선택 → "견적작성" → "일반 견적서"
|
||||
// ============================================================
|
||||
|
||||
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 {
|
||||
if (num === "" || num == null) return "";
|
||||
const n = Number(String(num).replace(/,/g, ""));
|
||||
if (Number.isNaN(n)) return "";
|
||||
return n.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||
}
|
||||
|
||||
function getCurrencySymbol(currencyName: string): string {
|
||||
const c = currencyName ?? "";
|
||||
if (c.indexOf("달러") >= 0 || c === "USD") return "$";
|
||||
if (c.indexOf("유로") >= 0 || c === "EUR") return "€";
|
||||
if (c.indexOf("엔") >= 0 || c === "JPY") return "¥";
|
||||
if (c.indexOf("위안") >= 0 || c === "CNY") return "¥";
|
||||
return "₩";
|
||||
}
|
||||
|
||||
// 단가 입력 시 실시간 콤마 처리 (wace input 이벤트 1:1)
|
||||
function formatPriceInput(raw: string): string {
|
||||
const cleaned = raw.replace(/,/g, "").replace(/[^0-9.]/g, "");
|
||||
if (cleaned === "") return "";
|
||||
return addComma(cleaned);
|
||||
}
|
||||
|
||||
// 라인 1행 상태
|
||||
interface ItemRow {
|
||||
rowId: string; // React key 용 클라이언트 ID
|
||||
partObjid: string;
|
||||
description: string; // 품명 (readonly)
|
||||
specification: string;
|
||||
quantity: string; // 숫자만 (콤마 없음)
|
||||
unit: string;
|
||||
unitPrice: string; // 표시용 (콤마 포함)
|
||||
amount: string; // 표시용 (통화기호 + 콤마)
|
||||
note: string;
|
||||
}
|
||||
|
||||
function emptyRow(): ItemRow {
|
||||
return {
|
||||
rowId: `r_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
||||
partObjid: "",
|
||||
description: "",
|
||||
specification: "",
|
||||
quantity: "",
|
||||
unit: "EA",
|
||||
unitPrice: "",
|
||||
amount: "",
|
||||
note: "",
|
||||
};
|
||||
}
|
||||
|
||||
// ─── 페이지 ──────────────────────────────────────────────────
|
||||
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") ?? "";
|
||||
|
||||
// 환율/통화 (영업 정보에서 로드)
|
||||
const [exchangeRate, setExchangeRate] = useState<number>(1);
|
||||
const [currencyName, setCurrencyName] = useState<string>("KRW");
|
||||
const currencySymbol = getCurrencySymbol(currencyName);
|
||||
|
||||
// 헤더 필드
|
||||
const [executor, setExecutor] = useState<string>(""); // 시행일자 (YYYY-MM-DD)
|
||||
const executorDateRef = useRef<HTMLInputElement>(null);
|
||||
const [recipient, setRecipient] = useState<string>(""); // 수신처 (customer_objid)
|
||||
const [estimateNo, setEstimateNo] = useState<string>("");
|
||||
const [contactPerson, setContactPerson] = useState<string>("");
|
||||
const [greetingText, setGreetingText] = useState<string>(
|
||||
"견적을 요청해 주셔서 대단히 감사합니다.\n하기와 같이 견적서를 제출합니다.",
|
||||
);
|
||||
const [managerName, setManagerName] = useState<string>("");
|
||||
const [managerContact, setManagerContact] = useState<string>("");
|
||||
const [noteRemarks, setNoteRemarks] = useState<string>("");
|
||||
const [note1, setNote1] = useState<string>("1. 견적유효기간: 일");
|
||||
const [note2, setNote2] = useState<string>("2. 납품기간: 발주 후 1주 이내");
|
||||
const [note3, setNote3] = useState<string>("3. VAT 별도");
|
||||
const [note4, setNote4] = useState<string>("4. 결제 조건 : 기존 결제조건에 따름.");
|
||||
const [showTotalRow, setShowTotalRow] = useState<boolean>(true);
|
||||
|
||||
// 결재상태 (운영 amaranth_approval 없으면 '작성중'으로 폴백)
|
||||
const [apprStatus, setApprStatus] = useState<string>("작성중");
|
||||
const readOnly = apprStatus === "결재완료" || apprStatus === "결재중";
|
||||
|
||||
// 라인
|
||||
const [items, setItems] = useState<ItemRow[]>([emptyRow(), emptyRow()]);
|
||||
|
||||
// 수정 모드용 templateObjid (저장 후 갱신)
|
||||
const [templateObjid, setTemplateObjid] = useState<string>(templateObjidParam);
|
||||
|
||||
// 데이터 로드 완료 플래그
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [contractObjid, setContractObjid] = useState<string>(contractObjidParam);
|
||||
|
||||
// ─── 합계 계산 (items 또는 환율 변경 시) ──────────────────────
|
||||
const { totalAmountNum, totalAmountKrwNum } = useMemo(() => {
|
||||
const total = items.reduce((sum, r) => {
|
||||
const a = parseFloat((r.amount ?? "").replace(/[^0-9.]/g, "")) || 0;
|
||||
return sum + a;
|
||||
}, 0);
|
||||
return { totalAmountNum: total, totalAmountKrwNum: total * (exchangeRate || 1) };
|
||||
}, [items, exchangeRate]);
|
||||
const totalAmountStr = `${currencySymbol}${addComma(totalAmountNum)}`;
|
||||
const totalAmountKrwStr = `₩${addComma(totalAmountKrwNum)}`;
|
||||
|
||||
// ─── 라인 수정 핸들러 ─────────────────────────────────────────
|
||||
function updateItem(idx: number, patch: Partial<ItemRow>) {
|
||||
setItems(prev => {
|
||||
const next = [...prev];
|
||||
const cur = { ...next[idx], ...patch };
|
||||
// 수량/단가 변경 시 금액 자동 계산 (wace fn_calculateAmount)
|
||||
if (patch.quantity != null || patch.unitPrice != null) {
|
||||
const qty = parseFloat((cur.quantity ?? "").replace(/,/g, "")) || 0;
|
||||
const price = parseFloat((cur.unitPrice ?? "").replace(/,/g, "")) || 0;
|
||||
const amt = qty * price;
|
||||
cur.amount = Number.isFinite(amt) && amt !== 0 ? `${currencySymbol}${addComma(amt)}` : "";
|
||||
}
|
||||
next[idx] = cur;
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
function addItemRow() {
|
||||
setItems(prev => [...prev, emptyRow()]);
|
||||
}
|
||||
|
||||
function removeItemRow(idx: number) {
|
||||
setItems(prev => prev.filter((_, i) => i !== idx));
|
||||
}
|
||||
|
||||
// ─── 데이터 로드 ────────────────────────────────────────────
|
||||
useEffect(() => {
|
||||
let cancel = false;
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
// 1) 영업 정보 로드 (헤더의 customer_objid, 통화, 환율, contract_item 라인)
|
||||
let contractInfo: any = null;
|
||||
if (contractObjidParam) {
|
||||
try {
|
||||
contractInfo = await salesEstimateApi.detail(contractObjidParam);
|
||||
} catch (e) {
|
||||
console.warn("영업정보 로드 실패", e);
|
||||
}
|
||||
}
|
||||
|
||||
// getById 응답: { ...contract_mgmt 헤더 필드들, items: [...] } (평면 구조)
|
||||
if (contractInfo && !cancel) {
|
||||
setExchangeRate(parseFloat(contractInfo.exchange_rate || "1") || 1);
|
||||
setCurrencyName(contractInfo.contract_currency_name || contractInfo.contract_currency || "KRW");
|
||||
// 수신처는 customer_objid (예: 'C_RPS001') — 견적요청의 고객사를 견적서에 자동 채움
|
||||
if (contractInfo.customer_objid) setRecipient(contractInfo.customer_objid);
|
||||
}
|
||||
|
||||
// 2) 기존 견적 차수 수정 (templateObjid 지정) — 우선
|
||||
if (templateObjidParam) {
|
||||
const tpl = await salesEstimateApi.getTemplate(templateObjidParam);
|
||||
if (tpl && !cancel) {
|
||||
if (tpl.contract_objid) setContractObjid(tpl.contract_objid);
|
||||
setExchangeRate(parseFloat(tpl.exchange_rate || "1") || 1);
|
||||
setCurrencyName(tpl.contract_currency_name || tpl.contract_currency || "KRW");
|
||||
setExecutor(tpl.executor ?? "");
|
||||
if (tpl.recipient) setRecipient(tpl.recipient);
|
||||
setEstimateNo(tpl.estimate_no ?? "");
|
||||
setContactPerson(tpl.contact_person ?? "");
|
||||
if (tpl.greeting_text) setGreetingText(tpl.greeting_text);
|
||||
if (tpl.manager_name) setManagerName(tpl.manager_name);
|
||||
if (tpl.manager_contact) setManagerContact(tpl.manager_contact);
|
||||
setNoteRemarks(tpl.note_remarks ?? "");
|
||||
if (tpl.note1) setNote1(tpl.note1);
|
||||
if (tpl.note2) setNote2(tpl.note2);
|
||||
if (tpl.note3) setNote3(tpl.note3);
|
||||
if (tpl.note4) setNote4(tpl.note4);
|
||||
setShowTotalRow((tpl.show_total_row ?? "Y") !== "N");
|
||||
|
||||
const loaded: ItemRow[] = (tpl.items ?? []).map(it => ({
|
||||
rowId: `t_${(it as any).objid ?? Math.random().toString(36).slice(2, 8)}`,
|
||||
partObjid: it.part_objid ?? "",
|
||||
description: it.description ?? "",
|
||||
specification: it.specification ?? "",
|
||||
quantity: (it.quantity ?? "").toString(),
|
||||
unit: it.unit ?? "EA",
|
||||
unitPrice: it.unit_price ? addComma(it.unit_price) : "",
|
||||
amount: it.amount
|
||||
? `${getCurrencySymbol(tpl.contract_currency_name || tpl.contract_currency || "KRW")}${addComma(it.amount)}`
|
||||
: "",
|
||||
note: it.note ?? "",
|
||||
}));
|
||||
if (loaded.length > 0) setItems(loaded);
|
||||
}
|
||||
} else if (contractInfo?.items?.length) {
|
||||
// 3) 신규 작성: 영업정보의 contract_item 품목을 기본 라인으로 깔아줌 (wace fn_loadContractItems)
|
||||
const loaded: ItemRow[] = contractInfo.items.map((it: any) => ({
|
||||
rowId: `c_${it.objid ?? Math.random().toString(36).slice(2, 8)}`,
|
||||
partObjid: it.part_objid ?? "",
|
||||
description: it.master_part_name ?? it.part_name ?? "",
|
||||
specification: "",
|
||||
quantity: (it.quantity ?? "").toString(),
|
||||
unit: "EA",
|
||||
unitPrice: "",
|
||||
amount: "",
|
||||
note: "",
|
||||
}));
|
||||
if (!cancel && loaded.length > 0) setItems(loaded);
|
||||
}
|
||||
|
||||
// 4) 로그인 사용자 정보 — 담당자 이름/연락처 자동 채움 (기존 값 없을 때만)
|
||||
// (백엔드에 별도 user 조회 API가 있으면 사용; 일단 비워두고 수동 입력 허용)
|
||||
} finally {
|
||||
if (!cancel) setLoading(false);
|
||||
}
|
||||
})();
|
||||
|
||||
return () => { cancel = true; };
|
||||
// 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());
|
||||
// wace MailUtil 패턴: cell_phone 우선, 없으면 tel
|
||||
setManagerContact(prev => prev || user.cellPhone || user.tel || "");
|
||||
}, [user, templateObjidParam]);
|
||||
|
||||
// ─── 저장 (wace fn_save 1:1) ─────────────────────────────────
|
||||
async function handleSave() {
|
||||
if (!contractObjid) {
|
||||
alert("견적서를 저장할 수 없습니다. 영업정보가 없습니다.");
|
||||
return;
|
||||
}
|
||||
if (!confirm("견적서를 저장하시겠습니까?")) return;
|
||||
|
||||
// 라인 → 페이로드 (콤마/통화기호 제거)
|
||||
const itemsBody: EstimateTemplateItemRow[] = items.map((r, idx) => ({
|
||||
seq: idx + 1,
|
||||
part_objid: r.partObjid || null,
|
||||
description: r.description || "",
|
||||
specification: r.specification || "",
|
||||
quantity: (r.quantity || "").replace(/[^0-9]/g, ""),
|
||||
unit: r.unit || "",
|
||||
unit_price: (r.unitPrice || "").replace(/[^0-9.]/g, ""),
|
||||
amount: (r.amount || "").replace(/[^0-9.]/g, ""),
|
||||
note: r.note || "",
|
||||
}));
|
||||
|
||||
try {
|
||||
const data = await salesEstimateApi.saveTemplate1({
|
||||
contract_objid: contractObjid,
|
||||
template_objid: templateObjid || undefined,
|
||||
executor,
|
||||
recipient,
|
||||
estimate_no: estimateNo,
|
||||
contact_person: contactPerson,
|
||||
greeting_text: greetingText,
|
||||
manager_name: managerName,
|
||||
manager_contact: managerContact,
|
||||
note_remarks: noteRemarks,
|
||||
note1, note2, note3, note4,
|
||||
show_total_row: showTotalRow ? "Y" : "N",
|
||||
total_amount: String(totalAmountNum),
|
||||
total_amount_krw: String(totalAmountKrwNum),
|
||||
items: itemsBody,
|
||||
});
|
||||
// 저장 성공 → templateObjid 동기화 (수정 모드 유지)
|
||||
if (data?.templateObjid) setTemplateObjid(data.templateObjid);
|
||||
alert("저장되었습니다.");
|
||||
// opener 새로고침 — wace는 window.opener.fn_search() 호출. RPS는 새 탭/창이라 별도 처리 없음.
|
||||
} catch (e: any) {
|
||||
console.error("저장 오류", e);
|
||||
alert("저장에 실패했습니다.\n" + (e?.response?.data?.message ?? e?.message ?? ""));
|
||||
}
|
||||
}
|
||||
|
||||
function handlePrint() {
|
||||
window.print();
|
||||
}
|
||||
|
||||
// PDF 다운로드 — wace fn_generatePdf 1:1 (클라이언트 html2canvas + jsPDF)
|
||||
async function handleDownloadPdf() {
|
||||
if (!confirm("PDF로 다운로드 하시겠습니까?")) return;
|
||||
try {
|
||||
// html2canvas-pro: oklab/oklch 등 모던 CSS color function 지원 (Tailwind 4 호환)
|
||||
const html2canvas = (await import("html2canvas-pro")).default;
|
||||
const { jsPDF } = await import("jspdf");
|
||||
|
||||
const container = document.querySelector(".estimate-container") as HTMLElement | null;
|
||||
if (!container) return;
|
||||
|
||||
const canvas = await html2canvas(container, {
|
||||
scale: 2,
|
||||
useCORS: true,
|
||||
logging: false,
|
||||
backgroundColor: "#ffffff",
|
||||
// 클론된 DOM에서 input/textarea/select → 텍스트 노드로 교체 (글자 잘림 방지)
|
||||
onclone: (doc) => {
|
||||
const replaceWithText = (el: HTMLElement, text: string) => {
|
||||
const span = doc.createElement("span");
|
||||
span.textContent = text;
|
||||
const style = el.getAttribute("style") || "";
|
||||
span.setAttribute("style", style + ";display:inline-block;white-space:pre-wrap;");
|
||||
el.parentNode?.replaceChild(span, el);
|
||||
};
|
||||
doc.querySelectorAll<HTMLInputElement>('input[type="text"],input[type="date"]').forEach(el => replaceWithText(el, el.value || ""));
|
||||
doc.querySelectorAll<HTMLTextAreaElement>("textarea").forEach(el => replaceWithText(el, el.value || ""));
|
||||
doc.querySelectorAll<HTMLSelectElement>("select").forEach(el => {
|
||||
const opt = el.options[el.selectedIndex];
|
||||
replaceWithText(el as unknown as HTMLElement, opt?.text || "");
|
||||
});
|
||||
// 인쇄 비대상 요소 숨김
|
||||
doc.querySelectorAll<HTMLElement>(".no-print, .btn-area, .delete-btn-cell button").forEach(el => { el.style.display = "none"; });
|
||||
},
|
||||
});
|
||||
|
||||
const imgData = canvas.toDataURL("image/jpeg", 0.85);
|
||||
const pdf = new jsPDF("p", "mm", "a4");
|
||||
const imgWidth = 210, pageHeight = 297;
|
||||
const imgHeight = canvas.height * imgWidth / canvas.width;
|
||||
let heightLeft = imgHeight;
|
||||
let position = 0;
|
||||
|
||||
pdf.addImage(imgData, "JPEG", 0, position, imgWidth, imgHeight, undefined, "FAST");
|
||||
heightLeft -= pageHeight;
|
||||
while (heightLeft > 1) {
|
||||
position = heightLeft - imgHeight;
|
||||
pdf.addPage();
|
||||
pdf.addImage(imgData, "JPEG", 0, position, imgWidth, imgHeight, undefined, "FAST");
|
||||
heightLeft -= pageHeight;
|
||||
}
|
||||
|
||||
const fileName = (estimateNo || "견적서") + ".pdf";
|
||||
pdf.save(fileName);
|
||||
} catch (e: any) {
|
||||
console.error("PDF 생성 오류", e);
|
||||
alert("PDF 생성 중 오류가 발생했습니다.\n" + (e?.message ?? ""));
|
||||
}
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
// 새 탭으로 열린 경우 닫기 시도 + 안되면 router back
|
||||
if (window.opener) {
|
||||
window.close();
|
||||
} else {
|
||||
router.back();
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) return <div style={{ padding: 40 }}>견적서를 불러오는 중...</div>;
|
||||
|
||||
// ─── 렌더링 (wace 마크업 1:1) ────────────────────────────────
|
||||
return (
|
||||
<div className="estimate-page">
|
||||
<style jsx global>{`
|
||||
@media print {
|
||||
@page { size: A4; margin: 10mm; }
|
||||
body { margin: 0; padding: 0; }
|
||||
.no-print { display: none !important; }
|
||||
.delete-btn-cell button { display: none !important; }
|
||||
}
|
||||
body {
|
||||
font-family: "Malgun Gothic", "맑은 고딕", Arial, sans-serif;
|
||||
font-size: 12pt;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
/* 견적서는 인쇄용 양식 — 다크모드와 무관하게 항상 흰 배경/검정 텍스트 */
|
||||
html.dark .estimate-page, html[data-theme="dark"] .estimate-page,
|
||||
.estimate-page { color: #000; background-color: #f5f5f5; min-height: 100vh; }
|
||||
.estimate-page .estimate-container,
|
||||
.estimate-page .estimate-container * { color: #000; }
|
||||
.estimate-container {
|
||||
width: 210mm;
|
||||
min-height: 297mm;
|
||||
background: white;
|
||||
margin: 0 auto;
|
||||
padding: 20mm;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.estimate-title {
|
||||
text-align: center;
|
||||
font-size: 28pt;
|
||||
font-weight: bold;
|
||||
letter-spacing: 20px;
|
||||
margin-bottom: 40px;
|
||||
padding: 10px 0;
|
||||
}
|
||||
.info-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.info-table td { padding: 5px 8px; border: 1px solid #000; font-size: 9pt; }
|
||||
.info-table .label { background-color: #f0f0f0; font-weight: bold; width: 80px; text-align: center; }
|
||||
.items-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 30px;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.items-table th, .items-table td {
|
||||
border: 1px solid #000;
|
||||
padding: 8px 2px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
font-size: 9pt;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.items-table th { background-color: #f0f0f0; font-weight: bold; }
|
||||
.items-table .col-no { width: 4%; }
|
||||
.items-table .col-desc { width: 12%; }
|
||||
.items-table .col-spec { width: 22%; }
|
||||
.items-table .col-qty { width: 4%; }
|
||||
.items-table .col-unit { width: 5%; }
|
||||
.items-table .col-price { width: 14%; }
|
||||
.items-table .col-amount { width: 15%; }
|
||||
.items-table .col-note { width: 9%; white-space: normal; word-break: break-all; }
|
||||
.items-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.items-table .text-left { text-align: left; }
|
||||
.items-table .text-right { text-align: right; overflow: hidden; }
|
||||
.estimate-page input[type="text"],
|
||||
.estimate-page input[type="date"],
|
||||
.estimate-page textarea,
|
||||
.estimate-page select {
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
width: 100%;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
box-sizing: border-box;
|
||||
color: #000;
|
||||
}
|
||||
.estimate-page input[readonly], .estimate-page textarea[readonly] { color: #000; }
|
||||
.estimate-page textarea {
|
||||
resize: none;
|
||||
height: 1.3em;
|
||||
min-height: auto;
|
||||
padding: 0 2px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
.estimate-page .item-price, .estimate-page .item-amount { text-align: right; }
|
||||
.estimate-page .item-amount { pointer-events: none; }
|
||||
.btn-area {
|
||||
position: fixed; bottom: 0; left: 0; right: 0;
|
||||
text-align: right;
|
||||
padding: 15px 30px;
|
||||
background-color: #ffffff;
|
||||
border-top: 3px solid #007bff;
|
||||
box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
|
||||
z-index: 1000;
|
||||
}
|
||||
.estimate-btn {
|
||||
display: inline-block;
|
||||
padding: 5px 15px;
|
||||
margin: 0 2px;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
border: 1px solid #60a5fa;
|
||||
background-color: #60a5fa;
|
||||
color: white;
|
||||
border-radius: 3px;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.estimate-btn:hover { background-color: #1e3a8a; border-color: #1e3a8a; }
|
||||
.estimate-btn[disabled] { background-color: #cbd5e1; border-color: #cbd5e1; cursor: not-allowed; }
|
||||
.company-stamp-placeholder {
|
||||
width: 100%; min-height: 200px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
border: 1px dashed #ccc; color: #666; font-size: 9pt;
|
||||
}
|
||||
.editable-input { background-color: transparent; }
|
||||
.readonly-input { background-color: #f5f5f5; }
|
||||
`}</style>
|
||||
|
||||
<div className="estimate-container" style={{ paddingBottom: 100 }}>
|
||||
{/* 제목 */}
|
||||
<div className="estimate-title">견 적 서</div>
|
||||
|
||||
{/* 상단 정보 테이블 */}
|
||||
<table className="info-table">
|
||||
<colgroup>
|
||||
<col width="80px" />
|
||||
<col width="*" />
|
||||
<col width="50px" />
|
||||
<col width="300px" />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="label">시행일자</td>
|
||||
<td>
|
||||
{/* 표시는 YYYY-MM-DD (text), 클릭 시 숨겨진 type=date의 showPicker 트리거 */}
|
||||
<div style={{ position: "relative", display: "inline-block", width: 150 }}>
|
||||
<input
|
||||
type="text"
|
||||
value={executor}
|
||||
readOnly
|
||||
placeholder="YYYY-MM-DD"
|
||||
onClick={() => { if (!readOnly) executorDateRef.current?.showPicker?.(); }}
|
||||
style={{ width: "100%", cursor: readOnly ? "default" : "pointer" }}
|
||||
/>
|
||||
<input
|
||||
ref={executorDateRef}
|
||||
type="date"
|
||||
value={executor}
|
||||
onChange={e => setExecutor(e.target.value)}
|
||||
tabIndex={-1}
|
||||
aria-hidden="true"
|
||||
style={{ position: "absolute", left: 0, top: 0, width: 1, height: 1, opacity: 0, pointerEvents: "none" }}
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
<td rowSpan={4} style={{ border: "none" }}></td>
|
||||
<td rowSpan={4} style={{ textAlign: "center", border: "none", verticalAlign: "middle", padding: 0 }}>
|
||||
<div style={{ width: "100%", textAlign: "center", marginBottom: 5 }}>
|
||||
<img
|
||||
src="/images/company_stamp.png"
|
||||
alt="회사 도장"
|
||||
style={{ width: "100%", height: "auto" }}
|
||||
onError={(e) => {
|
||||
const img = e.currentTarget;
|
||||
img.style.display = "none";
|
||||
const fb = img.nextElementSibling as HTMLElement | null;
|
||||
if (fb) fb.style.display = "flex";
|
||||
}}
|
||||
/>
|
||||
<div className="company-stamp-placeholder" style={{ display: "none" }}>
|
||||
㈜알피에스<br />RPS CO., LTD<br />대표이사 이동준
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="label">수신처</td>
|
||||
<td>
|
||||
<CustomerSelect
|
||||
value={recipient}
|
||||
onValueChange={setRecipient}
|
||||
placeholder="고객사 선택"
|
||||
disabled={readOnly}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="label">수신인</td>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
value={contactPerson}
|
||||
onChange={e => setContactPerson(e.target.value)}
|
||||
readOnly={readOnly}
|
||||
placeholder="OO 귀하"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="label">견적번호</td>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
value={estimateNo}
|
||||
onChange={e => setEstimateNo(e.target.value)}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{/* 인사말 + 담당자 + 부가세 별도 */}
|
||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start", marginBottom: 10, padding: "0 5px" }}>
|
||||
<div style={{ lineHeight: 1.6, fontSize: "10pt", whiteSpace: "pre-line" }}>
|
||||
{greetingText}
|
||||
</div>
|
||||
<div style={{ textAlign: "right", fontSize: "9pt", lineHeight: 1.8 }}>
|
||||
담당자 :{" "}
|
||||
<input
|
||||
type="text"
|
||||
value={managerName}
|
||||
onChange={e => setManagerName(e.target.value)}
|
||||
readOnly={readOnly}
|
||||
style={{ width: 120, borderBottom: "1px solid #ddd", fontSize: "9pt", padding: 2, backgroundColor: "#f5f5f5" }}
|
||||
/><br/>
|
||||
연락처 :{" "}
|
||||
<input
|
||||
type="text"
|
||||
value={managerContact}
|
||||
onChange={e => setManagerContact(e.target.value)}
|
||||
readOnly={readOnly}
|
||||
style={{ width: 120, borderBottom: "1px solid #ddd", fontSize: "9pt", padding: 2, backgroundColor: "#f5f5f5" }}
|
||||
/><br/><br/>
|
||||
<span style={{ fontSize: "10pt", marginTop: 5, display: "inline-block" }}>부가세 별도</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 품목 테이블 */}
|
||||
<table className="items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="col-no">번호<br/>NO.</th>
|
||||
<th className="col-desc">품 명<br/>DESCRIPTION</th>
|
||||
<th className="col-spec">규 격<br/>SPECIFICATION</th>
|
||||
<th className="col-qty">수량<br/>Q'TY</th>
|
||||
<th className="col-unit">단위<br/>UNIT</th>
|
||||
<th className="col-price">단 가<br/>UNIT PRICE</th>
|
||||
<th className="col-amount">금 액<br/>AMOUNT</th>
|
||||
<th className="col-note">비고</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{items.map((r, idx) => (
|
||||
<tr key={r.rowId}>
|
||||
<td>{idx + 1}</td>
|
||||
<td className="text-left">
|
||||
<input type="text" value={r.description} readOnly className="readonly-input" />
|
||||
</td>
|
||||
<td className="text-left">
|
||||
<textarea
|
||||
value={r.specification}
|
||||
onChange={e => updateItem(idx, { specification: e.target.value })}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
value={r.quantity}
|
||||
onChange={e => updateItem(idx, { quantity: e.target.value.replace(/[^0-9]/g, "") })}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
value={r.unit}
|
||||
onChange={e => updateItem(idx, { unit: e.target.value })}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
</td>
|
||||
<td className="text-right">
|
||||
<input
|
||||
type="text"
|
||||
value={r.unitPrice}
|
||||
onChange={e => updateItem(idx, { unitPrice: formatPriceInput(e.target.value) })}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
</td>
|
||||
<td className="text-right">
|
||||
<input type="text" value={r.amount} readOnly />
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
type="text"
|
||||
value={r.note}
|
||||
onChange={e => updateItem(idx, { note: e.target.value })}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
|
||||
{/* 계 행 */}
|
||||
{showTotalRow && (
|
||||
<tr className="total-row">
|
||||
<td colSpan={6} style={{ textAlign: "center", fontWeight: "bold", backgroundColor: "#f0f0f0" }}>계</td>
|
||||
<td className="text-right" style={{ fontWeight: "bold", backgroundColor: "#f0f0f0" }}>{totalAmountStr}</td>
|
||||
<td className="delete-btn-cell" style={{ backgroundColor: "#f0f0f0", textAlign: "center" }}>
|
||||
{!readOnly && (
|
||||
<button
|
||||
type="button"
|
||||
style={{ padding: "2px 8px", fontSize: "9pt", cursor: "pointer" }}
|
||||
onClick={() => { if (confirm("계 행을 삭제하시겠습니까?")) setShowTotalRow(false); }}
|
||||
>삭제</button>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
|
||||
{/* 원화환산 (KRW 외 통화 시만 표시) */}
|
||||
{currencyName && currencyName !== "KRW" && !currencyName.includes("원") && (
|
||||
<tr className="total-krw-row">
|
||||
<td colSpan={6} style={{ textAlign: "center", fontWeight: "bold", backgroundColor: "#e8f4f8" }}>원화환산 공급가액 (KRW)</td>
|
||||
<td className="text-right" style={{ fontWeight: "bold", backgroundColor: "#e8f4f8" }}>{totalAmountKrwStr}</td>
|
||||
<td style={{ backgroundColor: "#e8f4f8" }}></td>
|
||||
</tr>
|
||||
)}
|
||||
|
||||
{/* 비고 */}
|
||||
<tr className="remarks-row">
|
||||
<td colSpan={8} style={{ height: 100, verticalAlign: "top", padding: 10, textAlign: "left" }}>
|
||||
<div style={{ fontWeight: "bold", marginBottom: 10 }}><비고></div>
|
||||
<textarea
|
||||
value={noteRemarks}
|
||||
onChange={e => setNoteRemarks(e.target.value)}
|
||||
readOnly={readOnly}
|
||||
style={{ width: "100%", height: 70, border: "none", resize: "none", fontSize: "10pt", textAlign: "left", whiteSpace: "pre-line" }}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{/* 참조사항 */}
|
||||
<tr className="notes-row">
|
||||
<td colSpan={8} style={{ verticalAlign: "top", padding: 10, textAlign: "left", border: "1px solid #000" }}>
|
||||
<div style={{ fontWeight: "bold", marginBottom: 10 }}><참조사항></div>
|
||||
<div style={{ marginBottom: 5 }}>
|
||||
<input type="text" value={note1} onChange={e => setNote1(e.target.value)} readOnly={readOnly} style={{ fontSize: "10pt" }} />
|
||||
</div>
|
||||
<div style={{ marginBottom: 5 }}>
|
||||
<input type="text" value={note2} onChange={e => setNote2(e.target.value)} readOnly={readOnly} style={{ fontSize: "10pt" }} />
|
||||
</div>
|
||||
<div style={{ marginBottom: 5 }}>
|
||||
<input type="text" value={note3} onChange={e => setNote3(e.target.value)} readOnly={readOnly} style={{ fontSize: "10pt" }} />
|
||||
</div>
|
||||
<div style={{ marginBottom: 5 }}>
|
||||
<input type="text" value={note4} onChange={e => setNote4(e.target.value)} readOnly={readOnly} style={{ fontSize: "10pt" }} />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{/* 푸터 회사명 */}
|
||||
<tr className="footer-row">
|
||||
<td colSpan={8} style={{ textAlign: "right", padding: 15, fontSize: "10pt", fontWeight: "bold", border: "none" }}>
|
||||
㈜알피에스
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{/* 버튼 영역 (고정 하단) */}
|
||||
<div className="btn-area no-print">
|
||||
<button type="button" className="estimate-btn" onClick={handlePrint}>인쇄</button>
|
||||
<button type="button" className="estimate-btn" onClick={handleDownloadPdf}>PDF 다운로드</button>
|
||||
<button type="button" className="estimate-btn" onClick={handleSave} disabled={readOnly}>저장</button>
|
||||
<button type="button" className="estimate-btn" onClick={handleClose}>닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,761 @@
|
||||
"use client";
|
||||
|
||||
// ============================================================
|
||||
// 영업관리 > 견적관리 > 견적작성(장비)
|
||||
// wace estimateTemplate2.jsp 1:1 이식 (template_type='2')
|
||||
// 진입: 견적관리 그리드 행 선택 → "견적작성" → "장비 견적서"
|
||||
// 구조: CNC Machine 특별 영역 + 7개 기본 카테고리 (group1 4개 + 단독 3개) + 비고 + 푸터
|
||||
// ============================================================
|
||||
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { useParams, useSearchParams, useRouter } from "next/navigation";
|
||||
import { salesEstimateApi } from "@/lib/api/salesEstimate";
|
||||
import { CustomerSelect } from "@/components/common/CustomerSelect";
|
||||
|
||||
// ─── 포맷 헬퍼 ────────────────────────────────────────────────
|
||||
function addComma(num: number | string): string {
|
||||
if (num === "" || num == null) return "";
|
||||
const n = Number(String(num).replace(/,/g, ""));
|
||||
if (Number.isNaN(n)) return "";
|
||||
return n.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||
}
|
||||
|
||||
// ─── 데이터 타입 ──────────────────────────────────────────────
|
||||
// CNC Machine 특별 영역 (1개 row)
|
||||
interface CncRow {
|
||||
description: string;
|
||||
specification: string;
|
||||
quantity: string;
|
||||
unit_price: string; // 입력 시 콤마 포함
|
||||
amount: string; // 자동 계산
|
||||
remark: string;
|
||||
}
|
||||
|
||||
// 일반 카테고리 (N개, textarea 묶음 — 여러 줄)
|
||||
interface CategoryRow {
|
||||
category: string; // data-category 값 (예: 'structure', 'category_8')
|
||||
category_name: string; // 화면 표시명
|
||||
category_no: number;
|
||||
group: string; // 'group1' 또는 ''
|
||||
description: string; // 여러 줄
|
||||
specification: string;
|
||||
quantity: string;
|
||||
quantity2: string;
|
||||
remark: string;
|
||||
subtotal: string; // 개별 subtotal (group이 아닌 카테고리만)
|
||||
}
|
||||
|
||||
// ─── wace 1:1 기본 데이터 (신규 작성 시 깔리는 7개 카테고리) ──
|
||||
const DEFAULT_CATEGORIES: CategoryRow[] = [
|
||||
{
|
||||
category: "structure", category_name: "기구", category_no: 1, group: "group1",
|
||||
description: "X,Y,Z LINEAR\nLINEAR SCALE ENCODER\n주물 BODY\nX,Z AXIS COLUMN\nCOVER\nLM GUIDE\nLM GUIDE\nTABLE\nSUS 자바라 X, Y",
|
||||
specification: "\n\nMINERAL CASTING\nMINERAL CASTING\nSPCC 도장\nX,Y: SHS25 P급, C1 중예압\nZ: SRG25 P급, C0\n600 * 500\n벨로우즈 멀티 커버",
|
||||
quantity: "\n\n3\n1\n1\n1\n4\n2\n1\n4",
|
||||
quantity2: "", remark: "", subtotal: "",
|
||||
},
|
||||
{
|
||||
category: "spindle_module", category_name: "초음파 스핀들 모듈", category_no: 2, group: "group1",
|
||||
description: "초음파 스핀들 모듈\n제너레이터",
|
||||
specification: "AS030-080H2A2.0-U\n15~50kHz, 50W",
|
||||
quantity: "1\n1",
|
||||
quantity2: "", remark: "", subtotal: "",
|
||||
},
|
||||
{
|
||||
category: "electric", category_name: "전장", category_no: 3, group: "group1",
|
||||
description: "C-BOX\nINVERTER\nNC 제어기",
|
||||
specification: "Panel & Box, 공용 전기 자재, 냉각장치\nDELTA MS300\nSIEMENS CONTROL PANEL 828D",
|
||||
quantity: "1\n1\n1",
|
||||
quantity2: "", remark: "", subtotal: "",
|
||||
},
|
||||
{
|
||||
category: "utility", category_name: "UTILITY", category_no: 4, group: "group1",
|
||||
description: "공압 PANEL & HOSE\nCHILLER\n절삭유 공급장치\nOIL 자동급유장치\n절삭유 공급 필터",
|
||||
specification: "\n\t\t\t\nDSD-010S\n순환장치\nLUBRICATION\n1um 1ea, 10um 1ea",
|
||||
quantity: "1\n1\n1\n1\n1",
|
||||
quantity2: "", remark: "", subtotal: "",
|
||||
},
|
||||
{
|
||||
category: "option", category_name: "Option", category_no: 5, group: "",
|
||||
description: "OMP400\nNC4\nATC",
|
||||
specification: "OMP400(Renishaw)\nNV4Blue(Renishaw)\n-",
|
||||
quantity: "1\n1\n1",
|
||||
quantity2: "", remark: "", subtotal: "",
|
||||
},
|
||||
{
|
||||
category: "setup", category_name: "Set up", category_no: 6, group: "",
|
||||
description: "인건비 (기구+제어)\n인건비 (Training)\n기타(항공/숙박/교통/식비)",
|
||||
specification: "", quantity: "", quantity2: "", remark: "", subtotal: "",
|
||||
},
|
||||
{
|
||||
category: "packing", category_name: "포장/물류", category_no: 7, group: "",
|
||||
description: "포장비\n물류비",
|
||||
specification: "", quantity: "", quantity2: "", remark: "", subtotal: "",
|
||||
},
|
||||
];
|
||||
|
||||
const DEFAULT_NOTES_HTML = `<strong>■ 최종 견적가는 부가세 별도입니다.</strong><br>■ 장비 납기 : 발주 시 협의<br>■ 운송 조건 : 국내 RPS 에서 진행<br>국외 FOB 기준으로 운송비 / 포장비는 선 당사 부담후 실비 정산<br>■ 결제 조건 : 계약금 : 30% / 중도금 : 60% / 잔금 : 10%<br>-. 계약금 : 발주 후 7일 이내<br>-. 중도금 : 출하 전<br>-. 잔 금 : 설치 완료 후<br>■ 장비사양 : 본견적은 당사 표준 사항<br>사양 협의시 금액 변동성이 있음.<br>■ Warrenty Period: 1년(소모성 parts 제외)<br>■ 주의 : RPS 동의없이 초음파 스핀들의 임의 탈거 또는 해체시 보증 할수 없음.<br><br><div style="display: flex; justify-content: space-between; align-items: center;"><span>* 견적유효기간: 4주</span><span>㈜ 알 피 에 스</span></div>`;
|
||||
|
||||
// ─── 페이지 ──────────────────────────────────────────────────
|
||||
export default function EstimateTemplate2Page() {
|
||||
const params = useParams<{ contractObjid: string }>();
|
||||
const searchParams = useSearchParams();
|
||||
const router = useRouter();
|
||||
|
||||
const contractObjidParam = params?.contractObjid ?? "";
|
||||
const templateObjidParam = searchParams?.get("templateObjid") ?? "";
|
||||
|
||||
const [exchangeRate, setExchangeRate] = useState<number>(1);
|
||||
|
||||
// 헤더
|
||||
const [executorDate, setExecutorDate] = useState<string>("");
|
||||
const executorDateRef = React.useRef<HTMLInputElement>(null);
|
||||
const [recipient, setRecipient] = useState<string>("");
|
||||
const [partName, setPartName] = useState<string>("");
|
||||
const [partObjid, setPartObjid] = useState<string>("");
|
||||
const [modelCode, setModelCode] = useState<string>("");
|
||||
|
||||
// CNC Machine 특별 영역
|
||||
const [cnc, setCnc] = useState<CncRow>({
|
||||
description: "초음파 CNC Machine",
|
||||
specification: "Hole 가공",
|
||||
quantity: "1",
|
||||
unit_price: "",
|
||||
amount: "",
|
||||
remark: "",
|
||||
});
|
||||
|
||||
// 일반 카테고리 배열
|
||||
const [categories, setCategories] = useState<CategoryRow[]>(DEFAULT_CATEGORIES);
|
||||
|
||||
// group1 공유 subtotal
|
||||
const [group1Subtotal, setGroup1Subtotal] = useState<string>("");
|
||||
|
||||
// 비고/유효기간
|
||||
const [notesContent, setNotesContent] = useState<string>(DEFAULT_NOTES_HTML);
|
||||
const notesRef = React.useRef<HTMLDivElement>(null);
|
||||
const [validityPeriod, setValidityPeriod] = useState<string>("");
|
||||
|
||||
// 상태
|
||||
const [contractObjid, setContractObjid] = useState<string>(contractObjidParam);
|
||||
const [templateObjid, setTemplateObjid] = useState<string>(templateObjidParam);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [apprStatus, setApprStatus] = useState<string>("작성중");
|
||||
const readOnly = apprStatus === "결재완료" || apprStatus === "결재중";
|
||||
|
||||
// ─── 최종 견적가 계산 ────────────────────────────────────────
|
||||
// wace fn_calculateTotal: cnc.amount + group1Subtotal + 단독 subtotal들
|
||||
const { totalAmountNum, totalAmountKrwNum, cncAmountNum } = useMemo(() => {
|
||||
const cncAmt = parseFloat((cnc.unit_price || "0").replace(/,/g, "")) * parseFloat(cnc.quantity || "0");
|
||||
const cncAmtNum = Number.isFinite(cncAmt) ? cncAmt : 0;
|
||||
const g1 = parseFloat((group1Subtotal || "0").replace(/,/g, "")) || 0;
|
||||
const standalone = categories
|
||||
.filter(c => !c.group)
|
||||
.reduce((s, c) => s + (parseFloat((c.subtotal || "0").replace(/,/g, "")) || 0), 0);
|
||||
const total = cncAmtNum + g1 + standalone;
|
||||
return { totalAmountNum: total, totalAmountKrwNum: total * (exchangeRate || 1), cncAmountNum: cncAmtNum };
|
||||
}, [cnc.unit_price, cnc.quantity, group1Subtotal, categories, exchangeRate]);
|
||||
|
||||
// CNC amount는 cnc.amount 표시용으로 동기화
|
||||
useEffect(() => {
|
||||
setCnc(prev => ({ ...prev, amount: cncAmountNum ? addComma(cncAmountNum) : "" }));
|
||||
}, [cncAmountNum]);
|
||||
|
||||
// ─── 카테고리 핸들러 ─────────────────────────────────────────
|
||||
function updateCategory(idx: number, patch: Partial<CategoryRow>) {
|
||||
setCategories(prev => prev.map((c, i) => i === idx ? { ...c, ...patch } : c));
|
||||
}
|
||||
|
||||
function addCategory() {
|
||||
const visibleCount = categories.length;
|
||||
const next = visibleCount + 1;
|
||||
setCategories(prev => [...prev, {
|
||||
category: `category_${next}`,
|
||||
category_name: `카테고리 ${next}`,
|
||||
category_no: next,
|
||||
group: "",
|
||||
description: "", specification: "", quantity: "", quantity2: "", remark: "", subtotal: "",
|
||||
}]);
|
||||
}
|
||||
|
||||
function deleteCategory(idx: number) {
|
||||
if (!confirm("이 카테고리를 삭제하시겠습니까?")) return;
|
||||
setCategories(prev => {
|
||||
const next = prev.filter((_, i) => i !== idx);
|
||||
// 번호 재정렬 (cnc_machine 제외 — 여긴 일반 카테고리만)
|
||||
return next.map((c, i) => ({ ...c, category_no: i + 1 }));
|
||||
});
|
||||
}
|
||||
|
||||
// ─── 데이터 로드 ────────────────────────────────────────────
|
||||
useEffect(() => {
|
||||
let cancel = false;
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
// 영업 정보
|
||||
let contractInfo: any = null;
|
||||
if (contractObjidParam) {
|
||||
try {
|
||||
contractInfo = await salesEstimateApi.detail(contractObjidParam);
|
||||
} catch (e) {
|
||||
console.warn("영업정보 로드 실패", e);
|
||||
}
|
||||
}
|
||||
// getById 응답: { ...contract_mgmt 헤더 필드들, items: [...] } (평면 구조)
|
||||
if (contractInfo && !cancel) {
|
||||
setExchangeRate(parseFloat(contractInfo.exchange_rate || "1") || 1);
|
||||
if (contractInfo.customer_objid) setRecipient(contractInfo.customer_objid);
|
||||
}
|
||||
// 신규: contract_item[0]의 part_name을 품명/Model로
|
||||
if (contractInfo?.items?.[0] && !cancel) {
|
||||
const it0 = contractInfo.items[0];
|
||||
const pName = it0.master_part_name ?? it0.part_name ?? "";
|
||||
if (pName) {
|
||||
setPartName(pName);
|
||||
setModelCode(pName);
|
||||
setPartObjid(it0.part_objid ?? "");
|
||||
}
|
||||
if (it0.quantity) setCnc(prev => ({ ...prev, quantity: String(it0.quantity) }));
|
||||
}
|
||||
|
||||
// 기존 견적 차수 수정
|
||||
if (templateObjidParam) {
|
||||
const tpl = await salesEstimateApi.getTemplate(templateObjidParam);
|
||||
if (tpl && !cancel) {
|
||||
if (tpl.contract_objid) setContractObjid(tpl.contract_objid);
|
||||
setExchangeRate(parseFloat(tpl.exchange_rate || "1") || 1);
|
||||
setExecutorDate(tpl.executor_date ?? "");
|
||||
if (tpl.recipient) setRecipient(tpl.recipient);
|
||||
if (tpl.part_name) {
|
||||
setPartName(tpl.part_name);
|
||||
setModelCode(tpl.part_name);
|
||||
}
|
||||
if (tpl.part_objid) setPartObjid(tpl.part_objid);
|
||||
if (tpl.notes_content) {
|
||||
setNotesContent(tpl.notes_content);
|
||||
if (notesRef.current) notesRef.current.innerHTML = tpl.notes_content;
|
||||
}
|
||||
if (tpl.validity_period) setValidityPeriod(tpl.validity_period);
|
||||
if (tpl.group1_subtotal) setGroup1Subtotal(addComma(tpl.group1_subtotal));
|
||||
|
||||
// categories_json 복원
|
||||
if (tpl.categories_json) {
|
||||
try {
|
||||
const arr = JSON.parse(tpl.categories_json) as any[];
|
||||
const cncSaved = arr.find(c => c.category === "cnc_machine");
|
||||
if (cncSaved?.items?.[0]) {
|
||||
const it = cncSaved.items[0];
|
||||
setCnc({
|
||||
description: it.description ?? "초음파 CNC Machine",
|
||||
specification: it.specification ?? "",
|
||||
quantity: it.quantity ?? "1",
|
||||
unit_price: it.unit_price ? addComma(it.unit_price) : "",
|
||||
amount: it.amount ? addComma(it.amount) : "",
|
||||
remark: it.remark ?? "",
|
||||
});
|
||||
}
|
||||
const rest: CategoryRow[] = arr
|
||||
.filter(c => c.category !== "cnc_machine")
|
||||
.map((c: any, i: number) => ({
|
||||
category: c.category ?? `category_${i + 1}`,
|
||||
category_name: c.category_name ?? `카테고리 ${i + 1}`,
|
||||
category_no: c.category_no ?? i + 1,
|
||||
group: c.group ?? "",
|
||||
description: c.description ?? "",
|
||||
specification: c.specification ?? "",
|
||||
quantity: c.quantity ?? "",
|
||||
quantity2: c.quantity2 ?? "",
|
||||
remark: c.remark ?? "",
|
||||
subtotal: c.subtotal ? addComma(c.subtotal) : "",
|
||||
}));
|
||||
if (rest.length > 0) setCategories(rest);
|
||||
} catch (e) {
|
||||
console.warn("categories_json 파싱 실패", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (!cancel) setLoading(false);
|
||||
}
|
||||
})();
|
||||
|
||||
return () => { cancel = true; };
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [contractObjidParam, templateObjidParam]);
|
||||
|
||||
// ─── 저장 (wace fn_save 1:1) ─────────────────────────────────
|
||||
async function handleSave() {
|
||||
if (!contractObjid && !templateObjid) {
|
||||
alert("견적서를 저장할 수 없습니다. 영업정보가 없습니다.");
|
||||
return;
|
||||
}
|
||||
if (!confirm("견적서를 저장하시겠습니까?")) return;
|
||||
|
||||
// categories 배열 구성: CNC Machine + 일반 카테고리
|
||||
const cncAmtStr = (cnc.unit_price || "")
|
||||
? String(parseFloat(cnc.unit_price.replace(/,/g, "")) * parseFloat(cnc.quantity || "0") || 0)
|
||||
: "";
|
||||
const catsBody: any[] = [
|
||||
{
|
||||
category: "cnc_machine",
|
||||
category_name: "초음파 CNC Machine",
|
||||
category_no: 0,
|
||||
content: "",
|
||||
items: [{
|
||||
description: cnc.description || "",
|
||||
specification: cnc.specification || "",
|
||||
quantity: cnc.quantity || "",
|
||||
unit_price: (cnc.unit_price || "").replace(/,/g, ""),
|
||||
amount: cncAmtStr,
|
||||
remark: cnc.remark || "",
|
||||
}],
|
||||
subtotal: "",
|
||||
},
|
||||
...categories.map((c, idx) => ({
|
||||
category: c.category,
|
||||
category_name: c.category_name,
|
||||
category_no: idx + 1,
|
||||
group: c.group || "",
|
||||
description: c.description || "",
|
||||
specification: c.specification || "",
|
||||
quantity: c.quantity || "",
|
||||
quantity2: c.quantity2 || "",
|
||||
remark: c.remark || "",
|
||||
subtotal: c.group ? "" : (c.subtotal || "").replace(/,/g, ""),
|
||||
})),
|
||||
];
|
||||
|
||||
try {
|
||||
const data = await salesEstimateApi.saveTemplate2({
|
||||
contract_objid: contractObjid,
|
||||
template_objid: templateObjid || undefined,
|
||||
executor_date: executorDate,
|
||||
recipient,
|
||||
part_name: partName,
|
||||
part_objid: partObjid,
|
||||
notes_content: (notesRef.current?.innerHTML) ?? notesContent,
|
||||
validity_period: validityPeriod,
|
||||
categories_json: JSON.stringify(catsBody),
|
||||
group1_subtotal: (group1Subtotal || "").replace(/,/g, ""),
|
||||
total_amount: String(totalAmountNum),
|
||||
total_amount_krw: String(totalAmountKrwNum),
|
||||
});
|
||||
if (data?.templateObjid) setTemplateObjid(data.templateObjid);
|
||||
alert("저장되었습니다.");
|
||||
} catch (e: any) {
|
||||
console.error("저장 오류", e);
|
||||
alert("저장에 실패했습니다.\n" + (e?.response?.data?.message ?? e?.message ?? ""));
|
||||
}
|
||||
}
|
||||
|
||||
function handlePrint() {
|
||||
window.print();
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
if (window.opener) window.close();
|
||||
else router.back();
|
||||
}
|
||||
|
||||
if (loading) return <div style={{ padding: 40 }}>견적서를 불러오는 중...</div>;
|
||||
|
||||
// ─── 렌더링 (wace 마크업 1:1) ────────────────────────────────
|
||||
return (
|
||||
<div className="estimate2-page">
|
||||
<style jsx global>{`
|
||||
@media print {
|
||||
@page { size: A4; margin: 10mm; }
|
||||
body { margin: 0; padding: 0; }
|
||||
.no-print { display: none !important; }
|
||||
.btn-delete-category { display: none !important; }
|
||||
}
|
||||
.estimate2-page body, body { font-family: "Malgun Gothic","맑은 고딕",Arial,sans-serif; background-color: #f5f5f5; }
|
||||
/* 견적서는 인쇄용 양식 — 다크모드와 무관하게 항상 흰 배경/검정 텍스트 */
|
||||
.estimate2-page { color: #000; background-color: #f5f5f5; min-height: 100vh; }
|
||||
.estimate2-page .estimate-container, .estimate2-page .estimate-container * { color: #000; }
|
||||
.estimate2-page .estimate-container {
|
||||
width: 210mm; min-height: 297mm;
|
||||
background: white; margin: 0 auto;
|
||||
padding: 15mm; box-shadow: 0 0 10px rgba(0,0,0,.1);
|
||||
box-sizing: border-box; padding-bottom: 100px;
|
||||
}
|
||||
.estimate2-page .header-section {
|
||||
display: flex; justify-content: space-between;
|
||||
align-items: center; margin-bottom: 20px;
|
||||
}
|
||||
.estimate2-page .title-section { flex: 1; text-align: center; }
|
||||
.estimate2-page .title {
|
||||
font-size: 24pt; font-weight: bold; letter-spacing: 15px;
|
||||
}
|
||||
.estimate2-page .model-header {
|
||||
background: #f0f0f0; padding: 8px; text-align: center;
|
||||
font-size: 11pt; font-weight: bold; margin: 15px 0;
|
||||
}
|
||||
.estimate2-page .items-table {
|
||||
width: 100%; border-collapse: collapse;
|
||||
margin-bottom: 8px; font-size: 9pt;
|
||||
}
|
||||
.estimate2-page .items-table th, .estimate2-page .items-table td {
|
||||
border: 1px solid #000; padding: 4px 6px; vertical-align: top;
|
||||
}
|
||||
.estimate2-page .items-table th { background: #f0f0f0; text-align: center; font-weight: bold; }
|
||||
.estimate2-page .category-row td:first-child { text-align: center; font-weight: bold; }
|
||||
.estimate2-page .category-row td[contenteditable] {
|
||||
background: #fffef0; font-weight: bold; padding: 6px 10px;
|
||||
}
|
||||
.estimate2-page .subtotal-row td { background: #f5f5f5; font-weight: bold; }
|
||||
.estimate2-page input[type="text"], .estimate2-page input[type="date"],
|
||||
.estimate2-page textarea, .estimate2-page select {
|
||||
border: none; outline: none; background: transparent;
|
||||
width: 100%; font-family: inherit; font-size: inherit; box-sizing: border-box;
|
||||
color: #000;
|
||||
}
|
||||
.estimate2-page input[readonly], .estimate2-page textarea[readonly] { color: #000; }
|
||||
.estimate2-page textarea { resize: vertical; line-height: 1.6; white-space: pre-wrap; }
|
||||
.estimate2-page .estimate-btn-area {
|
||||
position: fixed; bottom: 0; left: 0; right: 0;
|
||||
text-align: right; padding: 12px 24px;
|
||||
background: #fff; border-top: 3px solid #007bff;
|
||||
box-shadow: 0 -2px 10px rgba(0,0,0,.1); z-index: 1000;
|
||||
}
|
||||
.estimate2-page .estimate-btn {
|
||||
display: inline-block; padding: 5px 15px; margin: 0 2px;
|
||||
font-size: 12px; cursor: pointer; border: 1px solid #60a5fa;
|
||||
background: #60a5fa; color: #fff; border-radius: 3px;
|
||||
}
|
||||
.estimate2-page .estimate-btn:hover { background: #1e3a8a; border-color: #1e3a8a; }
|
||||
.estimate2-page .estimate-btn[disabled] { background: #cbd5e1; border-color: #cbd5e1; cursor: not-allowed; }
|
||||
.estimate2-page .btn-delete-category {
|
||||
padding: 2px 8px; font-size: 10px; cursor: pointer;
|
||||
background: #dc3545; color: #fff; border: none; border-radius: 3px;
|
||||
}
|
||||
.estimate2-page .notes-section { margin-top: 15px; }
|
||||
.estimate2-page .notes-section [contenteditable] {
|
||||
width: 97%; min-height: 180px; border: 1px solid #ddd;
|
||||
padding: 10px; font-size: 9pt; line-height: 1.8; background: white;
|
||||
}
|
||||
`}</style>
|
||||
|
||||
<div className="estimate-container">
|
||||
{/* 헤더 (로고 + 제목 + 회사정보) */}
|
||||
<div className="header-section">
|
||||
<div style={{ flex: "0 0 120px" }}>
|
||||
<div style={{ fontSize: "12pt", fontWeight: "bold", color: "#dc3545" }}>RPS</div>
|
||||
</div>
|
||||
<div className="title-section">
|
||||
<div className="title">견 적 서</div>
|
||||
</div>
|
||||
<div style={{ flex: "0 0 200px" }}></div>
|
||||
</div>
|
||||
|
||||
{/* 기본 정보 (좌우 배치) */}
|
||||
<div style={{ display: "flex", justifyContent: "space-between", padding: "0 10px" }}>
|
||||
<div style={{ textAlign: "left", fontSize: "10pt", lineHeight: 2 }}>
|
||||
<div>
|
||||
<strong>시행일자 :</strong>{" "}
|
||||
{/* 표시는 YYYY-MM-DD (text), 클릭 시 숨겨진 type=date의 showPicker 트리거 */}
|
||||
<span style={{ position: "relative", display: "inline-block", width: 200 }}>
|
||||
<input
|
||||
type="text"
|
||||
value={executorDate}
|
||||
readOnly
|
||||
placeholder="YYYY-MM-DD"
|
||||
onClick={() => { if (!readOnly) executorDateRef.current?.showPicker?.(); }}
|
||||
style={{ width: "100%", borderBottom: "1px solid #999", padding: "2px 5px", cursor: readOnly ? "default" : "pointer" }}
|
||||
/>
|
||||
<input
|
||||
ref={executorDateRef}
|
||||
type="date"
|
||||
value={executorDate}
|
||||
onChange={e => setExecutorDate(e.target.value)}
|
||||
tabIndex={-1}
|
||||
aria-hidden="true"
|
||||
style={{ position: "absolute", left: 0, top: 0, width: 1, height: 1, opacity: 0, pointerEvents: "none" }}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<strong>수 신 처 :</strong>{" "}
|
||||
<span style={{ display: "inline-block", width: 200 }}>
|
||||
<CustomerSelect
|
||||
value={recipient}
|
||||
onValueChange={setRecipient}
|
||||
placeholder="고객사 선택"
|
||||
disabled={readOnly}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<strong>품 명 :</strong>{" "}
|
||||
<input
|
||||
type="text"
|
||||
value={partName}
|
||||
onChange={e => setPartName(e.target.value)}
|
||||
readOnly={readOnly}
|
||||
style={{ width: 200, borderBottom: "1px solid #999", padding: "2px 5px" }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ textAlign: "right" }}>
|
||||
<div style={{ display: "inline-block", minWidth: 300 }}>
|
||||
<div style={{ fontWeight: "bold", fontSize: "11pt", marginBottom: 5 }}>RPS CO., LTD</div>
|
||||
<div style={{ fontSize: "9pt", lineHeight: 1.5 }}>대전광역시 유성구 국제과학로 10로 8</div>
|
||||
<div style={{ fontSize: "9pt", lineHeight: 1.5 }}>TEL: (042)602-3300, FAX: (042)672-3399</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 설비 Model */}
|
||||
<div className="model-header">
|
||||
설비 Model :{" "}
|
||||
<input
|
||||
type="text"
|
||||
value={modelCode}
|
||||
onChange={e => setModelCode(e.target.value)}
|
||||
readOnly={readOnly}
|
||||
style={{ display: "inline-block", minWidth: 200, textAlign: "center", fontWeight: "bold" }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* CNC Machine 특별 영역 */}
|
||||
<table className="items-table" data-category="cnc_machine">
|
||||
<colgroup>
|
||||
<col style={{ width: "5%" }} />
|
||||
<col style={{ width: "26%" }} />
|
||||
<col style={{ width: "28.5%" }} />
|
||||
<col style={{ width: "6.5%" }} />
|
||||
<col style={{ width: "12%" }} />
|
||||
<col style={{ width: "12%" }} />
|
||||
<col style={{ width: "10%" }} />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>NO</th>
|
||||
<th>DESCRIPTION</th>
|
||||
<th>SPECIFICATION</th>
|
||||
<th>Q'TY</th>
|
||||
<th>UNIT PRICE</th>
|
||||
<th>AMOUNT</th>
|
||||
<th>REMARK</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowSpan={2} style={{ textAlign: "center" }}>1</td>
|
||||
<td rowSpan={2}>
|
||||
<input
|
||||
type="text" value={cnc.description}
|
||||
onChange={e => setCnc(prev => ({ ...prev, description: e.target.value }))}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
type="text" value={cnc.specification}
|
||||
onChange={e => setCnc(prev => ({ ...prev, specification: e.target.value }))}
|
||||
readOnly={readOnly}
|
||||
style={{ textAlign: "center" }}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
type="text" value={cnc.quantity}
|
||||
onChange={e => setCnc(prev => ({ ...prev, quantity: e.target.value.replace(/[^0-9]/g, "") }))}
|
||||
readOnly={readOnly}
|
||||
style={{ textAlign: "center" }}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
type="text" value={cnc.unit_price}
|
||||
onChange={e => {
|
||||
const cleaned = e.target.value.replace(/,/g, "").replace(/[^0-9.]/g, "");
|
||||
setCnc(prev => ({ ...prev, unit_price: cleaned === "" ? "" : addComma(cleaned) }));
|
||||
}}
|
||||
readOnly={readOnly}
|
||||
style={{ textAlign: "right" }}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" value={cnc.amount} readOnly style={{ textAlign: "right" }} />
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
type="text" value={cnc.remark}
|
||||
onChange={e => setCnc(prev => ({ ...prev, remark: e.target.value }))}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr className="subtotal-row">
|
||||
<td colSpan={2} style={{ textAlign: "center", fontSize: "8pt" }}>최종 견적가</td>
|
||||
<td colSpan={2}>
|
||||
<input
|
||||
type="text"
|
||||
value={totalAmountNum ? addComma(totalAmountNum) : ""}
|
||||
readOnly
|
||||
style={{ width: "70%", textAlign: "right", fontWeight: "bold" }}
|
||||
/>
|
||||
<span style={{ fontWeight: "bold", marginLeft: 5 }}>{exchangeRate === 1 ? "₩" : ""}</span>
|
||||
</td>
|
||||
<td style={{ textAlign: "center", fontSize: "8pt" }}>VAT 별도</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{/* 일반 카테고리 N개 */}
|
||||
{categories.map((c, idx) => {
|
||||
const isGroup1Last = c.group === "group1" &&
|
||||
(idx === categories.length - 1 || categories[idx + 1]?.group !== "group1");
|
||||
return (
|
||||
<React.Fragment key={`${c.category}_${idx}`}>
|
||||
<table className="items-table" data-category={c.category} data-group={c.group}>
|
||||
<colgroup>
|
||||
<col style={{ width: "5%" }} />
|
||||
<col style={{ width: "26%" }} />
|
||||
<col style={{ width: "28.5%" }} />
|
||||
<col style={{ width: "6.5%" }} />
|
||||
<col style={{ width: "24%" }} />
|
||||
<col style={{ width: "10%" }} />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr className="category-row">
|
||||
<td rowSpan={2} style={{ textAlign: "center" }}>{idx + 1}</td>
|
||||
<td
|
||||
colSpan={4}
|
||||
contentEditable={!readOnly}
|
||||
suppressContentEditableWarning
|
||||
onBlur={e => updateCategory(idx, { category_name: e.currentTarget.textContent ?? "" })}
|
||||
>{c.category_name}</td>
|
||||
<td style={{ textAlign: "center" }}>
|
||||
{!readOnly && (
|
||||
<button type="button" className="btn-delete-category" onClick={() => deleteCategory(idx)}>삭제</button>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
<tr className="detail-row">
|
||||
<td>
|
||||
<textarea
|
||||
value={c.description}
|
||||
onChange={e => updateCategory(idx, { description: e.target.value })}
|
||||
readOnly={readOnly}
|
||||
rows={5}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<textarea
|
||||
value={c.specification}
|
||||
onChange={e => updateCategory(idx, { specification: e.target.value })}
|
||||
readOnly={readOnly}
|
||||
rows={5}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<textarea
|
||||
value={c.quantity}
|
||||
onChange={e => updateCategory(idx, { quantity: e.target.value })}
|
||||
readOnly={readOnly}
|
||||
rows={5}
|
||||
style={{ textAlign: "right" }}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<textarea
|
||||
value={c.quantity2}
|
||||
onChange={e => updateCategory(idx, { quantity2: e.target.value })}
|
||||
readOnly={readOnly}
|
||||
rows={5}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<textarea
|
||||
value={c.remark}
|
||||
onChange={e => updateCategory(idx, { remark: e.target.value })}
|
||||
readOnly={readOnly}
|
||||
rows={5}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
{/* 단독 카테고리는 개별 Subtotal */}
|
||||
{!c.group && (
|
||||
<tr className="subtotal-row">
|
||||
<td colSpan={4}>Subtotal</td>
|
||||
<td>
|
||||
<input
|
||||
type="text" value={c.subtotal}
|
||||
onChange={e => {
|
||||
const cleaned = e.target.value.replace(/,/g, "").replace(/[^0-9.]/g, "");
|
||||
updateCategory(idx, { subtotal: cleaned === "" ? "" : addComma(cleaned) });
|
||||
}}
|
||||
readOnly={readOnly}
|
||||
style={{ textAlign: "right" }}
|
||||
/>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
{/* group1 마지막 카테고리 뒤 공유 Subtotal */}
|
||||
{isGroup1Last && (
|
||||
<table className="items-table" id="group1_subtotal">
|
||||
<colgroup>
|
||||
<col style={{ width: "5%" }} />
|
||||
<col style={{ width: "26%" }} />
|
||||
<col style={{ width: "28.5%" }} />
|
||||
<col style={{ width: "6.5%" }} />
|
||||
<col style={{ width: "24%" }} />
|
||||
<col style={{ width: "10%" }} />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr className="subtotal-row">
|
||||
<td colSpan={4}>Subtotal</td>
|
||||
<td>
|
||||
<input
|
||||
type="text" value={group1Subtotal}
|
||||
onChange={e => {
|
||||
const cleaned = e.target.value.replace(/,/g, "").replace(/[^0-9.]/g, "");
|
||||
setGroup1Subtotal(cleaned === "" ? "" : addComma(cleaned));
|
||||
}}
|
||||
readOnly={readOnly}
|
||||
style={{ textAlign: "right" }}
|
||||
/>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* 비고 (contenteditable HTML) */}
|
||||
<div className="notes-section">
|
||||
<div
|
||||
ref={notesRef}
|
||||
contentEditable={!readOnly}
|
||||
suppressContentEditableWarning
|
||||
dangerouslySetInnerHTML={{ __html: notesContent }}
|
||||
onBlur={e => setNotesContent(e.currentTarget.innerHTML)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 푸터 — 대외비 */}
|
||||
<div style={{ textAlign: "right", fontSize: "7pt", color: "#999", marginTop: 5 }}>
|
||||
* RPS 대외비 - 본자료는 RPS의 사전허가 없이 제3자에게 제공할 수 없음을 알려드립니다.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 버튼 영역 */}
|
||||
<div className="estimate-btn-area no-print">
|
||||
<button type="button" className="estimate-btn" onClick={addCategory} disabled={readOnly}>+ 카테고리 추가</button>
|
||||
<button type="button" className="estimate-btn" onClick={handlePrint}>인쇄</button>
|
||||
<button type="button" className="estimate-btn" onClick={handleSave} disabled={readOnly}>저장</button>
|
||||
<button type="button" className="estimate-btn" onClick={handleClose}>닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import { CommCodeSelect } from "@/components/common/CommCodeSelect";
|
||||
import { ItemSearchDialog, ItemRow } from "@/components/common/ItemSearchDialog";
|
||||
import { AttachmentDialog } from "@/components/common/AttachmentDialog";
|
||||
import { OrderFormViewDialog } from "@/components/sales/OrderFormViewDialog";
|
||||
import { OrderRegistDialog } from "@/components/sales/OrderRegistDialog";
|
||||
import { salesOrderMgmtApi, OrderRow, OrderBody, OrderItem } from "@/lib/api/salesOrderMgmt";
|
||||
|
||||
// wace_plm orderMgmtList.jsp 컬럼 순서/라벨에 맞춤
|
||||
@@ -70,8 +71,13 @@ const CONTRACT_RESULTS = [
|
||||
{ value: "0000965", label: "Cancel" },
|
||||
];
|
||||
|
||||
// wace estimateAndOrderRegistFormPopup 라인 — 제품구분/S/N/요청납기/반납사유/고객요청사항 포함
|
||||
const EMPTY_ITEM: OrderItem = {
|
||||
seq: 1, part_objid: "", part_no: "", part_name: "", quantity: 1,
|
||||
seq: 1,
|
||||
product: "", part_objid: "", part_no: "", part_name: "",
|
||||
serials: [],
|
||||
due_date: "", return_reason: "", customer_request: "",
|
||||
quantity: 1,
|
||||
order_quantity: "", order_unit_price: "0", order_supply_price: "0",
|
||||
order_vat: "0", order_total_amount: "0",
|
||||
};
|
||||
@@ -98,8 +104,18 @@ export default function SalesOrderPage() {
|
||||
items: [],
|
||||
});
|
||||
|
||||
// 품목 검색 모달
|
||||
// 품목 검색 모달 (라인별 진입)
|
||||
const [itemDialogOpen, setItemDialogOpen] = useState(false);
|
||||
const [itemSearchTargetIdx, setItemSearchTargetIdx] = useState<number | null>(null);
|
||||
|
||||
// S/N 관리 모달 + 연속번호 생성 (wace fn_openItemSnPopup / fn_openItemSequentialSnPopup)
|
||||
const [serialDialogOpen, setSerialDialogOpen] = useState(false);
|
||||
const [serialDialogIdx, setSerialDialogIdx] = useState<number | null>(null);
|
||||
const [serialDraft, setSerialDraft] = useState<string[]>([]);
|
||||
const [serialInput, setSerialInput] = useState("");
|
||||
const [seqDialogOpen, setSeqDialogOpen] = useState(false);
|
||||
const [seqStartNo, setSeqStartNo] = useState("");
|
||||
const [seqCount, setSeqCount] = useState("");
|
||||
|
||||
// 첨부파일 다이얼로그 (주문서첨부 클립 컬럼 클릭 시)
|
||||
const [attachDialogOpen, setAttachDialogOpen] = useState(false);
|
||||
@@ -115,6 +131,12 @@ export default function SalesOrderPage() {
|
||||
const [orderFormOpen, setOrderFormOpen] = useState(false);
|
||||
const [orderFormObjid, setOrderFormObjid] = useState<string | null>(null);
|
||||
|
||||
// 견적요청에서 시작된 행의 수주등록 다이얼로그 (wace orderRegistFormPopup 1:1)
|
||||
// - is_direct_order != 'Y' 행을 수정할 때 사용 (헤더 4개 + 라인 ORDER_*만 입력)
|
||||
// - 직접등록 통합폼(estimateAndOrderRegistFormPopup)과 완전 분리
|
||||
const [orderRegistOpen, setOrderRegistOpen] = useState(false);
|
||||
const [orderRegistContract, setOrderRegistContract] = useState<{ objid: string; contractNo: string } | null>(null);
|
||||
|
||||
// 수주확정 다이얼로그 (wace fn_openOrderConfirmPopup 이식 — 상태 select)
|
||||
const [confirmStatusOpen, setConfirmStatusOpen] = useState(false);
|
||||
const [confirmStatusValue, setConfirmStatusValue] = useState<string>("");
|
||||
@@ -192,7 +214,8 @@ export default function SalesOrderPage() {
|
||||
contract_no: contractNo,
|
||||
contract_currency: "KRW",
|
||||
paid_type: "paid",
|
||||
contract_date: new Date().toISOString().slice(0, 10),
|
||||
order_date: new Date().toISOString().slice(0, 10),
|
||||
is_direct_order: "Y",
|
||||
items: [{ ...EMPTY_ITEM }],
|
||||
});
|
||||
setDialogOpen(true);
|
||||
@@ -200,6 +223,14 @@ export default function SalesOrderPage() {
|
||||
|
||||
const openEdit = async () => {
|
||||
if (!selected) { toast.warning("수정할 주문서를 선택하세요."); return; }
|
||||
// wace 분기 (estimateAndOrderRegistFormPopup vs orderRegistFormPopup):
|
||||
// is_direct_order = 'Y' → 직접등록 통합폼 (헤더 9개 + 라인 13컬럼)
|
||||
// 그 외('','N',null) → 견적요청에서 시작된 행 → 별도 수주등록 폼 (헤더 4개 + 라인 ORDER_*)
|
||||
if ((selected.is_direct_order ?? "") !== "Y") {
|
||||
setOrderRegistContract({ objid: selected.objid, contractNo: selected.contract_no ?? "" });
|
||||
setOrderRegistOpen(true);
|
||||
return;
|
||||
}
|
||||
setDialogMode("edit");
|
||||
try {
|
||||
const detail = await salesOrderMgmtApi.detail(selected.objid);
|
||||
@@ -214,7 +245,9 @@ export default function SalesOrderPage() {
|
||||
contract_currency: detail.contract_currency ?? "KRW",
|
||||
exchange_rate: detail.exchange_rate ?? "",
|
||||
receipt_date: detail.receipt_date ?? "",
|
||||
contract_date: detail.contract_date ?? "",
|
||||
order_date: detail.order_date ?? "",
|
||||
approval_required: detail.approval_required ?? "N",
|
||||
is_direct_order: detail.is_direct_order ?? "Y",
|
||||
req_del_date: detail.req_del_date ?? "",
|
||||
po_no: detail.po_no ?? "",
|
||||
contract_result: detail.contract_result ?? "",
|
||||
@@ -225,11 +258,13 @@ export default function SalesOrderPage() {
|
||||
items: (detail.items ?? []).map((it: any) => ({
|
||||
objid: it.objid,
|
||||
seq: it.seq,
|
||||
product: it.product ?? "",
|
||||
part_objid: it.part_objid ?? "",
|
||||
part_no: it.part_no ?? "",
|
||||
part_name: it.part_name ?? "",
|
||||
part_no: it.master_part_no ?? it.part_no ?? "",
|
||||
part_name: it.master_part_name ?? it.part_name ?? "",
|
||||
quantity: it.quantity ?? 1,
|
||||
due_date: it.due_date ?? "",
|
||||
return_reason: it.return_reason ?? "",
|
||||
customer_request: it.customer_request ?? "",
|
||||
order_quantity: it.order_quantity ?? "",
|
||||
order_unit_price: it.order_unit_price ?? "",
|
||||
@@ -357,9 +392,95 @@ export default function SalesOrderPage() {
|
||||
return { ...prev, items };
|
||||
});
|
||||
};
|
||||
|
||||
// wace fn_calculateItemAmount / fn_calculateFromSupplyPrice / fn_calculateTotalFromVat 이식
|
||||
// 수량 또는 단가 변경 → 공급가액 = 수량×단가, 부가세 = round(공급가액×0.1), 총액 = 공급가액+부가세
|
||||
// 공급가액 직접 입력 → 부가세 = round(supply×0.1), 총액 = supply+vat
|
||||
// 부가세 직접 입력 → 총액 = supply+vat 재계산만
|
||||
// 총액 직접 입력 → 다른 값 영향 없음
|
||||
const toNum = (v: any) => Number(String(v ?? "0").replace(/,/g, "")) || 0;
|
||||
const updateItemWithCalc = (idx: number, key: keyof OrderItem, val: any) => {
|
||||
setForm((prev) => {
|
||||
const items = [...(prev.items ?? [])];
|
||||
const cur: any = { ...items[idx], [key]: val };
|
||||
if (key === "order_quantity" || key === "order_unit_price") {
|
||||
const supply = toNum(cur.order_quantity) * toNum(cur.order_unit_price);
|
||||
const vat = Math.round(supply * 0.1);
|
||||
cur.order_supply_price = String(supply);
|
||||
cur.order_vat = String(vat);
|
||||
cur.order_total_amount = String(supply + vat);
|
||||
} else if (key === "order_supply_price") {
|
||||
const supply = toNum(cur.order_supply_price);
|
||||
const vat = Math.round(supply * 0.1);
|
||||
cur.order_vat = String(vat);
|
||||
cur.order_total_amount = String(supply + vat);
|
||||
} else if (key === "order_vat") {
|
||||
cur.order_total_amount = String(toNum(cur.order_supply_price) + toNum(cur.order_vat));
|
||||
}
|
||||
items[idx] = cur;
|
||||
return { ...prev, items };
|
||||
});
|
||||
};
|
||||
const addItem = () => setForm((prev) => ({ ...prev, items: [...(prev.items ?? []), { ...EMPTY_ITEM, seq: (prev.items?.length ?? 0) + 1 }] }));
|
||||
const removeItem = (idx: number) => setForm((prev) => ({ ...prev, items: (prev.items ?? []).filter((_, i) => i !== idx).map((it, i) => ({ ...it, seq: i + 1 })) }));
|
||||
|
||||
// S/N 관리 (wace fn_openItemSnPopup) — 견적관리와 동일 패턴
|
||||
const openSerialDialog = (idx: number) => {
|
||||
const item = form.items?.[idx];
|
||||
setSerialDialogIdx(idx);
|
||||
setSerialDraft([...(item?.serials ?? [])]);
|
||||
setSerialInput("");
|
||||
setSerialDialogOpen(true);
|
||||
};
|
||||
const addSerialDraft = () => {
|
||||
const v = serialInput.trim();
|
||||
if (!v) { toast.warning("S/N을 입력해주세요."); return; }
|
||||
if (serialDraft.includes(v)) { toast.warning("이미 등록된 S/N입니다."); return; }
|
||||
setSerialDraft((prev) => [...prev, v]);
|
||||
setSerialInput("");
|
||||
};
|
||||
const removeSerialDraft = (i: number) => setSerialDraft((prev) => prev.filter((_, k) => k !== i));
|
||||
const applySerialDraft = () => {
|
||||
if (serialDialogIdx === null) return;
|
||||
updateItem(serialDialogIdx, "serials", [...serialDraft]);
|
||||
setSerialDialogOpen(false);
|
||||
};
|
||||
const openSeqDialog = () => { setSeqStartNo(""); setSeqCount(""); setSeqDialogOpen(true); };
|
||||
const generateSequentialSn = () => {
|
||||
const startNo = seqStartNo.trim();
|
||||
const count = parseInt(seqCount, 10);
|
||||
if (!startNo) { toast.warning("시작 번호를 입력해주세요."); return; }
|
||||
if (!count || count < 1) { toast.warning("생성 개수를 1 이상 입력해주세요."); return; }
|
||||
if (count > 100) { toast.warning("최대 100개까지만 생성 가능합니다."); return; }
|
||||
const m = startNo.match(/^(.*?)(\d+)$/);
|
||||
if (!m) { toast.warning("형식이 올바르지 않습니다. 마지막에 숫자가 있어야 합니다."); return; }
|
||||
const prefix = m[1]; const startNum = parseInt(m[2], 10); const numLen = m[2].length;
|
||||
setSerialDraft((prev) => {
|
||||
const next = [...prev];
|
||||
for (let i = 0; i < count; i++) {
|
||||
const sn = prefix + String(startNum + i).padStart(numLen, "0");
|
||||
if (!next.includes(sn)) next.push(sn);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
setSeqDialogOpen(false);
|
||||
};
|
||||
|
||||
// 라인 합계 자동 계산용 헬퍼
|
||||
const formatNum = (v: any) => {
|
||||
const n = Number(String(v ?? "0").replace(/,/g, ""));
|
||||
return isNaN(n) ? 0 : n;
|
||||
};
|
||||
const lineTotal = useMemo(() => {
|
||||
const items = form.items ?? [];
|
||||
return items.reduce((acc, it) => ({
|
||||
qty: acc.qty + formatNum(it.order_quantity),
|
||||
supply: acc.supply + formatNum(it.order_supply_price),
|
||||
vat: acc.vat + formatNum(it.order_vat),
|
||||
total: acc.total + formatNum(it.order_total_amount),
|
||||
}), { qty: 0, supply: 0, vat: 0, total: 0 });
|
||||
}, [form.items]);
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col overflow-hidden p-4 gap-4">
|
||||
{ConfirmDialogComponent}
|
||||
@@ -373,8 +494,10 @@ export default function SalesOrderPage() {
|
||||
<Button variant="outline" size="sm" onClick={fetchList} disabled={loading}>
|
||||
{loading ? <Loader2 className="w-4 h-4 mr-1 animate-spin" /> : <Search className="w-4 h-4 mr-1" />}조회
|
||||
</Button>
|
||||
<Button size="sm" onClick={openCreate}><Plus className="w-4 h-4 mr-1" />수주입력</Button>
|
||||
<Button size="sm" variant="outline" onClick={openEdit} disabled={!selected}><Pencil className="w-4 h-4 mr-1" />수정</Button>
|
||||
<Button size="sm" onClick={() => { if (selected) openEdit(); else openCreate(); }}>
|
||||
{selected ? <Pencil className="w-4 h-4 mr-1" /> : <Plus className="w-4 h-4 mr-1" />}
|
||||
{selected ? "수주수정" : "수주입력"}
|
||||
</Button>
|
||||
<Button size="sm" className="bg-emerald-600 hover:bg-emerald-700 text-white" onClick={handleConfirmOrder} disabled={!selected}>
|
||||
<CheckCircle2 className="w-4 h-4 mr-1" />수주확정
|
||||
</Button>
|
||||
@@ -486,107 +609,200 @@ export default function SalesOrderPage() {
|
||||
/>
|
||||
|
||||
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
||||
<DialogContent className="max-w-6xl max-h-[90vh] overflow-y-auto">
|
||||
<DialogContent
|
||||
className="!max-w-[95vw] w-[95vw] max-h-[92vh] overflow-y-auto"
|
||||
onInteractOutside={(e) => e.preventDefault()} /* 자식 S/N·연속번호 Dialog 닫힐 때 부모까지 닫히는 현상 차단 */
|
||||
>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{dialogMode === "create" ? "주문서 등록" : "주문서 수정"}</DialogTitle>
|
||||
<DialogDescription>주문 헤더 + 라인을 입력합니다.</DialogDescription>
|
||||
<DialogTitle>
|
||||
{/* 이 통합폼은 항상 is_direct_order='Y' 케이스만 처리 (wace estimateAndOrderRegistFormPopup) */}
|
||||
영업관리 _ 주문서관리 _ 수주통합{dialogMode === "edit" ? "수정" : "등록"}
|
||||
</DialogTitle>
|
||||
<DialogDescription className="sr-only">수주통합 기본정보 + 품목정보를 입력합니다. (wace estimateAndOrderRegistFormPopup 1:1)</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
{/* 수주통합 기본정보 — wace 헤더 9개 (영업번호 자동채번 표시 포함) */}
|
||||
<fieldset className="border rounded-md p-3">
|
||||
<legend className="text-sm font-semibold px-2">주문 헤더</legend>
|
||||
<legend className="text-sm font-semibold px-2">수주통합 기본정보</legend>
|
||||
<div className="grid grid-cols-4 gap-3">
|
||||
<div><Label className="text-xs">영업번호 (자동채번)</Label>
|
||||
<Input readOnly className="bg-muted/30"
|
||||
value={form.contract_no ?? ""}
|
||||
placeholder="저장 시 자동 부여됩니다" /></div>
|
||||
<div><Label className="text-xs">발주번호</Label>
|
||||
<Input value={form.po_no ?? ""} onChange={(e) => setForm({ ...form, po_no: e.target.value })} /></div>
|
||||
<div><Label className="text-xs">발주일</Label>
|
||||
<Input type="date" value={form.contract_date ?? ""} onChange={(e) => setForm({ ...form, contract_date: e.target.value })} /></div>
|
||||
<div><Label className="text-xs">요청납기</Label>
|
||||
<Input type="date" value={form.req_del_date ?? ""} onChange={(e) => setForm({ ...form, req_del_date: e.target.value })} /></div>
|
||||
<div><Label className="text-xs">고객사</Label>
|
||||
<CustomerSelect
|
||||
value={form.customer_objid ?? ""}
|
||||
onValueChange={(v) => setForm({ ...form, customer_objid: v })}
|
||||
/></div>
|
||||
<div><Label className="text-xs">접수일</Label>
|
||||
<Input type="date" value={form.receipt_date ?? ""} onChange={(e) => setForm({ ...form, receipt_date: e.target.value })} /></div>
|
||||
<div><Label className="text-xs">통화</Label>
|
||||
<Input value={form.contract_currency ?? "KRW"} onChange={(e) => setForm({ ...form, contract_currency: e.target.value })} /></div>
|
||||
<div><Label className="text-xs">환율</Label>
|
||||
<Input value={form.exchange_rate ?? ""} onChange={(e) => setForm({ ...form, exchange_rate: e.target.value })} /></div>
|
||||
<div><Label className="text-xs">유/무상</Label>
|
||||
<Select value={form.paid_type ?? "paid"} onValueChange={(v) => setForm({ ...form, paid_type: v })}>
|
||||
<SelectTrigger><SelectValue /></SelectTrigger>
|
||||
<div>
|
||||
<Label className="text-xs">영업번호 (자동채번)</Label>
|
||||
<Input readOnly className="bg-muted/30" value={form.contract_no ?? ""} placeholder="저장 시 자동 부여" />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">주문유형 <span className="text-rose-600">*</span></Label>
|
||||
<CommCodeSelect groupId="0000167" value={form.category_cd ?? ""}
|
||||
onValueChange={(v) => setForm({ ...form, category_cd: v })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">국내/해외 <span className="text-rose-600">*</span></Label>
|
||||
<CommCodeSelect groupId="0001219" value={form.area_cd ?? ""}
|
||||
onValueChange={(v) => setForm({ ...form, area_cd: v })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">고객사 <span className="text-rose-600">*</span></Label>
|
||||
<CustomerSelect value={form.customer_objid ?? ""}
|
||||
onValueChange={(v) => setForm({ ...form, customer_objid: v })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">유/무상 <span className="text-rose-600">*</span></Label>
|
||||
<Select value={form.paid_type || undefined}
|
||||
onValueChange={(v) => setForm({ ...form, paid_type: v })}>
|
||||
<SelectTrigger><SelectValue placeholder="선택" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="paid">유상</SelectItem>
|
||||
<SelectItem value="free">무상</SelectItem>
|
||||
</SelectContent>
|
||||
</Select></div>
|
||||
<div><Label className="text-xs">수주상태</Label>
|
||||
<Select value={form.contract_result || undefined} onValueChange={(v) => setForm({ ...form, contract_result: v })}>
|
||||
<SelectTrigger><SelectValue placeholder="선택" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
{CONTRACT_RESULTS.filter((o) => o.value).map((o) => (<SelectItem key={o.value} value={o.value}>{o.label}</SelectItem>))}
|
||||
</SelectContent>
|
||||
</Select></div>
|
||||
<div><Label className="text-xs">담당자(PM ID)</Label>
|
||||
<Input value={form.pm_user_id ?? ""} onChange={(e) => setForm({ ...form, pm_user_id: e.target.value })} /></div>
|
||||
<div><Label className="text-xs">출하방법</Label>
|
||||
<Input value={form.shipping_method ?? ""} onChange={(e) => setForm({ ...form, shipping_method: e.target.value })} /></div>
|
||||
<div className="col-span-4"><Label className="text-xs">고객사 요청사항</Label>
|
||||
<Textarea rows={2} value={form.customer_request ?? ""} onChange={(e) => setForm({ ...form, customer_request: e.target.value })} /></div>
|
||||
</Select>
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">접수일 <span className="text-rose-600">*</span></Label>
|
||||
<Input type="date" value={form.receipt_date ?? ""}
|
||||
onChange={(e) => setForm({ ...form, receipt_date: e.target.value })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">견적환종</Label>
|
||||
<CommCodeSelect groupId="0001533" value={form.contract_currency ?? ""}
|
||||
onValueChange={(v) => setForm({ ...form, contract_currency: v })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">견적환율</Label>
|
||||
<Input value={form.exchange_rate ?? ""}
|
||||
onChange={(e) => setForm({ ...form, exchange_rate: e.target.value })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">발주번호</Label>
|
||||
<Input value={form.po_no ?? ""}
|
||||
onChange={(e) => setForm({ ...form, po_no: e.target.value })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">발주일 <span className="text-rose-600">*</span></Label>
|
||||
<Input type="date" value={form.order_date ?? ""}
|
||||
onChange={(e) => setForm({ ...form, order_date: e.target.value })} />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
{/* 품목정보 — wace 13컬럼 + Total 합계 행 */}
|
||||
<fieldset className="border rounded-md p-3 space-y-2">
|
||||
<legend className="text-sm font-semibold px-2">주문 라인</legend>
|
||||
<legend className="text-sm font-semibold px-2 flex items-center justify-between w-full">
|
||||
<span>품목정보</span>
|
||||
</legend>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-xs">
|
||||
<thead className="bg-muted/50">
|
||||
<tr>
|
||||
<th className="p-2 w-10">#</th>
|
||||
<th className="p-2 w-32">품목 ID</th>
|
||||
<th className="p-2">품번</th>
|
||||
<th className="p-2">품명</th>
|
||||
<th className="p-2 w-24">수주수량</th>
|
||||
<th className="p-2 w-28">단가</th>
|
||||
<th className="p-2 w-28">공급가액</th>
|
||||
<th className="p-2 w-24">부가세</th>
|
||||
<th className="p-2 w-28">총액</th>
|
||||
<th className="p-2 w-28">납기</th>
|
||||
<th className="p-2 w-10"></th>
|
||||
<th className="p-2 w-10 whitespace-nowrap">No</th>
|
||||
<th className="p-2 w-28 whitespace-nowrap">제품구분 <span className="text-rose-600">*</span></th>
|
||||
<th className="p-2 w-40 whitespace-nowrap">품번 <span className="text-rose-600">*</span></th>
|
||||
<th className="p-2 w-56 whitespace-nowrap">품명 <span className="text-rose-600">*</span></th>
|
||||
<th className="p-2 w-40 whitespace-nowrap">S/N</th>
|
||||
<th className="p-2 w-36 whitespace-nowrap">요청납기</th>
|
||||
<th className="p-2 min-w-[220px] whitespace-nowrap">고객요청사항</th>
|
||||
<th className="p-2 w-28 whitespace-nowrap">반납사유</th>
|
||||
<th className="p-2 w-24 whitespace-nowrap text-right">수주수량 <span className="text-rose-600">*</span></th>
|
||||
<th className="p-2 w-28 whitespace-nowrap text-right">수주단가</th>
|
||||
<th className="p-2 w-32 whitespace-nowrap text-right">수주공급가액</th>
|
||||
<th className="p-2 w-28 whitespace-nowrap text-right">수주부가세</th>
|
||||
<th className="p-2 w-32 whitespace-nowrap text-right">수주총액</th>
|
||||
<th className="p-2 w-12 whitespace-nowrap">삭제</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(form.items ?? []).map((it, idx) => (
|
||||
<tr key={idx} className="border-t">
|
||||
<td className="p-1 text-center">{it.seq}</td>
|
||||
<td className="p-1"><Input className="h-8" value={it.part_objid} onChange={(e) => updateItem(idx, "part_objid", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8" value={it.part_no} onChange={(e) => updateItem(idx, "part_no", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8" value={it.part_name} onChange={(e) => updateItem(idx, "part_name", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8 text-right" value={it.order_quantity ?? ""} onChange={(e) => updateItem(idx, "order_quantity", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8 text-right" value={it.order_unit_price ?? ""} onChange={(e) => updateItem(idx, "order_unit_price", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8 text-right" value={it.order_supply_price ?? ""} onChange={(e) => updateItem(idx, "order_supply_price", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8 text-right" value={it.order_vat ?? ""} onChange={(e) => updateItem(idx, "order_vat", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8 text-right" value={it.order_total_amount ?? ""} onChange={(e) => updateItem(idx, "order_total_amount", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8" type="date" value={it.due_date ?? ""} onChange={(e) => updateItem(idx, "due_date", e.target.value)} /></td>
|
||||
<td className="p-1 text-center"><Button variant="ghost" size="icon" onClick={() => removeItem(idx)}><Trash2 className="w-3 h-3" /></Button></td>
|
||||
<td className="p-1">
|
||||
<CommCodeSelect groupId="0000001"
|
||||
value={it.product ?? ""}
|
||||
onValueChange={(v) => updateItem(idx, "product", v)} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<PartSelect mode="partNo" value={it.part_objid}
|
||||
onValueChange={(partObjId, row) => {
|
||||
setForm((prev) => {
|
||||
const items = [...(prev.items ?? [])];
|
||||
items[idx] = { ...items[idx], part_objid: partObjId,
|
||||
part_no: row?.item_number ?? "",
|
||||
part_name: row?.item_name ?? items[idx].part_name };
|
||||
return { ...prev, items };
|
||||
});
|
||||
}} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<PartSelect mode="partName" value={it.part_objid}
|
||||
onValueChange={(partObjId, row) => {
|
||||
setForm((prev) => {
|
||||
const items = [...(prev.items ?? [])];
|
||||
items[idx] = { ...items[idx], part_objid: partObjId,
|
||||
part_no: row?.item_number ?? items[idx].part_no,
|
||||
part_name: row?.item_name ?? "" };
|
||||
return { ...prev, items };
|
||||
});
|
||||
}} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8" readOnly
|
||||
value={(it.serials ?? []).join(", ")}
|
||||
onClick={() => openSerialDialog(idx)}
|
||||
placeholder="클릭하여 S/N 추가" />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8" type="date" value={it.due_date ?? ""}
|
||||
onChange={(e) => updateItem(idx, "due_date", e.target.value)} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Textarea className="min-h-[34px] resize-y text-xs" rows={1}
|
||||
value={it.customer_request ?? ""}
|
||||
onChange={(e) => updateItem(idx, "customer_request", e.target.value)} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<CommCodeSelect groupId="0001810"
|
||||
value={it.return_reason ?? ""}
|
||||
onValueChange={(v) => updateItem(idx, "return_reason", v)} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8 text-right" type="number" min={0}
|
||||
value={it.order_quantity ?? ""}
|
||||
onChange={(e) => updateItemWithCalc(idx, "order_quantity", e.target.value)} />
|
||||
</td>
|
||||
<td className="p-1"><Input className="h-8 text-right" value={it.order_unit_price ?? ""}
|
||||
onChange={(e) => updateItemWithCalc(idx, "order_unit_price", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8 text-right" value={it.order_supply_price ?? ""}
|
||||
onChange={(e) => updateItemWithCalc(idx, "order_supply_price", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8 text-right" value={it.order_vat ?? ""}
|
||||
onChange={(e) => updateItemWithCalc(idx, "order_vat", e.target.value)} /></td>
|
||||
<td className="p-1"><Input className="h-8 text-right" value={it.order_total_amount ?? ""}
|
||||
onChange={(e) => updateItem(idx, "order_total_amount", e.target.value)} /></td>
|
||||
<td className="p-1 text-center">
|
||||
<Button variant="ghost" size="icon" onClick={() => removeItem(idx)}>
|
||||
<Trash2 className="w-3 h-3" />
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{(!form.items || form.items.length === 0) && (
|
||||
<tr><td colSpan={11} className="p-3 text-center text-muted-foreground">라인이 없습니다.</td></tr>
|
||||
<tr><td colSpan={14} className="p-3 text-center text-muted-foreground">품목이 없습니다.</td></tr>
|
||||
)}
|
||||
</tbody>
|
||||
{(form.items?.length ?? 0) > 0 && (
|
||||
<tfoot>
|
||||
<tr className="bg-muted/30 font-semibold">
|
||||
<td colSpan={8} className="p-2 text-center">Total</td>
|
||||
<td className="p-2 text-right">{lineTotal.qty.toLocaleString()}</td>
|
||||
<td className="p-2"></td>
|
||||
<td className="p-2 text-right">{lineTotal.supply.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}</td>
|
||||
<td className="p-2 text-right">{lineTotal.vat.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}</td>
|
||||
<td className="p-2 text-right">{lineTotal.total.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}</td>
|
||||
<td className="p-2"></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
)}
|
||||
</table>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button size="sm" variant="outline" onClick={addItem}>
|
||||
<Plus className="w-3 h-3 mr-1" />라인 추가
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => setItemDialogOpen(true)}>
|
||||
<Search className="w-3 h-3 mr-1" />품목 검색
|
||||
<Plus className="w-3 h-3 mr-1" />품목 추가
|
||||
</Button>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -600,6 +816,82 @@ export default function SalesOrderPage() {
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* S/N 관리 — wace fn_openItemSnPopup */}
|
||||
<Dialog open={serialDialogOpen} onOpenChange={setSerialDialogOpen}>
|
||||
<DialogContent className="max-w-2xl" onInteractOutside={(e) => e.preventDefault()}>
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-center">S/N 관리</DialogTitle>
|
||||
<DialogDescription className="sr-only">시리얼 번호 추가/삭제 및 연속번호 생성</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4">
|
||||
<div className="max-h-[300px] overflow-y-auto border rounded">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-muted/50">
|
||||
<tr>
|
||||
<th className="border px-3 py-2 w-16 text-center">번호</th>
|
||||
<th className="border px-3 py-2 text-center">S/N</th>
|
||||
<th className="border px-3 py-2 w-20 text-center">삭제</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{serialDraft.length === 0 ? (
|
||||
<tr><td colSpan={3} className="border px-3 py-8 text-center text-muted-foreground">등록된 S/N이 없습니다.</td></tr>
|
||||
) : serialDraft.map((s, i) => (
|
||||
<tr key={i}>
|
||||
<td className="border px-3 py-1.5 text-center">{i + 1}</td>
|
||||
<td className="border px-3 py-1.5">{s}</td>
|
||||
<td className="border px-3 py-1.5 text-center">
|
||||
<Button size="sm" variant="outline" onClick={() => removeSerialDraft(i)}>삭제</Button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Input value={serialInput} onChange={(e) => setSerialInput(e.target.value)}
|
||||
onKeyDown={(e) => { if (e.key === "Enter") { e.preventDefault(); addSerialDraft(); } }}
|
||||
placeholder="S/N 입력" />
|
||||
<Button onClick={addSerialDraft} type="button">추가</Button>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter className="sm:justify-center">
|
||||
<Button variant="outline" onClick={openSeqDialog}>연속번호생성</Button>
|
||||
<Button onClick={applySerialDraft}>확인</Button>
|
||||
<Button variant="outline" onClick={() => setSerialDialogOpen(false)}>취소</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* 연속번호 생성 — wace fn_openItemSequentialSnPopup */}
|
||||
<Dialog open={seqDialogOpen} onOpenChange={setSeqDialogOpen}>
|
||||
<DialogContent className="max-w-sm" onInteractOutside={(e) => e.preventDefault()}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>연속번호 생성</DialogTitle>
|
||||
<DialogDescription className="sr-only">시작번호와 생성개수로 연속 S/N 일괄 추가</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<Label className="text-xs">시작번호 <span className="text-rose-600">*</span></Label>
|
||||
<Input value={seqStartNo} onChange={(e) => setSeqStartNo(e.target.value)} placeholder="예: ITEM-001" />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">생성개수 <span className="text-rose-600">*</span></Label>
|
||||
<Input type="number" min={1} max={100} value={seqCount}
|
||||
onChange={(e) => setSeqCount(e.target.value)} placeholder="예: 10" />
|
||||
</div>
|
||||
<div className="bg-muted/40 rounded p-2 text-[11px] leading-5 text-muted-foreground">
|
||||
예: ITEM-001, 개수 3 → ITEM-001, ITEM-002, ITEM-003<br />
|
||||
※ 최대 100개까지 생성 가능
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setSeqDialogOpen(false)}>취소</Button>
|
||||
<Button onClick={generateSequentialSn}>생성</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* 첨부파일 다이얼로그 — 주문서첨부 클립 컬럼 클릭 시 */}
|
||||
{attachContext && (
|
||||
<AttachmentDialog
|
||||
@@ -621,6 +913,15 @@ export default function SalesOrderPage() {
|
||||
objid={orderFormObjid}
|
||||
/>
|
||||
|
||||
{/* 견적요청에서 시작된 행의 수주등록 다이얼로그 (wace orderRegistFormPopup 1:1) */}
|
||||
<OrderRegistDialog
|
||||
open={orderRegistOpen}
|
||||
onOpenChange={setOrderRegistOpen}
|
||||
contractObjId={orderRegistContract?.objid ?? null}
|
||||
contractNo={orderRegistContract?.contractNo ?? null}
|
||||
onSaved={() => { setOrderRegistOpen(false); fetchList(); }}
|
||||
/>
|
||||
|
||||
{/* 수주확정 — wace fn_openOrderConfirmPopup 이식: 상태 select */}
|
||||
<Dialog open={confirmStatusOpen} onOpenChange={setConfirmStatusOpen}>
|
||||
<DialogContent className="max-w-md">
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* OrderRegistDialog — wace orderRegistFormPopup.jsp 1:1 이식
|
||||
*
|
||||
* 견적요청에서 시작된 행(is_direct_order != 'Y')의 "수주등록/수정" 폼.
|
||||
* 통합폼(estimateAndOrderRegistFormPopup)과 분리된 별도 화면.
|
||||
*
|
||||
* - 헤더 4개: 발주번호 / 발주일* / 견적환종 / 견적환율
|
||||
* - 라인: contract_item 자동 로드(읽기전용), ORDER_* 5컬럼만 입력
|
||||
* - 라인 추가/삭제 불가
|
||||
* - 자동계산: 수량×단가→공급가액, 공급가액×10%→부가세, 공급+부가세→총액
|
||||
*/
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import {
|
||||
Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Loader2, Save } from "lucide-react";
|
||||
import { CommCodeSelect } from "@/components/common/CommCodeSelect";
|
||||
import { salesOrderMgmtApi, OrderBody, OrderItem } from "@/lib/api/salesOrderMgmt";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export interface OrderRegistDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
contractObjId: string | null;
|
||||
contractNo: string | null;
|
||||
onSaved?: () => void;
|
||||
}
|
||||
|
||||
const toNum = (v: any) => Number(String(v ?? "0").replace(/,/g, "")) || 0;
|
||||
|
||||
export function OrderRegistDialog({ open, onOpenChange, contractObjId, contractNo, onSaved }: OrderRegistDialogProps) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [form, setForm] = useState<OrderBody>({ contract_currency: "KRW", items: [] });
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || !contractObjId) return;
|
||||
let cancelled = false;
|
||||
(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const detail = await salesOrderMgmtApi.detail(contractObjId);
|
||||
if (cancelled || !detail) return;
|
||||
setForm({
|
||||
objid: detail.objid,
|
||||
contract_no: detail.contract_no ?? "",
|
||||
category_cd: detail.category_cd ?? "",
|
||||
customer_objid: detail.customer_objid ?? "",
|
||||
product: detail.product ?? "",
|
||||
area_cd: detail.area_cd ?? "",
|
||||
paid_type: detail.paid_type ?? "paid",
|
||||
contract_currency: detail.contract_currency ?? "KRW",
|
||||
exchange_rate: detail.exchange_rate ?? "",
|
||||
receipt_date: detail.receipt_date ?? "",
|
||||
order_date: detail.order_date ?? new Date().toISOString().slice(0, 10),
|
||||
approval_required: detail.approval_required ?? "N",
|
||||
is_direct_order: detail.is_direct_order ?? "",
|
||||
req_del_date: detail.req_del_date ?? "",
|
||||
po_no: detail.po_no ?? "",
|
||||
contract_result: detail.contract_result ?? "",
|
||||
pm_user_id: detail.pm_user_id ?? "",
|
||||
customer_request: detail.customer_request ?? "",
|
||||
shipping_method: detail.shipping_method ?? "",
|
||||
incoterms: detail.incoterms ?? "",
|
||||
items: (detail.items ?? []).map((it: any) => ({
|
||||
objid: it.objid,
|
||||
seq: it.seq,
|
||||
product: it.product ?? "",
|
||||
part_objid: it.part_objid ?? "",
|
||||
part_no: it.master_part_no ?? it.part_no ?? "",
|
||||
part_name: it.master_part_name ?? it.part_name ?? "",
|
||||
quantity: it.quantity ?? 1,
|
||||
due_date: it.due_date ?? "",
|
||||
return_reason: it.return_reason ?? "",
|
||||
customer_request: it.customer_request ?? "",
|
||||
order_quantity: it.order_quantity ?? "",
|
||||
order_unit_price: it.order_unit_price ?? "",
|
||||
order_supply_price: it.order_supply_price ?? "",
|
||||
order_vat: it.order_vat ?? "",
|
||||
order_total_amount: it.order_total_amount ?? "",
|
||||
cancel_qty: it.cancel_qty ?? "",
|
||||
serials: it.serials ?? [],
|
||||
})),
|
||||
});
|
||||
} catch (err: any) {
|
||||
toast.error(`수주등록 폼 로드 실패: ${err?.response?.data?.message ?? err.message}`);
|
||||
} finally {
|
||||
if (!cancelled) setLoading(false);
|
||||
}
|
||||
})();
|
||||
return () => { cancelled = true; };
|
||||
}, [open, contractObjId]);
|
||||
|
||||
// wace fn_calculateItemAmount / fn_calculateTotalFromVat 이식
|
||||
const updateItemWithCalc = (idx: number, key: keyof OrderItem, val: any) => {
|
||||
setForm((prev) => {
|
||||
const items = [...(prev.items ?? [])];
|
||||
const cur: any = { ...items[idx], [key]: val };
|
||||
if (key === "order_quantity" || key === "order_unit_price") {
|
||||
const supply = toNum(cur.order_quantity) * toNum(cur.order_unit_price);
|
||||
const vat = Math.round(supply * 0.1);
|
||||
cur.order_supply_price = String(supply);
|
||||
cur.order_vat = String(vat);
|
||||
cur.order_total_amount = String(supply + vat);
|
||||
} else if (key === "order_vat") {
|
||||
cur.order_total_amount = String(toNum(cur.order_supply_price) + toNum(cur.order_vat));
|
||||
}
|
||||
items[idx] = cur;
|
||||
return { ...prev, items };
|
||||
});
|
||||
};
|
||||
|
||||
const formatNum = (v: any) => {
|
||||
const n = Number(String(v ?? "0").replace(/,/g, ""));
|
||||
return isNaN(n) ? 0 : n;
|
||||
};
|
||||
const lineTotal = useMemo(() => {
|
||||
const items = form.items ?? [];
|
||||
return items.reduce((acc, it) => ({
|
||||
qty: acc.qty + formatNum(it.order_quantity),
|
||||
supply: acc.supply + formatNum(it.order_supply_price),
|
||||
vat: acc.vat + formatNum(it.order_vat),
|
||||
total: acc.total + formatNum(it.order_total_amount),
|
||||
}), { qty: 0, supply: 0, vat: 0, total: 0 });
|
||||
}, [form.items]);
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!contractObjId) return;
|
||||
if (!form.order_date) { toast.warning("발주일을 입력해주세요."); return; }
|
||||
// wace fn_save 검증: 라인별 제품구분 + 수주수량
|
||||
for (const it of (form.items ?? [])) {
|
||||
if (!it.product) { toast.warning("제품구분을 선택해주세요."); return; }
|
||||
const oq = toNum(it.order_quantity);
|
||||
if (!oq || oq <= 0) { toast.warning("수주수량을 입력해주세요."); return; }
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
await salesOrderMgmtApi.update(contractObjId, form);
|
||||
toast.success("수주등록이 저장되었습니다.");
|
||||
onOpenChange(false);
|
||||
onSaved?.();
|
||||
} catch (err: any) {
|
||||
toast.error(`저장 실패: ${err?.response?.data?.message ?? err.message}`);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent
|
||||
className="!max-w-[90vw] w-[90vw] max-h-[92vh] overflow-y-auto"
|
||||
onInteractOutside={(e) => e.preventDefault()}
|
||||
>
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
영업관리 _ 주문서관리 _ 수주등록 (영업번호: {contractNo ?? "-"})
|
||||
</DialogTitle>
|
||||
<DialogDescription className="sr-only">
|
||||
견적요청에서 시작된 행의 수주등록 폼 (wace orderRegistFormPopup 1:1)
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
{loading ? (
|
||||
<div className="flex items-center justify-center py-10">
|
||||
<Loader2 className="w-5 h-5 animate-spin mr-2" /> 로드 중...
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{/* 수주 기본정보 — wace 헤더 4개 */}
|
||||
<fieldset className="border rounded-md p-3">
|
||||
<legend className="text-sm font-semibold px-2">수주 기본정보</legend>
|
||||
<div className="grid grid-cols-4 gap-3">
|
||||
<div>
|
||||
<Label className="text-xs">발주번호</Label>
|
||||
<Input value={form.po_no ?? ""}
|
||||
onChange={(e) => setForm({ ...form, po_no: e.target.value })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">발주일 <span className="text-rose-600">*</span></Label>
|
||||
<Input type="date" value={form.order_date ?? ""}
|
||||
onChange={(e) => setForm({ ...form, order_date: e.target.value })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">견적환종</Label>
|
||||
<CommCodeSelect groupId="0001533" value={form.contract_currency ?? ""}
|
||||
onValueChange={(v) => setForm({ ...form, contract_currency: v })} />
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs">견적환율</Label>
|
||||
<Input value={form.exchange_rate ?? ""}
|
||||
onChange={(e) => setForm({ ...form, exchange_rate: e.target.value })} />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
{/* 품목정보 — 견적요청에서 자동 로드 (라인 추가/삭제 불가) */}
|
||||
<fieldset className="border rounded-md p-3 mt-3">
|
||||
<legend className="text-sm font-semibold px-2">품목정보 (견적요청에서 자동 로드)</legend>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-xs">
|
||||
<thead className="bg-muted/50">
|
||||
<tr>
|
||||
<th className="p-2 w-10 whitespace-nowrap">No</th>
|
||||
<th className="p-2 w-28 whitespace-nowrap">제품구분 <span className="text-rose-600">*</span></th>
|
||||
<th className="p-2 w-32 whitespace-nowrap">품번</th>
|
||||
<th className="p-2 w-48 whitespace-nowrap">품명</th>
|
||||
<th className="p-2 w-36 whitespace-nowrap">S/N</th>
|
||||
<th className="p-2 w-24 whitespace-nowrap text-right">수주수량 <span className="text-rose-600">*</span></th>
|
||||
<th className="p-2 w-28 whitespace-nowrap text-right">수주단가</th>
|
||||
<th className="p-2 w-32 whitespace-nowrap text-right">수주공급가액</th>
|
||||
<th className="p-2 w-28 whitespace-nowrap text-right">수주부가세</th>
|
||||
<th className="p-2 w-32 whitespace-nowrap text-right">수주총액</th>
|
||||
<th className="p-2 w-12 whitespace-nowrap text-center">-</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(form.items ?? []).map((it, idx) => {
|
||||
const serials = (it.serials ?? []) as string[];
|
||||
const snDisplay = serials.length > 1
|
||||
? `${serials[0]} 외 ${serials.length - 1}개`
|
||||
: (serials[0] ?? "");
|
||||
return (
|
||||
<tr key={idx} className="border-t">
|
||||
<td className="p-1 text-center">{it.seq}</td>
|
||||
<td className="p-1">
|
||||
<CommCodeSelect groupId="0000001"
|
||||
value={it.product ?? ""}
|
||||
onValueChange={(v) => {
|
||||
setForm((prev) => {
|
||||
const items = [...(prev.items ?? [])];
|
||||
items[idx] = { ...items[idx], product: v };
|
||||
return { ...prev, items };
|
||||
});
|
||||
}} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8 bg-muted/30" readOnly value={it.part_no ?? ""} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8 bg-muted/30" readOnly value={it.part_name ?? ""} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8 bg-muted/30" readOnly title={serials.join(", ")} value={snDisplay} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8 text-right" type="number" min={0}
|
||||
value={it.order_quantity ?? ""}
|
||||
onChange={(e) => updateItemWithCalc(idx, "order_quantity", e.target.value)} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8 text-right" value={it.order_unit_price ?? ""}
|
||||
onChange={(e) => updateItemWithCalc(idx, "order_unit_price", e.target.value)} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8 text-right bg-muted/30" readOnly value={it.order_supply_price ?? ""} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8 text-right" value={it.order_vat ?? ""}
|
||||
onChange={(e) => updateItemWithCalc(idx, "order_vat", e.target.value)} />
|
||||
</td>
|
||||
<td className="p-1">
|
||||
<Input className="h-8 text-right bg-muted/30" readOnly value={it.order_total_amount ?? ""} />
|
||||
</td>
|
||||
<td className="p-1 text-center text-muted-foreground">-</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
{(!form.items || form.items.length === 0) && (
|
||||
<tr><td colSpan={11} className="p-6 text-center text-muted-foreground">견적요청에 등록된 품목이 없습니다.</td></tr>
|
||||
)}
|
||||
</tbody>
|
||||
{(form.items?.length ?? 0) > 0 && (
|
||||
<tfoot>
|
||||
<tr className="bg-muted/30 font-semibold">
|
||||
<td colSpan={5} className="p-2 text-center">Total</td>
|
||||
<td className="p-2 text-right">{lineTotal.qty.toLocaleString()}</td>
|
||||
<td className="p-2"></td>
|
||||
<td className="p-2 text-right">{lineTotal.supply.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}</td>
|
||||
<td className="p-2 text-right">{lineTotal.vat.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}</td>
|
||||
<td className="p-2 text-right">{lineTotal.total.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}</td>
|
||||
<td className="p-2"></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
)}
|
||||
</table>
|
||||
</div>
|
||||
</fieldset>
|
||||
</>
|
||||
)}
|
||||
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => onOpenChange(false)} disabled={saving}>닫기</Button>
|
||||
<Button onClick={handleSave} disabled={saving || loading}>
|
||||
{saving ? <Loader2 className="w-4 h-4 mr-1 animate-spin" /> : <Save className="w-4 h-4 mr-1" />}저장
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -140,4 +140,133 @@ export const salesEstimateApi = {
|
||||
const res = await apiClient.post("/sales/estimate/mail", body);
|
||||
return res.data?.data as { objid: string };
|
||||
},
|
||||
|
||||
// ─── G5 견적작성 (estimate_template) ──────────────────────────
|
||||
async saveTemplate1(body: EstimateTemplate1Body) {
|
||||
const res = await apiClient.post("/sales/estimate/template1", body);
|
||||
return res.data?.data as { templateObjid: string; isUpdate: boolean };
|
||||
},
|
||||
|
||||
async saveTemplate2(body: EstimateTemplate2Body) {
|
||||
const res = await apiClient.post("/sales/estimate/template2", body);
|
||||
return res.data?.data as { templateObjid: string; isUpdate: boolean };
|
||||
},
|
||||
|
||||
async getTemplate(templateObjid: string) {
|
||||
const res = await apiClient.get(`/sales/estimate/template/${templateObjid}`);
|
||||
return res.data?.data as EstimateTemplateDetail | null;
|
||||
},
|
||||
|
||||
async listTemplates(contractObjid: string) {
|
||||
const res = await apiClient.get(`/sales/estimate/templates/${contractObjid}`);
|
||||
return (res.data?.data ?? []) as EstimateTemplateRow[];
|
||||
},
|
||||
};
|
||||
|
||||
// ─── G5 견적작성 타입 ───────────────────────────────────────────
|
||||
|
||||
export interface EstimateTemplateItemRow {
|
||||
seq?: number;
|
||||
category?: string | null;
|
||||
part_objid?: string | null;
|
||||
description?: string | null;
|
||||
specification?: string | null;
|
||||
quantity?: string | null;
|
||||
unit?: string | null;
|
||||
unit_price?: string | null;
|
||||
amount?: string | null;
|
||||
note?: string | null;
|
||||
remark?: string | null;
|
||||
}
|
||||
|
||||
// 일반(template1) 저장 페이로드 — wace estimateTemplate1.jsp fn_save
|
||||
export interface EstimateTemplate1Body {
|
||||
contract_objid: string;
|
||||
template_objid?: string;
|
||||
executor?: string;
|
||||
recipient?: string;
|
||||
estimate_no?: string;
|
||||
contact_person?: string;
|
||||
greeting_text?: string;
|
||||
model_name?: string;
|
||||
model_code?: string;
|
||||
executor_date?: string;
|
||||
note1?: string;
|
||||
note2?: string;
|
||||
note3?: string;
|
||||
note4?: string;
|
||||
note_remarks?: string;
|
||||
total_amount?: string;
|
||||
total_amount_krw?: string;
|
||||
manager_name?: string;
|
||||
manager_contact?: string;
|
||||
show_total_row?: "Y" | "N";
|
||||
items: EstimateTemplateItemRow[];
|
||||
}
|
||||
|
||||
// 장비(template2) 저장 페이로드 — wace estimateTemplate2.jsp fn_save
|
||||
export interface EstimateTemplate2Body {
|
||||
contract_objid: string;
|
||||
template_objid?: string;
|
||||
executor_date?: string;
|
||||
recipient?: string;
|
||||
part_name?: string;
|
||||
part_objid?: string;
|
||||
notes_content?: string;
|
||||
validity_period?: string;
|
||||
categories_json: string;
|
||||
group1_subtotal?: string;
|
||||
total_amount?: string;
|
||||
total_amount_krw?: string;
|
||||
}
|
||||
|
||||
// 단건 조회 응답
|
||||
export interface EstimateTemplateDetail {
|
||||
objid: string;
|
||||
contract_objid: string;
|
||||
template_type: "1" | "2";
|
||||
executor: string | null;
|
||||
recipient: string | null;
|
||||
estimate_no: string | null;
|
||||
contact_person: string | null;
|
||||
greeting_text: string | null;
|
||||
model_name: string | null;
|
||||
model_code: string | null;
|
||||
executor_date: string | null;
|
||||
note1: string | null;
|
||||
note2: string | null;
|
||||
note3: string | null;
|
||||
note4: string | null;
|
||||
note_remarks: string | null;
|
||||
notes_content: string | null;
|
||||
validity_period: string | null;
|
||||
categories_json: string | null;
|
||||
group1_subtotal: string | null;
|
||||
total_amount: string | null;
|
||||
total_amount_krw: string | null;
|
||||
manager_name: string | null;
|
||||
manager_contact: string | null;
|
||||
show_total_row: string | null;
|
||||
part_name: string | null;
|
||||
part_objid: string | null;
|
||||
writer: string | null;
|
||||
regdate_str: string | null;
|
||||
chgdate_str: string | null;
|
||||
exchange_rate: string | null;
|
||||
contract_currency: string | null;
|
||||
contract_currency_name: string | null;
|
||||
items: EstimateTemplateItemRow[];
|
||||
}
|
||||
|
||||
// 차수 리스트 행
|
||||
export interface EstimateTemplateRow {
|
||||
objid: string;
|
||||
template_type: "1" | "2";
|
||||
estimate_no: string | null;
|
||||
recipient: string | null;
|
||||
total_amount: string | null;
|
||||
total_amount_krw: string | null;
|
||||
writer: string | null;
|
||||
regdate: string | null;
|
||||
chgdate: string | null;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ export interface OrderRow {
|
||||
order_appr_status: string | null;
|
||||
amaranth_status: string | null;
|
||||
cu01_cnt: number | null;
|
||||
is_direct_order: string | null;
|
||||
}
|
||||
|
||||
export interface OrderItem {
|
||||
@@ -88,10 +89,12 @@ export interface OrderBody {
|
||||
contract_currency?: string;
|
||||
exchange_rate?: string;
|
||||
receipt_date?: string;
|
||||
contract_date?: string;
|
||||
order_date?: string; // 발주일 (wace G2 필수)
|
||||
req_del_date?: string;
|
||||
po_no?: string;
|
||||
contract_result?: string;
|
||||
approval_required?: string; // 결재여부 'Y'|'N'
|
||||
is_direct_order?: string; // 'Y' 기본 (G2 직접등록)
|
||||
pm_user_id?: string;
|
||||
customer_request?: string;
|
||||
shipping_method?: string;
|
||||
|
||||
Generated
+19
-5
@@ -68,9 +68,10 @@
|
||||
"exceljs": "^4.4.0",
|
||||
"html-to-image": "^1.11.13",
|
||||
"html2canvas": "^1.4.1",
|
||||
"html2canvas-pro": "^2.0.2",
|
||||
"isomorphic-dompurify": "^2.28.0",
|
||||
"jsbarcode": "^3.12.1",
|
||||
"jspdf": "^3.0.3",
|
||||
"jspdf": "^3.0.4",
|
||||
"leaflet": "^1.9.4",
|
||||
"lucide-react": "^0.525.0",
|
||||
"mammoth": "^1.11.0",
|
||||
@@ -10942,6 +10943,19 @@
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/html2canvas-pro": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/html2canvas-pro/-/html2canvas-pro-2.0.2.tgz",
|
||||
"integrity": "sha512-9G/t0XgCZWonLwL0JwI7su6NdbOPUY7Ur4Ihpp8+XMaW9ibA2nDXF181Jr6tm94k8lX6sthpaXB3XqEnsMd5Cw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"css-line-break": "^2.1.0",
|
||||
"text-segmentation": "^1.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/http-proxy-agent": {
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz",
|
||||
@@ -11696,12 +11710,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jspdf": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/jspdf/-/jspdf-3.0.3.tgz",
|
||||
"integrity": "sha512-eURjAyz5iX1H8BOYAfzvdPfIKK53V7mCpBTe7Kb16PaM8JSXEcUQNBQaiWMI8wY5RvNOPj4GccMjTlfwRBd+oQ==",
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/jspdf/-/jspdf-3.0.4.tgz",
|
||||
"integrity": "sha512-dc6oQ8y37rRcHn316s4ngz/nOjayLF/FFxBF4V9zamQKRqXxyiH1zagkCdktdWhtoQId5K20xt1lB90XzkB+hQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.26.9",
|
||||
"@babel/runtime": "^7.28.4",
|
||||
"fast-png": "^6.2.0",
|
||||
"fflate": "^0.8.1"
|
||||
},
|
||||
|
||||
@@ -77,9 +77,10 @@
|
||||
"exceljs": "^4.4.0",
|
||||
"html-to-image": "^1.11.13",
|
||||
"html2canvas": "^1.4.1",
|
||||
"html2canvas-pro": "^2.0.2",
|
||||
"isomorphic-dompurify": "^2.28.0",
|
||||
"jsbarcode": "^3.12.1",
|
||||
"jspdf": "^3.0.3",
|
||||
"jspdf": "^3.0.4",
|
||||
"leaflet": "^1.9.4",
|
||||
"lucide-react": "^0.525.0",
|
||||
"mammoth": "^1.11.0",
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 163 KiB |
Reference in New Issue
Block a user