feat: Refactor work process and item inspection logic
- Updated SQL queries in `popProductionController` to separate work order process and result handling, ensuring batch_id is now managed in the work_order_process_result table. - Enhanced `workInstructionController` to include id generation for work items and details, preventing NULL values during insertion. - Implemented case-insensitive search functionality across various services, improving data retrieval accuracy. - Added sorting functionality in the item inspection page, allowing users to sort by different columns with visual indicators for sort direction. This refactor aims to improve data integrity and user experience across the production and inspection workflows.
This commit is contained in:
@@ -33,7 +33,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command";
|
||||
import { importFromExcel, getExcelSheetNames, exportToExcel } from "@/lib/utils/excelExport";
|
||||
import { importFromExcel, getExcelSheetNames } from "@/lib/utils/excelExport";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { EditableSpreadsheet } from "./EditableSpreadsheet";
|
||||
import {
|
||||
@@ -144,32 +144,64 @@ export const MultiTableExcelUploadModal: React.FC<MultiTableExcelUploadModalProp
|
||||
return cols;
|
||||
}, [selectedMode, config.levels]);
|
||||
|
||||
// 템플릿 다운로드
|
||||
const handleDownloadTemplate = () => {
|
||||
// 템플릿 다운로드 (필수 헤더는 빨강 폰트)
|
||||
const handleDownloadTemplate = async () => {
|
||||
if (!selectedMode) return;
|
||||
|
||||
const headers: string[] = [];
|
||||
const sampleRow: Record<string, string> = {};
|
||||
const sampleRow2: Record<string, string> = {};
|
||||
try {
|
||||
const headers: string[] = [];
|
||||
const requiredFlags: boolean[] = [];
|
||||
|
||||
for (const levelIdx of selectedMode.activeLevels) {
|
||||
const level = config.levels[levelIdx];
|
||||
if (!level) continue;
|
||||
for (const col of level.columns) {
|
||||
headers.push(col.excelHeader);
|
||||
sampleRow[col.excelHeader] = col.required ? "(필수)" : "";
|
||||
sampleRow2[col.excelHeader] = "";
|
||||
for (const levelIdx of selectedMode.activeLevels) {
|
||||
const level = config.levels[levelIdx];
|
||||
if (!level) continue;
|
||||
for (const col of level.columns) {
|
||||
headers.push(col.excelHeader);
|
||||
requiredFlags.push(!!col.required);
|
||||
}
|
||||
}
|
||||
|
||||
const ExcelJS = (await import("exceljs")).default;
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
const ws = workbook.addWorksheet("Sheet1");
|
||||
|
||||
headers.forEach((_, i) => {
|
||||
ws.getColumn(i + 1).width = 18;
|
||||
});
|
||||
|
||||
const headerRow = ws.addRow(headers);
|
||||
headerRow.height = 24;
|
||||
headerRow.eachCell((cell, colNumber) => {
|
||||
const isRequired = requiredFlags[colNumber - 1];
|
||||
cell.font = {
|
||||
bold: true,
|
||||
size: 10,
|
||||
color: { argb: isRequired ? "FFDC2626" : "FF1E293B" },
|
||||
};
|
||||
cell.fill = { type: "pattern", pattern: "solid", fgColor: { argb: "FFF1F5F9" } };
|
||||
cell.border = { bottom: { style: "medium", color: { argb: "FF94A3B8" } } };
|
||||
cell.alignment = { vertical: "middle", horizontal: "center" };
|
||||
});
|
||||
|
||||
// 빈 행 1줄 (사용자가 입력할 수 있도록)
|
||||
ws.addRow(headers.map(() => ""));
|
||||
|
||||
const buffer = await workbook.xlsx.writeBuffer();
|
||||
const blob = new Blob([buffer], {
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
});
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `${config.name}_${selectedMode.label}_템플릿.xlsx`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
toast.success("템플릿 파일이 다운로드되었습니다.");
|
||||
} catch (err) {
|
||||
console.error("템플릿 다운로드 실패:", err);
|
||||
toast.error("템플릿 다운로드에 실패했습니다.");
|
||||
}
|
||||
|
||||
// 예시 데이터 생성 (config에 맞춰)
|
||||
exportToExcel(
|
||||
[sampleRow, sampleRow2],
|
||||
`${config.name}_${selectedMode.label}_템플릿.xlsx`,
|
||||
"Sheet1"
|
||||
);
|
||||
|
||||
toast.success("템플릿 파일이 다운로드되었습니다.");
|
||||
};
|
||||
|
||||
// 파일 처리
|
||||
|
||||
Reference in New Issue
Block a user