优化CURD功能

This commit is contained in:
2026-03-21 11:18:11 +08:00
parent 5fd33dd87c
commit 7537c484ee
2 changed files with 13 additions and 2 deletions

View File

@@ -845,8 +845,9 @@ class Helper
return $itemJson; return $itemJson;
} }
public static function formatObjectKey(string $keyName): string public static function formatObjectKey(string|int $keyName): string
{ {
$keyName = is_int($keyName) ? strval($keyName) : $keyName;
if (preg_match("/^[a-zA-Z_][a-zA-Z0-9_]+$/", $keyName)) { if (preg_match("/^[a-zA-Z_][a-zA-Z0-9_]+$/", $keyName)) {
return $keyName; return $keyName;
} }

View File

@@ -95,7 +95,7 @@
:label-width="140" :label-width="140"
:block-help="t('crud.crud.For quick combination code generation location, please fill in the relative path')" :block-help="t('crud.crud.For quick combination code generation location, please fill in the relative path')"
:input-attr="{ :input-attr="{
onChange: onTableChange, onChange: (val) => onTableChange(val ?? state.table.generateRelativePath?.replace(/\\/g, '/') ?? state.table.name ?? ''),
onInput: debouncedOnRelativePathInput, onInput: debouncedOnRelativePathInput,
}" }"
/> />
@@ -1396,6 +1396,16 @@ const loadData = () => {
} }
state.table.isCommonModel = parseInt(res.data.table.isCommonModel) state.table.isCommonModel = parseInt(res.data.table.isCommonModel)
state.table.databaseConnection = res.data.table.databaseConnection ? res.data.table.databaseConnection : '' state.table.databaseConnection = res.data.table.databaseConnection ? res.data.table.databaseConnection : ''
// 复制设计时,根据接口返回刷新路径,确保与 getFileData 一致
const tableName = state.table.name || state.table.generateRelativePath?.replace(/\\/g, '/')
if (tableName) {
getFileData(tableName, state.table.isCommonModel).then((fileRes) => {
state.table.modelFile = fileRes.data.modelFile
state.table.controllerFile = fileRes.data.controllerFile
state.table.validateFile = fileRes.data.validateFile
state.table.webViewsDir = fileRes.data.webViewsDir
}).catch(() => {})
}
}) })
.finally(() => { .finally(() => {
state.loading.init = false state.loading.init = false