3달간 수정 사항
This commit is contained in:
@@ -11,7 +11,7 @@ import { PlusIcon, TrashBinIcon } from "@/icons";
|
||||
|
||||
|
||||
interface DeviceGooodsItem {
|
||||
slot: string;
|
||||
column_no: string;
|
||||
goods_id: number;
|
||||
price?: number;
|
||||
inventory?: number;
|
||||
@@ -40,23 +40,23 @@ export default function ManageGoodsModal({ multiState, onOk, isOpen, closeModal
|
||||
|
||||
function computeGoods(modal: GoodsModalProps): GoodsModalProps {
|
||||
// 1 & 2. 우선 slot이 빈 문자열("")이 아닌 아이템들만 추출 (1차 필터링)
|
||||
const filteredPrev = modal.prev_device_goods.filter(item => item.slot !== "");
|
||||
const filteredNew = modal.new_device_goods.filter(item => item.slot !== "");
|
||||
const filteredPrev = modal.prev_device_goods.filter(item => item.column_no !== "");
|
||||
const filteredNew = modal.new_device_goods.filter(item => item.column_no !== "");
|
||||
|
||||
// 3. slot이 같으면서 goods_id까지 같은 아이템은 양쪽에서 제거
|
||||
// 즉, "상대방 배열에 나랑 똑같은(slot & goods_id) 애가 없는" 것들만 남깁니다.
|
||||
// 즉, "상대방 배열에 나랑 똑같은(column_no & goods_id) 애가 없는" 것들만 남깁니다.
|
||||
|
||||
// device_goods 정제
|
||||
const final_device_goods = filteredPrev.filter(prevItem =>
|
||||
!filteredNew.find(newItem =>
|
||||
newItem.slot === prevItem.slot && newItem.goods_id === prevItem.goods_id
|
||||
newItem.column_no === prevItem.column_no && newItem.goods_id === prevItem.goods_id
|
||||
)
|
||||
);
|
||||
|
||||
// new_device_goods 정제
|
||||
const final_new_device_goods = filteredNew.filter(newItem =>
|
||||
!filteredPrev.find(prevItem =>
|
||||
prevItem.slot === newItem.slot && prevItem.goods_id === newItem.goods_id
|
||||
prevItem.column_no === newItem.column_no && prevItem.goods_id === newItem.goods_id
|
||||
)
|
||||
);
|
||||
|
||||
@@ -118,7 +118,7 @@ export default function ManageGoodsModal({ multiState, onOk, isOpen, closeModal
|
||||
return;
|
||||
}
|
||||
|
||||
const newItem: DeviceGooodsItem = { slot: "", goods_id: parseInt(multiState.values.optGoodsList[0].value) }
|
||||
const newItem: DeviceGooodsItem = { column_no: "", goods_id: parseInt(multiState.values.optGoodsList[0].value) }
|
||||
const newArray: DeviceGooodsItem[] = [...multiState.values.new_device_goods, newItem];
|
||||
|
||||
multiState.set("new_device_goods", newArray);
|
||||
@@ -133,7 +133,7 @@ export default function ManageGoodsModal({ multiState, onOk, isOpen, closeModal
|
||||
|
||||
const handleChangeSlot = (index: number, newValue: string) => {
|
||||
const newArray: DeviceGooodsItem[] = [...multiState.values.new_device_goods];
|
||||
newArray[index].slot = newValue;
|
||||
newArray[index].column_no = newValue;
|
||||
|
||||
multiState.set("new_device_goods", newArray);
|
||||
};
|
||||
@@ -165,7 +165,7 @@ export default function ManageGoodsModal({ multiState, onOk, isOpen, closeModal
|
||||
>
|
||||
<div>
|
||||
<Label>사업자원장</Label>
|
||||
<Input type="text" value={multiState.values.biz_group_name + "(" + multiState.values.biz_reg_num + ")"} disabled />
|
||||
<Input type="text" value={multiState.values.biz_group_name + (multiState.values.biz_reg_num ? `(${multiState.values.biz_reg_num})` : "")} disabled />
|
||||
</div>
|
||||
<div>
|
||||
<Label>무인기기명 또는 관리이름</Label>
|
||||
@@ -176,14 +176,14 @@ export default function ManageGoodsModal({ multiState, onOk, isOpen, closeModal
|
||||
<Label>상품정보 {index + 1}</Label>
|
||||
<div className="flex gap-2">
|
||||
<div className={"w-34"}>
|
||||
<Input type="text" placeholder="컬럼번호2" value={multiState.values.new_device_goods[index].slot} onChange={(e) => handleChangeSlot(index, e.target.value)} />
|
||||
<Input type="text" placeholder="컬럼번호2" value={multiState.values.new_device_goods[index].column_no} onChange={(e) => handleChangeSlot(index, e.target.value)} />
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<Select
|
||||
placeholder="상품을 선택하세요"
|
||||
options={multiState.values.optGoodsList}
|
||||
defaultValue={String(multiState.values.new_device_goods[index].goods_id)}
|
||||
onChange={(value) => handleChangeGoods(index, value)}
|
||||
onChange={(e) => handleChangeGoods(index, e.target.value)}
|
||||
className="dark:bg-dark-900" />
|
||||
</div>
|
||||
<div className={"w-34"}>
|
||||
|
||||
Reference in New Issue
Block a user