Merge remote-tracking branch 'origin/iipbs_cs' into iipbs_cs

# Conflicts:
#	apps/cs/next.config.ts
This commit is contained in:
2025-06-27 07:46:39 +09:00
215 changed files with 26267 additions and 2608 deletions
@@ -1,7 +1,7 @@
"use client"
import { Pie, PieChart } from "recharts";
import type { CSSProperties } from "react";
import { Pie, PieChart } from "recharts";
import {
Card,
CardContent
@@ -99,7 +99,7 @@ const CustomLegend = (props: LegendProps) => {
};
export default function DoughnutChart(props: {
chartConfig: ChartConfig;
chartConfig: any;
chartData: ChartDataItem[] | undefined;
chartTitle: string
}) {
@@ -12,37 +12,39 @@ import { FormControl } from "../form";
import { ko } from "date-fns/locale";
import { useState } from "react";
type DatePickerProps = DayPickerSingleProps & { field: { value: Date; onChange: (date: Date | undefined) => void } ,selectClass:string|undefined };
export function DatePicker({ field, selectClass }: DatePickerProps) {
type DatePickerProps = DayPickerSingleProps & { field: { value: Date; onChange: (date: Date | undefined) => void }, selectClass: string | undefined, readOnly?: boolean };
export function DatePicker({ field, selectClass, readOnly = false, ...props }: DatePickerProps) {
const [open, setOpen] = useState(false);
const handleSelect = (date: Date | undefined) => {
field.onChange(date); // React Hook Form 업데이트
setOpen(false);
};
if (!readOnly) { // readOnly가 아닐 때만 변경 허용
field.onChange(date); // React Hook Form 업데이트
setOpen(false);
}
};
return (
<Popover open={open} onOpenChange={setOpen}>
<Popover open={open && !readOnly} onOpenChange={readOnly ? undefined : setOpen}>
<PopoverTrigger asChild>
<FormControl>
<Button
color="white"
variant={"outline"}
className={!selectClass? cn(
disabled={readOnly} // readOnly일 때 버튼 비활성화
className={!selectClass ? cn(
"w-[240px] pl-3 text-left font-normal",
!field?.value && "text-muted-foreground",
):selectClass}
readOnly && "opacity-60 cursor-not-allowed" // readOnly 스타일 추가
) : cn(selectClass, readOnly && "opacity-60 cursor-not-allowed")}
>
{field?.value ? (
format(
field.value instanceof Date && !isNaN(field.value.getTime())
? field.value
: new Date()
? field.value
: new Date()
, "PPP", { locale: ko })
) : (
<span>Pick a date</span>
@@ -53,7 +53,8 @@ export const excelArrayStyle = async (data: ArrayBuffer, range: SheetParameter[]
if (item.data && item.data.length > 0) {
const numCols = item.data[0]?.length || 0;
const numRows = item.data.length;
const dataRange = workbook.activeSheet(index)?.sheet(index)?.range(`A1:${String.fromCharCode(65 + numCols - 1)}${numRows}`);
const lastColLetter = getExcelColumnLetter(numCols);
const dataRange = workbook.activeSheet(index)?.sheet(index)?.range(`A1:${lastColLetter}${numRows}`);
dataRange?.style((styleQ) => {
styleQ.verticalAlignment("center");
});
@@ -62,4 +63,60 @@ export const excelArrayStyle = async (data: ArrayBuffer, range: SheetParameter[]
}
makeExcelFile(workbook, fileNm)
}
}
export const excelStyleWithKoreanHeaders = async (
data: ArrayBuffer,
range: string = "A1:V3",
fileNm: string,
headerMapping: { [key: string]: string },
sampleData: any
) => {
const workbook = await XlsxPopulate.Workbook.fromData(data);
const sheet = workbook.activeSheet();
if (!sheet) {
throw new Error('워크시트를 찾을 수 없습니다.');
}
// 1. 영문 헤더를 한글로 교체
const englishHeaders = Object.keys(sampleData);
englishHeaders.forEach((englishHeader, index) => {
const koreanHeader = headerMapping[englishHeader] || englishHeader;
const cellAddress = String.fromCharCode(65 + index) + '1'; // A1, B1, C1, ...
sheet.cell(cellAddress).value(koreanHeader);
});
// 2. 헤더 스타일 적용
const headerCells = sheet.range(range);
headerCells?.style((styleQ) => {
makeCellStyle(styleQ);
});
// 3. 모든 데이터 셀에 세로 가운데 정렬 적용
const numCols = englishHeaders.length;
const numRows = sheet.usedRange()?.endCell()?.rowNumber() || 1;
if (numRows > 1) {
const dataRange = sheet.range(`A1:${String.fromCharCode(65 + numCols - 1)}${numRows}`);
dataRange?.style((styleQ) => {
styleQ.verticalAlignment("center");
styleQ.borderEach({ style: "thin", color: { rgb: "CCCCCC" } });
});
}
// 4. 파일 다운로드
await makeExcelFile(workbook, fileNm);
};
const getExcelColumnLetter = (colIndex: number): string => {
let letter = '';
while (colIndex > 0) {
const mod = (colIndex - 1) % 26;
letter = String.fromCharCode(65 + mod) + letter;
colIndex = Math.floor((colIndex - 1) / 26);
}
return letter;
};
@@ -1,5 +1,5 @@
import * as XLSX from 'xlsx';
import { excelArrayStyle, excelStyle } from './excelStyle';
import { excelArrayStyle, excelStyle, excelStyleWithKoreanHeaders } from './excelStyle';
type ExcelDownloadProps = {
data: JSON | JSON[];
@@ -164,4 +164,38 @@ export const filePickedBlobArray = (oFile: ArrayBuffer, fileNm: string, sheetArr
});
await excelArrayStyle(XLSX.write(wb, { bookType: "xlsx", type: "buffer" }), sheetArray, fileNm)
});
}
}
type ExcelDownloadWithHeaderProps = {
data: JSON | JSON[];
fileName: string;
sheetNameArray: string[];
headerRange?: string;
headerMapping: { [key: string]: string };
}
export const downloadExcelWithKoreanHeaders = async ({
data,
fileName = new Date().getTime().toString() + '.xlsx',
sheetNameArray = ["Sheet1"],
headerRange = 'A1:V3',
headerMapping
}: ExcelDownloadWithHeaderProps) => {
const dataArray = Array.isArray(data) ? data : [data];
if (dataArray.length === 0) {
throw new Error('데이터가 없습니다.');
}
// 1. 원본 데이터로 워크시트 생성
const worksheet = XLSX.utils.json_to_sheet(dataArray);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, sheetNameArray[0]);
// 2. 워크북을 ArrayBuffer로 변환
const buffer = XLSX.write(workbook, { bookType: "xlsx", type: "buffer" });
// 3. 헤더만 한글로 교체하는 커스텀 스타일 함수 호출
await excelStyleWithKoreanHeaders(buffer, headerRange, fileName, headerMapping, dataArray[0]);
};
@@ -3,7 +3,7 @@ import { CloudUpload, Paperclip } from "lucide-react";
import { FileInput, FileUploader, FileUploaderContent, FileUploaderItem } from "./lib/file_upload";
const dropZoneConfig = {
maxFiles: 5,
maxSize: 1024 * 1024 * 4,
maxSize: 1024 * 1024 * 100,
multiple: true,
};
@@ -12,12 +12,18 @@ const dropZoneConfig = {
files: File[]; // 파일 배열
setFiles: (files: File[] | null) => void; // 파일 배열 세터
fileTypes?: string; // 옵션 (파일 확장자 문자열)
onFileClick?:(index:number)=> void; // 파일 클릭 핸들러
onFileClick?:(index:number)=> void;
maxFiles?: number; // 파일 클릭 핸들러
}
export const FileUpload =
({ files, setFiles, fileTypes ,onFileClick}: FileUploadProps) => {
({ files, setFiles, fileTypes ,onFileClick, maxFiles}: FileUploadProps) => {
if(maxFiles){
dropZoneConfig.maxFiles = maxFiles;
if(maxFiles===1)
dropZoneConfig.multiple = false;
}
return (
<FileUploader
value={files}
@@ -271,7 +271,7 @@ export const FileUploaderContent = forwardRef<
{...props}
ref={ref}
className={cn(
"flex rounded-xl gap-1",
"w-full flex rounded-xl gap-1",
orientation === "horizontal" ? "flex-raw flex-wrap" : "flex-col",
className,
)}
@@ -295,7 +295,7 @@ export const FileUploaderItem = forwardRef<
ref={ref}
className={cn(
buttonVariants({ variant: "ghost" }),
"h-6 p-1 justify-between cursor-pointer relative",
"h-6 p-1 justify-between cursor-pointer relative w-full",
className,
isSelected ? "bg-muted" : "",
)}
@@ -308,9 +308,9 @@ export const FileUploaderItem = forwardRef<
{children}
</div>
<button
type="button"
className={cn(
"absolute",
"!w-1/5 z-50",
direction === "rtl" ? "top-1 left-1" : "top-1 right-1",
)}
@@ -1,6 +1,6 @@
import { Checkbox } from "@common/components/ui";
import React, { useCallback, useEffect, useState } from "react";
import { FormControl, FormItem, FormLabel, FormMessage } from "../form";
import { Button, Checkbox } from "@common/components/ui";
export const BZNM_TOT_NO = '종사업자등록번호';
export const CANDIDATE = '공급처 후보지 선택(필수아님)';
@@ -67,4 +67,4 @@ const FormUi = React.forwardRef<HTMLDivElement, FormUiProps>(
);
FormUi.displayName = 'FormUi';
export { FormUi };
export { FormUi };
@@ -19,4 +19,5 @@ export * from "./tab";
export * from "./table";
export * from "./table_div";
export * from "./title";
export * from "./sdmInsertForm";
export * from "./sdmInsertForm";
export * from "./popover_ui"
@@ -1,20 +1,19 @@
import './lib/css/gis.common.css';
import React, { createContext, useContext, useEffect, useMemo, useRef, useState, useCallback } from 'react';
import { Search } from 'lucide-react';
import OlMap from 'ol/Map';
import View from 'ol/View';
import { defaults as defaultControls, OverviewMap } from 'ol/control';
import { defaults } from 'ol/interaction';
import * as olProj from 'ol/proj';
import proj4 from 'proj4';
import { register } from 'ol/proj/proj4';
import GisApp from './lib/gis.core';
import GisContent from './GisContent';
import GisTree from './GisTree';
import proj4 from 'proj4';
import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
import GisLonLat from './GisLonLat';
import GisMapToggle from './GisMapToggle';
import GisSelect from './GisSelect';
import GisToolBar from './GisToolBar';
import GisMapToggle from './GisMapToggle';
import { Search } from 'lucide-react';
import GisTree from './GisTree';
import './lib/css/gis.common.css';
import GisApp from './lib/gis.core';
export const GisContext = createContext({ gisCore: null, gisMap: null, treeData: null, checkedLayerIds: null });
export const useGisContext = () => useContext(GisContext);
@@ -224,7 +223,6 @@ function Gis({ isOpen , gisMaps, isSearchModalOpen, treeData = [], isSearch = fa
{isSearch && (
<div className="absolute right-8 top-[305px] z-20">
<button
type="button"
onClick={() => setIsSearchModalOpen(true)}
className="overflow-hidden w-[40px] h-[40px] bg-white
border border-[#9aa7b8]
@@ -243,4 +241,4 @@ function Gis({ isOpen , gisMaps, isSearchModalOpen, treeData = [], isSearch = fa
);
}
export default React.memo(Gis);
export default React.memo(Gis);
@@ -60,7 +60,6 @@ export default function GisContent({ edit = false, onFeatureSelect, isSearch, se
{isSearch && (
<div className="absolute right-8 top-[254px] z-20">
<button
type="button"
onClick={() => setIsSearchModalOpen(true)}
className="overflow-hidden w-[40px] h-[40px] bg-white
border border-[#9aa7b8]
@@ -76,4 +75,4 @@ export default function GisContent({ edit = false, onFeatureSelect, isSearch, se
)}
</>
);
}
}
@@ -20,7 +20,6 @@
// <TabsTrigger value="layers" className="flex-1 h-10">레이어</TabsTrigger>
// {/* {isSearch && (
// <button
// type="button"
// onClick={() => setIsSearchModalOpen(true)}
// className="h-10 w-10 flex items-center justify-center px-0"
// >
@@ -0,0 +1,23 @@
import { Popover, PopoverContent, PopoverTrigger } from "@common/components/ui";
export default function PopoverUi({
childrenTriger,
childrenBody,
bodyClassName
}: {
childrenTriger: React.ReactNode;
childrenBody: React.ReactNode;
bodyClassName:string
}) {
return (
<>
<Popover>
<PopoverTrigger>{childrenTriger}</PopoverTrigger>
<PopoverContent className={bodyClassName}>
{childrenBody}
</PopoverContent>
</Popover>
</>
);
}
@@ -60,7 +60,7 @@ const defaultValues: FormSchema = {
bznmTotNo: '',
daddr: '',
telno: '',
rgtr: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
rgtr: '',
dmdAplyPswd: '',
};
@@ -16,14 +16,15 @@ const SelectBox = React.forwardRef<
className:string,
selectArray:SelectBox1[],
onSelectValue:(val:string|number)=>void,
value?: string|number
value?: string|number,
readOnly?: boolean // readOnly 속성 추가
}
>(({ label, className, selectClass, selectArray, onSelectValue, value }, ref)=>{
>(({ label, className, selectClass, selectArray, onSelectValue, value, readOnly = false }, ref)=>{
const placeHolder = selectArray?.[0]?.text ?? "";
return (
<div className={className+" flex items-center"} ref={ref}>
{label && <Label className="w-20 text-xl text-gray-600">{label}</Label>}
{label && <Label className="whitespace-nowrap w-20 text-xl text-gray-600">{label}</Label>}
<Select onValueChange={onSelectValue} value={value !== undefined ? String(value) : undefined}>
<SelectTrigger className={selectClass?selectClass:"flex-1 p-2 border rounded"}>
<SelectValue placeholder={placeHolder} />
@@ -1,9 +1,11 @@
"use client"
import { Table, TableBody, TableCell, TableHeader, TableRow } from "@common/components";
import { Checkbox, Table, TableBody, TableCell, TableHeader, TableRow } from "@common/components";
import { useEffect, useState } from "react";
import { HeadMakeColSpan } from "./HeadMakeColSpan";
import UiPageNations from "./uiPageNations";
import { AlignVerticalDistributeCenterIcon, Check } from "lucide-react";
import { boolean } from "zod";
type UiTableProps = {
headName: React.ReactNode | undefined;
@@ -17,6 +19,8 @@ type UiTableProps = {
resetPageNo?: boolean;
children?: React.ReactNode | undefined;
boldArray?: number[];
resetSelection?: boolean;
index?:number;
}
type UiHeadProps = {
@@ -26,9 +30,12 @@ type UiHeadProps = {
visible?:boolean;
}
export function UiTable({ tableData, headlist, pageSize, total, headName, children, cellClick, onPageChange, className = '', resetPageNo = false, boldArray = [] }: UiTableProps) {
export function UiTable({ tableData, headlist, pageSize, total, headName, children, cellClick, onPageChange, className = '', resetPageNo = false, boldArray = [], resetSelection = false, index=-1 }: UiTableProps) {
const [cur, setCur] = useState<number>(1);
const [idx, setIdx] = useState<number>(-1);
const [idx, setIdx] = useState<number>(index);
const [isCheck, seIsCheck] = useState<boolean>(false);
useEffect(() => {
if (resetPageNo) {
setCur(1);
@@ -36,6 +43,12 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
}
}, [onPageChange, resetPageNo]);
useEffect(() => {
if (resetSelection) {
setIdx(-1);
}
}, [resetSelection]);
const handlePageChange = (page: number) => {
setCur(page);
onPageChange(page);
@@ -47,6 +60,7 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
setIdx(index);
}
};
return (
<>
@@ -65,7 +79,9 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
.filter((item) => item.visible != false)
.map((head) => (
head.id && head.id.length > 1 && (
boldArray.includes(index) ? <TableCell
boldArray.includes(index)
?
<TableCell
className={`${head.align === 'right' ? 'text-right' : head.align === 'center' ? 'text-center' : typeof el[head.id] === 'number' ? 'text-right' : 'text-center'} ${
cellClick && idx === index ? '!font-[1000] cursor-pointer' :
cellClick ? 'cursor-pointer' : ''
@@ -78,7 +94,8 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
index === 0 ? part.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : part
).join('.')
: String(el[head.id] ?? '').replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
</TableCell>:
</TableCell>
:
<TableCell
className={`${head.align === 'right' ? 'text-right' : head.align === 'center' ? 'text-center' : typeof el[head.id] === 'number' ? 'text-right' : 'text-center'} ${
cellClick && idx === index ? '!font-[1000] cursor-pointer' :
@@ -87,11 +104,24 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
onClick={() => handleCellClick(index, head.id)}
key={`cell-${head.id}-${index}`}
>
{typeof el[head.id] !== 'number'?String(el[head.id] ?? ''): String(el[head.id]).includes('.')
{typeof el[head.id] === 'boolean'
?<Checkbox
checked={el[head.id] === true}
onCheckedChange={(checked) => {
el[head.id]= checked;
}}
>
<Check className="h-6 w-6 text-primary" />
</Checkbox>
:
typeof el[head.id] !== 'number'?
String(el[head.id] ?? ''):
String(el[head.id]).includes('.')
? String(el[head.id]).split('.').map((part, index) =>
index === 0 ? part.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : part
).join('.')
: String(el[head.id] ?? '').replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
).join('.')
:
String(el[head.id] ?? '').replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
</TableCell>
)
))}
@@ -28,3 +28,4 @@ export * from "./switch";
export * from "./table";
export * from "./tabs";
export * from "./textarea";
export * from "./tooltip";