功能迭代
This commit is contained in:
1 parent
617371be3e
commit
8e03c99cab
16 files changed
+1245
-21
No files matched your search
+124
-3
@@ -44,7 +44,7 @@ import AgreementSettingsPage from "./AgreementSettingsPage";
|
||||
import AboutUsSettingsPage from "./AboutUsSettingsPage";
|
||||
import DashboardPage from "./DashboardPage";
|
||||
import CrmCustomerPage from "./CrmCustomerPage";
|
||||
import { apiPost } from "./api";
|
||||
import { apiPost, assetUrl } from "./api";
|
||||
import { statusLabel } from "./statusLabels";
|
||||
import {
|
||||
ensureCurrentSiteCode,
|
||||
@@ -113,6 +113,13 @@ type Item = {
|
||||
sourceType?: string;
|
||||
statusLabel?: string;
|
||||
createTime?: number;
|
||||
primaryCategoryCode?: string;
|
||||
primaryCategoryName?: string;
|
||||
coverMediaUrl?: string;
|
||||
};
|
||||
type CategoryOption = {
|
||||
categoryCode: string;
|
||||
categoryName: string;
|
||||
};
|
||||
|
||||
/** 将毫秒时间戳格式化为本地列表时间。 */
|
||||
@@ -212,6 +219,9 @@ function App({
|
||||
const [items, setItems] = useState<Item[]>([]);
|
||||
const [error, setError] = useState("");
|
||||
const [query, setQuery] = useState("");
|
||||
const [categoryFilter, setCategoryFilter] = useState("");
|
||||
const [statusFilter, setStatusFilter] = useState("");
|
||||
const [categories, setCategories] = useState<CategoryOption[]>([]);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [siteDialogOpen, setSiteDialogOpen] = useState(false);
|
||||
@@ -305,7 +315,11 @@ function App({
|
||||
: section === "about-us"
|
||||
? { items: [] }
|
||||
: section === "products"
|
||||
? await post("/products/list", { siteCode: SITE })
|
||||
? await post("/products/list", {
|
||||
siteCode: SITE,
|
||||
primaryCategoryCode: categoryFilter || null,
|
||||
status: statusFilter || null,
|
||||
})
|
||||
: section === "pages"
|
||||
? await post("/pages/list", { siteCode: SITE })
|
||||
: section === "decoration"
|
||||
@@ -317,6 +331,8 @@ function App({
|
||||
: await post("/contents/list", {
|
||||
siteCode: SITE,
|
||||
contentType: section,
|
||||
primaryCategoryCode: categoryFilter || null,
|
||||
status: statusFilter || null,
|
||||
});
|
||||
setItems(data.items || []);
|
||||
} catch (e) {
|
||||
@@ -324,8 +340,33 @@ function App({
|
||||
setItems([]);
|
||||
}
|
||||
};
|
||||
/** 加载产品、新闻或案例列表所需的分类筛选项。 */
|
||||
const loadCategoryFilters = async () => {
|
||||
if (!["products", "NEWS", "CASE"].includes(section)) {
|
||||
setCategories([]);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const data =
|
||||
section === "products"
|
||||
? await post("/products/categories/list", { siteCode: SITE })
|
||||
: await post("/contents/categories/list", {
|
||||
siteCode: SITE,
|
||||
contentType: section,
|
||||
});
|
||||
setCategories(data.items || []);
|
||||
} catch {
|
||||
setCategories([]);
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [section, categoryFilter, statusFilter]);
|
||||
useEffect(() => {
|
||||
setQuery("");
|
||||
setCategoryFilter("");
|
||||
setStatusFilter("");
|
||||
void loadCategoryFilters();
|
||||
}, [section]);
|
||||
useEffect(() => {
|
||||
const handlePopState = () => {
|
||||
@@ -855,6 +896,39 @@ function App({
|
||||
placeholder={`搜索${title}名称或路径`}
|
||||
/>
|
||||
</div>
|
||||
{["products", "NEWS", "CASE"].includes(section) && (
|
||||
<div className="list-filters">
|
||||
<select
|
||||
aria-label="按分类筛选"
|
||||
value={categoryFilter}
|
||||
onChange={(event) =>
|
||||
setCategoryFilter(event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">全部分类</option>
|
||||
{categories.map((category) => (
|
||||
<option
|
||||
key={category.categoryCode}
|
||||
value={category.categoryCode}
|
||||
>
|
||||
{category.categoryName}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<select
|
||||
aria-label="按上下架状态筛选"
|
||||
value={statusFilter}
|
||||
onChange={(event) =>
|
||||
setStatusFilter(event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">全部状态</option>
|
||||
<option value="PUBLISHED">已上架</option>
|
||||
<option value="OFFLINE">已下架</option>
|
||||
<option value="DRAFT">草稿</option>
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
{error && (
|
||||
<div className="notice">
|
||||
@@ -862,7 +936,7 @@ function App({
|
||||
</div>
|
||||
)}
|
||||
<section
|
||||
className={`table ${section === "inquiries" ? "inquiry-table" : ""}`}
|
||||
className={`table ${section === "inquiries" ? "inquiry-table" : ""} ${section === "products" ? "product-list-table" : ["NEWS", "CASE"].includes(section) ? "content-list-table" : ""}`}
|
||||
>
|
||||
<div className="thead">
|
||||
{section === "inquiries" ? (
|
||||
@@ -875,6 +949,27 @@ function App({
|
||||
<span>状态</span>
|
||||
<span>操作</span>
|
||||
</>
|
||||
) : section === "products" ? (
|
||||
<>
|
||||
<span>图片</span>
|
||||
<span>名称</span>
|
||||
<span>产品编号</span>
|
||||
<span>分类</span>
|
||||
<span>英文路径</span>
|
||||
<span>状态</span>
|
||||
<span>发布时间</span>
|
||||
<span>操作</span>
|
||||
</>
|
||||
) : ["NEWS", "CASE"].includes(section) ? (
|
||||
<>
|
||||
<span>图片</span>
|
||||
<span>名称</span>
|
||||
<span>分类</span>
|
||||
<span>英文路径</span>
|
||||
<span>状态</span>
|
||||
<span>发布时间</span>
|
||||
<span>操作</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span>名称</span>
|
||||
@@ -940,6 +1035,24 @@ function App({
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{["products", "NEWS", "CASE"].includes(
|
||||
section,
|
||||
) && (
|
||||
<span className="list-cover">
|
||||
{item.coverMediaUrl ? (
|
||||
<img
|
||||
src={assetUrl(item.coverMediaUrl)}
|
||||
alt={
|
||||
item.productName || item.title || "封面"
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<span className="list-cover-empty">
|
||||
暂无图片
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
<span>
|
||||
<strong>
|
||||
{item.productName ||
|
||||
@@ -953,6 +1066,14 @@ function App({
|
||||
item.pageCode}
|
||||
</small>
|
||||
</span>
|
||||
{section === "products" && (
|
||||
<code>{item.productCode || "--"}</code>
|
||||
)}
|
||||
{["products", "NEWS", "CASE"].includes(
|
||||
section,
|
||||
) && (
|
||||
<span>{item.primaryCategoryName || "未分类"}</span>
|
||||
)}
|
||||
<code>/{item.slug}</code>
|
||||
<span
|
||||
className={`status ${item.status.toLowerCase()}`}
|
||||
|
||||
@@ -148,6 +148,8 @@ header p {
|
||||
.toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.search {
|
||||
@@ -173,6 +175,7 @@ header p {
|
||||
border-radius: 6px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
.list-filters{display:flex;align-items:center;gap:10px}.list-filters select{height:40px;min-width:150px;border:1px solid #d9e0e5;border-radius:6px;background:#fff;padding:0 34px 0 12px;color:#34434f;font:inherit}.product-list-table,.content-list-table{overflow-x:auto}.product-list-table .thead,.product-list-table .row{min-width:1420px;grid-template-columns:82px minmax(250px,1.8fr) 150px minmax(150px,1fr) minmax(240px,1.4fr) 90px 145px 210px}.content-list-table .thead,.content-list-table .row{min-width:1260px;grid-template-columns:82px minmax(260px,1.8fr) minmax(150px,1fr) minmax(240px,1.4fr) 90px 145px 210px}.list-cover{display:flex!important;align-items:center;justify-content:center;width:68px;height:52px;border:1px solid #e2e7ea;border-radius:5px;background:#f7f9fa;overflow:hidden}.list-cover img{width:100%;height:100%;object-fit:cover}.list-cover-empty{font-size:11px;color:#98a2aa}.product-list-table .row>code,.content-list-table .row>code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.notice {
|
||||
background: #fff6dc;
|
||||
border: 1px solid #ead38e;
|
||||
@@ -391,6 +394,7 @@ header p {
|
||||
.category-manager{max-width:1500px;margin:auto}.category-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:22px}.category-heading h1{margin:0 0 5px}.category-heading p{margin:0;color:#72808d;font-size:13px}.category-table{background:#fff;border:1px solid #dfe5e9;border-radius:6px;overflow:hidden}.category-table-head,.category-row{display:grid;grid-template-columns:minmax(300px,2fr) 1.2fr .7fr .6fr;align-items:center;gap:18px;padding:13px 20px}.category-table-head{background:#f8fafb;color:#6d7983;font-size:12px;font-weight:600;border-bottom:1px solid #e4e9ed}.category-row{min-height:64px;border-bottom:1px solid #edf0f2}.category-row:last-child{border-bottom:0}.category-name{display:grid;grid-template-columns:24px 1fr;align-items:center;min-width:0}.category-name small{grid-column:2;color:#8b969f;font-size:10px;margin-top:3px}.tree-toggle{width:24px!important;height:24px;padding:0!important;display:grid!important;place-items:center}.tree-space{width:24px}.category-actions{display:flex;gap:5px}.category-actions button{width:34px;height:34px;display:grid;place-items:center;border:1px solid #d8dee3;background:#fff;border-radius:5px;color:#176b5b;cursor:pointer}.category-dialog{width:min(720px,calc(100vw - 32px));background:#fff;border-radius:7px;box-shadow:0 24px 70px rgba(0,0,0,.24);overflow:hidden}.dialog-foot{display:flex;justify-content:flex-end;gap:10px;padding:16px 24px;border-top:1px solid #e6e9ed}.dialog-foot button{border:1px solid #d9dee5;background:#fff;border-radius:5px;padding:10px 18px}.dialog-foot .primary{background:#176b5b;color:#fff}
|
||||
.settings-tabs{display:flex;gap:20px;border-bottom:1px solid #dfe5e9;margin-bottom:18px}.settings-tabs button{border:0;background:transparent;padding:10px 2px;color:#6d7983;font:inherit;cursor:pointer}.settings-tabs button.active{color:#176b5b;border-bottom:2px solid #176b5b;font-weight:700}.forms-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}.forms-heading h2{margin:0 0 4px}.forms-heading p{margin:0;color:#72808d;font-size:13px}.forms-list{background:#fff;border:1px solid #dfe5e9;border-radius:6px;overflow:hidden}.form-list-row{display:grid;grid-template-columns:2fr .7fr .7fr .5fr;align-items:center;gap:16px;padding:16px 20px;border-bottom:1px solid #edf0f2}.form-list-row:last-child{border-bottom:0}.form-list-row>div{display:grid;gap:4px}.form-list-row small{color:#7b8791}.form-list-row .link{border:0;background:transparent;color:#176b5b;display:flex;align-items:center;gap:5px;cursor:pointer}.inquiry-form-editor{padding-bottom:50px}.inquiry-editor-layout{display:grid;grid-template-columns:minmax(0,1fr) 330px;gap:22px;align-items:start}.inquiry-form-editor .edit-section>label{display:grid;gap:7px}.inquiry-form-editor .edit-section>label>span{font-size:13px;font-weight:600}.inquiry-form-editor .edit-section>label>input{border:1px solid #d8dee3;border-radius:5px;padding:10px 12px;font:inherit}.setting-check{display:flex!important;align-items:center;gap:9px;padding:10px 0;font-size:13px;cursor:pointer}.editor-side .setting-check>input{width:18px;height:18px;margin:0;flex:none}.editor-side .setting-check>span{font-weight:500}.form-field-table{border:1px solid #e1e6e9;border-radius:6px;overflow:hidden}.form-field-head,.form-field-item{display:grid;grid-template-columns:minmax(150px,1.3fr) minmax(120px,1fr) minmax(110px,.8fr) 70px 70px 88px;gap:14px;align-items:center;padding:12px 16px}.form-field-head{background:#f7f9fa;color:#6d7983;font-size:12px;border-bottom:1px solid #e1e6e9}.form-field-item{min-height:42px;border-bottom:1px solid #edf0f2;font-size:13px}.form-field-item:last-child{border-bottom:0}.form-field-item strong{font-weight:500}.form-field-item code{overflow:hidden;text-overflow:ellipsis;color:#66737d}.field-actions{display:flex;gap:6px}.field-actions button{width:34px;height:34px;border:1px solid #d8dee3;border-radius:5px;background:#fff;color:#176b5b;display:grid;place-items:center;cursor:pointer}.field-actions button.danger{color:#ad3c3c}.field-actions button:disabled{color:#b8c0c5;background:#f5f6f7;cursor:not-allowed}.field-empty{padding:42px 20px;text-align:center;color:#87929a;font-size:13px}.field-dialog{width:min(780px,calc(100vw - 32px));max-height:calc(100vh - 48px);overflow:auto;background:#fff;border-radius:8px;box-shadow:0 24px 70px rgba(0,0,0,.24)}.field-dialog-grid{align-items:start}.field-dialog-grid input:disabled{background:#f1f3f4;color:#7c858c}.dialog-check{display:flex!important;grid-template-columns:auto 1fr!important;align-items:center!important;gap:9px!important;padding:4px 0}.dialog-check input{width:18px;height:18px;margin:0}.dialog-check span{font-weight:500!important}
|
||||
@media (max-width: 760px) {
|
||||
.toolbar{align-items:stretch;flex-direction:column}.search{width:auto}.list-filters{display:grid;grid-template-columns:1fr 1fr}.list-filters select{min-width:0;width:100%}
|
||||
.shell {
|
||||
grid-template-columns: 68px 1fr;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user