Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b0887b126 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "shrimp-admin",
|
||||
"version": "0.3.7",
|
||||
"version": "0.3.8",
|
||||
"private": true,
|
||||
"description": "Shrimp 框架前端 — 消费 ShrimpServer + ShrimpTable 契约的经典 Vue3 + Element Plus 实现",
|
||||
"main": "src/index.ts",
|
||||
|
||||
@@ -334,8 +334,10 @@ async function handleSave() {
|
||||
formFields.value.forEach(field => {
|
||||
if (field.editable === 'readonly') return
|
||||
if (field.editable === 'addOnly') return
|
||||
const newValue = formData.value[field.key]
|
||||
const oldValue = originalData.value[field.key]
|
||||
// 清空字段值为 undefined 时,JSON.stringify 会丢键 → 后端收不到、看似"提交无效"。
|
||||
// 归一成 null:既保证清空能提交(后端置空),又让"两边都空"不误判为有改动。
|
||||
const newValue = formData.value[field.key] ?? null
|
||||
const oldValue = originalData.value[field.key] ?? null
|
||||
if (newValue === oldValue) return
|
||||
submitData[field.key] = newValue
|
||||
})
|
||||
|
||||
@@ -39,9 +39,10 @@ const emit = defineEmits<{
|
||||
'update:modelValue': [value: any]
|
||||
}>()
|
||||
|
||||
// 编辑态清空:el-select 单选清空发 '',但 relation 是 ObjectId,存 '' 会 cast 报错 → 归一成 null(取消关联)
|
||||
// 编辑态清空:el-select 单选清空发 '' 或 undefined,relation 是 ObjectId、且 undefined 会被
|
||||
// JSON.stringify 丢键 → 都归一成 null(取消关联)。多选清空是 [],原样。
|
||||
function onEdit(v: any) {
|
||||
emit('update:modelValue', v === '' ? null : v)
|
||||
emit('update:modelValue', v === '' || v == null ? (props.field.multiple ? [] : null) : v)
|
||||
}
|
||||
|
||||
const options = ref<{ label: string; value: string }[]>([])
|
||||
|
||||
Reference in New Issue
Block a user