feat(inventory): 優化盤點顯示與權限設定
This commit is contained in:
@@ -79,7 +79,6 @@ export default function Show({ doc }: { auth: any, doc: AdjDoc }) {
|
||||
action: 'save',
|
||||
});
|
||||
|
||||
const [newItemOpen, setNewItemOpen] = useState(false);
|
||||
|
||||
// Helper to add new item
|
||||
const addItem = (product: any, batchNumber: string | null) => {
|
||||
@@ -107,7 +106,6 @@ export default function Show({ doc }: { auth: any, doc: AdjDoc }) {
|
||||
notes: '',
|
||||
}
|
||||
]);
|
||||
setNewItemOpen(false);
|
||||
};
|
||||
|
||||
const removeItem = (index: number) => {
|
||||
@@ -294,96 +292,99 @@ export default function Show({ doc }: { auth: any, doc: AdjDoc }) {
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<Card className="border border-gray-200 shadow-sm overflow-hidden gap-0">
|
||||
<CardHeader className="bg-white border-b flex flex-row items-center justify-between py-4 px-6">
|
||||
<CardTitle className="text-lg font-medium text-grey-900">調整項目清單</CardTitle>
|
||||
<div className="bg-white rounded-lg shadow-sm border p-6 space-y-4">
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<h3 className="text-lg font-medium text-grey-900">調整項目清單</h3>
|
||||
{isDraft && (
|
||||
<ProductSearchDialog
|
||||
warehouseId={doc.warehouse_id}
|
||||
onSelect={(product, batch) => addItem(product, batch)}
|
||||
/>
|
||||
)}
|
||||
</CardHeader>
|
||||
<Table>
|
||||
<TableHeader className="bg-gray-50">
|
||||
<TableRow>
|
||||
<TableHead className="w-[60px] text-center font-medium text-grey-600">#</TableHead>
|
||||
<TableHead className="pl-4 font-medium text-grey-600">商品資訊</TableHead>
|
||||
<TableHead className="font-medium text-grey-600">批號</TableHead>
|
||||
<TableHead className="w-24 text-center font-medium text-grey-600">單位</TableHead>
|
||||
<TableHead className="w-32 text-right font-medium text-grey-600 text-primary-main">調整前庫存</TableHead>
|
||||
<TableHead className="w-40 text-right font-medium text-grey-600">調整數量 (+/-)</TableHead>
|
||||
<TableHead className="font-medium text-grey-600">備註說明</TableHead>
|
||||
{isDraft && <TableHead className="w-[80px]"></TableHead>}
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{data.items.length === 0 ? (
|
||||
</div>
|
||||
<div className="border rounded-lg overflow-hidden">
|
||||
<Table>
|
||||
<TableHeader className="bg-gray-50">
|
||||
<TableRow>
|
||||
<TableCell colSpan={isDraft ? 8 : 7} className="h-32 text-center text-grey-400">
|
||||
尚未載入任何調整項目
|
||||
</TableCell>
|
||||
<TableHead className="w-[60px] text-center font-medium text-grey-600">#</TableHead>
|
||||
<TableHead className="pl-4 font-medium text-grey-600">商品資訊</TableHead>
|
||||
<TableHead className="font-medium text-grey-600">批號</TableHead>
|
||||
<TableHead className="w-24 text-center font-medium text-grey-600">單位</TableHead>
|
||||
<TableHead className="w-32 text-right font-medium text-grey-600 text-primary-main">調整前庫存</TableHead>
|
||||
<TableHead className="w-40 text-right font-medium text-grey-600">調整數量 (+/-)</TableHead>
|
||||
<TableHead className="font-medium text-grey-600">備註說明</TableHead>
|
||||
{isDraft && <TableHead className="w-[80px]"></TableHead>}
|
||||
</TableRow>
|
||||
) : (
|
||||
data.items.map((item, index) => (
|
||||
<TableRow
|
||||
key={`${item.product_id}-${item.batch_number}-${index}`}
|
||||
className="group hover:bg-gray-50/50 transition-colors"
|
||||
>
|
||||
<TableCell className="text-center text-grey-400 font-medium">{index + 1}</TableCell>
|
||||
<TableCell className="pl-4">
|
||||
<div className="font-bold text-grey-900">{item.product_name}</div>
|
||||
<div className="text-xs text-grey-500 font-mono">{item.product_code}</div>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{data.items.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={isDraft ? 8 : 7} className="h-32 text-center text-grey-400">
|
||||
尚未載入任何調整項目
|
||||
</TableCell>
|
||||
<TableCell className="text-grey-600">{item.batch_number || '-'}</TableCell>
|
||||
<TableCell className="text-center text-grey-500">{item.unit}</TableCell>
|
||||
<TableCell className="text-right font-medium text-grey-400">
|
||||
{item.qty_before}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{isDraft ? (
|
||||
<Input
|
||||
type="number"
|
||||
className="text-right h-9 border-grey-200 focus:ring-primary-main"
|
||||
value={item.adjust_qty}
|
||||
onChange={e => updateItem(index, 'adjust_qty', e.target.value)}
|
||||
/>
|
||||
) : (
|
||||
<span className={`font-bold ${Number(item.adjust_qty) > 0 ? 'text-green-600' : 'text-red-600'}`}>
|
||||
{Number(item.adjust_qty) > 0 ? '+' : ''}{item.adjust_qty}
|
||||
</span>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{isDraft ? (
|
||||
<Input
|
||||
className="h-9 border-grey-200 focus:ring-primary-main"
|
||||
value={item.notes || ''}
|
||||
onChange={e => updateItem(index, 'notes', e.target.value)}
|
||||
placeholder="輸入備註..."
|
||||
/>
|
||||
) : (
|
||||
<span className="text-grey-600 text-sm">{item.notes || '-'}</span>
|
||||
)}
|
||||
</TableCell>
|
||||
{isDraft && (
|
||||
<TableCell className="text-center">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-8 w-8 text-red-400 hover:text-red-600 hover:bg-red-50 p-0"
|
||||
onClick={() => removeItem(index)}
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</Button>
|
||||
</TableCell>
|
||||
)}
|
||||
</TableRow>
|
||||
))
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</Card>
|
||||
) : (
|
||||
data.items.map((item, index) => (
|
||||
<TableRow
|
||||
key={`${item.product_id}-${item.batch_number}-${index}`}
|
||||
className="group hover:bg-gray-50/50 transition-colors"
|
||||
>
|
||||
<TableCell className="text-center text-grey-400 font-medium">{index + 1}</TableCell>
|
||||
<TableCell className="pl-4">
|
||||
<div className="font-bold text-grey-900">{item.product_name}</div>
|
||||
<div className="text-xs text-grey-500 font-mono">{item.product_code}</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-grey-600">{item.batch_number || '-'}</TableCell>
|
||||
<TableCell className="text-center text-grey-500">{item.unit}</TableCell>
|
||||
<TableCell className="text-right font-medium text-grey-400">
|
||||
{item.qty_before}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{isDraft ? (
|
||||
<Input
|
||||
type="number"
|
||||
className="text-right h-9 border-grey-200 focus:ring-primary-main"
|
||||
value={item.adjust_qty}
|
||||
onChange={e => updateItem(index, 'adjust_qty', e.target.value)}
|
||||
/>
|
||||
) : (
|
||||
<span className={`font-bold ${Number(item.adjust_qty) > 0 ? 'text-green-600' : 'text-red-600'}`}>
|
||||
{Number(item.adjust_qty) > 0 ? '+' : ''}{item.adjust_qty}
|
||||
</span>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{isDraft ? (
|
||||
<Input
|
||||
className="h-9 border-grey-200 focus:ring-primary-main"
|
||||
value={item.notes || ''}
|
||||
onChange={e => updateItem(index, 'notes', e.target.value)}
|
||||
placeholder="輸入備註..."
|
||||
/>
|
||||
) : (
|
||||
<span className="text-grey-600 text-sm">{item.notes || '-'}</span>
|
||||
)}
|
||||
</TableCell>
|
||||
{isDraft && (
|
||||
<TableCell className="text-center">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-8 w-8 text-red-400 hover:text-red-600 hover:bg-red-50 p-0"
|
||||
onClick={() => removeItem(index)}
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</Button>
|
||||
</TableCell>
|
||||
)}
|
||||
</TableRow>
|
||||
))
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="bg-gray-50/80 border border-dashed border-grey-200 rounded-lg p-4 flex items-start gap-3">
|
||||
<CheckCircle className="h-5 w-5 text-primary-main mt-0.5 shrink-0" />
|
||||
|
||||
Reference in New Issue
Block a user