This commit is contained in:
2026-04-24 00:52:30 +08:00
parent 2bfce239fb
commit 06708df3af
4 changed files with 28 additions and 18 deletions
@@ -590,7 +590,7 @@ onMounted(async () => {
<span class="font-medium max-w-xs truncate">{{ item.Name }}</span> <span class="font-medium max-w-xs truncate">{{ item.Name }}</span>
</div> </div>
</td> </td>
<td class="px-5 py-3 text-xs text-gray-500 dark:text-gray-400 max-w-[140px] truncate">{{ item.serial_number || '—' }}</td> <td class="px-5 py-3 text-xs text-gray-500 dark:text-gray-400 max-w-[140px] truncate">{{ item.SerialNumber || '—' }}</td>
<td class="px-5 py-3 text-xs text-gray-500 dark:text-gray-400 max-w-[200px] truncate">{{ item.Remark || '—' }}</td> <td class="px-5 py-3 text-xs text-gray-500 dark:text-gray-400 max-w-[200px] truncate">{{ item.Remark || '—' }}</td>
<td class="px-5 py-3 text-center text-sm">{{ item.Quantity }}</td> <td class="px-5 py-3 text-center text-sm">{{ item.Quantity }}</td>
<td class="px-5 py-3 text-xs text-gray-400 dark:text-gray-500 whitespace-nowrap">{{ fmtTs(item.CreatedAt) }}</td> <td class="px-5 py-3 text-xs text-gray-400 dark:text-gray-500 whitespace-nowrap">{{ fmtTs(item.CreatedAt) }}</td>
@@ -260,6 +260,16 @@ async function submitMove() {
} }
} }
// ── 返回 ──
function goBack() {
const cid = item.value?.ContainerID
if (cid) {
router.push(`/warehouse/container/${cid}`)
} else {
router.push('/warehouse/container')
}
}
// ── 删除 ── // ── 删除 ──
async function doDelete() { async function doDelete() {
try { try {
@@ -312,7 +322,7 @@ onMounted(() => {
<div class="flex items-center justify-between gap-2"> <div class="flex items-center justify-between gap-2">
<button <button
class="inline-flex items-center gap-1.5 rounded-lg border border-gray-300 bg-white px-3 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 dark:border-dk-muted dark:bg-dk-base dark:text-white dark:hover:bg-dk-muted" class="inline-flex items-center gap-1.5 rounded-lg border border-gray-300 bg-white px-3 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 dark:border-dk-muted dark:bg-dk-base dark:text-white dark:hover:bg-dk-muted"
@click="router.back()" @click="goBack"
> >
<IconArrowLeft :size="14" /> <IconArrowLeft :size="14" />
返回 返回
@@ -63,11 +63,11 @@ async function fetchContainerMap() {
allContainerCount.value = data.all_count || 0 allContainerCount.value = data.all_count || 0
const map = {} const map = {}
for (const c of (data.containers || [])) { for (const c of (data.containers || [])) {
map[c.id] = c.title map[c.ID] = c.Title
} }
for (const c of (data.containers || [])) { for (const c of (data.containers || [])) {
if (c.child_count > 0) { if (c.ChildCount > 0) {
await fetchChildContainers(c.id, map) await fetchChildContainers(c.ID, map)
} }
} }
containerMap.value = map containerMap.value = map
@@ -82,7 +82,7 @@ async function fetchChildContainers(parentId, map) {
const { errCode, data } = await warehouseApi.getContainers({ entries: 500, page: 1, parent_id: parentId }) const { errCode, data } = await warehouseApi.getContainers({ entries: 500, page: 1, parent_id: parentId })
if (errCode === 0 && data) { if (errCode === 0 && data) {
for (const c of (data.containers || [])) { for (const c of (data.containers || [])) {
map[c.id] = c.title map[c.ID] = c.Title
} }
} }
} catch { } catch {
@@ -104,8 +104,8 @@ async function fetchItems() {
canModifyItems.value = data.canModifyItems || [] canModifyItems.value = data.canModifyItems || []
totalCount.value = data.all_count || 0 totalCount.value = data.all_count || 0
stats.total = data.all_count || 0 stats.total = data.all_count || 0
stats.inContainer = items.value.filter(i => i.container_id != null).length stats.inContainer = items.value.filter(i => i.ContainerID != null).length
stats.unstored = items.value.filter(i => i.container_id == null).length stats.unstored = items.value.filter(i => i.ContainerID == null).length
} }
} catch { } catch {
toast.error(t('message.server_error')) toast.error(t('message.server_error'))
@@ -161,7 +161,7 @@ const pageNumbers = computed(() => {
// ── 跳转物品详情 ── // ── 跳转物品详情 ──
function goToDetail(item) { function goToDetail(item) {
router.push(`/warehouse/item/${item.id}`) router.push(`/warehouse/item/${item.ID}`)
} }
// ── 删除 ── // ── 删除 ──
@@ -178,7 +178,7 @@ async function doDeleteItem() {
if (!deleteTarget.value) return if (!deleteTarget.value) return
deletingItem.value = true deletingItem.value = true
try { try {
const { errCode } = await warehouseApi.deleteItem(deleteTarget.value.id) const { errCode } = await warehouseApi.deleteItem(deleteTarget.value.ID)
if (errCode === 0) { if (errCode === 0) {
toast.success(t('message.delete_success')) toast.success(t('message.delete_success'))
confirmDelete.value = false confirmDelete.value = false
@@ -281,23 +281,23 @@ onMounted(() => {
<tbody> <tbody>
<tr <tr
v-for="(item, idx) in items" v-for="(item, idx) in items"
:key="item.id" :key="item.ID"
class="border-b border-gray-100 cursor-pointer transition-colors hover:bg-gray-50 dark:border-dk-muted dark:hover:bg-dk-base" class="border-b border-gray-100 cursor-pointer transition-colors hover:bg-gray-50 dark:border-dk-muted dark:hover:bg-dk-base"
@click="goToDetail(item)" @click="goToDetail(item)"
> >
<td class="px-5 py-3 font-medium max-w-[200px] truncate">{{ item.name }}</td> <td class="px-5 py-3 font-medium max-w-[200px] truncate">{{ item.Name }}</td>
<td class="px-5 py-3 text-xs text-gray-500 dark:text-gray-400 max-w-[160px] truncate">{{ item.serial_number || '—' }}</td> <td class="px-5 py-3 text-xs text-gray-500 dark:text-gray-400 max-w-[160px] truncate">{{ item.SerialNumber || '—' }}</td>
<td class="px-5 py-3 text-center text-sm">{{ item.quantity }}</td> <td class="px-5 py-3 text-center text-sm">{{ item.Quantity }}</td>
<td class="px-5 py-3"> <td class="px-5 py-3">
<span v-if="item.container_id != null" class="inline-flex items-center gap-1 text-blue-600 text-sm"> <span v-if="item.ContainerID != null" class="inline-flex items-center gap-1 text-blue-600 text-sm">
<IconArrowRight :size="13" /> <IconArrowRight :size="13" />
<span class="truncate max-w-[140px]">{{ getContainerTitle(item.container_id) }}</span> <span class="truncate max-w-[140px]">{{ getContainerTitle(item.ContainerID) }}</span>
</span> </span>
<span v-else class="inline-flex items-center gap-1 text-xs text-orange-500"> <span v-else class="inline-flex items-center gap-1 text-xs text-orange-500">
{{ t('warehouse.unstored_items') }} {{ t('warehouse.unstored_items') }}
</span> </span>
</td> </td>
<td class="px-5 py-3 text-xs text-gray-400 dark:text-gray-500 whitespace-nowrap">{{ formatDate(item.created_at) }}</td> <td class="px-5 py-3 text-xs text-gray-400 dark:text-gray-500 whitespace-nowrap">{{ formatDate(item.CreatedAt) }}</td>
<td class="px-5 py-3 text-right" @click.stop> <td class="px-5 py-3 text-right" @click.stop>
<button <button
v-if="canModifyItem(idx)" v-if="canModifyItem(idx)"
@@ -114,7 +114,7 @@ async function fetchAllContainerMap() {
const { errCode, data } = await warehouseApi.getContainers({ entries: 500, page: 1 }) const { errCode, data } = await warehouseApi.getContainers({ entries: 500, page: 1 })
if (errCode === 0 && data) { if (errCode === 0 && data) {
const map = {} const map = {}
for (const c of (data.containers || [])) map[c.id] = c.title for (const c of (data.containers || [])) map[c.ID] = c.Title
containerMap.value = map containerMap.value = map
} }
} catch { /* ignore */ } } catch { /* ignore */ }