feat(worker-platform): 分类标识改为系统自动生成并在前端UI隐藏
This commit is contained in:
@@ -28,7 +28,6 @@ import { uploadFile } from '@/services/files'
|
||||
import type { WorkCategory } from '@/types/worker-platform'
|
||||
|
||||
type CategoryFormValues = {
|
||||
categoryKey: string
|
||||
name: string
|
||||
parentId?: number
|
||||
iconUrl?: string
|
||||
@@ -63,7 +62,7 @@ export default function CategoriesPanel() {
|
||||
{ value: 0, label: '无(作为一级分类)' },
|
||||
...level1Categories.map((c) => ({
|
||||
value: c.categoryId,
|
||||
label: `${c.name} (${c.categoryKey})`,
|
||||
label: c.name,
|
||||
})),
|
||||
]
|
||||
}, [rawCategories, editingCategory])
|
||||
@@ -98,7 +97,6 @@ export default function CategoriesPanel() {
|
||||
function startEdit(category: WorkCategory) {
|
||||
setEditingCategory(category)
|
||||
form.setFieldsValue({
|
||||
categoryKey: category.categoryKey,
|
||||
name: category.name,
|
||||
parentId: category.parentId || 0,
|
||||
iconUrl: category.iconUrl || '',
|
||||
@@ -129,7 +127,7 @@ export default function CategoriesPanel() {
|
||||
async function saveCategory(values: CategoryFormValues) {
|
||||
try {
|
||||
await saveAdminWorkCategory({
|
||||
categoryKey: values.categoryKey,
|
||||
categoryId: editingCategory ? editingCategory.categoryId : undefined,
|
||||
name: values.name,
|
||||
parentId: values.parentId ? Number(values.parentId) : null,
|
||||
iconUrl: values.iconUrl ? String(values.iconUrl).trim() : null,
|
||||
@@ -147,7 +145,7 @@ export default function CategoriesPanel() {
|
||||
async function toggleCategory(category: WorkCategory) {
|
||||
try {
|
||||
await saveAdminWorkCategory({
|
||||
categoryKey: category.categoryKey,
|
||||
categoryId: category.categoryId,
|
||||
name: category.name,
|
||||
parentId: category.parentId || null,
|
||||
iconUrl: category.iconUrl || null,
|
||||
@@ -219,7 +217,6 @@ export default function CategoriesPanel() {
|
||||
return <Tag color="geekblue">{parent ? parent.name : `ID: ${row.parentId}`}</Tag>
|
||||
},
|
||||
},
|
||||
{ title: '标识', dataIndex: 'categoryKey', width: 150 },
|
||||
{ title: '排序', dataIndex: 'sortOrder', width: 90 },
|
||||
{
|
||||
title: '状态',
|
||||
@@ -275,13 +272,6 @@ export default function CategoriesPanel() {
|
||||
>
|
||||
<Select options={parentOptions} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="标识"
|
||||
name="categoryKey"
|
||||
rules={[{ required: true, message: '请输入标识' }]}
|
||||
>
|
||||
<Input placeholder="如 hpjy、dtts" />
|
||||
</Form.Item>
|
||||
<Form.Item label="名称" name="name" rules={[{ required: true, message: '请输入名称' }]}>
|
||||
<Input placeholder="如 和平精英、地铁装备" />
|
||||
</Form.Item>
|
||||
|
||||
@@ -147,7 +147,8 @@ export function fetchAdminWorkCategories() {
|
||||
}
|
||||
|
||||
export function saveAdminWorkCategory(payload: {
|
||||
categoryKey: string
|
||||
categoryId?: number
|
||||
categoryKey?: string
|
||||
name: string
|
||||
parentId?: number | null
|
||||
iconUrl?: string | null
|
||||
|
||||
Reference in New Issue
Block a user