sn: 순번 삭제 외
This commit is contained in:
@@ -16,7 +16,9 @@ import {
|
||||
buildObsltPplRepresentativeSggOptions,
|
||||
findObsltPplCtpvCodeByName,
|
||||
findObsltPplRepresentativeSggCode,
|
||||
isValidObsltPplEnvOfficeName,
|
||||
normalizeObsltPplSigunName,
|
||||
OBSLT_PPL_ENV_OFFICES,
|
||||
} from "../lib/obslt-ppl-region";
|
||||
import type { ObsltPplBusiness, ObsltPplBusinessSaveRequest } from "../model/obslt-ppl-types";
|
||||
|
||||
@@ -29,7 +31,7 @@ const REGION_FORM_KEYS: FormKey[] = ["sggCd", "ctpvNm", "sigunNm"];
|
||||
|
||||
/** 등록·수정 표에서 필드 순서, 라벨, 입력 종류와 필수 여부를 한 곳에서 관리한다. */
|
||||
const FIELDS: Array<{ key: FormKey; label: string; type?: "number" | "textarea"; required?: boolean; placeholder?: string }> = [
|
||||
{ key: "bizSe", label: "사업구분", required: true }, { key: "bizSeq", label: "순번", type: "number" },
|
||||
{ key: "bizSe", label: "사업구분", required: true },
|
||||
{ key: "prcisExmnCycl", label: "정밀조사차수" }, { key: "bizCd", label: "사업코드", required: true },
|
||||
{ key: "envoNm", label: "환경청" }, { key: "bizNm", label: "사업명", required: true },
|
||||
{ key: "prplPrst", label: "추진현황" }, { key: "bgngYr", label: "착수년도", placeholder: "YYYY" },
|
||||
@@ -41,7 +43,7 @@ const FIELDS: Array<{ key: FormKey; label: string; type?: "number" | "textarea";
|
||||
{ key: "rmrkCn", label: "비고", type: "textarea" }, { key: "pbcpOpnnCn", label: "공단의견", type: "textarea" },
|
||||
];
|
||||
|
||||
const NUMBER_KEYS = new Set<FormKey>(["bizSeq", "planPrlg", "frhfyrExpcPrlg", "rmndPrlg"]);
|
||||
const NUMBER_KEYS = new Set<FormKey>(["planPrlg", "frhfyrExpcPrlg", "rmndPrlg"]);
|
||||
|
||||
/** 모든 입력을 제어 컴포넌트로 유지하기 위한 빈 폼 값을 생성한다. */
|
||||
const createEmptyForm = (): FormState => Object.fromEntries(
|
||||
@@ -111,7 +113,11 @@ export function ObsltPplFormPage({ id }: { id?: string }) {
|
||||
const handleSave = async () => {
|
||||
if (!form.bizSe || !form.bizCd.trim() || !form.bizNm.trim()) { setNotice("사업구분, 사업코드, 사업명은 필수입니다."); return; }
|
||||
if (ctpvCd === "0" || sggCd === "0" || !form.ctpvNm.trim() || !form.sigunNm.trim()) { setNotice("시도와 시군구를 선택해주세요."); return; }
|
||||
if ([...NUMBER_KEYS].some((key) => form[key] && !Number.isFinite(Number(form[key])))) { setNotice("순번과 물량은 숫자로 입력해주세요."); return; }
|
||||
if ([...NUMBER_KEYS].some((key) => form[key] && !Number.isFinite(Number(form[key])))) { setNotice("연장 값은 숫자로 입력해주세요."); return; }
|
||||
if (!isValidObsltPplEnvOfficeName(form.envoNm)) {
|
||||
setNotice(`환경청은 ${OBSLT_PPL_ENV_OFFICES.map((office) => office.name).join(", ")} 중 하나여야 합니다.`);
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
if (id) await updateObsltPplBusiness(id, toRequest(form));
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import moment from "moment";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import moment from "moment";
|
||||
|
||||
import { SearchDiv, SearchFormLeft, SearchFormRight, SelectBox, UiTable } from "@common/business_components/ui";
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import { Button, Input, Label } from "@common/components/ui";
|
||||
|
||||
import {
|
||||
getAllObsltPplBusinesses,
|
||||
getObsltPplBusinesses,
|
||||
uploadObsltPplExcel,
|
||||
} from "../api/obslt-ppl-api";
|
||||
import { parseObsltPplExcel } from "../lib/obslt-ppl-excel";
|
||||
import { downloadObsltPplExcel, parseObsltPplExcel } from "../lib/obslt-ppl-excel";
|
||||
import { buildObsltPplRepresentativeSggOptions, normalizeObsltPplSigunName } from "../lib/obslt-ppl-region";
|
||||
import type { ObsltPplBusiness, ObsltPplPage } from "../model/obslt-ppl-types";
|
||||
|
||||
@@ -36,7 +38,6 @@ type ObsltPplTableRow = ObsltPplBusiness & {
|
||||
const TABLE_HEADLIST = [
|
||||
{ id: "rowNumber", title: "NO", widthPercent: 4 },
|
||||
{ id: "bizSe", title: "사업구분", widthPercent: 6 },
|
||||
{ id: "bizSeq", title: "순번", widthPercent: 5 },
|
||||
{ id: "prcisExmnCycl", title: "정밀조사차수", widthPercent: 6 },
|
||||
{ id: "bizCd", title: "사업코드", widthPercent: 7 },
|
||||
//{ id: "sggCd", title: "시군구코드", widthPercent: 6 },
|
||||
@@ -92,33 +93,6 @@ const formatBusinessForDisplay = (row: ObsltPplBusiness): ObsltPplBusiness => ({
|
||||
cmcnYmd: formatObsltPplDate(row.cmcnYmd) || null,
|
||||
});
|
||||
|
||||
/** 현재 조회조건 기준 전체 목록을 내려받기용 행으로 변환한다. */
|
||||
const toExcelRow = (row: ObsltPplTableRow) => ({
|
||||
NO: row.rowNumber,
|
||||
사업구분: row.bizSe ?? "",
|
||||
순번: row.bizSeq ?? "",
|
||||
정밀조사차수: row.prcisExmnCycl ?? "",
|
||||
사업코드: row.bizCd ?? "",
|
||||
시도: row.ctpvNm ?? "",
|
||||
시군: row.sigunNm ?? "",
|
||||
환경청: row.envoNm ?? "",
|
||||
사업명: row.bizNm ?? "",
|
||||
추진현황: row.prplPrst ?? "",
|
||||
착수년도: row.bgngYr ?? "",
|
||||
"준공(예정)년도": row.cmcnYr ?? "",
|
||||
"계획연장(km)": row.planPrlg ?? "",
|
||||
"상반기(예상)연장(km)": row.frhfyrExpcPrlg ?? "",
|
||||
"잔여연장(km)": row.rmndPrlg ?? "",
|
||||
증빙서류제출여부: row.evdncDcmntSbmsnStts ?? "",
|
||||
착수일자: formatObsltPplDate(row.bgngYmd),
|
||||
"준공(예정)일자": formatObsltPplDate(row.cmcnYmd),
|
||||
사업추진부진사유: row.bizPrplDlyRsnCn ?? "",
|
||||
"담당자 이름": row.bizPicNm ?? "",
|
||||
"담당자 연락처": row.bizPicCnpl ?? "",
|
||||
비고: row.rmrkCn ?? "",
|
||||
공단의견: row.pbcpOpnnCn ?? "",
|
||||
});
|
||||
|
||||
/** 노후하수관로 사업 목록, 검색, xlsx 업로드·다운로드 진입점을 제공한다. */
|
||||
export function ObsltPplListPage() {
|
||||
const router = useRouter();
|
||||
@@ -206,28 +180,16 @@ export function ObsltPplListPage() {
|
||||
}
|
||||
};
|
||||
|
||||
/** 현재 조회조건 기준 전체 목록을 화면 포맷 그대로 xlsx로 내려받는다. */
|
||||
/** 적용된 조회조건 전체를 두 업무 시트의 업로드 호환 위치로 내려받는다. */
|
||||
const handleDownload = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
page: "0",
|
||||
size: String(Math.max(data.totalElements, 1)),
|
||||
sort: "obsltSwagePplBizSn,desc",
|
||||
});
|
||||
const params = new URLSearchParams();
|
||||
Object.entries(appliedSearch).forEach(([key, value]) => {
|
||||
if (value.trim()) params.set(key, value.trim());
|
||||
});
|
||||
const result = await getObsltPplBusinesses(params);
|
||||
const exportRows = result.content.map((row, index) => ({
|
||||
...formatBusinessForDisplay(row),
|
||||
rowNumber: result.totalElements - index,
|
||||
}));
|
||||
const { utils, writeFileXLSX } = await import("xlsx");
|
||||
const worksheet = utils.json_to_sheet(exportRows.map(toExcelRow));
|
||||
const workbook = utils.book_new();
|
||||
utils.book_append_sheet(workbook, worksheet, "노후하수관로");
|
||||
writeFileXLSX(workbook, "노후하수관로 정밀조사 및 정비사업 현황.xlsx");
|
||||
const exportRows = await getAllObsltPplBusinesses(params);
|
||||
downloadObsltPplExcel(exportRows);
|
||||
} catch (error) {
|
||||
setNotice(error instanceof Error ? error.message : "엑셀을 내려받지 못했습니다.");
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user