fix: [재고생산] 등록일 저장, 이중 toast 제거, site_name 설정
This commit is contained in:
@@ -244,7 +244,7 @@ export function BendingLotForm({ initialData, isEditMode = false }: BendingLotFo
|
||||
if (initialData?.bendingLot) {
|
||||
const bl = initialData.bendingLot;
|
||||
return {
|
||||
regDate: getInitialForm().regDate,
|
||||
regDate: initialData.regDate || getInitialForm().regDate,
|
||||
prodCode: bl.prodCode || '',
|
||||
specCode: bl.specCode || '',
|
||||
lengthCode: bl.lengthCode || '',
|
||||
@@ -375,22 +375,22 @@ export function BendingLotForm({ initialData, isEditMode = false }: BendingLotFo
|
||||
);
|
||||
|
||||
// 저장
|
||||
const handleSave = useCallback(async () => {
|
||||
const handleSave = useCallback(async (): Promise<{ success: boolean; error: string }> => {
|
||||
if (!form.prodCode) {
|
||||
toast.error('품목명을 선택하세요.');
|
||||
return;
|
||||
return { success: false, error: '' };
|
||||
}
|
||||
if (!form.specCode) {
|
||||
toast.error('종류를 선택하세요.');
|
||||
return;
|
||||
return { success: false, error: '' };
|
||||
}
|
||||
if (!form.lengthCode) {
|
||||
toast.error('모양&길이를 선택하세요.');
|
||||
return;
|
||||
return { success: false, error: '' };
|
||||
}
|
||||
if (form.quantity < 1) {
|
||||
toast.error('수량을 입력하세요.');
|
||||
return;
|
||||
return { success: false, error: '' };
|
||||
}
|
||||
|
||||
setIsSaving(true);
|
||||
@@ -404,11 +404,11 @@ export function BendingLotForm({ initialData, isEditMode = false }: BendingLotFo
|
||||
);
|
||||
if (lotResult.__authError) {
|
||||
toast.error('인증이 만료되었습니다.');
|
||||
return;
|
||||
return { success: false, error: '' };
|
||||
}
|
||||
if (!lotResult.success || !lotResult.data) {
|
||||
toast.error(lotResult.error || 'LOT 번호 생성에 실패했습니다.');
|
||||
return;
|
||||
return { success: false, error: '' };
|
||||
}
|
||||
|
||||
const lotData = lotResult.data;
|
||||
@@ -420,6 +420,7 @@ export function BendingLotForm({ initialData, isEditMode = false }: BendingLotFo
|
||||
|
||||
const saveParams = {
|
||||
memo: form.memo,
|
||||
regDate: form.regDate,
|
||||
targetStockQty: form.quantity,
|
||||
bendingLot: {
|
||||
lot_number: lotData.lot_number,
|
||||
@@ -446,11 +447,10 @@ export function BendingLotForm({ initialData, isEditMode = false }: BendingLotFo
|
||||
|
||||
if (saveResult.__authError) {
|
||||
toast.error('인증이 만료되었습니다.');
|
||||
return;
|
||||
return { success: false, error: '' };
|
||||
}
|
||||
if (!saveResult.success) {
|
||||
toast.error(saveResult.error || '저장에 실패했습니다.');
|
||||
return;
|
||||
return { success: false, error: saveResult.error || '저장에 실패했습니다.' };
|
||||
}
|
||||
|
||||
toast.success(isEditMode ? '절곡품 재고생산이 수정되었습니다.' : '절곡품 재고생산이 등록되었습니다.');
|
||||
@@ -459,6 +459,7 @@ export function BendingLotForm({ initialData, isEditMode = false }: BendingLotFo
|
||||
} else {
|
||||
router.push(basePath);
|
||||
}
|
||||
return { success: true, error: '' };
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ export function StockProductionDetail({ orderId }: StockProductionDetailProps) {
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>등록일</Label>
|
||||
<Input value={data.createdAt} disabled />
|
||||
<Input value={data.regDate} disabled />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>수량</Label>
|
||||
|
||||
@@ -134,7 +134,7 @@ export function StockProductionList() {
|
||||
|
||||
return matchesSearch && matchesFilter;
|
||||
})
|
||||
.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
||||
.sort((a, b) => new Date(b.regDate).getTime() - new Date(a.regDate).getTime());
|
||||
|
||||
// 핸들러
|
||||
const handleView = (order: StockOrder) => {
|
||||
@@ -212,7 +212,7 @@ export function StockProductionList() {
|
||||
{ key: "lotNumber", label: "로트번호", className: "px-2", copyable: true },
|
||||
{ key: "itemSummary", label: "품목", className: "px-2", sortable: true, copyable: true },
|
||||
{ key: "quantity", label: "수량", className: "px-2 text-center", sortable: true },
|
||||
{ key: "createdAt", label: "등록일", className: "px-2", sortable: true, copyable: true },
|
||||
{ key: "regDate", label: "등록일", className: "px-2", sortable: true, copyable: true },
|
||||
{ key: "status", label: "상태", className: "px-2 text-center", sortable: true },
|
||||
{ key: "memo", label: "비고", className: "px-2", copyable: true },
|
||||
], []);
|
||||
@@ -249,7 +249,7 @@ export function StockProductionList() {
|
||||
</TableCell>
|
||||
<TableCell>{order.itemSummary || "-"}</TableCell>
|
||||
<TableCell className="text-center">{order.quantity || "-"}</TableCell>
|
||||
<TableCell>{order.createdAt || "-"}</TableCell>
|
||||
<TableCell>{order.regDate || "-"}</TableCell>
|
||||
<TableCell className="text-center">{getStatusBadge(order.status)}</TableCell>
|
||||
<TableCell className="max-w-[150px] truncate">{order.memo || "-"}</TableCell>
|
||||
</TableRow>
|
||||
@@ -286,7 +286,7 @@ export function StockProductionList() {
|
||||
infoGrid={
|
||||
<div className="grid grid-cols-2 gap-x-4 gap-y-3">
|
||||
<InfoField label="수량" value={`${order.quantity}`} />
|
||||
<InfoField label="등록일" value={order.createdAt || "-"} />
|
||||
<InfoField label="등록일" value={order.regDate || "-"} />
|
||||
<InfoField label="로트번호" value={order.bendingLot?.lotNumber || "-"} />
|
||||
<InfoField label="품목 수" value={`${order.itemCount}개`} />
|
||||
</div>
|
||||
@@ -373,7 +373,7 @@ export function StockProductionList() {
|
||||
endDate,
|
||||
onStartDateChange: setStartDate,
|
||||
onEndDateChange: setEndDate,
|
||||
dateField: "createdAt",
|
||||
dateField: "regDate",
|
||||
},
|
||||
|
||||
itemsPerPage,
|
||||
|
||||
@@ -97,6 +97,7 @@ export interface StockOrder {
|
||||
manager: string;
|
||||
itemCount: number;
|
||||
itemSummary: string;
|
||||
regDate: string;
|
||||
createdAt: string;
|
||||
items: StockOrderItem[];
|
||||
bendingLot?: {
|
||||
@@ -202,6 +203,7 @@ function transformApiToFrontend(apiData: ApiStockOrder): StockOrder {
|
||||
manager: apiData.options?.manager_name || '',
|
||||
itemCount: items.length,
|
||||
itemSummary: firstItemName ? `${firstItemName}${extraCount}` : '-',
|
||||
regDate: apiData.options?.reg_date || formatDate(apiData.created_at),
|
||||
createdAt: formatDate(apiData.created_at),
|
||||
items,
|
||||
bendingLot: bendingLotData ? {
|
||||
@@ -245,7 +247,7 @@ function transformFrontendToApi(data: StockOrderFormData): Record<string, unknow
|
||||
// STOCK 전용: 불필요 필드 명시적 null
|
||||
client_id: null,
|
||||
client_name: null,
|
||||
site_name: null, // API 자동 설정 '재고생산'
|
||||
site_name: '재고생산', // API 자동 설정 '재고생산'
|
||||
delivery_date: null,
|
||||
delivery_method_code: null,
|
||||
discount_rate: 0,
|
||||
@@ -677,6 +679,7 @@ export async function generateBendingLot(
|
||||
*/
|
||||
export async function createBendingStockOrder(params: {
|
||||
memo?: string;
|
||||
regDate?: string;
|
||||
targetStockQty: number;
|
||||
bendingLot: BendingLotFormData;
|
||||
item: {
|
||||
@@ -700,6 +703,7 @@ export async function createBendingStockOrder(params: {
|
||||
options: {
|
||||
production_reason: '절곡품 재고생산',
|
||||
target_stock_qty: params.targetStockQty || null,
|
||||
reg_date: params.regDate || null,
|
||||
bending_lot: {
|
||||
lot_number: params.bendingLot.lot_number,
|
||||
prod_code: params.bendingLot.prod_code,
|
||||
@@ -712,7 +716,7 @@ export async function createBendingStockOrder(params: {
|
||||
},
|
||||
client_id: null,
|
||||
client_name: null,
|
||||
site_name: null,
|
||||
site_name: '재고생산',
|
||||
delivery_date: null,
|
||||
delivery_method_code: null,
|
||||
discount_rate: 0,
|
||||
@@ -752,6 +756,7 @@ export async function createBendingStockOrder(params: {
|
||||
*/
|
||||
export async function updateBendingStockOrder(id: string, params: {
|
||||
memo?: string;
|
||||
regDate?: string;
|
||||
targetStockQty: number;
|
||||
bendingLot: BendingLotFormData;
|
||||
item: {
|
||||
@@ -775,6 +780,7 @@ export async function updateBendingStockOrder(id: string, params: {
|
||||
options: {
|
||||
production_reason: '절곡품 재고생산',
|
||||
target_stock_qty: params.targetStockQty || null,
|
||||
reg_date: params.regDate || null,
|
||||
bending_lot: {
|
||||
lot_number: params.bendingLot.lot_number,
|
||||
prod_code: params.bendingLot.prod_code,
|
||||
@@ -787,7 +793,7 @@ export async function updateBendingStockOrder(id: string, params: {
|
||||
},
|
||||
client_id: null,
|
||||
client_name: null,
|
||||
site_name: null,
|
||||
site_name: '재고생산',
|
||||
delivery_date: null,
|
||||
delivery_method_code: null,
|
||||
discount_rate: 0,
|
||||
|
||||
Reference in New Issue
Block a user