up
This commit is contained in:
@@ -149,6 +149,7 @@
|
||||
"not_found": "Work order not found",
|
||||
"confirm_delete": "Are you sure you want to delete this work order? This action cannot be undone.",
|
||||
"confirm_delete_commit": "Are you sure you want to delete this progress?",
|
||||
"linked_items": "Linked Items",
|
||||
"submit": "Submit",
|
||||
"save_changes": "Save Changes"
|
||||
},
|
||||
@@ -178,6 +179,7 @@
|
||||
"container_count": "Containers",
|
||||
"item_count": "Items",
|
||||
"unstored_items": "Unstored",
|
||||
"unstored": "Unstored",
|
||||
"title_required": "Container name is required",
|
||||
"delete_confirm_title": "Delete Container",
|
||||
"delete_confirm_msg": "Are you sure you want to delete \"{name}\"? This cannot be undone.",
|
||||
@@ -301,6 +303,9 @@
|
||||
"pending_orders": "Pending orders"
|
||||
},
|
||||
"message": {
|
||||
"save": "Save",
|
||||
"cancel": "Cancel",
|
||||
"delete_success": "Deleted successfully",
|
||||
"functionality_not_yet_developed": "Functionality not yet developed",
|
||||
"hello": "Hello",
|
||||
"welcome": "Welcome",
|
||||
|
||||
@@ -149,6 +149,7 @@
|
||||
"not_found": "工单不存在",
|
||||
"confirm_delete": "确定要删除此工单吗?此操作不可撤销。",
|
||||
"confirm_delete_commit": "确定要删除此进度吗?",
|
||||
"linked_items": "关联物品",
|
||||
"submit": "提交",
|
||||
"save_changes": "保存修改"
|
||||
},
|
||||
@@ -178,6 +179,7 @@
|
||||
"container_count": "容器数",
|
||||
"item_count": "物品数",
|
||||
"unstored_items": "未入库",
|
||||
"unstored": "未入库",
|
||||
"title_required": "容器名称不能为空",
|
||||
"delete_confirm_title": "删除容器",
|
||||
"delete_confirm_msg": "确定要删除容器「{name}」吗?此操作不可撤销。",
|
||||
@@ -301,6 +303,9 @@
|
||||
"pending_orders": "待处理订单"
|
||||
},
|
||||
"message": {
|
||||
"save": "保存",
|
||||
"cancel": "取消",
|
||||
"delete_success": "删除成功",
|
||||
"functionality_not_yet_developed": "功能未开发",
|
||||
"hello": "你好",
|
||||
"welcome": "欢迎",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { ref, reactive, computed, onMounted, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useToastStore } from '@/stores/toast'
|
||||
@@ -27,9 +27,20 @@ const usersStore = useUsersStore()
|
||||
|
||||
const containerId = computed(() => parseInt(route.params.id))
|
||||
|
||||
// ── 路由参数变化时重新加载 ──
|
||||
watch(containerId, async () => {
|
||||
subPage.value = 1
|
||||
itemPage.value = 1
|
||||
await fetchContainer()
|
||||
fetchSubContainers()
|
||||
fetchItems()
|
||||
})
|
||||
|
||||
// ── 容器详情 ──
|
||||
const container = ref(null)
|
||||
const photos = ref([])
|
||||
const parentChain = ref([])
|
||||
const containerDepth = ref(0)
|
||||
const loadingDetail = ref(true)
|
||||
const notFound = ref(false)
|
||||
|
||||
@@ -89,12 +100,31 @@ const deleting = ref(false)
|
||||
// ── 时间格式化 ──
|
||||
function fmtTs(ts) {
|
||||
if (!ts) return '—'
|
||||
const d = new Date(parseInt(ts) * 1000)
|
||||
let d
|
||||
if (typeof ts === 'number') {
|
||||
// Unix timestamp in seconds (number)
|
||||
d = new Date(ts * 1000)
|
||||
} else if (typeof ts === 'string') {
|
||||
// Check if it's a Unix timestamp string like "1712345678"
|
||||
if (/^\d+$/.test(ts)) {
|
||||
d = new Date(parseInt(ts, 10) * 1000)
|
||||
} else {
|
||||
// ISO 8601 or other string format
|
||||
d = new Date(ts)
|
||||
}
|
||||
} else {
|
||||
d = new Date(ts)
|
||||
}
|
||||
if (isNaN(d.getTime())) return '—'
|
||||
return d.toLocaleString()
|
||||
}
|
||||
|
||||
// ── 拉取容器详情 ──
|
||||
async function fetchContainer() {
|
||||
container.value = null
|
||||
photos.value = []
|
||||
parentChain.value = []
|
||||
containerDepth.value = 0
|
||||
loadingDetail.value = true
|
||||
notFound.value = false
|
||||
try {
|
||||
@@ -102,6 +132,8 @@ async function fetchContainer() {
|
||||
if (errCode === 0 && data) {
|
||||
container.value = data.container
|
||||
photos.value = data.photos ?? []
|
||||
parentChain.value = data.parent_chain ?? []
|
||||
containerDepth.value = data.depth ?? 0
|
||||
} else {
|
||||
notFound.value = true
|
||||
}
|
||||
@@ -114,6 +146,7 @@ async function fetchContainer() {
|
||||
|
||||
// ── 拉取子容器 ──
|
||||
async function fetchSubContainers() {
|
||||
subContainers.value = []
|
||||
loadingSub.value = true
|
||||
try {
|
||||
const { errCode, data } = await warehouseApi.getContainers({
|
||||
@@ -135,6 +168,7 @@ async function fetchSubContainers() {
|
||||
|
||||
// ── 拉取物品 ──
|
||||
async function fetchItems() {
|
||||
items.value = []
|
||||
loadingItems.value = true
|
||||
try {
|
||||
const { errCode, data } = await warehouseApi.getItems({
|
||||
@@ -278,10 +312,17 @@ onMounted(async () => {
|
||||
|
||||
<!-- 面包屑 + 操作栏 -->
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-2 text-sm">
|
||||
<div class="flex items-center gap-1 text-sm flex-wrap">
|
||||
<RouterLink to="/warehouse/container" class="text-blue-500 hover:underline">
|
||||
{{ t('warehouse.container_list') }}
|
||||
</RouterLink>
|
||||
<template v-for="p in parentChain" :key="p.id">
|
||||
<span class="text-gray-400">/</span>
|
||||
<RouterLink
|
||||
:to="`/warehouse/container/${p.id}`"
|
||||
class="text-blue-500 hover:underline"
|
||||
>{{ p.title }}</RouterLink>
|
||||
</template>
|
||||
<span class="text-gray-400">/</span>
|
||||
<span class="font-medium text-gray-900 dark:text-white">{{ container.Title }}</span>
|
||||
</div>
|
||||
@@ -359,6 +400,7 @@ onMounted(async () => {
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
v-if="containerDepth < 4"
|
||||
class="inline-flex items-center gap-1.5 rounded-lg bg-blue-600 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-blue-700"
|
||||
@click="showAddSub = true"
|
||||
>
|
||||
|
||||
@@ -12,7 +12,9 @@ import {
|
||||
IconEdit,
|
||||
IconTrash,
|
||||
IconArrowRight,
|
||||
IconArrowLeft,
|
||||
IconSearch,
|
||||
IconPlus,
|
||||
} from '@tabler/icons-vue'
|
||||
|
||||
usePageTitle('warehouse.item_detail')
|
||||
@@ -84,7 +86,22 @@ function getStatusLabel(status) {
|
||||
// ── 时间格式化 ──
|
||||
function fmtTs(ts) {
|
||||
if (!ts) return '—'
|
||||
const d = new Date(parseInt(ts) * 1000)
|
||||
let d
|
||||
if (typeof ts === 'number') {
|
||||
// Unix timestamp in seconds (number)
|
||||
d = new Date(ts * 1000)
|
||||
} else if (typeof ts === 'string') {
|
||||
// Check if it's a Unix timestamp string like "1712345678"
|
||||
if (/^\d+$/.test(ts)) {
|
||||
d = new Date(parseInt(ts, 10) * 1000)
|
||||
} else {
|
||||
// ISO 8601 or other string format
|
||||
d = new Date(ts)
|
||||
}
|
||||
} else {
|
||||
d = new Date(ts)
|
||||
}
|
||||
if (isNaN(d.getTime())) return '—'
|
||||
return d.toLocaleString()
|
||||
}
|
||||
|
||||
@@ -150,6 +167,21 @@ function getContainerName(id) {
|
||||
return containerNames[id] || `#${id}`
|
||||
}
|
||||
|
||||
// ── 关联工单 ──
|
||||
function openLinkWorkOrder() {
|
||||
if (!item.value) return
|
||||
// 存储预填数据到 localStorage
|
||||
const prefillData = {
|
||||
itemId: item.value.ID,
|
||||
title: item.value.SerialNumber
|
||||
? `${item.value.Name}-${item.value.SerialNumber}`
|
||||
: item.value.Name,
|
||||
description: item.value.Remark || '',
|
||||
}
|
||||
localStorage.setItem('prefill_work_order', JSON.stringify(prefillData))
|
||||
router.push('/work_order/add')
|
||||
}
|
||||
|
||||
// ── 编辑 ──
|
||||
function openEdit() {
|
||||
editForm.name = item.value?.Name ?? ''
|
||||
@@ -297,16 +329,23 @@ onMounted(() => {
|
||||
|
||||
<template v-else-if="item">
|
||||
|
||||
<!-- 面包屑 + 操作栏 -->
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-2 text-sm">
|
||||
<RouterLink to="/warehouse/item" class="text-blue-500 hover:underline">
|
||||
{{ t('warehouse.item_list') }}
|
||||
</RouterLink>
|
||||
<span class="text-gray-400">/</span>
|
||||
<span class="font-medium text-gray-900 dark:text-white">{{ item.Name }}</span>
|
||||
</div>
|
||||
<!-- 操作栏 -->
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<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"
|
||||
@click="router.back()"
|
||||
>
|
||||
<IconArrowLeft :size="14" />
|
||||
返回
|
||||
</button>
|
||||
<div class="flex gap-2">
|
||||
<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"
|
||||
@click="openLinkWorkOrder"
|
||||
>
|
||||
<IconPlus :size="14" />
|
||||
关联工单
|
||||
</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"
|
||||
@click="openMove"
|
||||
|
||||
@@ -222,8 +222,8 @@ async function fetchItems() {
|
||||
items.value = data.items || []
|
||||
itemTotal.value = data.all_count || 0
|
||||
itemStats.total = data.all_count || 0
|
||||
itemStats.inContainer = items.value.filter(i => i.container_id != null).length
|
||||
itemStats.unstored = items.value.filter(i => i.container_id == null).length
|
||||
itemStats.inContainer = items.value.filter(i => i.ContainerID != null).length
|
||||
itemStats.unstored = items.value.filter(i => i.ContainerID == null).length
|
||||
}
|
||||
} catch { toast.error(t('message.server_error')) }
|
||||
finally { itemLoading.value = false }
|
||||
@@ -260,7 +260,7 @@ const itemPageNumbers = computed(() => {
|
||||
})
|
||||
|
||||
function goToItemDetail(item) {
|
||||
router.push(`/warehouse/item/${item.id}`)
|
||||
router.push(`/warehouse/item/${item.ID}`)
|
||||
}
|
||||
|
||||
const deleteItemTarget = ref(null)
|
||||
@@ -276,7 +276,7 @@ async function doDeleteItem() {
|
||||
if (!deleteItemTarget.value) return
|
||||
deletingItem.value = true
|
||||
try {
|
||||
const { errCode } = await warehouseApi.deleteItem(deleteItemTarget.value.id)
|
||||
const { errCode } = await warehouseApi.deleteItem(deleteItemTarget.value.ID)
|
||||
if (errCode === 0) {
|
||||
toast.success(t('message.delete_success'))
|
||||
showDeleteItemConfirm.value = false
|
||||
@@ -298,14 +298,36 @@ function getContainerTitle(cid) {
|
||||
function formatDate(dateStr) {
|
||||
if (!dateStr) return '—'
|
||||
try {
|
||||
const d = new Date(dateStr)
|
||||
let d
|
||||
if (typeof dateStr === 'string' && /^\d+$/.test(dateStr)) {
|
||||
// Unix timestamp string like "1712345678"
|
||||
d = new Date(parseInt(dateStr, 10) * 1000)
|
||||
} else {
|
||||
d = new Date(dateStr)
|
||||
}
|
||||
if (isNaN(d.getTime())) return '—'
|
||||
return d.toLocaleDateString(isEn.value ? 'en-US' : 'zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' })
|
||||
} catch { return dateStr }
|
||||
}
|
||||
|
||||
function fmtTs(ts) {
|
||||
if (!ts) return '—'
|
||||
const d = new Date(parseInt(ts) * 1000)
|
||||
let d
|
||||
if (typeof ts === 'number') {
|
||||
// Unix timestamp in seconds (number)
|
||||
d = new Date(ts * 1000)
|
||||
} else if (typeof ts === 'string') {
|
||||
// Check if it's a Unix timestamp string like "1712345678"
|
||||
if (/^\d+$/.test(ts)) {
|
||||
d = new Date(parseInt(ts, 10) * 1000)
|
||||
} else {
|
||||
// ISO 8601 or other string format
|
||||
d = new Date(ts)
|
||||
}
|
||||
} else {
|
||||
d = new Date(ts)
|
||||
}
|
||||
if (isNaN(d.getTime())) return '—'
|
||||
return d.toLocaleString()
|
||||
}
|
||||
|
||||
@@ -552,23 +574,23 @@ onMounted(() => {
|
||||
</tr>
|
||||
<tr
|
||||
v-else
|
||||
v-for="item in items" :key="item.id"
|
||||
v-for="item in items" :key="item.ID"
|
||||
class="cursor-pointer border-b border-gray-100 transition-colors hover:bg-gray-50 dark:border-dk-muted dark:hover:bg-dk-base"
|
||||
@click="goToItemDetail(item)"
|
||||
>
|
||||
<td class="px-6 py-3 font-medium max-w-[200px] truncate">{{ item.name }}</td>
|
||||
<td class="px-6 py-3 max-w-[160px] truncate text-xs text-gray-500 dark:text-gray-400">{{ item.serial_number || '—' }}</td>
|
||||
<td class="px-6 py-3 text-center text-sm">{{ item.quantity }}</td>
|
||||
<td class="px-6 py-3 font-medium max-w-[200px] truncate">{{ item.Name }}</td>
|
||||
<td class="px-6 py-3 max-w-[160px] truncate text-xs text-gray-500 dark:text-gray-400">{{ item.SerialNumber || '—' }}</td>
|
||||
<td class="px-6 py-3 text-center text-sm">{{ item.Quantity }}</td>
|
||||
<td class="px-6 py-3">
|
||||
<span v-if="item.container_id != null" class="inline-flex items-center gap-1 text-sm text-blue-600">
|
||||
<span v-if="item.ContainerID != null" class="inline-flex items-center gap-1 text-sm text-blue-600">
|
||||
<IconArrowRight :size="13" />
|
||||
<span class="max-w-[140px] truncate">{{ getContainerTitle(item.container_id) }}</span>
|
||||
<span class="max-w-[140px] truncate">{{ getContainerTitle(item.ContainerID) }}</span>
|
||||
</span>
|
||||
<span v-else class="inline-flex items-center gap-1 text-xs text-orange-500">
|
||||
{{ t('warehouse.unstored_items') }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-3 whitespace-nowrap text-xs text-gray-400 dark:text-gray-500">{{ formatDate(item.created_at) }}</td>
|
||||
<td class="px-6 py-3 whitespace-nowrap text-xs text-gray-400 dark:text-gray-500">{{ formatDate(item.CreatedAt) }}</td>
|
||||
<td class="px-6 py-3 text-right" @click.stop>
|
||||
<button
|
||||
class="flex h-7 w-7 items-center justify-center rounded text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20"
|
||||
|
||||
@@ -46,9 +46,27 @@ function getPhotoHashes() {
|
||||
}
|
||||
|
||||
// ==================== 加载编辑数据 ====================
|
||||
onMounted(async () => {
|
||||
if (!isEdit.value) return
|
||||
const linkedItemId = ref(null)
|
||||
|
||||
onMounted(async () => {
|
||||
// 新增模式:检查预填数据
|
||||
if (!isEdit.value) {
|
||||
const prefillStr = localStorage.getItem('prefill_work_order')
|
||||
if (prefillStr) {
|
||||
try {
|
||||
const prefill = JSON.parse(prefillStr)
|
||||
form.title = prefill.title || ''
|
||||
form.description = prefill.description || ''
|
||||
linkedItemId.value = prefill.itemId || null
|
||||
localStorage.removeItem('prefill_work_order')
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 编辑模式
|
||||
pageLoading.value = true
|
||||
try {
|
||||
const res = await workOrderApi.get(orderId.value)
|
||||
@@ -117,6 +135,7 @@ async function handleSubmit() {
|
||||
title: form.title,
|
||||
description: form.description,
|
||||
photos,
|
||||
item_id: linkedItemId.value,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
IconX,
|
||||
IconSearch,
|
||||
IconExternalLink,
|
||||
IconPackage,
|
||||
} from '@tabler/icons-vue'
|
||||
|
||||
usePageTitle('work_order.detail_title')
|
||||
@@ -32,6 +33,7 @@ const orderId = computed(() => parseInt(route.params.id))
|
||||
const order = ref(null)
|
||||
const photos = ref([])
|
||||
const commits = ref([])
|
||||
const linkedItems = ref([])
|
||||
const canModify = ref(false)
|
||||
const canCommit = ref(false)
|
||||
const loading = ref(true)
|
||||
@@ -136,6 +138,7 @@ async function fetchOrder() {
|
||||
canCommit.value = data.canCommit ?? false
|
||||
photos.value = data.photos ?? []
|
||||
commits.value = data.commits ?? []
|
||||
linkedItems.value = data.linkedItems ?? []
|
||||
// 初始化进度提交状态为当前状态
|
||||
if (order.value?.CurrentStatus) {
|
||||
commitStatus.value = order.value.CurrentStatus
|
||||
@@ -426,6 +429,22 @@ onUnmounted(() => {
|
||||
<label class="mb-1 block text-xs font-medium text-gray-400">{{ t('work_order.description') }}</label>
|
||||
<p class="whitespace-pre-wrap text-sm text-gray-700 dark:text-gray-300">{{ order.Description }}</p>
|
||||
</div>
|
||||
<!-- 关联物品 -->
|
||||
<div v-if="linkedItems.length > 0">
|
||||
<label class="mb-1 block text-xs font-medium text-gray-400">{{ t('work_order.linked_items') }}</label>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<RouterLink
|
||||
v-for="item in linkedItems"
|
||||
:key="item.ID"
|
||||
:to="`/warehouse/item/${item.ID}`"
|
||||
class="inline-flex items-center gap-1 rounded-full border border-green-200 bg-green-50 px-2.5 py-1 text-xs font-medium text-green-700 transition-colors hover:bg-green-100 dark:border-green-800 dark:bg-green-900/30 dark:text-green-300 dark:hover:bg-green-900/50"
|
||||
>
|
||||
<IconPackage :size="12" />
|
||||
{{ item.Name }}
|
||||
<span v-if="item.SerialNumber" class="text-green-500">-{{ item.SerialNumber }}</span>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 关联采购订单汇总(去重) -->
|
||||
<div v-if="allPurchaseOrders.length > 0">
|
||||
<label class="mb-1 block text-xs font-medium text-gray-400">关联采购订单</label>
|
||||
|
||||
Reference in New Issue
Block a user