fix(web): 系统设置 CRUD 修复 — version 乐观锁 + 语言字段映射 + JSON 显示
- API 层所有 Info/Request 接口添加 version 字段,update 函数传递 version
- delete 函数改为 client.delete(url, { data: { version } }) 发送 JSON body
- LanguageInfo.enabled → is_active,匹配后端 LanguageResp 字段名
- LanguageManager 编辑弹窗简化为只读详情(后端仅支持 is_active 切换)
- SystemSettings 设置值显示改用 JSON.stringify 而非 String()
- SystemSettings updateSetting 发送解析后的 JSON 对象而非字符串
This commit is contained in:
@@ -66,7 +66,7 @@ export default function DictionaryManager() {
|
||||
const handleDictSubmit = async (values: CreateDictionaryRequest) => {
|
||||
try {
|
||||
if (editDict) {
|
||||
await updateDictionary(editDict.id, values);
|
||||
await updateDictionary(editDict.id, { ...values, version: editDict.version });
|
||||
message.success('字典更新成功');
|
||||
} else {
|
||||
await createDictionary(values);
|
||||
@@ -82,9 +82,9 @@ export default function DictionaryManager() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteDict = async (id: string) => {
|
||||
const handleDeleteDict = async (id: string, version: number) => {
|
||||
try {
|
||||
await deleteDictionary(id);
|
||||
await deleteDictionary(id, version);
|
||||
message.success('字典已删除');
|
||||
fetchDictionaries();
|
||||
} catch {
|
||||
@@ -139,7 +139,7 @@ export default function DictionaryManager() {
|
||||
if (!activeDictId) return;
|
||||
try {
|
||||
if (editItem) {
|
||||
await updateDictionaryItem(activeDictId, editItem.id, values as UpdateDictionaryItemRequest);
|
||||
await updateDictionaryItem(activeDictId, editItem.id, { ...values, version: editItem.version } as UpdateDictionaryItemRequest);
|
||||
message.success('字典项更新成功');
|
||||
} else {
|
||||
await createDictionaryItem(activeDictId, values);
|
||||
@@ -155,9 +155,9 @@ export default function DictionaryManager() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteItem = async (dictId: string, itemId: string) => {
|
||||
const handleDeleteItem = async (dictId: string, itemId: string, version: number) => {
|
||||
try {
|
||||
await deleteDictionaryItem(dictId, itemId);
|
||||
await deleteDictionaryItem(dictId, itemId, version);
|
||||
message.success('字典项已删除');
|
||||
fetchDictionaries();
|
||||
} catch {
|
||||
@@ -196,7 +196,7 @@ export default function DictionaryManager() {
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="确定删除此字典?"
|
||||
onConfirm={() => handleDeleteDict(record.id)}
|
||||
onConfirm={() => handleDeleteDict(record.id, record.version)}
|
||||
>
|
||||
<Button size="small" danger>
|
||||
删除
|
||||
@@ -232,7 +232,7 @@ export default function DictionaryManager() {
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="确定删除此字典项?"
|
||||
onConfirm={() => handleDeleteItem(dictId, record.id)}
|
||||
onConfirm={() => handleDeleteItem(dictId, record.id, record.version)}
|
||||
>
|
||||
<Button size="small" danger>
|
||||
删除
|
||||
|
||||
Reference in New Issue
Block a user