From f5c7a2aae92aceda21c4f264737e698325d061d8 Mon Sep 17 00:00:00 2001 From: lingxiaotian Date: Fri, 5 Dec 2025 10:56:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=95=86=E5=93=81=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A1=A8=E6=A0=BC=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加编辑按钮和编辑弹窗,支持修改商品详情 - 修复导入排序和尾随空格问题 - 表头添加 whitespace-nowrap 防止换行 - 操作列添加 sticky 冻结,支持左右滑动时固定显示 - 设置表格最小宽度确保内容完整显示 --- frontend/src/pages/items/Items.tsx | 171 +++++++++++++++++++++++------ 1 file changed, 138 insertions(+), 33 deletions(-) diff --git a/frontend/src/pages/items/Items.tsx b/frontend/src/pages/items/Items.tsx index ee59ec8..dcbcf41 100644 --- a/frontend/src/pages/items/Items.tsx +++ b/frontend/src/pages/items/Items.tsx @@ -1,12 +1,12 @@ -import { useState, useEffect } from 'react' -import { Package, RefreshCw, Search, Trash2, Download, CheckSquare, Square, Loader2, ExternalLink } from 'lucide-react' -import { getItems, deleteItem, fetchItemsFromAccount, batchDeleteItems, updateItemMultiQuantityDelivery, updateItemMultiSpec } from '@/api/items' +import { useEffect, useState } from 'react' +import { CheckSquare, Download, Edit2, ExternalLink, Loader2, Package, RefreshCw, Search, Square, Trash2, X } from 'lucide-react' +import { batchDeleteItems, deleteItem, fetchItemsFromAccount, getItems, updateItem, updateItemMultiQuantityDelivery, updateItemMultiSpec } from '@/api/items' import { getAccounts } from '@/api/accounts' import { useUIStore } from '@/store/uiStore' import { PageLoading } from '@/components/common/Loading' import { useAuthStore } from '@/store/authStore' import { Select } from '@/components/common/Select' -import type { Item, Account } from '@/types' +import type { Account, Item } from '@/types' export function Items() { const { addToast } = useUIStore() @@ -20,6 +20,11 @@ export function Items() { const [fetching, setFetching] = useState(false) const [fetchProgress, setFetchProgress] = useState({ current: 0, total: 0 }) + // 编辑弹窗状态 + const [editingItem, setEditingItem] = useState(null) + const [editDetail, setEditDetail] = useState('') + const [editSaving, setEditSaving] = useState(false) + const loadItems = async () => { if (!_hasHydrated || !isAuthenticated || !token) { return @@ -54,7 +59,7 @@ export function Items() { while (hasMore) { setFetchProgress({ current: page, total: page }) const result = await fetchItemsFromAccount(selectedAccount, page) - + if (result.success) { const fetchedCount = (result as { count?: number }).count || 0 totalFetched += fetchedCount @@ -177,6 +182,30 @@ export function Items() { } } + // 打开编辑弹窗 + const handleEdit = (item: Item) => { + setEditingItem(item) + setEditDetail(item.item_detail || item.desc || '') + } + + // 保存编辑 + const handleSaveEdit = async () => { + if (!editingItem) return + setEditSaving(true) + try { + await updateItem(editingItem.cookie_id, editingItem.item_id, { + item_detail: editDetail, + }) + addToast({ type: 'success', message: '商品详情已更新' }) + setEditingItem(null) + loadItems() + } catch { + addToast({ type: 'error', message: '更新失败' }) + } finally { + setEditSaving(false) + } + } + const filteredItems = items.filter((item) => { if (!searchKeyword) return true const keyword = searchKeyword.toLowerCase() @@ -208,8 +237,8 @@ export function Items() { 删除选中 ({selectedIds.size}) )} - + +
+
+ + +
+
+ + +
+
+ +