From 1c1c1019b6af72771358d387a2ae70ca965cd9f9 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 26 May 2025 04:25:47 +0000
Subject: (김준회) 아이템 리스트를 자재그룹으로 변경하고 PLM 인터페이스 처리
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/items/table/update-item-sheet.tsx | 199 ++++++++++++++++++++++++++++++++--
 1 file changed, 187 insertions(+), 12 deletions(-)

(limited to 'lib/items/table/update-item-sheet.tsx')

diff --git a/lib/items/table/update-item-sheet.tsx b/lib/items/table/update-item-sheet.tsx
index 4bcdbfcb..fcdc0a70 100644
--- a/lib/items/table/update-item-sheet.tsx
+++ b/lib/items/table/update-item-sheet.tsx
@@ -1,7 +1,6 @@
 "use client"
 
 import * as React from "react"
-import { tasks, type Task } from "@/db/schema/tasks"
 import { zodResolver } from "@hookform/resolvers/zod"
 import { Loader } from "lucide-react"
 import { useForm } from "react-hook-form"
@@ -19,7 +18,6 @@ import {
 import {
   Select,
   SelectContent,
-  SelectGroup,
   SelectItem,
   SelectTrigger,
   SelectValue,
@@ -35,8 +33,6 @@ import {
 } from "@/components/ui/sheet"
 import { Textarea } from "@/components/ui/textarea"
 
-import { modifiTask } from "@/lib//tasks/service"
-import { updateTaskSchema, type UpdateTaskSchema } from "@/lib/tasks/validations"
 import { Item } from "@/db/schema/items"
 import { updateItemSchema, UpdateItemSchema } from "../validations"
 import { modifyItem } from "../service"
@@ -57,7 +53,14 @@ export function UpdateItemSheet({ item, ...props }: UpdateItemSheetProps) {
       itemCode: item?.itemCode ?? "",
       itemName: item?.itemName ?? "",
       description: item?.description ?? "",
-
+      parentItemCode: item?.parentItemCode ?? "",
+      itemLevel: item?.itemLevel ?? null,
+      deleteFlag: item?.deleteFlag ?? "",
+      unitOfMeasure: item?.unitOfMeasure ?? "",
+      steelType: item?.steelType ?? "",
+      gradeMaterial: item?.gradeMaterial ?? "",
+      changeDate: item?.changeDate ?? "",
+      baseUnitOfMeasure: item?.baseUnitOfMeasure ?? "",
     },
   })
 
@@ -68,6 +71,14 @@ export function UpdateItemSheet({ item, ...props }: UpdateItemSheetProps) {
         itemCode: item.itemCode ?? "",
         itemName: item.itemName ?? "",
         description: item.description ?? "",
+        parentItemCode: item.parentItemCode ?? "",
+        itemLevel: item.itemLevel ?? null,
+        deleteFlag: item.deleteFlag ?? "",
+        unitOfMeasure: item.unitOfMeasure ?? "",
+        steelType: item.steelType ?? "",
+        gradeMaterial: item.gradeMaterial ?? "",
+        changeDate: item.changeDate ?? "",
+        baseUnitOfMeasure: item.baseUnitOfMeasure ?? "",
       });
     }
   }, [item, form]);
@@ -111,10 +122,9 @@ export function UpdateItemSheet({ item, ...props }: UpdateItemSheetProps) {
               name="itemCode"
               render={({ field }) => (
                 <FormItem>
-                  <FormLabel>Item Code</FormLabel>
+                  <FormLabel>자재그룹코드</FormLabel>
                   <FormControl>
-                    <Input   placeholder="e.g." {...field} />
-
+                    <Input placeholder="예: BOLT001" {...field} />
                   </FormControl>
                   <FormMessage />
                 </FormItem>
@@ -125,10 +135,10 @@ export function UpdateItemSheet({ item, ...props }: UpdateItemSheetProps) {
               name="itemName"
               render={({ field }) => (
                 <FormItem>
-                  <FormLabel>Item Name</FormLabel>
+                  <FormLabel>자재그룹명</FormLabel>
                   <FormControl>
                     <Input
-                      placeholder="e.g."
+                      placeholder="예: 육각볼트 M8x20"
                       {...field}
                     />
                   </FormControl>
@@ -142,10 +152,10 @@ export function UpdateItemSheet({ item, ...props }: UpdateItemSheetProps) {
               name="description"
               render={({ field }) => (
                 <FormItem>
-                  <FormLabel>Description</FormLabel>
+                  <FormLabel>상세</FormLabel>
                   <FormControl>
                     <Textarea
-                      placeholder="e.g."
+                      placeholder="예: 표준 육각 볼트 스테인리스 스틸"
                       {...field}
                     />
                   </FormControl>
@@ -154,6 +164,171 @@ export function UpdateItemSheet({ item, ...props }: UpdateItemSheetProps) {
               )}
             />
 
+            {/* 2열 레이아웃 */}
+            <div className="grid grid-cols-2 gap-4">
+              <FormField
+                control={form.control}
+                name="itemLevel"
+                render={({ field }) => (
+                  <FormItem>
+                    <FormLabel>레벨</FormLabel>
+                    <FormControl>
+                      <Input
+                        type="number"
+                        min="1"
+                        max="5"
+                        placeholder="1-5"
+                        {...field}
+                        value={field.value ?? ""}
+                        onChange={(e) => field.onChange(e.target.value ? parseInt(e.target.value) : null)}
+                      />
+                    </FormControl>
+                    <FormMessage />
+                  </FormItem>
+                )}
+              />
+
+              <FormField
+                control={form.control}
+                name="deleteFlag"
+                render={({ field }) => (
+                  <FormItem>
+                    <FormLabel>삭제 플래그</FormLabel>
+                    <FormControl>
+                      <Select onValueChange={field.onChange} value={field.value || ""}>
+                        <SelectTrigger>
+                          <SelectValue placeholder="선택" />
+                        </SelectTrigger>
+                        <SelectContent>
+                          <SelectItem value="N">N (사용)</SelectItem>
+                          <SelectItem value="Y">Y (삭제)</SelectItem>
+                        </SelectContent>
+                      </Select>
+                    </FormControl>
+                    <FormMessage />
+                  </FormItem>
+                )}
+              />
+            </div>
+
+            <div className="grid grid-cols-2 gap-4">
+              <FormField
+                control={form.control}
+                name="parentItemCode"
+                render={({ field }) => (
+                  <FormItem>
+                    <FormLabel>부모 아이템 코드</FormLabel>
+                    <FormControl>
+                      <Input
+                        placeholder="예: BOLT001"
+                        {...field}
+                        value={field.value || ""}
+                      />
+                    </FormControl>
+                    <FormMessage />
+                  </FormItem>
+                )}
+              />
+
+              <FormField
+                control={form.control}
+                name="steelType"
+                render={({ field }) => (
+                  <FormItem>
+                    <FormLabel>강종</FormLabel>
+                    <FormControl>
+                      <Input
+                        placeholder="예: SS, CS, AL"
+                        maxLength={2}
+                        {...field}
+                        value={field.value || ""}
+                      />
+                    </FormControl>
+                    <FormMessage />
+                  </FormItem>
+                )}
+              />
+            </div>
+
+            <div className="grid grid-cols-2 gap-4">
+              <FormField
+                control={form.control}
+                name="unitOfMeasure"
+                render={({ field }) => (
+                  <FormItem>
+                    <FormLabel>단위</FormLabel>
+                    <FormControl>
+                      <Input
+                        placeholder="예: EA, SET, KG"
+                        maxLength={3}
+                        {...field}
+                        value={field.value || ""}
+                      />
+                    </FormControl>
+                    <FormMessage />
+                  </FormItem>
+                )}
+              />
+
+              <FormField
+                control={form.control}
+                name="baseUnitOfMeasure"
+                render={({ field }) => (
+                  <FormItem>
+                    <FormLabel>기본단위</FormLabel>
+                    <FormControl>
+                      <Input
+                        placeholder="예: EA, SET, KG"
+                        maxLength={3}
+                        {...field}
+                        value={field.value || ""}
+                      />
+                    </FormControl>
+                    <FormMessage />
+                  </FormItem>
+                )}
+              />
+            </div>
+
+            <div className="grid grid-cols-2 gap-4">
+              <FormField
+                control={form.control}
+                name="gradeMaterial"
+                render={({ field }) => (
+                  <FormItem>
+                    <FormLabel>등급 재질</FormLabel>
+                    <FormControl>
+                      <Input
+                        placeholder="예: Marine Grade A"
+                        {...field}
+                        value={field.value || ""}
+                      />
+                    </FormControl>
+                    <FormMessage />
+                  </FormItem>
+                )}
+              />
+
+              <FormField
+                control={form.control}
+                name="changeDate"
+                render={({ field }) => (
+                  <FormItem>
+                    <FormLabel>변경일자</FormLabel>
+                    <FormControl>
+                      <Input
+                        placeholder="YYYYMMDD"
+                        maxLength={8}
+                        {...field}
+                        value={field.value || ""}
+                      />
+                    </FormControl>
+                    <FormMessage />
+                  </FormItem>
+                )}
+              />
+            </div>
+
             <SheetFooter className="gap-2 pt-2 sm:space-x-0">
               <SheetClose asChild>
                 <Button type="button" variant="outline">
-- 
cgit v1.2.3

