Merge pull request 'lhj' (#328) from lhj into main
Reviewed-on: http://39.117.244.52:3000/kjs/ERP-node/pulls/328
This commit is contained in:
commit
0f027f2382
|
|
@ -107,10 +107,10 @@ export function LocationSwapSelectorComponent(props: LocationSwapSelectorProps)
|
|||
const dbTableName = config.dbTableName || "vehicles";
|
||||
const dbKeyField = config.dbKeyField || "user_id";
|
||||
|
||||
// 기본 옵션 (포항/광양)
|
||||
// 기본 옵션 (포항/광양) - 한글로 저장
|
||||
const DEFAULT_OPTIONS: LocationOption[] = [
|
||||
{ value: "pohang", label: "포항" },
|
||||
{ value: "gwangyang", label: "광양" },
|
||||
{ value: "포항", label: "포항" },
|
||||
{ value: "광양", label: "광양" },
|
||||
];
|
||||
|
||||
// 상태
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ export const LocationSwapSelectorDefinition = createComponentDefinition({
|
|||
labelField: "location_name", // 표시 필드
|
||||
codeCategory: "", // 코드 관리 카테고리 (type이 "code"일 때)
|
||||
staticOptions: [
|
||||
{ value: "pohang", label: "포항" },
|
||||
{ value: "gwangyang", label: "광양" },
|
||||
], // 정적 옵션 (type이 "static"일 때)
|
||||
{ value: "포항", label: "포항" },
|
||||
{ value: "광양", label: "광양" },
|
||||
], // 정적 옵션 (type이 "static"일 때) - 한글로 저장
|
||||
},
|
||||
// 필드 매핑
|
||||
departureField: "departure", // 출발지 저장 필드
|
||||
|
|
|
|||
|
|
@ -2248,9 +2248,9 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
// 🆕 편집 모드 진입 placeholder (실제 구현은 visibleColumns 정의 후)
|
||||
const startEditingRef = useRef<() => void>(() => {});
|
||||
|
||||
// 🆕 각 컬럼의 고유값 목록 계산
|
||||
// 🆕 각 컬럼의 고유값 목록 계산 (라벨 포함)
|
||||
const columnUniqueValues = useMemo(() => {
|
||||
const result: Record<string, string[]> = {};
|
||||
const result: Record<string, Array<{ value: string; label: string }>> = {};
|
||||
|
||||
if (data.length === 0) return result;
|
||||
|
||||
|
|
@ -2258,16 +2258,34 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
if (column.columnName === "__checkbox__") return;
|
||||
|
||||
const mappedColumnName = joinColumnMapping[column.columnName] || column.columnName;
|
||||
const values = new Set<string>();
|
||||
// 라벨 컬럼 후보들 (백엔드에서 _name, _label, _value_label 등으로 반환할 수 있음)
|
||||
const labelColumnCandidates = [
|
||||
`${column.columnName}_name`, // 예: division_name
|
||||
`${column.columnName}_label`, // 예: division_label
|
||||
`${column.columnName}_value_label`, // 예: division_value_label
|
||||
];
|
||||
const valuesMap = new Map<string, string>(); // value -> label
|
||||
|
||||
data.forEach((row) => {
|
||||
const val = row[mappedColumnName];
|
||||
if (val !== null && val !== undefined && val !== "") {
|
||||
values.add(String(val));
|
||||
const valueStr = String(val);
|
||||
// 라벨 컬럼 후보들 중 값이 있는 것 사용, 없으면 원본 값 사용
|
||||
let label = valueStr;
|
||||
for (const labelCol of labelColumnCandidates) {
|
||||
if (row[labelCol] && row[labelCol] !== "") {
|
||||
label = String(row[labelCol]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
valuesMap.set(valueStr, label);
|
||||
}
|
||||
});
|
||||
|
||||
result[column.columnName] = Array.from(values).sort();
|
||||
// value-label 쌍으로 저장하고 라벨 기준 정렬
|
||||
result[column.columnName] = Array.from(valuesMap.entries())
|
||||
.map(([value, label]) => ({ value, label }))
|
||||
.sort((a, b) => a.label.localeCompare(b.label));
|
||||
});
|
||||
|
||||
return result;
|
||||
|
|
@ -5756,16 +5774,16 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
)}
|
||||
</div>
|
||||
<div className="max-h-48 space-y-1 overflow-y-auto">
|
||||
{columnUniqueValues[column.columnName]?.slice(0, 50).map((val) => {
|
||||
const isSelected = headerFilters[column.columnName]?.has(val);
|
||||
{columnUniqueValues[column.columnName]?.slice(0, 50).map((item) => {
|
||||
const isSelected = headerFilters[column.columnName]?.has(item.value);
|
||||
return (
|
||||
<div
|
||||
key={val}
|
||||
key={item.value}
|
||||
className={cn(
|
||||
"hover:bg-muted flex cursor-pointer items-center gap-2 rounded px-2 py-1 text-xs",
|
||||
isSelected && "bg-primary/10",
|
||||
)}
|
||||
onClick={() => toggleHeaderFilter(column.columnName, val)}
|
||||
onClick={() => toggleHeaderFilter(column.columnName, item.value)}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
|
|
@ -5775,7 +5793,7 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
>
|
||||
{isSelected && <Check className="text-primary-foreground h-3 w-3" />}
|
||||
</div>
|
||||
<span className="truncate">{val || "(빈 값)"}</span>
|
||||
<span className="truncate">{item.label || "(빈 값)"}</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
|
|
|||
Loading…
Reference in New Issue